pax_global_header00006660000000000000000000000064121447114770014522gustar00rootroot0000000000000052 comment=724a653ee3cb542097e838d978d711a22b520bf6 ivtools-1.2.11a1/000077500000000000000000000000001214471147700135255ustar00rootroot00000000000000ivtools-1.2.11a1/CHANGES-0.4000066400000000000000000000422601214471147700150230ustar00rootroot00000000000000This is a list of patches applied to ivtools over the course of ivtools-0.4 development, which ran from approximately September 1994 until October 1995. ivtools originated with a 0.3 version designation in January 1994, since this was approximately the third time our team had started from scratch building a value-added library version of idraw. From January 1994 until September 1994 the structure of the libraries of ivtools was determined, and the first versions of OverlayUnidraw, FrameUnidraw, and GraphUnidraw were created, along with their sample programs: idraw, ov-idraw (now drawtool), frame-idraw (now flipbook), and graph-idraw (now graphdraw). fix-01a adds cmtag Imakefile target fix-01b NameView and NameState classes migrated from maptools fix-01c put OverlayUnidraw comp classes back in as placeholders fix-01d fix pathnames in iv-3.1 patches fix-01e fix up graph-idraw fix-02a fixes NodeView::Update method and upgrades Unidraw.inc.patch fix-02b OverlayKit now builds Glyph menus fix-02c update TextGraphic in NodeView::Update with SetOriginal fix-02d finish changeover to OverlayKit* from OverlayKit& fix-02e adds glyph based toolbars to ov-idraw and graph-idraw fix-02f add Hide and Desensitize capability to Graphic fix-02g fix cmchkin Makefile target fix-02h fix edge/node sizes, remove extra interactors fix-02i add keymap to toolbar fix-02j move text-editor classes to IVGlyph, remove toolbar fix-02k skeleton FrameUnidraw and frame-idraw fix-02l migrate more methods from OverlayEditor to OverlayKit fix-02m clean up OverlayKit/OverlayEditor fix-02n add Hide/Show and Desensitize/Sensitize methods to OverlayView fix-02o add initial frame-oriented structures fix-02p wrapping up for patch 0.2.4 fix-03a FrameUnidraw and frame-idraw fix-03b create initial ScriptView object fix-03c add FrameIdrawComp and FrameIdrawView fix-03d add ScriptView class to OverlayUnidraw fix-03e restructured FrameUnidraw fix-03f GraphEditor constructors changed to expect GraphKit fix-03g fix copy/paste between frames, wb titlebar fix-03h add current/total frames stateviews, create&move command fix-03i fix wm titlebars fix-03j disfunctional FrameUngroupCmd fix-03k fix node delete, edge move fix-03l fix frame-idraw crash, add keycodes to frame cmds fix-03m work struct command for FrameUnidraw fix-03n fix PostScript save of *IdrawComp fix-03o fixed dup cmd and updates menu names fix-03p add prelabeled node tool fix-03q fix new, open of a graph-idraw component when previous selection existed fix-03r ScriptView, cm for special directories, and OvGroupCmd fix-03s last minor fix for patch #3 fix-04a fix some problems with TextEditor glyph fix-04b better text-editor layout, add text get/set methods fix-04c add multiple toolbars to graph-idraw fix-04d add complete graphic hierarchies for OverlayComp, ScriptView, and OvPostScriptView fix-04e declare OverlayView prior to OverlayViewer class definition fix-04f fix graph-idraw cut cmd, labeled node create fix-04g getting ready for patch-0.4.4 fix-05a fix alter of rectangle comp fix-05b add hierarchical menus example to OverlayKit fix-05c begin to support modifiable radiobutton groups fix-05d add non-working radiogroup example fix-05e better RadioEnumEditor, radiogroup example fix-05f irix-happy patch fix-05f fix-05h fix NodeView::Update and bring src/include into imake system fix-05g make radiogroup work by recreating layout glyphs fix-05i fix Save command for OverlayUnidraw and related libraries/programs fix-05j add new bounded value table state, glyph, example program fix-05k last minor fix for #5 fix-06a layout improvements to the BoundedValueTableEditor fix-06b add ParamList object for reading ScriptView's fix-06c fix-06c sketch of framescripts fix-06d more work on OverlayComp methods associated with ParamList fix-06e modify ObsTextEditor glyph fix-06f get ready for major patch 6 fix-07a fix-07a: paramlist and scriptview work in progress fix-07b fix problems in TopoFace::insert_ordered fix-07c fix-07c reads in OverlayIdrawComp grid fix-07d remove another bug from TopoFace::insert_ordered fix-07e fix handle zoom in OverlayView's fix-07f fix-07f, again fix-07g fix-07g, ellipse reading in fix-07h fix various frame-idraw commands fix-07i fix-07i fix-07j fix problem in OverlayCatalog::Retrieve fix-07k abandonment of TopoFace edge sorting mechanism fix-07l add new FieldEditor subclass that accepts on every key fix-07m another improvement to TopoFace::load_points fix-07n chop up EivTextEditor for easier reuse fix-07o first cut at annotate tool fix-07p fix-07p pictures, splines and polygons fix-07q fix-07q add texteditor to frame-idraw fix-07r changes to ParamStruct and ParamList fix-07s fix-07s, annotations and OvTextComp fix-07t extend table to observe each value within it fix-07u fix-07u fix-07v remove focus from frame-idraw texteditor fix-07w fix-07w FrameUnidraw, frame-unidraw, OverlayUnidraw fix-07x everything else fix-08b fix-08b text migration fix-08a fix-08a fix-08c fix grid spacing cmd fix-08d fixes warranted by isat work fix-08e last patch for #8 fix-09a make OvDeleteCmd non-reversible for real fix-09b fix-09b annotation and pattern fix-09c fix-09c add first/last frame cmds, fix graph-idraw save/restore/print fix-09d fix-09d a wrap fix-10a fix-10a fix printing of graph-idraw arrowlines fix-10c fix-10c a wrap fix-10b fix-10b fillbg fix-11a fix-11a fix graph-idraw save/restore fix-11b fix disappearing glyph bug fix-11c fix NameView/TextObserver glyphs, update to linux gcc2.5.8 fix-11d fix select-all and select-by-rectangle of desensitized graphics fix-11e fix-11e extra char in date-time string fix-11f workaround for R6 makedepend fix-11g more work on R6 makedepend config file happiness fix-11h still trying to get those R6 makedepend patches installed correctly fix-11i OvPSPicture generates idraw format PostScript for (almost) any Picture graphic fix-11j fix-11j script save/restore graph-idraw fix-11k fix for iv-3.1 nested menu bug fix-11l make install, X11R6 XFillRectangle workaround, README editing fix-11m new FrameUnidraw Print command creates multi-page PostScript document fix-11n patches/iv-3.1-irix* cleanup fix-11o ScriptRaster can now save/restore tiff files by name fix-11p graph-idraw save/restore nodecomp tuning fix-11q Add new constructor to NodeComp with no arguments fix-11r filename arguments, ParamList callback functions, better frame loading fix-11s UngroupCmd fix for frame-idraw fix-11t Minor fix to ivtools-0.4.11r fix-11u adjust AdjustForZoom, add more ParamList callbacks, soften impact of MoveFrameCmd fix-11v adds DeleteFrameCmd to FrameUunidraw fix-11w adjust OverlayViewer and edit README's fix-11x adds PageCmd, beefs up OverlayPage, tunes DeleteFrameCmd fix-11y fix problem with OvPSPicture erroneously deleting graphics fix-11z fix OvPSPicture's handling of sub-graphic fonts fix-11aa last fix for patch 11 fix-12a new OvTextFileComp, improved OvRasterComp, ParamList::parse_string fix-12b make PGM work for real fix-12c frame number display and Goto First Frame changes fix-12d initialize Number of Frames fix-12e add PBM and gzip support to ImportGraphic, finalize ScriptStencil, and make frame-idraw start on 1 fix-12f add a new "Export Graphic" command fix-12g Bitmap constructor fix-12h in-memory deep-copy for OverlayComps::Copy fix-12i more bug hunting... fix-12j frame-idraw grouping, current frame display fix-12k restore graph connnectivity during Undo Delete fix-12l grid spacing removed from *IdrawComp and other fixes/cleanups fix-12m fix memory leak in GraphDeleteCmd fix-12n new Unidraw patch set fix-12o one more bug fix for iv-3.1 fix-12p confirm dialog glyph fix-12q *NewViewCmd, fix a few open problems with frame-idraw, add example script file fix-12r adds keystroke handling to GConfirmDialog fix-13a :linewidth added to textfile fix-13b add sub-frames to FrameComp and fix popen/pclose pairing fix-13c make OvPostScriptView's Viewer sensitive fix-13d patch that makes vpf-unidraw "Export Graphic" work fix-13e better looking toolbar for SGI X11 setup fix-13f implement Chin-Fu's suggestions, etc.. fix-13g use -> in fix-13e fix-13h fix the export graphic command fix-13i make postscript output work for maptools fix-13j handle off-size pbm files fix-13k add insert_string to EivTextEditor fix-13l make strchooser embedable fix-13m clean up after fix-13l fix-13n support for color raster postscript fix-13o add pure glyph field editor fix-13p migrate to new class names for views and comps fix-13q works on RasterPS, ArrowMultiLinePS, ArrowMultiLineScript, and ArrowSplineScript fix-13r gcc-2.6.1 changes to GFieldEditor fix-13s reinstate #define SCRIPT_VIEW and create FrameFile* classes fix-13t SetCommand and GetCommand added to OverlayPS, and OverlayScript set to inherit fix-13u addition to fix-13t fix-13v localize use of OverlayPS::SetCommand to Create* methods fix-13w make color raster postscript work fix-13x fix problem with OverlayScript::Transformation created by last fix fix-13y glyph-based PrintChooser for new OvPrintCmd fix-13z PrintChooser check boxes fix-13aa precise page command fix-13ab add cursor on/off to GFieldEditor fix-13ac framefile fleshing out fix-13ad removes the extra frames in framefile fix-13ae remove -Dprivate=protected to compile on gcc 2.6.4 fix-13af a few more diffs for gcc-2.6.4 fix-13ag fix :pattern problem fix-13ah update Unidraw.inc.patch after fix-13ae fix-13ai finalize PrintChooser glyph work fix-13aj fix graphkit toolbuttons fix-13ak separate out base class from PrintChooser (OpenFileChooser) fix-13al fixes for gcc-2.6.4 (?) fix-13am make printchooser compile on gcc-2.6.4 fix-13an glyph-based export file chooser fix-13ao compile on gcc-2.6.4, bigger radiobuttons fix-13ap more work on choosers fix-13aq adds GAcknowledgeDialog fix-13ar more chooser work fix-13as creates ParamList::parse_filename and uses ParamList::output_text fix-13at relative-pathname mechanism for script files and format-specific export commands fix-13au tying up loose-ends on relative-pathname mechanism fix-13av remove scrollfield example program fix-13aw fix bug in NameView glyph fix-13ax import chooser with option to load graphics at 0,0 fix-13ay last patch for 13? fix-13az last minor patch for patch-0.4.13 fix-14a hide/show commands fix-14b gcc-2.6.3 happy fix-14c fix hide problem of EllipseOvComp fix-14d chain viewers together for panning fix-14e add chained zooming fix-14f handle arbitrary length annotations and add UnchainViewCmd fix-14g fix-14h make fixed-location work at other than 1x fix-14i add glyphterp example program to ivtools fix-14j really add glyphterp example program fix-14k fix position of raster display when left edge is off screen fix-14l fix update of mag display fix-14m postpone reading pixel data until raster is on screen and add ovfile mechanism fix-14n ovfile and chained pan/zoom work fix-14o fix bug in unchaining views fix-14p fix another bug in chain viewing stuff fix-14q fix Linux magic-byte problem (?) and work on comterp linefeeds fix-14r more robust locating of error file for comterp fix-14s fix parser/scanner problem with "3+.4" fix-14t make text-editor default focus for glyphterp and add "()" button fix-14u remove -Dprivate=protected in a better way fix-14v div-by-zero exception added to comterp and glyphterp fix-14w adds MeterObservor, virtualizes IdrawEditor::InitStateVars() fix-14x add :gs option and reimplement ovfile object fix-14y add "incomplete expression" and "unexpected left paren" exceptions to comterp fix-14z check for ovfile loops and add "-" filename support fix-14aa rework config files to make a site.def fix-14ab changes for gcc-2.7.0 compilation fix-14ac fix a few stray bugs and edit the README fix-14ad generalize BoundedValue with format string fix-14ae more upgrading to gcc-2.7.0, etc.. fix-14af upgrade to gcc-2.7.1 for SUN4 fix-14ag adds meter and fixes ExtraCCLdLibs fix-14ah default iv-3.1-SUN4.patch to gcc-2.7.1 fix-14ai more meter work fix-14aj remove -lmalloc from gcc.def and add -xc++ to glyphterp/Imakefile fix-14ak restore scrollfield example program fix-14al extend scrollfield and add OverlaySelection::ViewsWithin fix-14am new scrollfield and OverlayFileComp::GetFileName problem fixed fix-14an more diffs for fix-14am fix-14ao restore framefile to old style fix-14ap default params only in header file fix-14aq scrollfield focus work and fix unloaded raster printing fix-14ar fix input handling for frame around field editors in scrollfield fix-14as upgrade bdvtable to use GFieldEditor fix-14at revert bdvtable/Imakefile, InstallScriptAs fix-14au new improved frame-idraw and support for compressed script files fix-14av site.def.SGI up to gcc-2.7.2 fix-14aw fix OpenFileChooser bug and add in WishList's fix-14ax add :sub (image) capability to PPM and PGM rasters fix-14ay small layout fix for frame-idraw fix-14az massages *Script::Definition(ostream& out) fix-14aaa adds a font and fgcolor to a TextfileComp's graphic fix-14bb fixes a bug in EivTextBuffer constructor fix-14bc fixes an initial display bug in BoundedValueEditor fix-14bd ParamList::add_param_indirect() fix-14be sets the bdvalue when a GFieldEditor is focused out fix-14bf add ESC and BS support to GFieldEditor fix-14bg fixes a bug in ovraster and ovstencil fix-14bh fix x11r6fillrect.patch, change sample site.def.LINUX to gcc-2.7.2 fix-14bi optimize graphic point lists and fix other bugs fix-14bj keep GFieldEditor string left justified fix-14bk position cursor where mouse clicks in a GFieldEditor fix-14bl fix ref problem on spline graphic's multilineobj (uni-idraw crash) fix-14bm add "invisible" selection mechanism to GFieldEditor fix-14bn again, add a new menu enum editing form fix-14bo fixes a small bug in ArrowLineScript::ReadOriginal fix-14bp white-on-gray selection highlighting in GFieldEditor fix-14bq changes to MenuEnumEditor fix-14br graph-idraw cleaning up fix-14bs point list compaction, GFieldEditor fixes, separate observables fix-14bt add pointer and accept() to observables fix-14bu add object type to comterp fix-14bv add object type ref and val methods to comterp, fix warning fix-14bw add comtest and string value to ComValue fix-14bx add no-param constructor to ComValue fix-14by fix missing unhighlight bug fix-14bz properly initialize a ComValue on a symbol id fix-14ca fix string ComValue fix-14cb new config files fix-14cc fixes to graph-idraw edge moving fix-14cd temporarily fix table size in ComTerp fix-14ce add equality system for OverlayComps fix-14cf add pic compaction to frame-idraw fix-14cg ComUnidraw and com-idraw fix-14ch add row add/delete to scrollfield fix-14ci better XOR rubberbanding in front of gray-level imagery fix-14cj swag at fixing viewport in scrollable example program fix-14ck fix-14cl fix boolean editor glyphs to reflect initial value fix-14cm shared libraries for SunOS fix-14cn shared libraries for everyone? fix-14co allow for redefinition of shared library building command fix-14cp make shared libraries work on linux fix-14cq gets shared libs working for SGI fix-14cr virtualize start and stop buffering fix-14cs enables raster (and stencil) scripts without :transform fix-14ct drops the auto-centering of raster and stencil scripts patch-02n convert camera tool to rpc fix-14cu adds a mouse documentation line fix-14cv add new Attribute library fix-14cw migrate ParamList, set up AttributeList, add one to OverlayComp fix-14cx further work on AttributeList, add AttributeListEditor fix-14cy fixes a few memory leaks found with Purify fix-14cz alter mouse-doc lines and fix const problem in Attribute library fix-14da create standalone AttributeValue fix-14db drop LexScan into Attribute library fix-14dc link ComUtil library under Attribute library fix-14dd add Attribute tool and attribute editing dialog fix-14de drops in a skeleton for attribute save/restore fix-14df adds a get_next_attr method to LexScan fix-14dg work on Attribute and AttributeValue memory mgmt fix-14dh further work on attribute editing fix-14di gets a simple Attribute save/restore working fix-14dj more work on Attribute Edit/Save/Restore fix-14dk use EivTextEditor to display attribute list fix-14dl fix AttributeList memory problems fix-14dm move attredit to AttrGlyph library fix-14dn get scrollfield running (but not working) fix-14do fix-14do (from Brian) fix-14dp fix-14dp (from Brian) fix-14dq fixes some attribute problems fix-14dr final minor patch for major patch 14 fix-15a add OTHER to config/params.def fix-15b add polygon clipping commands fix-15c fix-15d fix configs for clippoly fix-15e fix creation of polygon for clippoly fix-15f make clipping work with edited polygons fix-15g command line switches for colormap mgmt fix-15h remove -lg++, move -lstdc++ and -lm to the end fix-15i fix crash when derived programs don't define color/gray attributes fix-15j enables export of color rasters to scriptfile format fix-15k last patch for ivtools-0.4.15 fix-16a extends GraphUnidraw to import a graph-idraw document fix-16b gets graph-idraw copy/paste/dup cmds working again fix-16c shows unconnected subgraph edges fix-16d fix bug in MultiLineObj cacheing fix-16e enforces graph-idraw edge connection directionality fix-16f fix save/restore and export of raster graphics fix-16g gets Undo working for graphnode connections fix-16h add optional config file support for Fresco fix-16i last patch for ivtools-0.4.16 fix-17a gets graph copy/paste working fix-17b gets graph cut working fix-17c gets graph dup working fix-17d adds a graph-idraw import-by-filename or -flat mechanism fix-17e fix graph import, wrap up ivtools-0.4.17 ivtools-1.2.11a1/CHANGES-0.5000066400000000000000000000161171214471147700150260ustar00rootroot00000000000000December 17th 1997 ivtools-0.5.10 Drawing Editor Changes * changed idraw to snap-to-grid when importing with gravity on, and drawtool to snap-to-grid when importing with centering and gravity on. * changed iclass to work better with ACE header files. * fixed bug in relative pathnames (of a raster or stencil) when document is saved to an alternate directory by forcing them to absolute pathnames. * tested and fixed comdraw's reading commands from stdin. Now it works for redirected stdin as well. Interpreter Changes * added an exit() command to comterp and comdraw. * added default values to ComFunc::stack_arg (to return when argument not found) and ComFunc::stack_key (to return when keyword is found with no argument). Library Changes * added support for arbitrary numeric types to GrayRaster (char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, float, double). * expanded OverlayRaster's support for the GrayRaster API by adding dummy methods as required. * changed Painter::x_or back to Painter::xor to get Target Jr 3.0beta compiling on top of ivtools. * evolved the fixed size graphics mechanism to have a scaleability factor. Hardwired to power of 2 zoom at present. * created static void GAcknowledgeDialog::post(Window*,const char*) (useful for posting simple acknowledge dialog boxes) * added a static AttributeValue::type_size(ValueType) method as well as member AttributeValue::type_size() method * added static and member AttributeValue::is_char, is_short, is_int, is_long, is_float, and is_double methods (treats unsigned same as signed) * added an OverlayViewer::SetMagnification which calls AdjustForZoom. Configuration Changes * adopted include-file install targets and extra __linux__ #ifdef'ed code (IV-X11/xwindow.c, Dispatch/netinet_in.h, Dispatch/rpcregistery.c) from Guenter Geiger's ivtools_0.5-1.diffs (the Debian 2.0 package diff file). * rearranged the build order in src/Imakefile to contruct binaries as soon as required libraries exist. * removed specification of GccIncludeDir from config/gcc.def, because this is no longer needed now that we do makedepend with gcc. October 31st 1997 ivtools-0.5.9 * adds ACE import to flipbook multi-frame editor. * new flipbook frame creation commands: "copy forward" and "copy backward" (CopyMoveFrameCmd). * new flipbook frame viewing commands: "show previous frame" and "hide previous frame" (ShowOtherFrameCmd). * changes the MoveFrameCmd's to use the deferring Unidraw::Update instead of the immediate FrameEditor::Update, so that MacroCmd's that contain a MoveFrameCmd do all the work before the a) cursor is reset, and b) the viewer is moved to the new frame. * fixes problem with symbolic links generated by "make install" when InstallRelative is enabled. * adds dialog boxes to inform the user when an import fails or the colormap allocation fails. * add OverlaySelectTool that ignores single-clicks on graphic views that match a list of types. Useful when selecting graphics in front of rasters and stencils. Not used by default. * make text graphics painted at 1x ignore a stipple pattern in the graphic context just like they do at 2x and .5x. October 1st 1997 ivtools-0.5.8 * add "telcat" mode to comterp test program, allowing for the remote cat'ing of files to drawtool, etc., i.e. "comterp telcat localhost 20001 test.ppm" would connect to a drawtool with import service at port 20001 and transmit a PPM image file. * add these methods to OverlayViewer to simplify translation between coordinate systems: ScreenToDrawing, DrawingToScreen. * rename OvGrayImage to GrayRaster, and set up a static RasterOvComp::UseGrayRaster() to enable/disable its use (GrayRaster is an OverlayRaster with in-memory copy of original pixel values). * generalize PBM/PGM/PPM header reading to allow for line-feeds between ncols and nrows. * modify MoveFrameCmd to optionally disallow moving to the background frame. * remove an unnecessary call to FrameEditor::UpdateFrame from within FrameEditor::Update (that should only be done when the current frame changes, not just when anything changes within the current frame). * modify TopoFace::npts() to only count the points in the first face (ignoring islands). This fixes a bug in ivmaps dlgviewer. * remove static linking conflict of StringList object (one has been renamed CopyStringList). * add a slightly modified ivmkmf to the script directory * modify iclass to work on the vtk-2.0 source tree September 15th 1997 ivtools-0.5.7 * various bugs were isolated and removed from the command interpreter server mechanism embedded in ivtools, notably infinite loops caused by premature disconnects of remote clients. * floating point geometric objects were expanded to be able to render themselves to a bitmap without the use of an X server. * other attempts were made to isolate any X server dependencies in the server framework -- currently one remains, a need to store the patterns of a graphic state on the X server -- to be removed by the 0.6 release. July 24th 1997 ivtools-0.5.6 * the import service mechanism was further expanded in ivtools, so any remote program can ship drawings or images to a viewer by establishing a connection over the network. * commands to desensitize graphics in a viewer were added to ivtools (to complement existing commands for hiding graphics in a viewer, fixing the size or location of graphics in a viewer). Although a long standing capability of the software, this was the first time it was exposed to the user with a sample command. * the save/restore spatial object transcription mechanism of ivtools was expanded to include support for inline bitmaps. It was also reorganized to be more object-oriented. * an initial attempt was made to blend in the graph-node editing mechanisms of the GraphUnidraw class library with the command interpreter mechanisms of the ComUnidraw class library. July 1st 1997 ivtools-0.5.5 * ivtools was expanded to include support for importing by piping from a command line filter, useful for displaying the results of various idraw compatible renderers (see http://www.vectaport.com/ivtools/idraw.html for examples). Here is a partial list of patches applied to ivtools-0.5 prior to ivtools-0.5.5: patch-0.5.1a fix non-shared library usage and -tile bug patch-0.5.1b more config fixes and a new INSTALL file patch-0.5.1c first stab at ACE integration patch-0.5.1d sample integration of ACE into drawtool patch-0.5.1l separate vtk stuff from 2d maps and add ACE msg patch-0.5.1e migrate ACE usage to comdraw patch-0.5.1f add a -port argument to comdraw patch-0.5.1g ACE into comterp into Unidraw patch-0.5.1i more diffs to go with previous patch patch-0.5.1h work event handling and graphic state propogation patch-0.5.1j improve config/params.def for multiple add-in libraries patch-0.5.1k add import service to comdraw server patch-0.5.2a fix Imakefile problems patch-0.5.2b clippoly in float coords, fix comdraw Imakefile patch-0.5.2c move fgeomobjs and float cliplinepoly ivtools-1.2.11a1/CHANGES-0.6000066400000000000000000001170671214471147700150350ustar00rootroot00000000000000October 23rd 1998 ivtools-0.6.12 Drawing Editor Changes * ivtools drawtool can now automatically open or import (over the net) a wider variety of graphical file formats, using external filters that convert to idraw PostScript or a pbmplus image format: arbitrary PostScript --> pstoedit GIF --> giftopnm TIFF --> tiftopnm JPEG --> djpeg drawtool can also launch on idraw PostScript and pbmplus image formats (PBM/PGM/PPM in raw and ASCII), a new feature. Before these could only be imported. The import dialog box still behaves the same as before. It can import drawtool or idraw documents, PBM/PGM/PPM image formats, anything that can be converted with a Unix command line to those formats if the "pipe-from-filter" button is checked, and anything that can be handled by the anytopnm script if the "auto-convert" button is checked. * ivtools flipbook inherits the same new support for an extended set of graphic file formats imported over the net. However it still only launches on (opens) flipbook format files. Script Changes * add a new bash script, cntsrclines, to count the lines of source in a source tree, using comterp to sum it up. * add a new bash script, tiftopnm, which wraps the pbmplus filter tifftopnm, which can't handle stdin directly itself. * add support for dithering of JPEG's to the standard colormap to anytopnm. * add support for using a newly created temporary file name in the ivgetjpg script, which downloads a JPEG URL using w3c and exports it over the net to an ivtools drawing editor using comterp in telcat mode. Utility Changes * add a new src/utils directory, and populate it with two small programs: tmpnam -- write newly generated temporary file name to stdout. stdcmapppm -- write 216 pixel PPM image with one entry for each color in the standard X11 colormap (6R*6G*6B == 216). Both are used in the tiftopnm and anytopnm scripts described above. * change "comterp telcat" to read/write with a 1K buffer instead of a character at a time. Library Changes -- ComTerp -- * fix bugs in ComTerp where the nargs associated with a KeywordType ComValue were being taken from ::nargs instead of ::keynarg_val. * fix bug in ComTerpServ where a new _pbuf was getting allocated of size _pfnum instead of _pfsiz. * fix bug in saving ComTerp state in ComTerpServ(const char* expression...) Similar problems still exist in ComTerp::runfile and ComTerpServ::runfile, I'm sure. * zero out all the unique member variables of ComValue (the ones that AttributeValue does not have). -- OverlayUnidraw -- * fix bug in OverlayCatalog where member variable _ed needed to be initialized to nil before it was set. Similar bug in OverlayEditor for _viewer member variable. * change OverlayCatalog::Retrieve to use an OvImportCmd to construct whatever it needs. In this way the open (via dialog box or command line) and import over the net can handle the same set of file formats. The import via dialog box hasn't been modified yet to make use of this mechanism, so the set of formats it supports with or without the auto-convert button is different. * add support to OvImportCmd::Import(istream&) for new file formats using external filters that convert to idraw or pbmplus formats as described above. * fix over-the-net import for PGM and PPM ASCII formats * add support for reading ASCII PBM images. -- FrameUnidraw -- * add support for importing drawtool documents via dialog box into the flipbook editor. -- ComUnidraw -- * add an update func to ComUnidraw, to do an immediate mode update of the Unidraw environment. This allows for watching the progress of a for-loop in comdraw that is drawing graphics. Config/Build Changes * make use of the --prefix=DIR argument of the ./configure script, to set the prefix used when InstallRelative is false. * change all the Imakefile's to not use -xc or -xc++ argument for gcc/g++ (because various egcs distributions no longer support this). * add rules to config/rules.def to support explicit C (instead of C++) compilation. Tie this to the configure script's CC variable. * change the default CCDriver for Linux to g++, and create a default CDriver, gcc. * move build of GraphUnidraw and graphdraw after FrameUnidraw and flipbook. October 6th 1998 ivtools-0.6.11 Config and Miscellaneous Changes * utilize the configure script to determine the C++ compiler * make use of the configure script the default for all supported OS'es (i.e. linux, solaris, sunos4, hpux, irix5, and alpha). * add --enable-install-relative[=ARG] and --enable-use-rpath[=ARG] to the configure script. * make use of the PWD environment variable to define the base of the ivtools source tree, which is in turn used to fix this value for the ivmkmf script. Now the ivmkmf script can be slackly used from within something like the original 3.1 source tree to build stand-alone example programs (i.e. doc or logo) on top of ivtools. * add shell script wrappers that preset the PATH and LD_LIBRARY_PATH environment variables for each of the following executables: ivct --> comterp ivdt --> drawtool ivcd --> comdraw ivfb --> flipbook ivgd --> graphdraw ivds --> drawserv * make most of the changes suggested by Bruno Delfosse after compiling with insure++ 4.1 on an Alpha. This tool discovered places where no value was returned, places where the number and type of arguments to a printf call did not match the format string, and a few places where significance was lost when converting a pointer to an int on a 64 bit architecture. It also reported on places where a local (auto) variable reference was returned, and called it an error. However, since the reference was to a non-local variable (an object in the middle of a member array of objects) these were ignored. A patch was added to the web pages that can be used to reproduce his build environment: http://www.vectaport.com/ivtools/insure.ALPHA.patch Drawing Editor Changes * change the orientation of the Text manipulator when the orientation of the viewer has changed. Debian bug request by Mark Eichin , #26165. Interpreter Changes * finalize implementation of while and for commands. Here are two sets of test commands that now work as expected: for(i=0 i<10 i++ :body if(i/2*2==i :then print("even\n") :else print("odd\n"))) i=10;while(i :body i--;print("%d\n" i)) * add sum, mean, var, stddev, and sqrt commands to comterp * make the interpreters brought up under the Editors menu (in comdraw, flipbook, and graphdraw) be an instance of the default interpreter for that application. In this way the interactive interpreter dialog box can be used to control the application. However it still needs some thought and work, because by default it is set up to act on only the current selection list, computing attributes for each selected object. Library Changes -- ComTerp -- * fix bug in ComTerp::eof(), where an empty unitialized token buffer would cause a segfault. -- Unidraw -- * upgrade Unidraw to work on 64 bit architectures, by changing the places where an int was being used to store a void*. This affected the Unidraw API in two places: ObjectMap::GetId and UHashTable::Hash, which now return an unsigned long instead of an int. -- ComUnidraw -- * add all the default commands to the interpreter initialized by ComEditor::AddCommands(ComTerp*) -- FrameUnidraw -- * actually check the value of FrameEditor::_autonewframe before executing the body of FrameEditor::DoAutoNewFrame(). September 24th 1998 ivtools-0.6.10 Config and Miscellaneous Changes * introduce a configure script that has been setup and tested on Linux only. See Appendix A in the INSTALL file for more details. * add a MANIFEST.perceps file to list the files processed by PERCEPS (http://friga.mer.utexas.edu/mark/perl/perceps/). Resulting web pages posted at: http://www.vectaport.com/ivtools/classes/ Drawing Editor Changes * fix recently introduced bug in "New View" command. Now it is back to its old self. Interpreter Changes * fix evaluation of nested post-evaluation (control) commands with keyword arguments. So now something like the following works: if(a :then if(b :then if(c :then "abc" :else "ab!c") :else if(c :then "a!bc" :else "a!b!c")) :else if(b :then if(c :then "!abc" :else "!ab!c") :else if(c :then "!a!bc" :else "!a!b!c"))) By default this will print "!a!b!c". Set values of a, b, and c (i.e. "a=1") to see the other possibilities. Library Changes -- OverlayUnidraw -- * fix ArrowMultiLinePS::Definition to better support ivmaps export of map line features in idraw postscript format. September 14th 1998 ivtools-0.6.9 Drawing Editor Changes * add support for ASCII PGM and PPM image files to the import service of all the drawing editors (previously it was supported only via the import dialog box). * add "Auto New Frame" mode (under the Frame menu) to flipbook editor, so that each imported object can automatically be placed in a newly created frame. This feature is enabled by default for the import service but not the import dialog box. * limit screen repair on the flipbook editor to only the times when something actually changed within the viewer. This speeds the processing of repeated Ctrl-f's that run off the end of the frames. Interpreter Changes * fix display of parser/scanner error strings. Now something like "3 + + 4" or an unterminated character string (no double-quote or back-slash before a new-line) are handled correctly and reported on correctly. This has always been a capability of the underlying compiler components written in C (fashioned after the Fischer-LeBlanc textbook), but a bug existed in the interface to the C++ objects. Library Changes -- ComUtil -- * convert to all new-style function arguments to facilitate compilation with CC (type declararions included with argument names). * add an underbar to the front of ComUtil files parser.c, scanner.c, and lexscan.c, to keep gdb from confusing them with ComTerp/parser.c, ComTerp/scanner.c, and Attribute/lexscan.c. -- ComTerp -- * add a "boolean once=false" argument to ComTerp::run, so that it can be used by ComTerp/comhandler.c * use the body of ComTerp::run from ComTerpServ::run, instead of its own copy of the run-eval loop. * add Parser::Parser(istream&), so a parser can be started up on an existing istream. Also add static methods Parser::istream_fgets, ::istream_feof, and ::istream_ferror, so the scanner, parser, or interpreter can be run on an istream as well a FILE* and via sockets. -- OverlayUnidraw -- * add support for ASCII PGM and PPM to OvImportCmd::Import(istream&) * add OverlayScript::skip_comp(istream&) to skip unrecognized components being read in by an istream constructor (of something derived from OverlayComp). * fix defaulting of _grayflag in OverlayRaster to false. -- FrameUnidraw -- * add auto-new-frame mode to FrameEditor, which causes OvImportCmd to create a new frame for each import. New methods on FrameEditor: virtual void ToggleAutoNewFrame(); virtual boolean AutoNewFrame(); virtual void DoAutoNewFrame(); // used by import command with a DoAutoNewFrame required on OverlayEditor, so OvImportCmd can use it. * add AutoNewFrameCmd to call FrameEditor::ToggleAutoNewFrame Script Changes * add ivgetjpg.bash script to download JPEG file using w3c, dither its colormap and convert it to ppm using djpeg, and export to import service on a drawing editor using comterp. * remove fgrab10.bash and cntsrcheng.bash scripts, because of their lack of general applicability. * fix to ivmkmf script when -a not supplied as argument. Config and Miscellaneous Changes * incorporate some of the diffs from patch for Debian package ivtools-0.6.7-1 * switch the LdPath rule (from config/rules.def) to use IVTOOLSSRC instead of LIBSRC. Since the LdPath rule is used only to find the original iv-3.1 libraries, this works in more situations, including in a directory set up with ivmkmf. August 14th 1998 ivtools-0.6.8 Interpreter Changes * add a print func to comterp -- print(fmtstr val) * disable continuation prompting (">") when running comterp from a pipe or socket. * add a postfix func to comterp, to display the result of the scanner/parser for debug purposes. Tokens are printed in postfix order, with each command or symbol followed by a pair of bracketed numbers that indicate the number of arguments and keywords associated with the token, and each keyword is followed by a 1 or 0 to indicate if it has an associated argument or not. For example: postfix(func1(a*b :key1 c :key2)) prints this: a b mpy[2|0] c :key1(1) :key2(0) func1{2|2} * add a posteval func to comterp, to test out a new mechanism for post-evaluation of a func's arguments, a pre-requisite for implementing conditional control operators. * reimplement the cond operator to use post evaluation. * experimentally add if, for, and while control funcs to comterp: if(booltest :then thenexpr :else elseexpr) for(initexpr whileexpr [nextexpr] :body bodyexpr) while(untilexpr :body bodyexpr) Library Changes -- ComTerp -- * add a new iofunc.c module for the print func. * add a new postfunc.c module for the post-evaluations funcs described above. * add new methods to ComFunc to support post (or lazy) evaluation, a first step in implementing conditional run-time control operators: stack_arg_post_eval, stack_key_post_eval, skip_arg_on_stack, and skip_key_on_stack. -- InterViews -- * redeclare an ApplicationWindow(Glyph*) constructor to go along with the ApplicationWindow(Glyph*, const char* display) constructor introduced in the last release. The "display" argument had been defaulted to nil, which made for backward compatibility, but it turns out Target Jr had a copy of the IV-X11/xwindow.c in it source tree, so xcv, the main Target Jr app, wouldn't link without the original ApplicationWindow constructor as well. This represents a somewhat rare duplication or interface modification of original InterViews sources in either distribution (Target Jr or ivtools) and kind of ironic that we bumped heads over it. But the workaround was simple. * fix segfault in the use of idraw's FileChooser dialog box (for Open and Import). It was caused by a pointer to a deleted transient window that is saved by the string editor, and when the dialog box is redrawn because of a change in caption, this pointer is used to unmap the window, which fails. The fix was to create a bodyclear() method on FileChooser and MonoGlyph, so that the internals of the FileChooser could be cleared before the caption is changed which triggers a complete rebuild of the glyph tree. The end result is still as inefficient as it ever was (requiring the complete rebuild of the dialog box for every action), but it works. And a more efficient implementation can be found in the IVGlyph library's OpenFileChooser class which is used by the rest of ivtools drawing editors. Script Changes * add a "make Makefile" to the execution of ivmkmf when -a is not specified. This snaps the new Makefile to the current directory, which is needed even if "make Makefiles" and "make depend" are not. Config Changes * more configuration changes for Alpha from Bruno Delfosse at Thomson-CSF. Now it has been verified to work. * introduction of an experimental configure script and configure.in autoconf file borrowed from Target Jr 3.1 and modified. Configure options of interest so far that would be specific to ivtools: --with-ace= Path to ACE --with-ace-libs= Path to ACE libraries --with-clippoly= Path to clippoly --with-clippoly-libs= Path to clippoly libraries --with-fresco= path to Fresco --with-fresco-libs= path to compiled Fresco libs --with-x use the X Window System The fresco options would do nothing until some use of Fresco glyphs is made underneath Unidraw or 3.1 glyphs. The with-x option (should it be without-x?) could be used to build a comterp only version of ivtools. The next step is to hook up the two mechanisms of configure and imake. Right now when you run configure from the top-level directory it executes until it can't find config/"host"-"compiler".mk (i.e. config/linux-gcc.mk). This seems where the connection between the config/site.def.$CPU files and the config/*.mk files could be made in some fashion. This represents an opportunity for any party who always wanted InterViews to be auto-configured. One thing to note: there needs to be a mapping between the upper-case $CPU convention of InterViews and the lower case os-arch-compiler (or whatever it is) of GNU. This is an issue when building Target Jr on top of ivtools as well, one that can be worked around by simply using the upper case convention. But maybe someone else has an idea of a better way to proceed. July 9th 1998 ivtools-0.6.7 Drawing Editor Changes * in drawtool add a "Graylevel Processing" sub-menu to the Edit menu, with a Scale, LogScale, and PseudoColor options. * group similar items on the View menu into a submenu for each: - graphic hide/show - viewer chain/unchain - graphic fix/unfix size * add an "Enable Looping" and "Disable Looping" to the flipbook Frame menu. Only works in the forward direction at present. Interpreter Changes * add a 'run' argument to comterp, to run a file of commands and exit. * add a createframe(:after) func to flipbook. Library Changes -- InterViews -- * add a nil-defaulted argument to the ApplicationWindow constructor, a new X11 display name, i.e. "localhost:0.0". Tested with a "New Display" command on the View menu of drawtool that is #if 0'd for now. -- Attribute -- * add more type checking methods (both static and otherwise) to AttributeValue (more generic is_integer and is_floatingpoint methods) -- Unidraw -- * increment the idraw format version number to 11 to accomodate changes to work better with plotutil. The only thing changed so far is the addition of closepath's to the postscript output for a circle or ellipse graphic. Future plans are for adding capstyle, joinstyle, and floating point line widths to the brush description. -- UniIdraw -- * fix bug in printing out idraw format version numbers when reading in newer or older versions. -- OverlayUnidraw -- * make the top-level GrayRaster::pseudocolor method calls the lower level GrayRaster::pseudocolor method (instead of the OverlayRaster one). * change the low-level GrayRaster::pseudocolor method to do something more reasonable for a floating point image. * set up the use of a string-editor dialog box to enter the min and max values for linear and log scaling of grayrasters, and conversion of them to color rasters with a pseudocoloring operation. * add blue to the pseudocoloring, going from red to green to blue. * create a do-nothing virtual void OverlayEditor::ResetStateVars method that can be filled in by derived OverlayEditor's. -- FrameUnidraw -- * change to support using with frames disabled, for programs derived from FrameUnidraw that don't always need the mechanism. -- IVGlyph -- * evolve the construction of GFieldEditor to be embedded into Page's and boxes equally well. * create a StrEditDialog for bringing up a single string editor and having the result returned to the application. -- OverlayUnidraw -- * add a GraphicLoc tool to drawtool. Displays the position of a pointer click in the local coordinate system of the graphic. Gives the offset in pixels when clicked on a raster. Script Changes * fix pnmtopgm shell script to avoid infinite loop on an empty file. * add example bash script, fgrab10, that grabs 10 jpeg files from a series of 10 URL's using w3c, converts and dithers them with djpeg, then transfers them to a newly created frame in a separately running flipbook. * add example bash script, cntsrcheng, that counts the number of various search engine URL's found in a file of referring URL's, and plots them as a bar plot in comdraw using plotmtv. Config Changes * change the default on InstallRelative in site.def.$CPU to be NO. * add configuration changes for Alpha from Bruno Delfosse at Thomson-CSF. * move certain definitions from local.def to site.def.$CPU, so that they can be customized in site.def.ALPHA: HasDynamicSharedLibraries, SharedCCFlags, SharedCCLdFlags, BuildRPCClasses * generalize ivxt Imakefile to use $CPU * temporarily disable the default build and install of ivxt, the example program that shows how to wrap Xt and Motif objects around an InterViews application. You can bring it back by changing a #if 0 in src/Imakefile to #if 1 and remaking the Makefiles (make Makefiles). June 5th 1998 ivtools-0.6.6 Overall Changes * test and fix rebuild with ACE-4.5 using egcs Interpreter Changes * add a "shell" command to comterp, for executing arbitary Unix commands via system(3). Library Changes -- TopoFace -- * add a TopoEdgeList::get_edge method that combines the ::elem and ::edge methods into one call. * migrate const's from certain method return values in this library to the method itself, which was probably the original intent. -- Unidraw -- * add two inline methods to Graphic, ::ToggleHide ::ToggleDesensitize, for programmer convenience. -- IVGlyph -- * add blinkability to NameView text labels. -- OverlayUnidraw -- * add a public OverlayEditor::IsClean method, to work around the protected Unidraw::IsClean(Editor*) method. * fix bug in OvImportCmd::TIFF_Raster. It was using the wrong variable to construct the resultant OverlayRaster. -- GraphUnidraw -- * add the propogation of graphic state to EdgeView::Update, which will include the hide/desensitize mask. May 19th 1998 ivtools-0.6.5 Documentation * man pages generated from README's for drawtool, flipbook, and graphdraw from Guenter Geiger, (came with the Debian ivtools-0.6.2-4 diffs). * set up src/man/man1 directory with dclock.1, iclass.1, idraw.1, and ivmkf.1 copied directly from the corresponding original iv-3.1 file (iv/src/man/commands/*.n) Overall Changes * fixes required to build on redhat-5.0, glibc, egcs-1.0.2 * minor diffs gleaned from Debian ivtools-0.6.2-4 Drawing Editor Changes * makes -color6 the default for drawtool. * change "pipe to command" in export dialog box to read "pipe to filter" * add support for ASCII PGM and PPM files. Interpreter Changes * fix up the comterp client mode to interpret and handle continuation prompts "> " * fix up the comterp telcat mode to simply cat the file without expectation of any response. Library Changes -- Attribute -- * add BooleanType to output of AttributeValue * fix a warning in compiling a program that uses ParamList::add_param_first -- ComTerp -- * have ComTerp::read_expr return false when the parser or scanner had a problem, to partially fix the output of parser/scanner error messages. * disable the restoration of _bufptr in a ComTerpServ::run call, because any existing _buffer would be already fully converted to postfix tokens before such a run call was made. * fix up the ComterpHandler::handle_input to handle empty lines of input by echoing a \n -- OverlayUnidraw -- * adds void GrayRaster::graypoke(unsigned long x, unsigned long y, AttributeValue val) * adds OverlayRaster* GrayRaster::pseudocolor( ColorIntensity mingray, ColorIntensity maxgray ) * fixes reading of inlined gray floating point rasters, getting the top2bottom flag right. * fix bug in output of readonly components. * fix raster import on Solaris * changes the boolean function used to detect if a breakout of the Session::read event loop is needed from one that checks only the unidraw update flag, to one that checks both that flag and whether there is anything appended to OverlayUnidraw::_cmdq, a MacroCmd. * add a generic GetFrame method at the OverlayEditor level and change EdgeView::InterpretManipulator to use it. * make sure an OverlayViewer::Update doesn't get done before an OverlayViewer::Resize -- FrameUnidraw -- * take out what seems an unnecesary call to FrameEditor::SetFrame in FrameViewer::Update, because the same thing is done in the proceeding call to FrameEditor::InitFrame. -- GraphUnidraw -- * notify nodes with outgoing edges during edge update * fix EdgeUpdateCmd for subclasses of NodeComp. -- ComUnidraw -- * add a BarPlotFunc using plotmtv and a patched pstoedit-2.60 (see http://www.vectaport.com/ivtools/comdraw.html for details). April 15th 1998 ivtools-0.6.4 * adds a pnmtopgm.sh script, to convert from pbm (binary) or ppm (color) to pgm (gray-level) image formats. * changes from streambuf.h to iostream.h in ComTerp/comterpserv.c to fix-up a Debian ivtools work-around. * remove bug in initialization of attribute expression dialog box. * fix #define's in src/include/std/math.h to use __svr4__ instead of solaris. * define a Version 11 idraw PostScript format for the use of the GNU Plotting Utilities (plotutils-2.0). When finalized it would add support for cap-styles, join-styles, and floating point line widths, to the graphics library underlying idraw and drawtool. * adds a GrayRaster::set_minmax method used to set the minimum and maximum numeric value used when mapping onto the minimum (0) and maximum (255) gray-level values. * adds a static ParamList* RasterOvComp::get_param_list() to return the list of parameter parsing structures, and a ParamList::add_param_first() method useful for overriding a default parameter. April 8th 1998 ivtools-0.6.3 New Programs * adds an ivxt example program, which demonstrates the newly developed embedabbility of an ivtools drawing editor in a Motif or Xt applications that uses the Motif or Xt event loop. Drawing Editor Changes * adds "X" as the keyboard shortcut for "Copy Forward" in flipbook, and "Y" for "Copy Backward" (under the Frame menu). * adds two bash scripts for generating GIF89A animations from the Print dialog box on flipbook, mkgif89a and mkgif89ac. See the scripts in ivtools-0.6/src/scripts for more details, or look at http://www.vectaport.com/ivtools/flipbook.html for instructions on how to use them. * adds an updated anytopnm sh script to ivtools, which gets installed along with the rest of the binaries, which gets used by the import dialog box when the new "auto convert" button is selected. Originally from Jef Poskanzer and pbmplus, it tries to figure out what kind of image file has been selected, and convert it to either pbm, pgm, or ppm format. Doesn't work (yet) for converting ASCII versions of the pbmplus formats to the necessary binary ones. * expanded usage documentation for drawtool, flipbook, and comdraw: * added -panner_off, -zoomer_off, -slider_off arguments to all three. * added -panner_align tl|tc|tr|cl|c|cr|cl|bl|br|l|r|t|b|hc|vc to all three * added -toolbarloc l|r to drawtool and flipbook * added -help to all three Interpreter Changes * adds sorting for the output of the help command in any comterp. * add a remote command to comterp, which can be tested by running "comterp remote". The documentation for this command is: remote(hoststr portnum cmdstr) -- remotely evaluate command string then locally evaluate result string This can be used to run an arbitrary (new-line terminated) command on a remote server (it doesn't have to be a comterp), and read back a (new-line terminated) result that is then evaluted within the local interpreter and the result pushed on the stack. * adds a continuation prompt to comterp "> ", for when expressions are detected as incomplete by the parser. Disabled when running commands from a file. Glyph Example Changes * reinstates the string chooser in the glyphterp example program that lists all predefined commands in the associated interpreter, including all the operators (i.e. "++") which are converted to commands by the underlying scanner/parser (i.e. "incr_before" or "incr_after"). Library Changes -- InterViews -- * extends the InterViews Session class to allow for something else (like Motif) to create the Display object, by adding a nil-defaulted Display* argument to Session::init. -- Unidraw -- * adds a reverse flag to Unidraw's DirtyCmd, to allow it to be used as "CleanUpCmd", i.e. to clear the modified flag in a drawing editor, which in turn causes the Save dialog box not to appear when an editor is quit. * moves the PageGraphic class definition from Unidraw/upage.c to Unidraw/upage.h, so that other applications can get at the page size after the page graphic is created. -- Attribute -- * adds dump method to AttributeList (Attribute/attrlist.h) for debug purposes. There is also a typedef class AttributeValue _AV; in Attribute/attrvalue.h, to aid in casting in debugger to avoid seeing static class members on ComTerp/comvalue.h when debugging the use of ComValue's. -- ComTerp -- * adds method to ComTerp to return a sorted list of commands added to it. * makes ComTerpServ's run methods re-entrant by saving then restoring more of the interpreter state,, so that a derived ComFunc can call comterp()->run(...) in its execute() method. *add more type test methods to AttributeValue:is_unknown() (whether the type is UnknownType), is_known(), and an is_string() which is true for string and symbol. * adds a fourth boolean argument to ComFunc::stack_key to always return the third argument as the default, not just as a default for when the keyword is supplied without argument. In this case a value of true is returned whenever the keyword is supplied without argument. -- OverlayUnidraw -- * adds these methods to OverlayComp, and the symid version to OverlaysComp: virtual AttributeValue* FindValue (const char* name, boolean last = false, boolean breadth = false, boolean down = true, boolean up = false); virtual AttributeValue* FindValue (int symid, boolean last = false, boolean breadth = false, boolean down = true, boolean up = false); at present only depth-first downward search returning the first value found (prefix) is fleshed out. * sets up mixin classes for indexing gs's, point lists, and pictures (compound graphics) * uses those classes in OverlayIdrawComp to mix in the indices formerly internal to the class. * creates an alternate to OverlayComp::GetAttributeList, ::attrlist(), which returns nil if it doesn't exist, as opposed to creating one. Therefore attribute checking code can be written that never creates an attribute list if one doesn't exist. * used OverlayComp::attrlist to add a readonly attribute to a comp. * changed all the composite comp ::Definition methods to check for the readonly attribute on their children, and suppress output if true. -- FrameUnidraw -- * allows for the reading in of arbitrary graphics in FramesScript::ReadChildren Configuration Changes * adds an ProjectDir definition to config/site.def.$CPU and a PROJECTDIR make variable to config/params.def. Now the base directory for all the source packages relied on for the build of ivtools can be set in a single place. The default is /proj * configuration fixes for Solaris 2.6 compilation -- see http://www.vectaport.com/vectaport/solaris-2.6-build.txt for more details. Bug Fixes * fixes bug in OverlayUnidraw (drawtool), whereby duplicated groups (OverlaysComp's with Picture graphics) shared a Transformer between the subject and the view, which effectively disabled the damage repair mechanism whenever the only change to the group graphic was described by a change to the Transformer (i.e. a rotate, scale, move, or stretch). * fixes a bug in the export of rasters by pathname in drawtool documents February 26th 1998 ivtools-0.6.2 Drawing Editor Changes * conditionally adds a ConvexHull tool to drawtool if qhull from the University of Minnesota Geometry Center can be found via your PATH environment variable. To acquire and build this separate executable see http://www.geom.umn.edu/software/download/qhull.html * adds a "Compute Attributes" item to the Edit menu (SetAttrByExprCmd). This brings up a dialog box on the current selection, and allows the user to enter an arbitrary attribute value expression and evaluate it. For example, if a component had an attribute of "likelihood", a new attribute called "likelihoodsquared" could be set with an expression of "likelihoodsquared=likelihood*likelihood". Keyboard shortcut in drawtool is "#" Interpreter Changes * adds these mathematical functions: acos, asin, atan, atan2, cos, sin, tan, pow, exp, log, log10 * adds a min and max function that promotes operands as needed, similar to the other arithmetic operators. * adds a cond operator that returns one of two values based on a boolean test. Pre-evaluates all parameters (like every other current command except help). In the future there can be "if", "for", and "while" commands that use a lazy, post-evaluation technique. * adds a paste command to comdraw, for use in any derived application that builds up a component that needs pasting in the viewer. Library Changes * TopoFace -- adds methods to construct and return a floating point geomobj that reuses the points without duplicating them: FPointObj* TopoNode::point_obj(); FMultiLineObj* TopoEdge::multiline(); FFillPolygonObj* TopoFace::polygon() * OverlayUnidraw -- - fixes linear scaling and logarithmic scaling of GrayRaster's - fixes mechanism for embedding of a graylevel test strip in GrayRaster's - adds an edlauncher() mechanism to OverlayEditor to allow for the inclusion of arbitrary editors into the main.c of one specific editor. - adds a comterplist() mechanism to OverlayEditor to manage a global list of registered interpreters. Allows for one editor to execute expressions on another editor's associated interpreter. - adds more mouse documentation lines to OverlayKit - adds OverlayViewer ::ScreenToGraphic and ::GraphicToScreen methods, for converting between the x,y of mouse clicks and the coordinate system of a graphic. Useful for addressing individual pixels of a raster. - adds a boolean OverlayKit::bincheck to test for the presence of an executable before relying on it. Uses OverlayKit::bintest under the hood. - mixes in Observer and Observable as multiply inherited base classes of OverlayComp. Now other update/notify systems can be constructed around and within the subject/view hierarchy of a Unidraw editor. * ComTerp -- - clones the above into a ComFunc::bincheck and ComFunc::bintest, for use of generic ComFunc programmers - add a new parameter to ComFunc::argcnts, nargskey (defaulted to zero), which is used by ComTerp to inform the func of how many arguments are associated with keywords. - add a ComTerp::stack_height() method to tell the current size of the stack. Configuration Changes * sets up drawserv to link in FrameUnidraw as well as GraphUnidraw, and then tests this with a new Editors menu that allows for the launching of other GraphEditor's or FrameEditor's * sets up drawserv to be installed with "make install" * sets up comterp to use the original Iterator and UList objects from Unidraw, instead of the ALIterator and AList in the Attribute library. But then, so raw comterp programs won't have to link in all of Unidraw and InterViews, new libraries called Unidraw-command and IV-common were set up to build with only symbolic links to the necessary files: IV-common: listimpl.c, memory.c, regexp.c, resource.c, textbuffer.c Unidraw-common: iterator.c, ulist.c * removes the RCS tags from the TIFF source Bug Fixes * fixes a segfault when attempting to import an empty file * fixes bug in the mechanism for managing absolute and relative pathnames for drawtool and related documents. January 23rd 1998 ivtools-0.6.1 Drawing Editor Changes * clear any error message on the import, export, open, and save-as dialog boxes from previous attempts upon starting a new attempt. Interpreter Changes * add help command that lists available commands by default, or specific information about each command supplied as an argument. * to support the help command the interpreter was evolved to support a lazy-eval command, one that gets invoked before its arguments get computed. The next release of ivtools should make use of this with conditional and looping commands, the traditional control constructs of procedural programming. Library Changes * TopoFace -- add separate methods to attach start and end nodes to an edge: TopoEdge::attach_start_node(TopoNode*); TopoEdge::attach_end_node(TopoNode*); -- and methods to test if a edge starts or ends at this node: TopoEdge::starts_at(TopoNode*); TopoEdge::ends_at(TopoNode*); * OS -- add a method to test the table iterator's current entry. helps avoid a nil pointer reference in case of an empty table: TableEntry(Table)* cur_entry(); * OverlayUnidraw -- fix bugs caught by ElectricFence, including one to the gs-based selection highlighting mechanism of OverlayUnidraw. Also fix problem with flushing of deferred-loading rasters and save/restore of arbitrary numeric gray-level rasters (GrayRaster) * ComTerp -- fix bugs caught by ElectricFence, like referencing off the ComTerp stack. Increase default buffer size on ComTerpServ to 1k. Change the ";" operator (SeqFunc) to return the second argument on the ComTerp stack. Add a ComValue::unkval() to return a static ComValue of UnknownType. * Attribute -- disable Attribute's call to symbol_del which sometimes inadvertently removes a symbol from the symbol table when an Attribute is destructed. This needs to be evolved so that either the symbols are never removed after being created, or there is an accurate ref counting done when using ComUtil's symbol_add and symbol_del. This release also improves the overall memory mgmt of Attribute's, AttributeList's, and AttributeValueList's. Finally, this release adds support for reading in comma-separated list of AttributeValue's (into an AttributeValueList). Configuration Changes * incorporate patches to iv-3.2a published by Randall C. O'Reilly and others of the CMU Psychology Dept., part of the pdp++_1.2 distribution. One thing this does is prefix all the globals in InterViews/coord.h with "iv" (i.e. inch is ivinch, cm is ivcm) if PDP_PLUS_PLUS is defined. If PDP_PLUS_PLUS isn't defined (the default), these global variables stay the same, but #define's are included which prefix "iv". * also incorporate Alpha and Stratus entries for config/arch.def from the pdp++ distribution. Still probably need the associate iv-*.cf files. * change the build order so that ComUnidraw (and comdraw) get built before GraphUnidraw and FrameUnidraw, and then inherit GraphEditor and FrameEditor from ComEditor. * incorporate Doug Scott's iv-3.1 event handling patch that enables use of the shift key. * remove all explicit e-mail addresses from ivtools for spam protection December 23rd 1997 ivtools-0.6 * version change * renamed Topology library to TopoFace to avoid conflict with IUE and Target Jr class libraries of the same name. ivtools-1.2.11a1/CHANGES-0.7000066400000000000000000001613571214471147700150370ustar00rootroot00000000000000September 14th 1999 ivtools-0.7.10 Drawing Editors * propogate the horizontal-drawing-of-text-while-in-landscape-mode enhancement that's been in drawtool for awhile to idraw, because this is a long-standing Debian request, and it's hard to see how it would bother anyone. Before you would be entering vertical text when in landscape mode. Now it will be horizontal, just like it is in portrait mode. Interpreter Changes * change comterp's for and while command to accept an extra fixed argument for the body expression if no :body argument exists, i.e.: for(x=0 x<10 x++ print("%d\n" x)) x=0;while(x<10 print("%d\n" x)) instead of: for(x=0 x<10 x++ :body print("%d\n" x)) x=0;while(x<10 :body print("%d\n" x)) * fix bugs in incr_after (postfix ++) and decr_after (postfix --) commands in comterp. Library Changes -- Attribute -- * add methods for checking a "blank" AttributeValue. These are pushed on the stack by comterp whenever an interpreter command fails to put anything on the stack. AttributeValue::is_blank static AttributeValue::is_blank(ValueType t) -- OverlayUnidraw -- * set up a new method, OverlayEditor::ReplaceComponent, to do what ::SetComponent does, plus delete the old component if it is no longer used in the Unidraw environment. This gets rid of a bug that appeared in ivtools-0.7.9, where the deleting of the old component was done in two places, once in OvNewCompCmd::Execute (where it has always been done) and once in OverlayEditor::SetComponent (where it was done for the duration of ivtools-0.7.9). * fix bug (that appeared in ivtools-0.7.9) for handling of the New command Postscript-format option on the export dialog box. Miscellaneous and Configuration Changes * a set of changes to config files and some source files to get ivtools compiled on Windows NT using Cygwin beta 20. Everything works to build the executables, including the configure script and the imake process. Haven't yet tested it with an X server. See README.cygwin for more details. Thanks to John Carlson at Lawrence Livermore National Labs for showing this was possible with his copy of InterViews, Cygnus Solutions' Cygwin environment, and X11R6.4 Xlib binaries from NASA. * change the script in aclocal.m4 for finding the CPlusPlusIncludeDir to work on Windows NT (with Cygwin) as well. * rename these directories: comterp, iueserv, drawserv to: comterp_, iueserv_, drawserv_ This is to avoid a collision with the library directions ComTerp, IueServ, and DrawServ which would happen when untar'ing ivtools on a Windows NT box (using the Cygwin tar). Although upper and lower case are preserved, they are not distinct for purposes of file comparison on that platform. July 30th 1999 ivtools-0.7.9 Drawing Editors * add a "PostScript" format to the export dialog box, which means when checked to use the existing incompatible extension to idraw PostScript format which supports color image rendering. With normal idraw format, which is a restricted formulation of real PostScript, the color images print grey. * terminate a multi-point drawing tool if right-clicks cause the number of vertices to become zero. * added keyboard shortcuts for zoom-in (Shift-Z) and zoom-out (Ctrl-Z). * change behavior of magnify-tool to zoom by 2 around a single-click. Done in all drawing editors, including idraw. Interpreter Changes * modify the comterp "+" operator to concatenate two strings. * create a comterp eval command to take a set of strings and return an array of evaluated results on the stack. Same functionality as the "," operator, only from strings. * add a :str and :err keywords to comterp's print func. :string already existed, :str is just shorter for something so commonly used (since the advent of string concatenation). :err writes to stderr instead of stdout. * fixed bug in comterp help func that caused a segfault when help was requested for unknown operator strings, i.e. help("^") Library Changes -- IV-common and Unidraw-common -- * add a link to Unidraw/geomobjs.c from Unidraw-common, and a link to OS/math.c to IV-common. This is done so that both geomobjs.c and fgeomobjs.c can be used from comterp. This is tested with the construction of a PointObj and FPointObj in comterp/main.c. So if you can get everything built through comterp you can make use of these geometric objects without any other IV or Unidraw code. -- Attribute -- * added API to ComModule () to inspect the operator table for infix,postfix, or prefix operators that match a string. -- Unidraw -- * deprivatize boolean Unidraw::updated(), so it can be used to prune unnecessary calls to Unidraw::Update from comdraw. -- AttrGlyph -- * modified AttributeListEditor::update_text to put a blank after long attribute names. -- OverlayUnidraw -- * three partial experiments to improve the incremental loading of rasters from URLs. Each temporarily disabled for various reasons with a unique #define: #define OPEN_DRAWTOOL_URL // define for drawtool document loading // from a URL in ovimport.c #define RASTER_DAMAGE1 // define for incremental flushing of raster // in ovraster.c #define RASTER_DAMAGE2 // define to use mb of incrementally loaded // region for raster damage in ovraster.c The OPEN_DRAWTOOL_URL attempt first causes a placeholder graphic to be opened and displayed, and nothing more happens until you manipulate the placeholder graphic in some way, like moving it. Then the contents of the drawtool document is displayed, which may include raster referenced by URL, which are incrementally displayed as they are loaded. The RASTER_DAMAGE1 attempt works when importing images or opening them by themselves or another document, but you can see artifacts (all white rows) if you zoom in and out repeatedly during the load process. The RASTER_DAMAGE2 attempt works when importing images but not completely when opening images by URL whether stand-alone or in a drawtool document. -- ComUnidraw -- * start work on an ivtools distributed whiteboard capability. Decided to implement this using the comdraw command interpreter. Now all the Command objects generated by a Manipulator are indirectly executed via a new ComEditor::ExecuteCmd method (the base class method, OverlayEditor::ExecuteCmd, just calls Command::Execute immediately). This indirect execution is where things will get beefed up to make for a distributed whiteboard. Right now, whether you specify -wbmaster or -wbslave on the comdraw command line, all the PasteCmd's (the commands that result when a GraphicCompTool is used) are converted into comdraw script capable of constructing and pasting the equivalent comp. In the future this script would be transmitted to the whiteboard master, then redistributed to each whiteboard slave. Right now it is simply interpreted within the local comdraw, to show that things work (somewhat). The script is generated by constructing a SCRIPT_VIEW of the components in the clipboard of the PasteCmd, then having it write it's ::Definition out to an ostrstream. This worked fine for ellipse with no changes to the generated script. Synonym commands had to be set up for rectangle (rect), arrowline (line), arrowmultiline (multiline), and arrowspline (closedspine). Right now it works for everything but the text graphic, and any of the multi-point graphics. Currently it ignores all the additional arguments that get spewed out in the script (like :fgcolor) and takes these instead from the default graphic state of the viewer. When used in a true distributed fashion these would need to be used, and this would then allow each person to have their own default graphic state. Miscellaneous and Config Changes * fix the inclusion of nan.h when using glibc-2.0. It already worked for glibc-2.1. It migrates the conditional include of nan.h from OverlayUnidraw/grayraster.c to src/include/ivstd/nan.h. It tests for !glibc-2.0 before using bits/nan.h as the include file pathname. Worked out with help from Guenter Geiger. * patches to compile on SunOS 4.1.4 from Nico Kadel-Garcia at the Massachusetts Eye and Ear Infirmary. * remove fgeomobjs.c from Unidraw-common. It didn't really belong there. * modify the configure script to detect if necessary symbolic links are missing and add them. This happens when you get a copy of ivtools from a cvs repository. * threw out the Dispatch/ace*.h files. If there are used anywhere those references will have to be changed to AceDispatch/ace*.h. * added links from the PERCEPS-generated documentation to the old 3.1 man pages for the Dispach library. Full-up links for InterViews and Unidraw remain to be done. * fixes for building with ACE 4.6.15 and glibc-2.1, submitted by Guenter Geiger. * beefed up MANIFEST.comterp (and README.comterp) so that now a stand-alone comterp tar file can be created, untarred in a new place, configured, built, and installed. All works smoothly now. The resultant tar file is 1/5th the size of the entire ivtools. * removed a Use_libInterViews() from src/Attribute/Imakefile, because this library doesn't really have an InterViews dependency (only IV-common and Unidraw-common). From Guenter Geiger. * new InstallXDefaultAs rule in config/rules.def from Guenter Geiger, to get the permission right when installing InterViews.defaults. June 10th 1999 ivtools-0.7.8 Interpreter Changes * migration of the stream operator "," upwards in the parsing priority table, to have higher priority than the assignment operators, so that something like: v=1,2,3,4 ends up assigning a list to the variable v that can be passed to commands like size, at, sum, etc.. * came up with a solution for iterating over multiple space delimited expressions in a single line of input when using a comterp in server mode. Now something like: 1 2 3 4 returns: 1 2 3 4 * add an echo of returned results to the comterp client mode. Library Changes -- Attribute -- * add extra predicates to AttributeValue: AttributeValue::is_numeric() (same as ::is_num) AttributeValue::is_object() * change timer mechanism in ComTerpHandler to disable old timer before creating new one. -- ComTerp -- * catch one more place (ComTerpServ::runfile()), where the bufsiz needed to be kicked up to 1M. -- FrameUnidraw -- * fix bug in deserializing code for a FrameIdrawComp so that if a background frame already exists another one is not created. Config and Miscellaneous Changes * add IET Inc. to the overall copyright, to reflect their new status as a contributor to and supporter of ivtools. * added workarounds for glibc-2.* needed by Dispatch/dispatcher.c and OverlayUnidraw/grayraster.c. Makes ivtools compile on RedHat 6.0. May 3rd 1999 ivtools-0.7.7 Drawing Editor and Drawing Editor Framework Changes * add Ellipse::ellipse_to_polygon method, to return a list of points that define an ellipse as a polygon. Interpreter and Interpreter Framework Changes * add command to return the size of a list (ListSizeFunc/size). * add command to return the nth member of a list (ListAtFunc/at). * add a :nowait argument to the remote command, to allow for asynchronous transmission of commands to a remote interpreter. * add a ComFunc::exec method for use of derived class ::execute methods. It calls ComFunc::push_funcstate, then ::execute, then ComFunc::pop_funcstate. * fix a bug where the print command was passing a double to a float format string. * add an AttributeList::merge method, for combining the contents of two AttributeList's. * add a ComFunc::stack_keys method, for returning all the keyword/value pairs of a ComFunc invocation in an AttributeList. * create a SetAttrFunc in ComUnidraw that can be used to set the attributes of a graphic component via the command interpreter. Config and Miscellaneous Changes * fix problem with relative install of shared libraries that was recently introduced. * TopoFace/fgeomobjs.c temporarily incorporated into Unidraw-common so it can be made use of from comterp and other IV-free applications. The better long-term approach is to link the TopoFace library into comterp, and incorporate any IV or Unidraw classes that it relies on into IV-common or Unidraw-common. * Experiment with a MANIFEST.comterp that specifies a stand-alone subset of ivtools that excludes the bulk of IV and Unidraw. The resultant source tree builds with a "./configure;make World", but there are lots of warnings and errors to be smoothed over. * increment all the buffer sizes associated with comterp from the default 1K (BUFSIZ) to 1M. A better solution would be to revisit the continuity of command input over multiple input buffers for the various modes of input (or at least make it a command line parameter or X resource). When entering command via stdin it is easy enough to use command line continuation (automatically invoked if an expression is incomplete) or character string continuation (a backslash followed immediately by a newline). But this generality does not apply to socketed interactions, etc.. The buffer overrun (at 1K) was being correctly detected, and disaster averted, but it was still a problem because there was no course of correction. So upping it to 1M is a quick fix. * fix a file id limitation of 20 on Solaris. April 16th 1999 ivtools-0.7.6 Drawing Editor and Library Changes * when reading rasters from URL's, set the "by-pathname" flag based on import dialog box check box. This flag controls whether a raster is serialized with just a pathname or with all the pixel data. * update flipbook's view menu to include things like the scribble pointer, etc.. Still no support for multiple viewers. * fix some very old event handling bugs in drawtool etc.. Have you ever seen the cursor jump the first time you draw or move something in an editor? There were two different problems, one where X coordinates were not getting converted to IV coordinates (upper-left origin to lower-left origin), and the other was a little more tricky. Whenever something is dragged in an editor, the software issues an XGrabPointer to the server, so that all subsequent events come through relative to the canvas of the drawing editor. Except, because of the client-server nature of X, it was possible for some motion events to slip through before the XGrabPointer had taken affect! * add a pointer-tracking mechanism to drawtool (invoke with -ptrloc command line argument). This introduces an extra bar across the top (below the menu-bar) with a constantly updated readout of the pointer in document coordinates. Several things had to be developed to make this work: - a static function pointer (a callback) was added to the Event class, to be invoked (if defined) for every event read from the X server. This is its signature: typedef void (*event_tracker_ptr)(Event&); and these are the methods for setting and retrieving the static function pointer: static event_tracker_ptr event_tracker() { return _event_tracker; } static void event_tracker(event_tracker_ptr ptr) { _event_tracker = ptr; } - a static method on OverlayUnidraw was developed that matched this signature: static pointer_tracker_func(Event&); this method ignores all but motion events, but still had to deal with 3 different kinds of motion events: 1. motion events associated with the top-level window (the ApplicationWindow) before the offset to Unidraw canvas is known (this requires traversing the X Window tree to compute the offset using a new method Window::offset_from_toplevel). 2. motion events associated with the top-level window after the offset to Unidraw canvas is known (which happens after the first mouse click within the Unidraw canvas). 3. motion events directly associated with the Unidraw canvas (these occur during a drag operation within the canvas). In each case the right thing was done to convert the raw XEvent locations to canvas screen coordinates, which are then converted to drawing coordinates using OverlayViewer::ScreenToDrawing. This method also deals with multiple-editor/viewers, by searching the Unidraw editor list to find which editor/viewer the event corresponds to. - finally, a state variable was developed (PtrLocState) that converts the screen coordinates to drawing coordinates and displays them in a glyph. Config and Miscellaneous Changes * really make things work without a CPU environment variable. It was necessary to change a $$CPU to a $(CPU) in the makefile stuff. * modify configure script to allow for the specification of only one pathname for each underlying library. You can still specify the second pathname to explicitly say where the libraries are, but if it can find them without this everything works. For example, you only have to supply --with-ace, and not --with-ace-libs, if the libraries and include files for ACE are co-located. * fix unnecessary bash dependency in configure script. export PWD=`pwd` is now PWD=`pwd';export PWD. * various fixes to Solaris 2.6 build and install submitted by Roy M. Lecates of Fore Systems: - workaround for collision with #define of ManDir in config/config-solaris-gcc.mk - new command line for installing symbolic links: "tar cf - file | (cd dir; tar xfp -)" instead of "cp -d" - patch to make src/sripts/bsdinst.sh handle multiple files * patch to add "[]" after delete where ever purify wants it, submitted by Roy M. Lecates of Fore Systems. * explicit definition of FloatCoord (same as the default Coord) in src/include/InterViews/coord.h March 19th 1999 ivtools-0.7.5 Drawing Editor Changes * re-center rasters imported from a URL as soon as the width and height are known. * fully animate move/scale/stretch/rotate tools. Can be disabled with -opaque_off or -opoff given to drawtool or any derivative editor. Interpreter Changes * add an import command to comdraw, which for now takes a raster URL and imports it into the drawing editor. To try it out, run ivtools flipbook, enable auto-new-frame (under the View menu), then enter something like the following into stdin: for(x=1 x<5 x++ :body import(print("http://www.vectaport.com/ivtools/aaron-%d.gif" x :string))) Library Changes -- OS -- * make the offset for String::contains apply to the internal string. Didn't make much sense applied to the first argument. -- IV-2_6 -- * add a ClassId system to all the classes derived from Rubberband, for use of the OpaqueDragManip described below. -- ComTerp -- * add short and ushort output to ComValue ostream operator. -- OverlayUnidraw -- * fixed a bug in OvImportCmd where imports via ACE were getting treated like URL imports for asynchronous incremental download (because the is_url flag was set). * migrate OvImportCmd::is_url to be a method that computes its value from a pathname, instead of needing to be set and cleared. * in OvImportCmd, separate out the code fragment for centering a newly imported component, snapping to grid if gravity on: static void OvImportCmd::center_import(Editor*, GraphicComp*) then use it to re-center a raster being imported from a URL as soon as the width and height are known. * create OpaqueDragManip (OverlayUnidraw/ovmanips.c) to replace the rubberbands with directly visualization of graphical transformations (move/scale/stretch/rotate). Care was taken in the creation of OpaqueDragManip, making sure that there was no cumulative error accrued with many small mouse moves, so hopefully you'll never see the graphic jump when you let go of the mouse button. -- FrameUnidraw -- * fixed a bug in FrameViewer::Update, where ::Update was getting erroneously called when a resize was needed (same problem was fixed a short while back in OverlayViewer::Update). Config and Miscellaneous Changes * upgrade the configure script to auto-determine the CPU type, the PWD, the XCONFIGDIR, and the GPLUSPLUSINCLUDEDIR. This greatly simplifies the INSTALL directions. Now the following command is all it should take to build from source on most commercial Unix'es (as long as imake invokes a gcc version of cpp): ./configure;make World;su -c "make install" To do this I had to generate two output files from configure, one to feed the imake process as before (a config/config--gcc.defs generated from config/config.defs.in), and another (config/config.mk) to be directly pulled in by the top-level Makefile (and every other Makefile). * restructure the declaration of make variables for library pathnames in config/local.def (adds a new file, config/makevars.def), so that each library has to be listed only twice, once for the LIB* variable, and once for the DEP* variable. * add support for file: to ParamList::urltest and OpenFileChooser::urltest (this is conditional on finding w3c or curl). * gcc-2.8.1 warnings fixed. * remove a duplicate -I on the src directory when compiling. February 27th 1999 ivtools-0.7.4 Drawing Editor Changes * make use of the X Shared Memory extensions for raster display. * implement asynchronous download and incremental display of color images from a URL. To test, make a local copy of http://www.vectaport.com/ivtools/anteaters.drs, and open it with ivtools drawtool. Watch while the rasters within this drawing are downloaded from various web servers. Before its finished you can pan or zoom the drawing, and move or draw any graphic (including the partially downloaded rasters). Then you can Undo all your changes to get back to a fully-loaded, unmodified drawing! * add support for Ctrl-K (delete-until-end-of-line) to the string editor used throughout ivtools. * add support for pasting the current X Window selection when the middle mouse button is clicked within a string editor. Especially useful for the string editor used within the Open and Import dialog boxes. * add a one-line welcome message to every drawing editor that gives the ivtools version number, identifies the editor, and states how to find more information. * complete support for floating point brush width (line width) in all ivtools drawing editors. New idraw PostScript format version number (12) introduced to facilitate this. Version 11 has been in use since ivtools-0.6.7, and differed from the class Version 10 in only one detail, the addition of "closepath" to the PostScript fragments for circle and ellipse graphics. Version 12 is forward-compatible, in that future versions of idraw will be able to always read it, but for the first time in a long while there is no guarantee of backward compatibility. This has been the design and intent of the idraw version numbering system all along. Ideally what this means is that users of older versions of idraw would see a warning message that explained why a newer format drawing didn't load. Unfortunately pre-existing bugs in idraw (ones that have been fixed since ivtools-0.6.7) cause the warning message to have zero's where version numbers should go and/or cause idraw to segfault when it can't load a newer format. The warning message should work ok for users of idraw from Debian 2.1. For more details see: http://www.vectaport.com/ivtools/faq.html#idrawversions. * The incrementing of the idraw format version number was undertaken to add support for floating point line widths, at the request of Robert S. Maier, the developer of GNU plotutils. This possiblity has not been enabled yet. But to show off the new capability a "Precise Width" was added to the Brush menu of drawtool, etc.. For kicks try something like 10000. * add a check for using the curl download utility, after checking for the w3c download utility, and before trying the native ivdl utility. Interpreter Changes * add a one-line welcome message to every interpreter that gives the ivtools version number, identifies the interpreter, and states how to find more information. Documentation Changes * finalize the embedding of PERCEPS extractable comments in the header files for most of the class libraries: http://friga.mer.utexas.edu/mark/perl/perceps/ * add a -t argument to iclass to generate a tree structured web page of links to HTML class documentation. * create a src/html directory with enough instructions and PERCEPS template files to allow a third party to recreate most of the HTML documentation for ivtools found under: http://www.vectaport.com/ivtools/doc/ ComTerp Framework Changes -- ComTerp -- * make NilFunc that ignores all its arguments, does (almost) nothing except for returning nil on the stack. Bind it to the nil symbol in comterp. * fix problem with undefined commands inside the body of a control command by substituting a NilFunc to execute (while preserving the symbol id associated with the undefined command). * add a _command_symid member variable to ComFuncState, so that this value can be used a NilFunc to report what undefined command is being skipped by returning nil on the stack. * add numeric conversion funcs: char (CharFunc), short (ShortFunc), int (IntFunc), long (LongFunc), float (FloatFunc), double (DoubleFunc). In the future unsigned'ness can be added with keyword arguments, and maybe a boolean func could be defined as well. Glyph Framework Changes -- IV-X11 -- * add support for the SelectionNotify X11 event type. This is what a client receives after it makes a request for the current X selection (i.e. what happens when the middle mouse button gets pressed in something like an xterm). * add a new InputHandler virtual method: InputHandler::selection_notify(const Event&); this gets called whenever a SelectionNotify event arrives at an InputHandler. -- InterViews -- * make a FieldEditor::selection_notify(const Event&) method that in turn delegates the SelectionNotify event to a new FieldStringEditor::do_xselection_paste. * finally (actually this was first), change the FieldStringEditor::press method to call a new FieldStringEditor::do_xselection_request whenever the midddle button is pressed. When that happens the client asks the server to get the current window manager selection from whomever owns it, and assign it to a property on the local window. When this is done a SelectionNotify event gets generated and FieldStringEditor::do_xselection_paste ends up getting called to paste the result into the FieldEditor. Voila! -- glyphs/examples3.1 -- * add most of the InterViews 3.1 glyph example programs in a subdirectory alongside the rest of the glyph examples, except for gl which requires gl.h and punidraw which requires Unidraw. morpher and plot/sendplot need to be debugged. * to run the button2 example you have supply a tif file as the first argument on the command line, or have a copy of jello.tif (from the 3.1 distribution) in your current directory. * create README's for src/glyphs and src/glyphs/examples3.1 * make the morpher example use its own classnames for things in figure.(ch) This is the same process that created IVGlyph/figure.(ch) a long time ago. These could be made to use the same classes, but not worth doing until the morpher example looks more promising. Maybe even the morpher example should be thrown out (again). Unidraw Framework Changes -- OverlayUnidraw -- * change Overlay(s)Comp's interpretation of a duplicate command (DUP_CMD), to duplicate the AttributeList as well if one exists. * change the ::Copy methods of all the comp's in OverlayUnidraw, to replicate the associated AttributeList if there is one. -- GraphUnidraw -- * debug the duplicate (DUP_CMD) command when used on NodeComp's in graphdraw. Turns out the istream constructed NodeComp's did not have the same layout of graphic state as the others. The underlying TextGraphic did not have a Font pointer, for example. This was no problem in rendering, but was a problem for the duplicate command, which invoked a get-extent operation which failed for lack of knowing the font. Fix was to push down gs of the Picture graphic associated with the NodeComp to be in the underlying ellipse and text graphics as well. -- DrawServ -- * rename all the classes in DrawServ to have a "Draw" prefix instead of a "Com" prefix, to alleviate confusion between the ComUnidraw and DrawServ layers. * derive everything in DrawServ from FrameUnidraw. Already DrawServ had been able to handle components from GraphUnidraw without having its mechanisms inherited from GraphUnidraw. This "finishes" the job, making for a multi-frame graph editing framework. Miscellaneous and Config Changes * remove all WishList files. This is now handled outside of the tarfile, some of it on: http://www.vectaport.com/ivtools/help-wanted.html * changes required based on feedback from M. Rasit Eskicioglu at the University of Alberta, as he tried (and succeeded) building ivtools on Solaris 2.6, as well as a few changes based on feedback from Bruno DelFosse at Thompson CSF (Dec Alpha guy). * many improvements to the non-relative installation process (the default), including fixing the generated ivmkmf script. * creation of an uninstall makefile target, which reverses the effect of "make install". Useful for backing out the installation of one version of ivtools before installing another, or before switching modes of installation. * src/include/std renamed to src/include/ivstd, so it makes a little more sense when someone does a non-relative install in /usr/local. * upgrade to gcc-2.8.1 and libstdc++-2.8.1.1, which required some changes: - new src/include/ivstd/signal.h file, to reset NULL to be 0 (instead of ((void*)0). Same trick required in src/include/ivstd/string.h (to avoid new warnings). - add the OS String class to the IV-common library, and extend it so that utils/ivdl could be ported to use it, to avoid any use of libg++ String (libg++ is no longer recommended, at least by the gcc-2.8.1 distribution). - changes to Attribute/paramlist.c and a few others to get rid of new warnings. * upgrade to ACE-4.6, which required some changes: - the register_stdin_handler method on the Reactor is no longer - need to add -UHAVE_ACE to makedepend - more changes required for ivmaps (like #undef CLOSED after -- that'll be in a patch someday. * add a src/tests directory, with the first program useful for demonstrating no Y2K problem in ivtools (y2k/y2ktest.cc). * incorporate COPYRIGHT.proposed as another way of getting comments. * add comtop.tgz directly to the tar file, the tar file for a sample stand alone custom comterp. * fix up the use ivmkmf in conjunction with comtop.tgz, making it work equally well with and without --enable-relative-install supplied to ./configure. * rewrite the definitions of the library makefile variables in config/local.def, so that a conditionally determined macro gets defined first, then each library requires only a single line after that (and a single line for the dependency make variable). Because of the inflexiblity of the C preprocessor this is not so elegant, in that the arguments to the macro have to include the library name without and without the prefix, and one with a -l prefix. But is still only a single line, which is a big improvement. * make use of the UseInstalled preprocessor define to indicate when Makefiles should be generated to use the installed copy. This really only makes sense (or is only currently used) for ivmkmf when --enable-relative-install was not given to ./configure. * adds a historical list of changes to ivtools over the course of version 0.4 * appends to CHANGES-0.5 changes which occurred for 0.5.1 and 0.5.2. This leaves only 0.5.3 and 0.5.4 (and any work prior to 0.4.0) undocumented. * small change found in Debian ivtools-0.7.3-1 changes. January 26th 1999 ivtools-0.7.3 Drawing Editor Changes * add support for CR and ESC to the attribute editing dialog box of any drawing editor. Now CR accepts the contents of the two field editors (when the focus is in one of them) and ESC clears the field editor with current focus. Also the current contents of the field editors is added to the attribute list whenever OK is clicked. * glyphify (grayish 3d look) the "Precise Page" dialog box, which invokes the command to reset the drawing editor page size. * fix the use of the "save by pathname" checkbox on the export dialog box. * change both the export and print dialog boxes so that they don't clobber a command line or pathname that has been entered when you click on the "to command" checkbox or the output format enums/checkboxes. This is done by disabling the auto-update feature (the thing that automatically places a ghostview/idraw/drawtool command line when "to command" is checked) whenever the contents of the field-editor has changed from the default. Utility Changes * add a -d argument to iclass to dump an html file of links to web pages named the same, i.e. Interactor.html or OverlayComp.html. Each class link is followed by a menu of derived classes. See the result when used on ivtools at http://www.vectaport.com/ivtools/doc/classes/derivedclasses.html. Library Changes -- Attribute -- * add a ParamStruct copy constructor. * protect "int AttributeList::add_attr(Attribute*)", because it requires the user to be aware of the return status and free memory if required, and replace it with a public "void AttributeList::add_attribute(Attribute*)". NOTE: This is a less-than 100% backward compatible change to the API of the Attribute library. You may have to switch your code over to the new method, and in the process you might remove a memory leak. * add AttributeList::add_attr methods that take an "int symid". -- ComTerp -- * changes ComTerp/assignfunc.c to use AttributeList::add_attribute instead of the now protected ::add_attr(Attribute*); -- InterViews -- * remove limitation of 1024 command line arguments for any program. Found while running iclass with more than 1024 header files in the command line. -- Unidraw -- * add a ::Width() and ::Height() method to PageGraphic. * change the copyright notices on all the Graphic-related files that were changed back in 1994 to accomodate hide/show/sensitivity and gs/pts/pic compaction. -- UniIdraw -- * add support for floating point line widths to idraw, as requested by Robert S. Maier, the GNU plotutils guy. This is indicated by Version 11 of the idraw format, but a floating point line width can a) be successfully read if incorporated in an older idraw format, and b) can be successfully ignored by older idraw executables (because the istream method for reading an integer can handle floats). This was easy to do, because the object underlying the idraw brush object PSBrush is Brush, and it had always supported a floating point line width. Further plans for Version 11 of idraw format include support for the capstyle and joinstyle of a brush. * fix an egcs revealed problem in the Arrowhead class (UniIdraw/idarrowhead.*), where an Arrowhead& Arrowhead::operator=(Arrowhead&) needed to be defined as well as the existing Graphic& Arrowhead::operator=(Arrowhead&) (Debian bug #30749). This had not been a problem with earlier C++ compilers, because they defaulted to using the assignment operator for Graphic& whenever an assignment operator for Arrowhead& wasn't available. -- OverlayUnidraw -- * remove a mysterious call to OverlayViewer::Update from within OverlayViewer::Update (invoked when _needs_resize is true). * change the classid macro in OverlayUnidraw/ovcomps.h so that it adds methods ::class_name() and ::class_symid() to any class definition (instead of the previous ::classname() and ::classid(), the latter which had a confusing similarity to the ::ClassId() method on Unidraw components). NOTE: this is a less-than 100% backward compatible change to the OverlayUnidraw API, and may require changes in third-party code that makes use of the macro. * add a call to Observable::notify at the end of OverlayComp::SetAttributeList (something that gets invoked when an attribute editing dialog box gets OK clicked). By default this invokes OverlayComp::update, which calls OverlayComp::Notify, so the ::notify method (used for generic observable/observer notification) quickly gets transmuted into a subject/view sort of Notify/Update. However a derived class can override this (by providing a different ::update method), keeping the two tracks of notify/update separate, which is exactly what happens in NodeComp described below. -- ComUnidraw -- * create ComUnidraw/plotfunc.(ch) to hold BarPlotFunc and the forthcoming LinePlotFunc and ScatPlotFunc. * set up a :newview argument to the barplot func, to make plotting in the current viewer the default behavior. * wrap an OverlayKit::bincheck("plotmtv") around the comterp->add_command for the barplot func. -- GraphUnidraw -- * make each end-node an Observer of each start-node (whenever an edge connects two nodes). Create this observer/observable link in the EdgeConnectCmd, remove it within a GraphDeleteCmd, and restore it after a graphdraw document is newly opened. * use this new observer/observable mechanism between nodes to trigger a dataflow process, where each node recomputes its :value attribute based on a :valexpr attribute when told to ::update itself. Nothing happens if no :valexpr attribute exists. The command that makes up a valexpr assumes in1, in2, etc.. are predefined. The NodeComp::update method goes out and gets these values and builds up a string for ComTerp to evaluate that first sets the values within the interpreter, then executes the :valexpr. The result is place back within a :value attribute. * Here is an example of a graphdraw document with embedded dataflow. The executable script (the :valexpr) with each of the three computational nodes represent the AND, OR, and NOT operators of 4-value Null Convention Logic, 4NCL (http://www.theseus.com): graphdraw(5,5 gs( :fillbg 1 :brush 65535,0 :fgcolor "Black",0,0,0 :bgcolor "White",1,1,1 :font "-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*","Helvetica",12 :graypat 1), gs( :fillbg 1 :brush 65535,0 :fgcolor "Black",0,0,0 :bgcolor "White",1,1,1 :graypat 0), node( :reqlabel 1 :ellipse 300,458,35,20 :ellipsetrans 1,0,0,1,15,36 :text 12,"NOT" :texttrans 1,0,0,1,302.5,487 :gs 0 :valexpr "if(in1=='I'||in1=='N' :then in1 :else !in1) /* NOT */" :val N), node( :reqlabel 1 :ellipse 300,458,35,20 :ellipsetrans 1,0,0,1,-102,-33 :text 12,"AND" :texttrans 1,0,0,1,185,418 :gs 0 :valexpr "if(in1=='I'||in2=='I' :then 'I' :else if(in1=='N'||in2=='N' :then if(in1=='N'&&in2=='N' :then 'N' :else 'I') :else in1&&in2)) /* OR */" :val 'N'), node( :reqlabel 1 :ellipse 300,458,35,20 :ellipsetrans 1,0,0,1,151,-34 :text 12,"OR" :texttrans 1,0,0,1,442.5,418 :gs 0 :transform 1,0,0,1,0,1 :valexpr "if(in1=='I'||in2=='I' :then 'I' :else if(in1=='N'||in2=='N' :then if(in1=='N'&&in2=='N' :then 'N' :else 'I') :else in1||in2)) /* OR */" :val 'N'), node( :reqlabel 0 :ellipse 178,503,35,20 :ellipsetrans 1,0,0,1,-118,-3 :text 16,"" :texttrans 1,0,0,1,60,485 :gs 0 :val 'N'), node( :reqlabel 0 :ellipse 172,341,35,20 :ellipsetrans 1,0,0,1,-116,15 :text 16,"" :texttrans 1,0,0,1,56,341 :gs 0 :val 'N'), edge(85,486,173,439 :arrowscale 1.5 :tail :startnode 3 :endnode 1 :gs 1), edge(82,369,172,412 :arrowscale 1.5 :tail :startnode 4 :endnode 1 :gs 1), edge(222,439,291,480 :arrowscale 1.5 :tail :startnode 1 :endnode 0 :gs 1), edge(341,481,425,438 :arrowscale 1.5 :tail :startnode 0 :endnode 2 :gs 1), edge(233,425,416,424 :arrowscale 1.5 :tail :startnode 1 :endnode 2 :gs 1) ) * add these methods to ease access of other components from an EdgeComp: EdgeComp* EdgeIn(int n) const; // return pointer to nth incoming edge. EdgeComp* EdgeOut(int n) const; // return pointer to nth outgoing edge. EdgeComp* EdgeByDir(int n, boolean out_edge) const; // return pointer to nth edge of given direction. NodeComp* NodeIn(int n) const; // return pointer to node on other side of nth incoming edge. NodeComp* NodeOut(int n) const; // return pointer to node on other side of nth outgoing edge. * add these methods to ease access of other components from an NodeComp: NodeComp* NodeStart() const; // return pointer to start node. NodeComp* NodeEnd() const; // return pointer to end node. Configuration, Documentation, and Miscellaneous Changes * add PERCEPS (http://friga.mer.utexas.edu/mark/perl/perceps/) extractable documentation to the header files of these class libraries: Attribute, ComTerp, OverlayUnidraw, GraphUnidraw. Result can be found at http://www.vectaport.com/ivtools/doc/classes/index.html. * add man pages from iv/src/man/(Dispatch|InterViews|Unidraw) to src/man/man3/. Also put them online at http://www.vectaport.com/ivtools/doc/man3.1/ * add PostScript copy of InterViews 3.1 reference manual. Also put up online at http://www.vectaport.com/ivtools/doc/refman3.1/ * add in PERCEPS class comments with URLs to point to man page from InterViews 3.1 (i.e. href=../man3.1/Border.html) to be embedded in PERCEPS generated web pages, as well as comments with reference manual web page URLs. * add output of attributes when serializing a toplevel FrameUnidrawComp or GraphUnidrawComp. * fix Solaris build problems with OverlayUnidraw/grayraster.c and utils/ivdl, thanks to feedback from Dan DeJohn at Digicomp. * same fixes apply to an Alpha build, given feedback from Bruno Delfosse at Thomson CSF. December 23rd 1998 ivtools-0.7.2 Drawing Editor Changes * enable deferred loading of rasters-by-URL, similar to the deferred loading of PGM/PPM rasters. Tested with the following flipbook document, which brings up the first frame, and loads the subsequent frames only when moved to: flipbook( frame(), frame( raster("http://www.nps.gov/apis/photo1.jpg" :transform 1,0,0,1,120.5,271) ), frame( raster("http://www.nps.gov/apis/photo2.jpg" :transform 1,0,0,1,120.5,271) ), frame( raster("http://www.nps.gov/apis/photo3.jpg" :transform 1,0,0,1,120.5,271) ), frame( raster("http://www.nps.gov/apis/photo4.jpg" :transform 1,0,0,1,120.5,271) ) ) * set up a continuously-looping slideshow mechanism for flipbook, invoked by a "-slideshow secs" command line argument or a ":slideshow secs" attribute in the flipbook document. At present requires building with ACE (or downloading Linux binaries). Typing "exit" into stdin or Ctrl-Q through the GUI will terminate the show. See this URL for sample on-line slideshows: http://www.vectaport.com/ivtools/slideshows.html * glyphify the precise move/scale/rotate dialog boxes in drawtool/comdraw/flipbook/graphdraw (under the Edit menu). This leaves only the precise page dialog box (under the View menu) left to be glyphified. * test the new comdraw funcs described below with a script like this entered into stdin: for(x=0 x<100 x++ :body ellipse(rand(0,ncols-1),rand(0,nrows-1),rand(20,30),rand(10,20));rotate(rand(1,180));update;colors(rand(1,ncolors) rand(1,ncolors));pattern(rand(1,npatterns))) ** happy random jelly beans ** Interpreter Changes * add rand([minval,maxval]) and srand(seedval) funcs to comterp. * add :string argument to print(fmtstr val) func, to cause the output to be pushed on the stack in the form of a string. * update documentation (both README and man pages) for comterp and comdraw. * add comdraw funcs to return menu sizes: nfonts(), nbrushes(), npatterns(), and ncolors(). * add comdraw funcs to return onscreen extent of canvas in pixels: ncols() and nrows(). * generalize the timeexpr func to take a :sec argument, and include this func in a comterp built with ACE (server mode). Library Changes -- ComTerp -- * generalize the timeoutscript mechanism on the ComterpHandler to take a seconds argument as well (ComTerpHandler::timeoutseconds()). -- IVGlyph -- * add a GFieldEditor::select_all method, to facilitate its use from new precise move/scale/rotate dialog boxes. * extend StrEditDialog to accept an arbitrary extra glyph. * generalize RadioEnumEditor to allow for horizontal layout and no frame. -- OverlayUnidraw -- * set up OvPreciseMoveCmd, OvPreciseScaleCmd, and OvPreciseRotateCmd, to allow for the glyphification of the "Precise" command dialog boxes. * create an OverlayGraphic::new_painter() for use by OverlayUnidraw to slip in an OverlayPainter for the default Graphic Painter (Graphic::_p). It was discovered that every OverlayRasterRect was creating a new OverlayPainter and stuffing it in Graphic::_p, which wasn't a problem, until I tried to defer the loading of rasters-by-URL. This meant that the Painter was engaged in rendering the raster before the final OverlayRasterRect was constructed, which caused the Painter currently being used to be deleted (oops). -- FrameUnidraw -- * create a FrameEditor::InitCommands (invoked by the ::Resize method on the viewer) to initialize the slideshow mechanism. Configuration and Miscellaneous Changes * change the construction of the toolbar glyphs, to use a layout.vflexible with infinite stretchability and 0 shrinkability. This works to make the whole toolbar automatically appear no matter how long, and obviates the need to have a funky constant that guesses how many pixels long the toolbar really is. * switch flipbook from using a Dispatcher based ComTerpIOHandler on stdin to using a Reactor based UnidrawComterpHandler (when built with ACE). This facilitates the use of the timeexpr func in the flipbook slideshow mechanism. In the future the older Dispatcher mechanism could handle the slideshow mechanism as well (since timer objects are supported by the Dispatcher). December 4th 1998 ivtools-0.7.1 Drawing Editor Changes * add support for %s embedding in print and export dialog box command strings. This facilitates the cat'ing of a file to a device (i.e. cat %s >/dev/lp1), and use of utilities like pstoedit (i.e. "pstoedit -f tgif %s /tmp/temp.obj;tgif /tmp/temp.obj") from these dialog boxes. If no %s is found when the "to command" button is checked, the command line is built up the old way, by appending the pathname of the temporary file used for rendering output. So "ghostview" will still work, as well as "ghostview %s". * propagate the stay-on-grid bugfix that was introduced in ivtools-0.7 down to idraw. * recognize and accept the partial idraw format generated by xfig2idraw (idraw already could handle it) * add full URL support for black-and-white JPEG's and GIF's (color and graylevel were already handled). Interpreter Changes * fix :abs argument on flipbook moveframe func. Now on a four-frame flipbook these work equally as well: for(i=0 i<100 i++ :body for(j=0 j<4 j++ :body moveframe(1);update);moveframe(-3);update) *and* for(i=0 i<100 i++ :body for(j=0 j<4 j++ :body moveframe(1);update);moveframe(1 :abs);update) * complete the iueserv example program, a derived comterp that links against the Image Understanding Environment (http://www.aai.com/AAI/IUE/IUE.html). Now the following command string works to process an image and export it to a drawing editor: export(conncomp(threshold(image("test.pgm") 150)) "localhost" 20001) Library Changes -- ComTerp -- * fix bug in post-evaluation handling of keyword arguments with no associated values. See flipbook example above. -- Unidraw -- * second attempt to fix the interaction of the Modified (dirty) state variable and the New command. This time, when ModifStatusVar::SetComponent is called, a check is made to ensure the new component is actually different than the old component before clearing the modified flag. Configuration and Miscellaneous Changes * remove conflicting include of memory.h that impacted a Solaris build in these file: Attribute/attrvalue.c, IV-2_6/textbuffer.c, and IV-2_6/texteditor.c. * add back the need for XCONFIGDIR for "make World" in the INSTALL file. * expand the Acknowledgements section of the README. * incorporate changes suggested by Debian ivtools-0.6.7-4 (the last packaging for the slink release of Debian). * rename scripts/install.sh to scripts/install-sh, to avoid a make rule that would automatically create a confusing (to make) install file. November 12th 1998 ivtools-0.7 Drawing Editor Changes * ivtools drawtool (and every drawing editor that inherits the same mechanism) can now import or open a wide variety of graphics file by URL. This is done with a separate ivtools executable, ivdl, written by Eric Kahler, which makes a straightforward attempt to connect to any http or ftp server and download the requested file. Any error messsages are printed to stderr. This means that ivtools now supports hyper-structured-graphics, as defined (invented?) by William Chia-Wei Cheng, the author of Tgif: http://bourbon.cs.umd.edu:8001/tgif/hgviewer.html To try it out, acquire or build a copy of ivtools drawtool, and launch it on this URL: http://www.vectaport.com/ivtools/anteaters.drs * In addition to URL support, ivtools drawtool supports launching or importing (to an import port if built with ACE) on any JPEG, GIF, TIFF, or pbmplus image file, any idraw format PostScript, and non-raster portions of any arbitrary PostScript file. These capabilities require the use of the following executables distributed separately from ivtools: djpeg, giftopnm, tifftopnm, pstoedit. * ivtools drawtool supports launching or importing of any graphic file compressed by gzip or compress as well. * The "auto-convert" check-box on the import dialog box has been removed (by default). This feature is still available for use in custom applications, or the same effect can be had by entering an "anytopnm" command line into the import dialog box, and selecting the "from command" checkbox before hitting the Import button. * this release fixes a very old stay-on-grid-when-zooming problem in drawtool. The changes ended up being very minor, and will be propogated to idraw by ivtools-0.7.1, but for now they exist only in drawtool to facilitate independent verification that the problem is gone. This might have been one of the inadvertent reasons why Fresco went to all floating-point coordinates. In the Unidraw graphics library, the graphics are all rendered in integers (collected from the screen coordinates of the original drawing events), then mapped to a floating point drawing coordinate system with a floating point affine transform. There was an unsolved problem with this strategy, and you can reproduce it in idraw with these steps: 0) turn on the grid (?) and gravity (,) 1) zoom in once 2) pan left once (while at 2x magnification) 3) zoom back to 1x magnification 4) draw a rectangle 5) zoom in four times or so -- you'll see rectangle isn't on grid The reason is that the pan at 2x is really the equivalent of a fractional pan at 1x, so when you get back to 1x the grid is no longer on an integer boundary, but halfway between pixels. Of course this is impractical for drawing the grid, so the grid coordinates are rounded before rendering. The same thing is done for the x,y coordinates of the mouse events in Grid::Constrain. The resultant rectangle looks great at 1x, where the rounding effects on the grid display match up with the integer-constrained coordinates that define the rectangle. But as you zoom in, the grid positions are no longer rounded, and you see the error between the actual grid location and the rectangle drawn with gravity on. The fix was to simply ensure that the transformer used to construct a graphic when gravity is on would always produce integerized drawing coordinates, by rounding the last two arguments of the affine transform used to map from screen coordinates to drawing coordinates. This counters for the necessary rounding effect when x,y events are constrained (Grid::Constrain) not to the actual floating point location of the grid, but to the nearest pixel. Try the above directions in an ivtools-0.7 copy of drawtool, and you'll see the problem is gone. Bug reported by Larry Larson and others. Server Changes * a new server, iueserv, was set up to begin experimenting with the packaging of the extensive capability of the Image Understanding Environment class libraries into the command language of comterp. The IUE is available from: http://www.aai.com/AAI/IUE/IUE.html --with-iue and --with-iue-libs arguments were added to the configure script to facilitate this. See src/iueserv/README for more details. * add affine transform funcs to comterp, to assist in debugging: point=xform(x,y a00,a01,a10,a11,a20,a21) -- affine transform of x,y coordinates affine=invert(a00,a01,a10,a11,a20,a21) -- invert affine transform Utility Changes * incorporate a URL downloading utility written by Eric F. Kahler, now called ivdl, into the src/utils directory. Library Changes -- IVGlyph -- * make changes to the ::accept_editor methods of OpenFileChooser and ImportChooser to recognize a URL and avoid pre-processing it like it was a local pathname. -- Unidraw -- * fix bug where the modified flag on a drawing editor was getting inadvertently cleared when the user does the following: - open and modify a drawing - invoke open again, and say No to saving the drawing - type in the same pathname The result is that the system recognizes the drawing is the same, and does not reload it, but clears the modified flag without ever saving it. This is now fixed. Bug reported by K.C. Ng. -- OverlayUnidraw -- * the majority of work on URL open/import, and compressed image open/import was done in the OvImportCmd. One evolution (from ivtools-0.6.12) was the use of the ::pathname() method to indicate when a file was coming from a file (instead of just a pipe), which would then allow the import command to configure a filtering command to be popen'ed. Without knowing the pathname (or when the pathname was an URL or "-"), there was a need to use double-fork/double-pipe architecture, with the child reading the source and writing to the grandchild, and the grandchild exec'ing the filter, causing the result to be written back to the original process. * support for GIF and JPEG file formats was extended by extending the RasterOvComp istream constructor to invoke an OvImportCmd to read them in. In this way GIF and JPEG files can be saved/restored by pathname, in the same manner long supported for TIFF and pbmplus raster files. -- GraphUnidraw -- * fix bug in Alter tool (RESHAPE_TOOL) to make it set the modified flag when something is changed. * fix another bug in Alter tool, reported by K.C. Ng, that caused the recreated TextGraphic to have a foreground color with a nil name. * finally, fix old problem with moving more than one arc reported by K.C. Ng as well. The problem occurred when two arcs were selected then moved -- nothing would happen. This had been disabled a long time ago, because there was a solution in place to handle moving one edge (the CreateManipulator pre-selected the nodes on each end of the edge as well), but there had never been a solution for more than one edge at once. The fix was simple, in that it only required a derived MoveTool (GraphMoveTool) with a single derived method of note, ::InterpretManipulator, that checks for a selection list longer than 1, and runs through it to augment the selection with any nodes that lie between selected edges. Config/Build Changes * a new library, AceDispatch, was set up to isolate any use of the ACE library from the InterViews Dispatch library. In this way older executables, like idraw, can run without any reference to ACE shared library. * further work was done to isolate older executables from newer shared libraries. This required #ifdef 0'ing all the OTHER_* make variables defined in config/params.def (OTHER_CCFLAGS, OTHER_CCDEFINES, OTHER_CCINCLUDES, OTHER_CCLDLIBS, OTHER_CCDEPLIBS) and instead defining them within the relevant Imakefile's. For example, src/comterp/Imakefile has these new definitions: OTHER_CCDEFINES = $(ACE_CCDEFINES) OTHER_CCINCLUDES = $(ACE_CCINCLUDES) OTHER_CCLDLIBS = $(ACE_CCLDLIBS) * extraneous arguments were manually trimmed from the configure script generated by autoconf from configure.in. This process needs to be repeated each time autoconf is run until the time someone figures out how to change configure.in to remove the Cygnus-standard options that are not utilized in the ivtools setup. ivtools-1.2.11a1/CHANGES-0.8000066400000000000000000001032011214471147700150200ustar00rootroot00000000000000August 23rd 2000 ivtools-0.8.4 - builds and works on FreeBSD 4.0 (tested at bsd.compile.sourceforge.net) - add :popen keyword to comdraw import command, so that Unix command lines can be substituted for pathnames, i.e.: import("pbmtext \"TEST STRING\" | pnmalias" :popen) will cause a anti-aliased rendering of TEST STRING to be imported as a PPM raster file. - fix bug in editing text graphics in Landscape mode. A while back things were changed so you could enter horizontal text in landscape mode. This changed code that was used both when you typed in new text, and when you edited existing text. But the test for Landscape mode (and the resultant rotation by 90 degrees before pasting) needed only to be done in the case of new text. This is the explanation for the text disappearing after its been edited with the Reshape tool which some have seen, but seemed to be a hard-to-replicate bug. - extend the use of -stripped to ivtools flipbook as well as comdraw. Now you can bring up a flipbook without any toolbar or menubar. - cause the menubar and toolbar (and state variables) to be constructed anyways when -stripped is given. This keeps the keyboard shortcuts working, a necessary feature when there is no GUI for those commands and tools. - part 2 of patch to fix Landscape-mode text editing. This makes all cases works, and propogates the fix to idraw as well. - make a brush undashed when drawing any arrowhead. It just didn't look good to see three quarters of an arrowhead at the end of a dashed line. There are still discrepancies between the how an arrowhead looks in the ArrowVarView and how it looks in a drawing. This math could be reviewed and improved. - rename ComTerpServState to ComTerpState (because that is what it was), and make more widespread use of it in all the ::run* methods. This makes multiple run commands on the same line work for the first time. - first version of comterp trace command: trace([flag] :get) -- toggle or set trace mode When true, the trace mode causes the interpreter to print out the name of the command (ComFunc) ready to be executed, and the number of arguments and number of keywords supplied to it. Indentation is 4 spaces time the depth of post-evaluate expression, i.e. a doubly nested for-loop has 8 spaces of indentation on the inner loop, four for the outer loop. - expand on the trace output for non-post-evaluated commands (ComFunc's). Since each of them has all its arguments (and keywords) ready to go on the stack, it is a simple matter to loop through and print these. It gives an interesting visualization of the innards of any complex comterp expression with control constructs, because you get to see what the arguments of each command (or operator) evaluated to before the command itself was executed. The next step would be print the unevaluated expressions for a post-evaluated command before they are executed. It might also be possible to trace their value after they are determined at run-time, to see what the "cond" or "if" conditional evaluated too. - if the pathname given to drawing editor doesn't exist, launch the drawing editor so that it is ready to edit a file of that name. The file won't come into existence until a File/Save is done, but the user doesn't have to enter the pathname again if they don't want to. - attempt to workaround an ACE-related NetBSD bug. Todd Gruhn has been faced with the problem comterp doesn't work in server mode when compiled with ACE on NetBSD for quite a while. We confirmed that for whatever reason, ACE would accept the connection to the port, and construct the handler, but subsequent data transmitted to the port would not cause select() to return. We also confirmed that ACE_wrappers/examples/Logger did work on NetBSD (the Acceptor-server version). Since this was the example from which comterp's use of ACE was derived, the next thing to do was a line-by-line comparison of the comterp ACE code to the Logger example. I found that little had changed in the past five years regarding the ACE Acceptor/Handler/Reactor API. But I did find two differences between how that API was used in the Logger example, and how it was used by comterp in server mode. The first was I had removed the call to Reactor::schedule_timerin ComterpHandler::open, something that had been used in Logging_Handler::open. I was trying to avoid the use of timers in the case of comterp in server mode. This patch conditionally enables this again for NetBSD. The second was I had added a call to Reactor::register_handler in comterp's main.c (to register the templated Acceptor object) that wasn't to be found in the main program of the Logger Acceptor-server example. This patch backs that out for NetBSD. I think I had done this to fix things after the change described in the previous paragraph. The pair of changes worked quite well on Linux, but might be the cause of the problem on NetBSD. - this patch also fixes an initialization bug in the TextView object, one that only recently surfaced. - fix bug in use of ComTerpState. The ComTerp::pop_servstate method always deletes the _pfnum member variable, but in the case of the ComTerpServ::run method that takes a buffer of tokens as an argument, you don't want to do this. The fix was to nil out _pfbuf before popping the state. - add method to return symbol associated with type of an AttributeValue (AttributeValue::type_symid()). - add comterp commands for returning the type of a value, and the class of a value of object type. - modify the various comterp assignment operators to look up the value of an attribute given as the second, or right-hand side operand. Symbols are treated differently, in that they behave like attributes when explicitly given, but get assigned as symbols when they are computed and returned from some other expression. - add a symbol comparison option to EqualFunc, i.e.: eq(sym1 sym2 :sym) This assumes sym1 and sym2 are computed by an expression that returns symbols, and then subsequent lookup is suppressed. - set limits on the traversal of the posteval expression buffer by adding an offlimit argument to the various ComTerp::skip_* methods (i.e. ::skip_func, ::skip_arg, and ::skip_key). Now you get a warning when this condition occurs, and the related segfault is avoided. - remove printf in EivTextBuffer that squawked when the text buffer was reallocated into large space. - add a LISP-like backquote operator to comterp. Works for attributes as well. - add floor, ceil, and round commands to comterp. In each case a long integer is returned when the argument is a float or double. - add pastemode command to comdraw, to allow for construction of off-screen graphics. These can be later inserted with the comdraw paste command, or maybe they can be used as a prototype for a toolbutton. This will require investigating the graphics-to-glyph conversion software that exists somewhere in the glyphs examples source tree. - modify the comterp lexical scanner to always skip lines that begin with a "#". This allows someone to write stand-alone executable scripts for comterp that begin like this: #!/usr/local/bin/comterp run - migrate classes for representing graphics as glyphs from the morpher example program to the IVGlyph library. This includes a method for constructing glyphs given an idraw file. - migrate the morpher example from the examples3.1 sub-tree to the main glyphs directory. - add customizable toolbar to drawtool, that consists of everything but the Annotate and graphic drawing tools. You switch to this toolbar by using a new "Tools" menu in the top menu bar. Also in that new menu is an "Add Custom Tool" menu item, that brings up a filechooser and prompts you to enter the path of an idraw document to use as the prototype for the tool button and for the tool action. The reason it needs to be an idraw document is the tool button glyph construction relies on an IdrawReader::load method reused from the InterViews 3.1 morpher example. This is the gateway between glyphs and graphics, which finally allows the same drawing to be used in both worlds. This gives extra usefulness to the Export-in-idraw-format mode. These idraw-format icons need to be small enough to fit in a toolbutton, and they need to centered on 0,0. - attempt to set up configuration files for a port of ivtools to FreeBSD, at the request of Wilhelm B. Kloke. - new addtool command in comdraw takes the pathname of an idraw drawn (or drawtool, etc. exported) picture and makes it a button in the alternate toolbar. compview=addtool(pathname) -- add button to toolbar based on zero-centered idraw drawing. The idraw graphics need to be zero-centered, which can be done in comdraw like this: g=at(select) /* gets the first graphic in the selection */ move(-at(center(g) -at(center(g) 1))) /* zero-centers */ followed by ^X (File/Export) with idraw format checked. - perhaps now building on FreeBSD. June 12th 2000 ivtools-0.8.3 - remove the output for a ComValue of BlankType in the related ostream operator. This puts it back to the way it has long been. The output of "" was just a temporary debugging thing. - add an "acknowledgebox" command (AcknowledgeBoxFunc) to command, to allow a script to pop-up a dialog box and require the user to press ok. - add a confirmbox command to comdraw that returns 1 for Yes, 0 for No, and -1 if Cancelled. - use a self-growing STL (Standard Template Library) vector to read comterp commands from a socket. This replaces the year-old hack of using a 1 megabyte input buffer (BUFSIZ*BUFSIZ), which was problematic in certain run-time environments, causing an inexplicable crash at the head of ComterpHandler::handle_input before any code of the method was executed. If this approach proves out, it should be migrated to all the other large input buffers spread around ivtools (where-ever the size is BUFSIZ*BUFSIZ), and would make for a significant reduction in the runtime footprint of some programs. - fix AttributeValue::geta(int classid) and add back a ComValue::geta(int classid) - fix the use of CLASS_SYMID macro in OverlaysComp class definition. It was missing the "s" from the class name string. - new comterp commands to "split" a string or symbol into a list of characters, and to "join" a list of characters into a string or symbol. - add -DUnidrawCommon to the compiler command line in the Unidraw-common library, and make judicious use of "#ifndef UnidrawCommon" in Unidraw/component.c and Unidraw/compview.c, so they only pull in stuff out of libUnidraw-common. - print "nil" instead of "Unknown type" when a ComValue is of UnknownType, since that is how UnknownType is used throughout comterp, as the nil value which means no value. - bug fixed in AttributeListEditor where a fixed buffer of length 1024 was overflowed. Replaced with a vector instead. - change comterp eval command to return a single value if it has only one argument. - change the Dialog class so that a box put up with ::map_for or ::map_for_aligned (as opposed to ::post_for or ::post_for_aligned) can unmap itself when cancelled or accepted. - add highlight command to comdraw interpreter: highlight(compview compviewgs) -- set the highlight graphic state for a graphic - changed ComTerpModule::reset to reuse buffers without reallocating them. - fixed equality comparisons in comterp against nil (which is ComValue::UnknownType under the hood). Now nil!=0 is true (1) and nil==0 is false (0). - added base class method to set an OverlayView's HighlightGraphic and member variable _hilite_gs to hold it. - fixed bug in OverlayScript::ReadOther. Now the attribute built from a keyword with no following value(followed by the closing paren) gets a value of true (1). - add a global variable capability to comterp. Now you can: global(v1)=100 and the value v1 will be available in all other copies of the command interpreter running at the time. If a local variable of the same name exists, you can access the global value by: symval(global(v1)) The "global" command returns a ComValue of SymbolType with a new global flag set to true. This flag is subsequently checked when doing symbol lookup, and if true the values are taken from the global symbol table (a static class variable of ComTerp). - add a AttributeValue::clear() method to zero out all the bytes of the double sized multi-value union _v. - add "frame" command to comdraw (and flipbook) to return the current composite graphic. - make comdraw versions of the "at" and "size" commands that work on composite graphic objects (i.e. the list of sub-graphics gets used as the list). - add a static method ComValue::minusoneval to return a ComValue set to -1. - ensure a ComValue is really of ObjectType before returning the value of the ::object_compview() flag. - test for global symbol flag before doing local symbol table lookup in comterp. - ensure the global symbol flag is zeroed when constructing a ComValue from a postfix_token struct. - remove bug in comdraw "center" command. - fix bug in "mbr" and "points" commands of comdraw (same one that was in "center"). - annotate (prefix) the result from a timeexpr command with "timeexpr result: ". Otherwise it is kind of hard to tell where these things come from. - modify min and max commands of comterp so that max(num nil) is always num, and min(num nil) is always num as well. - preserve the ComTerp associated with a ComterpHandler if there is a timer evaluated expression still running. - define AttributeValue::boolean_val() to return true for any symbol or string value if the symbol id is greater than or equal to zero. - new "delete" command for comdraw. - new :clear flag on the "select" command of comdraw. - new :scrn flag on the "center" and "mbr" commands of comdraw (to return screen relative coordinates as opposed to drawing coordinates). - fix :str keyword of print command (shortcut for :string) - add :sym and :symbol keyword to print command, for generating symbols the same way :str and :string can generate strings. - fix a few cases in the execute method of a derived Comfunc where a reference is initialized to a ComValue on the interpreter stack (ComValue&), and then used after the stack has been reset for this command (ComFunc::reset_stack), which obliterates all the input arguments. Instead a local copy of the ComValue is initialized. - add a comdraw "growgroup" command: newgroup=growgroup(groupview compview) -- add graphic to existing group graphic This is implemented with a MacroCmd (macro command) that has two members, an UngroupCmd to break down the initial group into its constituent parts, and an (Ov)GroupCmd to build it back up to include the new graphic. - add comdraw "trimgroup" command, to reverse the effect of a "growgroup" command: newgroup=trimgroup(groupview compview) -- remove graphic from existing group graphic Underneath the hood this a macro command (MacroCmd) with an ungroup command (UngroupCmd) followed by group command (OvGroupCmd) with the specified graphic removed from the list. This does not delete that graphic, but that can be done with a "delete" command if so desired. - fix bug in comdraw "select" command, so that changes to the current selection are graphically represented in the viewer. - add pause command to comdraw. Can be embedded in the middle of a script, and allows for arbitrary commands to be evaluated until a simple C/R is entered. - add a "logger" mode to comterp: comterp logger 'portnum' Listens for and accept connections on portnum, then simply forward the incoming messages to stdout, while ack'ing back with newlines. For debugging purposes, not really a use of the interpreter. - revise comdraw documentation, to make it more obvious that the "import" command requires a string for its pathname argument, and that a string has to be embedded in double-quotes. - upgrades to smoothly compile on RedHat 6.2 - add a :n argument to the eq command (the command that underlies the "==" operator), so that it can be used for partial string comparison, i.e.: eq("string1" "string2" :n 6) returns true. - fix up the comdraw text command to work at other than 1x mag. - fix two bugs in the Attribute tool dialog box. Make things work when there are no attributes defined (a problem that cropped up since using STL vector template to store the contents of the dialog buffer). And use a ComponentView to hold the pointer to a Component being examined by the dialog box, so that if the Component gets deleted in the drawing editor the Attribute tool dialog box won't be fooled into thinking it still has a good Component pointer. April 28th 2000 ivtools-0.8.2 - Add a new version of a dot (".") func to comdraw, one that accesses the AttributeList of a graphical component. This allows for easy set/get access to the attributes of graphics in a drawing editor. - Change default behavior of comdraw select func to return list of graphics in current selection. Implement the :all feature as well. This is a non-backward compatible change for anyone who has relied on the undocumented way the select func has behaved up until now (which was the same as :all behavior should have been). - change comterp list output (what gets printed when a list is returned on the stack) to use "," instead of "\n" and surround the entire list with "{" and "}". Now you can see the difference between lists of length 1 and scalars. - copy/move capability for text editor with interpreter from FrameUnidraw to OverlayUnidraw, and make use of it in comdraw. - add a flag to ComValue (use space from one of two type-specific unions) to indicate the void* pointer stored in an ComValue of ObjectType is really a ComponentView, not the class indicated by the classid symbol associated with it. This allows derived ComFunc's to detect whether an object pointer is really a ComponentView indirection to some Component object. - fix bug in comterp telcat mode where a bad pathname segfaults. - extend OverlayComp::FindValue to support the "up" flag. - change all the derived ComFunc's that work with ComponentView's to set the ComValue::_object_compview flag, and provide a symbol for the classid that corresponds to the kind of component. This needs to become a virtual method on every component, which requires adding CLASS_SYMID to all the *comp(s).h in the OverlayUnidraw library. - create "attrname" command to return name of attribute name/value pair. - create "attrlist" command to return the AttributeList of a component. - fix the adjusting of relative pathnames for an OverlayFileComp when the whole document is saved out to a different directory. - finish migration to use of ComValue::object_compview method. - add FrameScript::suppress_frame method to trim the output of "frame" objects from a derived program, i.e. a map viewer. - extend the use of a symbol-table based class id to all the components in OverlayUnidraw, GraphUnidraw, and FrameUnidraw, so that the command interpreter can print the class name of objects returned on the stack. Elide the "Ov" from certain class names, i.e. "RasterComp" instead of "RasterOvComp". - fix the equality operator (==) of comterp to return 0 when one argument is of unknown type (unless both are of unknown type) - finalize arrangement of symbol manipulating commands of comterp: symid return symbol id given symbol symbol return symbol given symbol id symval lookup value associated with symbol symadd return symbol without value lookup because symbol lookup is automatic in the interpreter, you only have to use symval when passing a symbol argument by variable to a command that accepts symbols without lookup. The command will take the name of the variable for input, not its contents, so wrapping it in symval() has the desired affect. symadd() is how you get a symbol assigned to a variable. - add test for non-existent input file to run() command. - extend list() command to initialize new list with contents of old list supplied as the first argument, i.e. with "l1=1,2,3; l2=list(v),4" lists l1 and l2 are distinct, where as with "l1=1,2,3; l2=l1,4" l1 and l2 are the same. - add numframes() command to flipbook interpreter, and FrameEditor::NumFrames method. - fix bug in comterp ! operator that made it not work for anything but boolean. - show many frames at once in ivtools flipbook with a new "showframes" command. If four frames (plus background) existed in a flipbook editor, this would show the first and third frame (and the the background), when entered into the interpreter: showframes(1,4) This required generalizing the "other" frame concept of FrameEditor to be a list of other frames to see instead of a single frame. To preserve the "current frame" concept in the editor, the list of frames given to "showframes" is searched for the max frame to make it the current (and foremost) frame, then internally all other "other" frames are stored as negative offsets from this frame. It would be possible to have a mode (a keyword flag) on "showframes" to interpret the input list as offsets both positive and negative from the current flag (i.e. :offsets). - add ComTerp::lookup_symval(int symid), to give a non-in-place way of looking up a variable's value. - make the comterp nil command post-evaluated, so none of its arguments are processed or pushed on the stack. - fix a problem where inner-parenthesis (or extra outer parentheses) on an expression wouldn't work when part of the body of a post-evaluated command (i.e. for, cond, while, etc.). Before this didn't work: cond(1 (1+2)*3) Or this: cond(1 (1)) This time the bug wasn't in the mechanism for post-evaluating the byte-compiled script, as many similar bugs have been in the past. This time the fix was to a parser tweak adopted not that long ago to generate blank placeholders in the parser output (the postfix expression) to preserve where free-standing parentheses existed in the original expression. - and now a better fix for the inner paren problems of the comterp parser. I finally came to understand the origin of the problem was not the popping of matched stand-alone parens, but in the failure to recognize when parenthesized expressions are different from parenthesized arguments. Consider "a(b (3))" v.s. "a(2 (3))" (try this with "comtest parser" if you want. You might think the command "a" has two arguments in each case. But in the first case it has only one, and the "(3)" is interpreted as arguments for the command "b". March 9th 2000 ivtools-0.8.1 Interpreter Changes * Add the "." (dot) operator to comterp, to allow for compound variables (i.e. "a.b"). They can be used on the right-hand or left-hand side of an assignment operator, and used pretty much anywhere a symbol can be used. The first operand is either a symbol to assign an AttributeList to, or an expression that evaluates to an AttributeList. The second operand is always a symbol. They can be concatenated (i.e. "a.b.c"). * create a list func that initializes an empty list object. * extended the print func to invoke the ostream ComValue "<<" operator if it only has one argument. * add new symval command to returns the symbol value instead of looking up the value of that symbol in the variable tables. * documented acos, asin, and atan as returning radians, and cos, sin, tan as taking radians. * created autoframe command in flipbook command interpreter, and synched it with the "Auto New Frame" checkbox on the Frame pulldown menu. So now you can set/reset this feature from either the GUI or interpreter, and the GUI reflects the state. * settle on "dotname" for the command that returns the name of a name/value attribute pair. This is because "." (dot) is the operator used to create attribute list objects in the comterp command interpreter. Normally most attribute objects are automatically indirected to the attribute value when finally applied, but in this command overrides that and returns the symbol which is the attribute name. * enable the command interpreter in the text editor panel at the bottom of the flipbook user interface. * copy anything but the last line in the interpreter text buffer to the end of the buffer before executing -- like shell mode in emacs. Library Changes -- Attribute -- * migrate macro for declaring symbol-table based class ids to one place -- Attribute/_comutil.h. Rename it CLASS_SYMID (from classid). * AttributeList::add_attr fix. * new twist to the classid stuff. Now classid() gets defined as a virtual function along with static methods for class_name() and class_symid() when you add the CLASS_SYMID macro () to a class definition. This was used for identifying derived ComFunc's, ComFunc's that have a func symbol id as well, but might vary with internationalization or other custom changes to the interpreter. But the symbol id of the class name itself doesn't change. -- ComUtil -- * modify lexical scanner to preserve token state between invocations. This fixes a problem with multi-line comments when comterp is in server (when comterp is receiving input strings one at a time from an external source). However, this does not fix the problem with multi-line strings when comterp is in server mode, which will require a better solution for preserving more of the token state (i.e. the partial token buffer) between invocations. This is also a necessary step in preserving parallel use of one lexical scanner by more than one comterp in the same program. -- ComTerp -- * fix a problem in server-mode comterp. Part of making server-mode work was figuring out how to return from the depths of the lexical scanner in the middle of an expression, when an expression continues across multiple-lines, but the capability to retrieve a new line (or string) is external to the parser/scanner. To make this work I made up the convention that if the input function (the function pointer with an fgets signature passed to the parser/scanner C routines) returns a null string (a string that begins with '\000'), return out of the scanner and parser, yet assume there is more to come. When that function (ComTerpServ::s_fgets) was going to return the null string, it still traversed the entire input buffer, which is huge by default. * compress some code by making use of the new ComValue::is_object(int classid) method to test both whether something has a generic void* pointer for its value, and whether it has a known matching classid (based on a id in a symbol table for that kind of object). * migrate ComValue::geta() to AttributeValue::geta(). This is the method that returns a void* to an ObjectType if the classid matches. Work for every object but ComFunc's and AttributeValueList's, which have their own types (CommandType and ArrayType). -- IVGlyph -- * new Dialog methods to support stay-up dialog boxes that don't block events being handled by the main application: void map_for(Window*); virtual void map_for_aligned(Window*, float xalign, float yalign); void map_at(Coord x, Coord y); virtual void map_at_aligned( Coord x, Coord y, float xalign, float yalign ); void unmap(); boolean mapped(); These are an alternate to the pre-existing Dialog::post_* methods, which map the dialog box to the screen then enter their own event handling loop (the run() method), then unmap the dialog box when done. With this new approach you call one of the Dialog::map_* methods to bring up the dialog box, and control returns to the normal event-handling loop of the main application. The action taken when a Close or OK button has to be different with this new approach. Instead of setting a flag that causes the local run loop to terminate, you need to explicitly call Dialog::unmap. Dialog::unmapped is provided as a way to test if the dialog is currently displayed. Repeated calls to Dialog::map_* are ok, because the first thing these methods do is check if already mapped, and if so they do nothing. * create a new ObsTextDialog that uses the new Dialog::map_* methods (IVGlyph/odialogs.[ch]). * store the symbol id for a given ComFunc in a new _funcid member variable. * create a ComTerp::eval_expr method that takes an array of fully code-converted ComValue's ready to be executed. * so that a ComFunc execute method can ask ComTerp to invoke a certain ComFunc on the subsequent symbol to be encountered after the ComFunc execute method returns (ComTerp::func_for_next_sym()). * modify the various func of symbolfunc.c to generate scalar or vector results depending on whether there is a single or multiple argument. Affected are symbol, symid, and symvar. * add mechanism to ComTerp to pass values to the next expression (ComTerp::val_for_next_func) and invoke a func on the next symbol (ComTerp::func_for_next_sym). This allows for the stringing together of stand-alone expressions interspersed by keywords that lack parenthization. * add ComValue constructor that takes a ComFunc* directly and makes something of CommandType. * derive ComGlyph's ComTextEditor and ComTE_View from IVGlyph's EivTextEditor and TE_View. This adds an interactive command interpreter capability to the text editor object, where the user can enter expressions and see results computed. While a command history plus anything else goes to stdout, the results follow just the expression, so it is sometimes easier to keep track of the commands you're using. All of stdout could be rerouted to the texteditor window in the future. vhclmaps vhclviewer is the first place in the source tree where this capability is exposed for now. Check it out. -- OverlayUnidraw -- * the GraphicLoc tool to use the new ObsTextDialog box. Now the GraphicLoc dialog box can stay up between uses of the tool, and each new click refreshes the displayed text. -- FrameUnidraw -- * generalize the "select" command of comdraw to work in the interpreter of flipbook and anything derived from flipbook, by using the OverlayEditor::GetFrame() virtual method, which hides the fact whether a multi-frame system is in place or not. Miscellaneous and Config Changes * change the default behavior of make with no arguments to be the same as "make World" the first time it used. So now ivtools can build out of the box with the ubiquitous "./configure;make" * add --enable-install-subdir argument to ./configure. This allows a user to install in /usr/local/lib/ivtools and /usr/local/bin/ivtools if they want (/usr/local can be changed with --prefix). * change src/scripts/mkdirhier.sh to work with new versions of mkdir that no longer accept multiple arguments. * pare down the various config/site.def.$CPU files to the things actually used/required. Take out all definitions now provided by the ./configure script. * patches submitted by Gregor Zych to compile ivtools-0.8 with frozen Debian Potato. The first patch adds a function definition that is disabled by default. Someone would need to change the #if clause to correctly test for the Debian 2.2 release. This was the only thing that didn't compile smoothly on RedHat 5.1. * give variable names to all the constructor arguments in Attribute/attrvalue.h and ComTerp/comvalue.h, to improve the PERCEPS extracted web page. * change signature of accept() used in utils/sockets.cc to use an unsigned instead of signed int* as the third argument. This seems to be more the recent standard. - format bug in ComValue::ULongType ostream output. January 18th 2000 ivtools-0.8 Drawing Editor Changes * add "center" and "mbr" commands to comdraw, to return the center and minimum-bounding rectangle of a graphic. * make select-all the default behavior of the comdraw "select" command. * add -stripped argument to comdraw, to remove menubar and toolbar. Use a -geometry as well to specify size of canvas. Control resultant program via stdin or telnet using the builtin command interpreter. * add Pull/Push By One Commands to the Structure menu in drawtool, also making them available to any OverlayUnidraw based program. Interpreter Changes * add LISP-like symbol assignment semantics to comterp. Now expressions that return a symbol can appear on the right hand or left hand side of an assigment operator. See new command "symvar", and "symbol" has been renamed "symval". * add support for command aliases to comterp, to allow multiple symbols to point to a command without having them listed via help. * make posteval((1)) work, by improved handling of the token generated for the extra nested parens. Problem still remain with the handling of some forms of nested parens in post-evaluated expressions, but this is a start at fixing them. This is the last outstanding known bug in the comterp language, though many features remain to be added. * fix problem with nested parens in post-evaluated expressions. Now commands like these work: posteval((1+2)*3) cond((1+2)*3 1 0) The problem originated when for some reason the underlying parser was modified to spew a Blank whenever it popped an empty paren pair from the parser stack. Doing that made something, I don't recall what, and could be useful in the future for representing n-depth streams by nested parens (i.e. ((1,2,3),(3,4,5),(5,6,7)) could be a 3x3 pixmap (or a list of 3 rgb values). Config and Misc. Changes * add NetBSD support. * finalize links from embedded html (extractable by PERCEPS) to pre-existing man pages. Now every man page can be reached by its corresponding classes html documentation. * test and revise the src/html/README that describes how to gen a set of ivtools html documentation. ivtools-1.2.11a1/CHANGES-0.9000066400000000000000000000362631214471147700150360ustar00rootroot00000000000000Oct 16th 2001 ivtools-0.9.7 ** last release before 1.0 -- if things are ok with this distribution I will simply roll over the version number ** - fix the pnmtopgm script to do the right thing for PBM files. - better error messages when someone tries to open an idraw format PostScript file that has ColorRast objects in it. These are rasters that are color-printer ready, and do not conform the idraw format. A future version upgrade of this format will include support for these. As an aside, these ColorRast objects cannot be filtered through pstoedit either (pstoedit -f idraw), because they have separate sources for R, G, and B. A future pstoedit back-end for the ivtools drawtool format would be needed to make this work instead, one that relied on the ghostscript mechanism for dumping out rasters to PNG files. - modifies the pstoedit import command lines to always use a temporary file for output with a %d indicator to support multi-page files. - add a StreamObject to AttributeValue/ComValue. This consists of a pointer to a ComFunc to use in getting the next value out of a stream, and local data storage to indicate current position. Sort of a procedural iterator. - add streaming mechanism to comterp, that leverages the ".." iterate and "**" repeat operators. Now arbitrary expressions can be composed where each operator is overdriven (repeatedly executed) by one or more of its arguments. Some examples: s1=0..10 # stream that iterates from 0 to 10 s2=0..10*3 # stream that iterates from 0 to 30 in steps of 3 next(s1) # returns 0 on first call, incremented by 1 each call after next(s2) # returns 0 on first call, incremented by 3 each call after A more complicated example counts to 4 Meg without using megs of memory: s=1..pow(2 22) x=0 while(next(s) x++) An example for computing a ramp step-function for a look-up-table: 0..255-0..255%10 Overdriven streaming operators were first presented here: "Command Language for Developing Real-Time Signal and Image Processing Applications", S. Johnston, R.C. Fitch, SPIE Proceedings on Automated Inspection and High Speed Vision Architectures II, vol. 1004, Nov. 1988. - fix != comparison of symbols. Found this problem when experimenting with the new stream objects. A while loop terminates on either 0 or nil, but a stream terminates with only nil. To differentiate nil from 0 I looked at the return type: s=0..255 while(`type(v=next(s))!=`type(nil) print("%d\n" v)) This didn't work without this change. - adds partial-string (:n) and symbol (:sym) comparison to the rest of the equality operators (!=, >, <, >=, <=). - add :nilchk option to terminate the while loop upon nil (instead of nil and zero). - make the seq operator (;) post-evaluated so that this works: s=0..100;while(v=next(s) print("%d " v) :nilchk) Without post-eval the stream on the left would overdrive the ";", which just didn't work. - more work on new stream and list concepts in comterp. Now ",," is the stream concatenator, and "," remains the list concatenator. stream(lst) converts a list to a stream, and list(strm) will converts a stream to a list (as soon as I debug it). - makes list(strm) work. Now you can convert streams to lists and lists to streams (with stream(lst)). - equate lists to arrays in all the API of ComValue, and make type(strm) return ListType instead of ArrayType. - fix problem with interacting with the KDE X server. Seems all other X servers allow a negative "length" argument, which causes the server to index backwards from a data pointer. This was not documented in the man pages, so the KDE folks "fixed" the problem by changing the code instead of the man page. So I have to fix the code as well. - Now the streams are really flowing. The ",," concatenation operator works for the most part, allowing for the composition of complex streams like this: s=0,,1,,2,,3**3,,4+100 which generates the sequence: 100 101 102 103 103 103 104 nil Probably a few minor issues left to clean up. So far I've discovered: 0,1**2 works partially as expected, generating a {0,1} followed by a {0,1}. But then it generates a {0,nil} repeatedly, never terminating. Hmmmm. - make ",," concat operator lower priority than the "," tuple operator. This means these two examples behave in a similar fashion: s=1,2,,3 # yields {1,2} followed by a 3 s=1,2,3,,4 # yields {1,2,3} followed by a 4 and you can construct 2-d structures in a pleasing way: s=1,2,3,,4,5,6,,7,8,9 # 3x3 grid - ensure streaming doesn't happen on post-evaluated commands. - create a hidden :strmlst argument to the list command, to have a way at looking at the AttributeValueList associated with a stream object. - NetBSD compile fix - fix the AttributeValueList constructor so it does a list copy as it advertises. - evaluate symbols when popping them off the stack to build a stream object. This may not be desirable in the long run, and it really wasn't causing any problem to delay this that I know of. Hmmm... - make the default value of the second "at" argument zero instead of nil, so that if nil is supplied it can be used to return nil (to terminate stream handling). - set up to "stream" over an AttributeList. - ensure ComValue::is_true() returns true for StreamType that exists. - touchups to glyph-based graphics (Graphic31). There were difficult-to-decipher problems in allocate/requisition which clipped graphics by one row or one column. So I just padded things a bit. This is only used in the addtool (custom toolbutton) mechanism of comdraw. - revert to using "r" instead of "r+" in fopen calls for graphics files to be read in. I had added "r+" when gcc-3.0 needed it to allow rewinding. Now gcc-3.0.1 has that fixed, and "r+" got in the way of read-only access (CD-ROMS). - set "." dot operator to 1) create AttributeList's as needed on the fly, and 2) create an emtpy AttributeList when a second argument is not given. For example: a.b.c.d.e.f=100 # this now works, without having to create # all the intermediate AttributeList's x=dot(z) # creates an empty AttributeList z which is # can be accessed through the variable x as well. - go through all the math commands to ensure they return nil given any nil argument. - add a :set argument to the list at() command. Aug 20th 2001 ivtools-0.9.6 - minor adjustments to adapt to gcc-3.0.1. One advantage of upgrading to gcc-3.0.1 is that incremental import of rasters from URL's works again. - introduce all the bitwise operators from C to comterp: &, |, ^, and ~. This change is slightly backward incompatible, in that "^" had been used as a shortcut for the pow command (raise something to a power). Scripts that rely on that single operator will need to be rewritten. Sorry for doing that -- but it is the first incompatible change in I can't remember how long, and something I wanted to get done before version 1.0 (where the syntax and semantics of comterp get "frozen", ready for wider use). - renames the tiftopnm bash script to a less confusing ivtiftopnm (less confusing in that people won't think it is part of netpbm). ivtiftopnm is a wrapper script for tifftopnm, which doesn't accept stdin input directly (because of its need for random access to the tiff file). Jul 25th 2001 ivtools-0.9.5 ** Most of the outstanding problems with gcc-3.0 and libstdc++-v3 have ** been resolved. Only known problem is with incremental importing ** (and display) of rasters from URL's. This is a long-standing ** stable feature of ivtools. Perhaps newer versions of gcc-3.* and ** libstdc++-v3 will fix the problem. - fixes a problem with importing files introduced when migrating away from the use of istream::gets (required for gcc-3.0 and libstdc++ v3). istream::gets would automatically skip the newline delimeter. When using istream::get in libstdc++ v3 I needed to manually skip the newline delimeter. - globally change optimization from -O6 to -O2, which makes gcc-3.0 compile time much more reasonable. - all the necessary changes to support ACE and gcc-3.0 at the same time. The majority of the work is in deferring (or avoiding) an fclose on a fdopen'ed socket, by a) saving a FILE* in some class to be fclose'd later, or b) rewriting without iostreams. Now there should no longer be any dangling FILE*'s to worry about. - adds built-in support for PNG rasters. That means they can be imported and save/restored by pathname (like JPEG and GIF). This requires that pngtopnm be available to be invoked by the ivtools drawing editors. - added test for whether socklen_t is typedef'ed to the configure script. Seems older versions of FreeBSD doen't have this. - fix the test for whether the X11 Shared Memory extensions exists in the server, and whether it can be utilized (which requires co-resident client and server). - add a -c argument (copy instead of move) to every install command for the benefit of the BSD's. - use "r+" for fopen of files to be rewound, otherwise they never get rewound. This is a recently introduced problem. "r+" is supposed to mean opening for reading and writing, but it seems necessary for rewinding as well. Jun 15th 2001 ivtools-0.9.4 - monstrous amount of changes required by forthcoming gcc-3.0. The heavy lifting was mostly due to the absence of filebuf::attach in v3 of libstdc++. Other issues to deal with: templated iostreams, change to meaning of -U (undefine compiler option), can't have static const char initializes in class definition, need class between "friend" and class name, use of , missing ostream::form, missing istream::gets, round needs to be Math::round. Unfortunately, gdb can't debug C++ generated by gcc-3.0 yet, so although things mostly work, I can't resolve problems with the wild iostream hacking I did. My recommendation: stick to gcc-2.95.* for now. - add an :eps and :idraw option to the comdraw export keyboard command. Now you can generate these formats as well as the default drawtool format. - fix export of EPS with color imagery, by correctly reading radio button for output format on export dialog box. Before it only generated the idraw format, which is EPS, but has only graylevel rasters visible to any PostScript interpreter (the color information is in comments). - change the declaration of an argument to getsockname() from unsigned int to socklen_t (in Dispatch/rpcbuf.c). This fixes the problem with portability caused by the fact signedness of a socklen_t is unstandardized. - restore full support for XBM (X bitmap) images to drawtool and its derivatives. idraw was always XBM capable, but drawtool lost support for this a while back. From John Denker (jsd at research.att.com): >Here is a patch that will allow ivtools to correctly output text >objects that contain backslashes. May 18th 2001 ivtools-0.9.3 Keyboard Commands: - add save func to comdraw: error=save([path]) -- save editor document (to pathname) With no argument it saves using the current document name. If none is current the SaveAs dialog box pops up. If the file already exists a warning dialog box pops up. If the current document is unmodified the func returns zero without doing anything. With a pathname argument it always tries to save to the document to that file, returning zero if the save doesn't work (at least it will after a bug is fixed). If the file already exists a warning dialog box pops up. - add export func to comdraw: with ACE: export(compview[,compview[,...compview]] [path] :host host_str :port port_int :socket :string|:str) -- export in drawtool format without ACE: export(compview[,compview[,...compview]] [path] :string|:str) -- export in drawtool format "; - add comdraw funcs to convert between drawing and screen coordinates: dx,dy=stod(sx,sy) -- convert from screen to drawing coordinates sx,sy=dtos(dx,dy) -- convert from drawing to screen coordinates - convert output of help func to a string, so it can be displayed in the keyboard command window on comdraw/graphdraw/flipbook/drawserv. Miscellaneous: - applied diffs by Guenter Geiger to generate ivtools-0.9.2-1 for latest Debian (sid). - attempt to upgrade to ACE 5.1 - put an arbitrary glyph in the lower left of each drawing editor with a keyboard command window. Defaults to text describing the editor and how to get help on keyboard commands. - check that an AttributeValue is_object() or is_command() before returning the void* pointer associated with some C++ object. - change for building on Solaris 2.6. - bug fix in growgroup comdraw func. Apr 5th 2001 ivtools-0.9.2 - set of changes to allow save/restore of graphics files internal to a drawing by the Unix command line used to generate them. For example, if "xwdtopnm temp.xwd" was used to import a raster file (with "from command" checked on the import dialog box), a subsequent save would write this command (and only this command) to the document on disk, and a subsequent restore would re-run the command to regenerate the contents. Should work equally well for rasters, PostScript, and ivtools drawtool files. - remove anytopnm from ivtools, since the enhancements our copy had over pbmplus were incorporated directly into the netpbm variant. The salient feature was the ability for anytopnm to recognize it had a file that was already in a pbmplus format, and pass it through. - remove duplicate IVGlyph/figure.[ch] from MANIFEST - add /usr/local/include/g++-3 and /usr/local/include/g++-2 to paths searched for libstdc++ include files by configure. - add "wget" to the list of download utilities searched for and used by the code that reads URLs. The others are ivdl (from ivtools), curl, and w3c. - changes to support compiling with older versions of libg++ and changes to support relative installation (--enable-install-relative) on FreeBSD. - add "name" and "value" labels to the attribute-list editing dialog box. - save rasters imported from Unix commands by writing out only the command string in an generic by-file drawtool object. For example: ovfile(:popen "djpeg -pnm test.jpg" ) would be output to the saved document if save-by-path was checked on the import box and save-by-path is checked (for the whole document) on the export box. Subsequent opens rerun the command. Jan 10th 2001 ivtools-0.9.1 Correct 0.9 oversights: - restore GPL dual licensing documentation in COPYRIGHT, COPYING, and MANIFEST. - correctly set version number to 0.9.1 December 19th 2000 ivtools-0.9 - fix segfault in new comdraw addtool command when the supplied pathname is non-existent. - allow for using new symbols (those with a nil value) in the various assignment operators of comterp, i.e. x++ or x+=1 work if x was undefined. - make ivtools available under the GPL as well as the original X11 style license. - changes type of third argument to accept() from an unportable (unsigned int*) to a more correct (socklent_t *) (in src/utils/sockets.cc). First done by Guenter Geiger in his Debianization of ivtools-0.8.3 - partial build (up to glyphterp and comterp) on SunOS 4.1.4 with gcc-2.4.5. After that I ran into static initialization (even though using collect2) and multiple-inheritance problems that made it no longer worth it. - patches for building with libace5.0 under Debian 2.3 (woody). - fix up the construction of symbolic links for Unidraw-common done by the configure script. - revises and extends the comterp pause, trace, and step commands. ivtools-1.2.11a1/CHANGES-1.0000066400000000000000000000316141214471147700150210ustar00rootroot00000000000000November 26th, 2002 ivtools-1.0.7 - fixes for compiling with gcc-3.2 using ACE (on RedHat 6.2) - new comdraw funcs submitted by Secil Ugurel: help(fontbyname colorsrgb pokeline) "fontbyname(fontname) -- set current font by X font name", "colorsrgb(fgcolorname bgcolorname) -- set current colors by RGB name. The colorname format is \"#RGB\" for 4 bits, \"#RRGGBB\" for 8 bits,\"#RRRGGGBBB\" for 12 bits,\"#RRRRGGGGBBBB\" for 16 bits", "pokeline(compview x y vallist) -- poke pixel values of a line listed in vallist into raster." - migrate glyphs/text-editor to stand-alone ivtext. - add Quit option under File menu to ivtext.. - preliminary support for SVG export. For those interested in playing along at home, ivtools now supports export of line graphics via SVG, with support for variable widths, colors, and dash-patterns, as well as rectangle export with fill colors that are blends of foreground and background (plus none fill). - refactor OverlayPS::idraw_format to be a pair of set/get methods where the get method overrides the internal static member value (_idraw_format) with the value of an idraw_format flag on an associated Command if there is one, either OvExportCmd or OvPrintCmd. - the export dialog box now defaults to everything if nothing is selected in the drawing editor. - fix drawserv attribute expression propogation used for Null Convention Logic emulation (http://www.theseus.com). - a new version number 13 for the idraw format adds support for executable fonts (as opposed to static fonts). Required by recent versions of RedHat Linux. - fix out-of-order destruction of member objects of the central Unidraw object at program termination. - disable use of X11 shared memory extension for MacOS X. This may only be a problem with 10.1, or only be a problem with XFree86 4.2, so it may be reinstated in the future. - customize iostream include files for MacOS X Jaguar (10.2), to mask the difference between Apple's version of gcc-3.1 libstdc++ and everyone elses. This is untested, so let me know if it worked for you. - apply diffs generated by Ben Hines in creating a fink package for Jaguar (MacOS X 10.2) August 2nd, 2002 ivtools-1.0.6 - more changes for compiling with gcc-2.96 on RedHat 7.* August 1st, 2002 ivtools-1.0.5 - various compile time fixes for Solaris and Cygwin. - a proper fix for handling non-idraw PostScript. An improper fix was introduced in ivtools-1.0.3 that made all idraw format files get filtered through pstoedit (if you had it). Pointed out by Todd Gruhn. - changes required to compile ivtools with gcc-3.1. Most all in the area of migrating from use of an fstream constructor that accepted a FILE* to use of a derivative class (__gnu_cxx::stdio_filebuf) that does the same. Wrapped up the difference between 3.0.* and 3.1 by conditionally defining a fileptr_fstream in src/include/ivstd/fstream.h to filebuf for 3.0.* and __gnu_cxx::stdio_filebuf for 3.1. ** Constant evolution of the behavior and API of filebuf has been the single most challenging aspect of keeping ivtools compiling with gcc and working for the past decade. I really hope things will be stable for the next decade. ** - fixes for using ACE and ivtools with gcc-3.1 - fix up compiling with ACE using less than gcc-3.* - disable incremental display while incrementally loading from a URL. A placeholder raster still gets inserted before the connection is established, and the rest of the download and display is asynchronous, which avoids hanging on a net connection. - compilation fixes based on feedback from Gregory Kriehn. Mostly adding #include where missing. Don't know why this wasn't a problem in every environment. Should improve support for RedHat 7.*. June 21st, 2002 ivtools-1.0.4 - give special meaning to a set of parentheses that proceed the tuple operator ",", by adding an extra level of nesting to the resultant list. Before the expression "(1,2),(3,4)" yielded "{1,2,{3,4}}". Now it yields "{{1,2},{3,4}}" as one might expect. This anomaly stemmed from the fact the tuple operator "," works by concatenating its right-hand argument to its left-hand argument if the left-hand argument is already a list (that's how the interpreter concatenates a compound tuple-expression, i.e. "1,2,3,4"). - fix unitialized variable used when reading from sockets that would cause a hang. - add comterp commands for the value of PI (pi), converting radians to degrees (radtodeg), and converting degrees to radians (degtorad). - add new matrix transpose command (xpose), which takes a 2d list of numbers (i.e. a matrix), and transposes them. Examples: xpose(1,2,3) {{1,2,3}} xpose((1,2),(3,4)) {{1,3},{2,4}} xpose((1,2,3),(11,12,13),(21,22,23)) {{1,11,21},{2,12,22},{3,13,23}} - add a matrix addition capability to the comterp "+" operator. - add matrix multiplication to comterp "*" operator. If: a=(1,4),(2,-3),(3,1),(-1,0) b=(-1,2,1),(-9,2,-3) Then: a*b Yields: {{-37,10,-11},{25,-2,11},{-12,8,0},{1,-2,-1}} - extend matrix multiply to support vector inputs. Now: a=list,list(1),list(2),list(3) b=list,list(1,2,3) a*b Yields the same as: a=1,2,3 b=list,list(1,2,3) a*b Conversely: a=list,list(1,2,3) b=list,list(1),list(2),list(3) a*b Yields the same as: a=list,list(1,2,3) b=1,2,3 a*b And: list(2)*list(3) Yields: {{6}} - add support for panning with cursor keys (left/right/up/down) as well as Page Up and Page Down (PgUp/PgDn) for larger vertical moves. - greatly improve the efficiency of rendering alpha-transparent rasters with a TrueColor visual. Prior to this each input color was being looked up in a table that could be as long as 2 to the 24th, then the weighed average computed in floating point, then the result rescaled into a TrueColor color. Now everything is done with nothing more than 32 bit integer multiplies, adds, and shifts. Performance has gone from a multi-second lag to adequately interactive. - rename "Custom Tools" to "Extra Tools". - migrate Attribute, Annotate, and GraphicLoc to "Extra Tools". - add a :next flag to comdraw's import func. It attempts to auto-increment the numerics in the last URL and import again. - sync with diffs from latest Debian release (ivtools-0.9.2-6). - add gcc-2.96 warning to INSTALL and README files - remove installation of extraneous scripts when non-local install. - save/restore raster alpha-transparency value in drawing documents. - create AlphaTransparentCmd and make available under Edit/"Image Processing" - create raster peek command for comdraw (RasterPeekFunc). March 11th, 2002 ivtools-1.0.3 - add missing src/include/ivstd/stdlib.h to MANIFEST. This was needed to get socklen_t defined for Dispatch/rpc*.c on Darwin. - recognize files that start with plain "%!PS" as PostScript files. March 1st, 2002 ivtools-1.0.2 - add -stdin_off argument to comdraw/flipbook/graphdraw/drawserv to disable a comterp interpreter on stdin. - changes required to get things compiling with Cygwin under Windows 2K - try -gdwarf-2 as a compilation option for debugging with gdb-5.1 and gcc-3.0.*. Not sure if there was an improvement. Maybe this is already the default. - fix bug in GraphicLoc tool, where the text wasn't refreshed on subsequent uses after the dialog box had been unmapped. - make the "Show Prev Frame" command of flipbook take effect immediately (same for "Hide Prev Frame"). Needed to call FrameEditor::UpdateFrame as well as Unidraw::Update. - fix submitted by E.J. Neafsey (Loyola University) for drawing multi-point graphics with shift key pressed to make all the lines either completely horizontal or vertical. The shift key always worked, yet the origin used (for limiting motion to the horizontal or vertical) was never updated to the last vertex as the new points were added. - added alpha-transparency to raster display. It works, but there is no save/restore of the alpha value, or user interface to set or view the value. However, you can use OverlayRasterRect::alphaval() to set/get the constant (one per raster). No PostScript output yet as well. - propogated "None" background color to all drawing editor's BgColor menu. - add an alpha command to comdraw, to set/get the alpha value of a raster graphic: alpha(compview [alphaval]) -- set/get alpha transparency value a command line like the following will spin a raster forward as it appears (assume g is a variable pointing to a RasterComp, and the current selection): for(x=0 x<10 x++ alpha(g float(x)/10);rotate(30);scale(1/.9 1/.9);update) - partial changes for HPUX compilation. There might be other problems with the HP linker's desire to fully link a shared library when it is built, and problems with parameters like ExtraCCFlags that might need commenting out for reasons I don't understand (note -- it seems this might be avoided by using "ld -r" instead of "gcc -shared"). - further work on comdraw whiteboard capability. Setting up for a distributed drawing environment by ensuring that all graphics can be constructed via command line instead of directly. - instituted (then disabled) a transparent pixel capability. Needs an API in comdraw or drawtool first. - fix problem with hanging on stdin when comdraw/graphdraw/flipbook is launched as a helper app from a web browser. - all the changes necessary to bring up ivtools under Mac OS X (Darwin). - fix rewind() vulnerability in early libstdc++-v3 iostreams. Better to close/reopen the file than rewind. January 9th, 2002 ivtools-1.0.1 - add comdraw funcs to poke (grey-level) pixel values into a raster, and return the horizontal and vertical extent of the raster: poke(compview x y val) -- poke pixel value into raster pcols(compview) -- number of columns in a raster pcols(compview) -- number of rows in a raster - sometimes you can accidentally create a polygon with zero points (or a multi-line or spline). Changes to safeguard against crashing whenever this happens. - fix bug in comterp stream traversal via NextFunc::execute_impl. It was leaving an extra null-value on the stack, which confused the interpreter. - add an undocumented debug comterp func, stackheight - tweak of imake system to facilitate NetBSD packaging - add "None" color to background color menu, exposing the hidden fillbg flag (transparent background mechanism) for the first time in the history of this software. - fix drawing editor import's use of gunzip to decompress graphic files. - update config.guess and config.sub, support scripts for the configure script from the autoconf package. May fix some known problems with HPUX, ALPHA, and ARM. - add a comdraw command to create white rasters initialized with a 2 pixel wide black border: compview=raster(x0,y0,x1,y1) -- create an empty raster - make equality and inequality operators work for list objects. Note that the "," list concatenation operator always appends the second operand to the first operand if it is already a list, as illustrated by this example ("> " inserted for clarity): > l1=1,2,3 {1,2,3} > l2=l1,4 {1,2,3,4} > l1==l2 1 Alternately the "list" command can be used to create a distinct list: > l1=1,2,3 {1,2,3} > l2=list(l1),4 {1,2,3,4} > l1==l2 0 - fix up some more handling of nil by arithmetic operators. The rule is nil in, nil out. - minor fixup in comterp error message system - pclip command for clipping of rasters via a polygonal point list: pclip(compview x1,y1,x2,y2,x3,y3[,...,xn,yn]) -- clip raster with polygon - dtog and gtod commands for translating to/from graphic coordinates to drawing coordinates: gx,gy=dtog(compview dx,dy) -- convert from drawing to graphic coordinates dx,dy=gtod(compview gx,gy) -- convert from graphic to drawing coordinates - migration of conditional #define's from Time.c to Time.h by Todd Gruhn. - work on stdin handling for comdraw, flipbook, graphdraw, and drawserv November 2nd, 2001 ivtools-1.0 See CHANGES-0.9 for recent major changes. Minor changes since Oct. 16th 2001 (ivtools-0.9.7): - revise MANIFEST.comterp to reflect current state of comterp. - fix comterp memcpy problem on 64 bit Alpha - fix gcc-3.0.* build without ACE - fix compilation of Time/Time.c on NETBSD. - add :posteval flag to comterp help command in order to see which commands are control constructs (post-evaluated, i.e. there arguments are passed to them in an unevaluated state. The result is: cond,for,help,if,list,next,posteval,postfix,stream,while There are some post-evaluated operators as well. - restore symid and symadd to be normal, non post-evaluated commands. Didn't seem to be necessary, and making this change makes them available for streaming. - make confirmbox command return nil if Cancel is pressed. - comterp operator streaming fixes, mostly along the lines of working out nil termination in different circumstances. - $ unary-prefix operator as a short-cut for stream command. Useful when copying the same stream many times in one command. - each operator traverses a stream, exercising it until the end, and returns the length count. - make the AttributeValueList constructor that takes an AttributeValueList* a truly deep copy. - doc changesivtools-1.2.11a1/CHANGES-1.1000066400000000000000000000032461214471147700150220ustar00rootroot00000000000000February 18th, 2004 ivtools-1.1.3 - continue evolution of iostreams usage to keep up with changes to libstdc++-v3. Many thanks for reinstating a filebuf constructor that accepts an integer file descriptor. Hard to wrap them around sockets any other way. - fix problem with use of ACE on Darwin with gcc-3.3. - fix problem with lexical scanning introduced when "#" comment lines were first handled. December December 8th, 2003 ivtools-1.1.2 - fixes a problem with using gcc-2.95 to compile ivtools-1.1.*. It avoids the use of a local copy of strstream.h, which worked fine for gcc-3.3, but not for gcc-2.9.5. Instead it uses strstream directly, and appends istrstream and ostrstream with the std:: using prefix. Fix contributed by Mark Davies. November 16th, 2003 ivtools-1.1.1 - add missing src/include/ivstd/strstream.h to MANIFEST file and tar file October 29th, 2003 ivtools-1.1.0 - re-enable use of shared memory for X11 image rendering under MacOS X - fix command passed to popen() to detect executables on MacOS X - fix up some AttrValue stuff - all the changes it took to get it built with ACE on MacOS X (though it doesn't work yet). - the cpp bundled with gcc-3.3 has a bug, and gets confused by back-slashed commas in macro arguments (it thinks they start a new argument, which they don't). This introduced a problem to long stable config files, but a workaround is here. - this also fixes things so FreeBSD can configure on alpha architectures. - add -svgexport flag to drawtool that by default suppresses (the incomplete) SVG export mechanism. - incorporate an XML dump of all the SourceForge tracker info, in case SourceForge goes away (sourceforge.102203.xml). ivtools-1.2.11a1/COPYING000066400000000000000000000012151214471147700145570ustar00rootroot00000000000000From Sept. 6th 2000 to May 18th 2001 I represented that ivtools was dual-licensed under its original BSD-like license and the GPL. On May 18th 2001 I became aware of the complete requirements for dual-licensing against GPL (in terms of required headers in each source file), and decided to discontinue dual licensing for the time being. ivtools is still free software, as defined by the Free Software Foundation, it's just not dual-licensed with the GPL. I would still be amenable to the creation of a dual distribution (with provisions for possible GPL-only enhancements) if requested by other collaborators. Scott Johnston http://www.ivtools.org ivtools-1.2.11a1/COPYRIGHT000066400000000000000000000037041214471147700150240ustar00rootroot00000000000000/* * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Scott E. Johnston * Copyright (c) 2000 Vectaport Inc., IET Inc * Copyright (c) 1999 Vectaport Inc., IET Inc, R.B. Kissh and Associates * Copyright (c) 1998 Vectaport Inc., R.B. Kissh and Associates, Eric F. Kahler * Copyright (c) 1997 Vectaport Inc., R.B. Kissh and Associates * Copyright (c) 1996 Vectaport Inc., R.B. Kissh and Associates, Cider Press * Copyright (c) 1994, 1995 Vectaport Inc., Cartoactive Systems, Cider Press * Copyright (c) 1993 David B. Hollenbeck * Copyright (c) 1993 Ellemtel Telecommunication Systems Labratories * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991 Silicon Graphics, Inc. * Copyright (c) 1989 Triple Vision Inc. * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * related documentation and data files for any purpose is hereby granted * without fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice appear in * supporting documentation, and that the names of the copyright holders not * be used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. The copyright holders * make no representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ ivtools-1.2.11a1/INSTALL.OLD000066400000000000000000000247451214471147700152070ustar00rootroot00000000000000 INSTALL for ivtools-1.2 Instructions for building ivtools-1.2.11 from source, the short version: ./configure make su -c "make install" And if that doesn't work... Instructions for building ivtools-1.2.11 from source, the long version: 0. Compilation Environment Things you will need (or might want) before building ivtools: 0.a. a Unix machine (for Windows see README.cygwin). We know it has been built on Linux, NetBSD, FreeBSD, Solaris, Irix, Dec Alpha, HPUX, and SunOS. It also builds on Mac OS X (Darwin) which is a BSD-derivative OS. As of version 1.0.7 ivtools is Jaguar ready. 0.b GNU make. Test to make sure this is the version you are using with "make -v" 0.c. The gcc compiler. Almost any recent version of gcc will work, up to gcc-4.4. You will also need an equivalent copy of libstdc++. libstdc++ comes bundled with gcc-3.0 and greater. Before that the libstdc++ version numbers stay roughly in synch with the gcc version numbers. If you have gcc-2.8.1 you'd want libstdc++-2.8.1, etc.. Be aware that sometimes the include files for libstdc++ are in /usr/local/include/g++-2, a place that cannot be auto-determined by the configure script. Establishing a symbolic link to /usr/local/include/g++ will fix the problem. 0.d. An installed copy of X11R6 as distributed by the Open Group, or an equivalent (XFree86 for Linux/BSD/MacOS-X, or X11R5 from MIT). If you use a vendor's X11 product, the product should be based on X11R4 or later and the product should include imake and the config files. If you can't find imake on your system, you can get the sources for imake from the X11R5 or X11R6 distribution at several public ftp archives (such as ftp.x.org). ** warning -- imake used in combination with a non-GNU C preprocessor ** can be troublesome (i.e. the default one delivered with Solaris or ** DEC Alpha). You'll want to rig your PATH environment variable to ** find the gcc variant of cpp. Read more about it at ** http://www.ivtools.org/ivtools/faq.html#imakecppprob 0.e. If you want to use the polygon intersection tools, acquire and build clippoly, a LGPLed library for polygon clipping from: http://clippoly.sourceforge.net Add -fPIC to the CCFLAGS in the Makefile, then do a make, then build a shared library in the clippoly directory with: "gcc -shared -o libclippoly.so *.o" (you can leave out test.o if you want). 0.f. If you want to use the network server capabilities of the ivtools programs, acquire and build ACE, a C++ middleware toolkit available from: http://www.cs.wustl.edu/%7Eschmidt/ACE.html We are currently using ACE-6.1.0 (or the latest copy of ACE) built without threads support. Follow these steps to build it from source, or use the Debian binary if you happen to be working on that platform (libace5.1-dev): tar xvfz ACE-5.6.tar.gz cd ACE_wrappers export ACE_ROOT=`pwd` # csh: setenv ACE_ROOT `pwd` cd ace cp config-linux.h config.h # substitute appropriate OS name cd ../include/makeinclude cp platform_linux.GNU platform_macros.GNU # substitute OS emacs platform_macros.GNU # add "threads = 0" near top of file, step may no longer be needed cd ../../ace make Then use "--with-ace=$ACE_ROOT" when running the configure script as described below. 0.g if you want to build the ivxt example program, which demonstrates the embedding of a ivtools drawing editor inside Motif widgets, you'll need some version of lesstif or Motif (libXm). To enable the ivxt build, change line 7 of src/Imakefile from "#if 0" to "#if 1". Without these libraries and include files the build of ivxt will fail, which can be safely ignored. 0.h Finally, you might have an interest in building the IueServ library and iueserv program, a networked command interpreter wrapped around the class libraries of the Image Understanding Environment. See http://www.aai.com/AAI/IUE/IUE.html for details on acquiring and building this sizeable collection of public-domain and free software class libraries for image understanding application development. 1. Configuring ivtools: 1.a. You no longer need to set your CPU environment variable to build ivtools, but you still need a CPU specific configuration file. Ready-made configurations that have been known to work exist for LINUX, SUN4 (and Solaris), SGI, HP800 (HPUX), ALPHA, NETSBD, FREEBSD, and CYGWIN (for Windows NT). HPUX config file is known to be out of quite out of date, the others will probably work with little or no tweaks. Use "make CPU" from the top directory to see the symbol ivtools will use for your OS (grep config/arch.def for ArchitectureName to get a complete list of possible OS'es). Then look for a matching config/site.def. file, where is the value returned by "make CPU". If it is there proceed to step 1.b. Other variants of Unix can be attempted by creating the corresponding config/site.def., i.e. site.def.AIX or site.def.MIPS. Use SUN4 for Solaris as well as SunOS. Although SUN5 would be more correct, the config files automatically determine the difference between the two OS'es by checking for SVR4'ness. 1.b Run the configure script in the top-level directory, by entering "./configure" followed by any of the following arguments (--with arguments are recognized as --enable as well): --with-ace= Path to ACE source --with-ace-libs= Path to ACE libraries --with-clippoly= Path to clippoly source --with-clippoly-libs= Path to clippoly libraries --with-iue= Path to IUE source --with-iue-libs= Path to IUE libraries --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR --enable-install-relative[=ARG] install relative to source tree --enable-install-subdir[=ARG] install in ivtools sub-directory --prefix=DIR to use when install-relative is false (default is /usr/local) --enable-use-rpath[=ARG] use -rpath when linking, to embed shared-library pathnames in executable. ARG can be 0 or 1, default is 1 when not specified. The configure script is usually able to automatically determine --x-includes and --x-libraries (except on DEC Alpha). If the arguments for ACE, clippoly, or IUE are not supplied, the configure script prints a reminder, then proceeds to set up to build ivtools without these libraries. If you want to run the executables without installing them, use --enable-use-rpath to embed the shared library pathnames into the executables at link time. Here is an example of using the configure script with ACE and clippoly libraries: ./configure --with-clippoly=/proj/clippoly --with-ace=/proj/ACE_wrappers Running the configure script generates two files, a config/config.mk that gets included into each Makefile when used, and a config/config--gcc.defs that gets used by "make Makefiles" described below. is something like linux. The last line of output from the configure script shows this pathname. Verify that this is the same as the file included at the end of the config/site.def. file. Change the site.def. file if necessary. Also you may want to review the rest of the entries in the site.def. file to see if they are good defaults for your system. ** See http://www.ivtools.org/ivtools/faq.html for more info. 2. Compiling ivtools: 2.a. cd to the ivtools-1.2/ directory (you'd already be in this directory after running the configure script). 2.b. Compile it with a "make" command. The first time it is run it does all these individual steps (the equivalent of "make World"): - regenerates the top-level Makefile to snap it to the current directory ("make Makefile"). - runs through the source tree and generates all the other Makefile's ("make Makefiles"). - generates compilation dependencies for each directory with code to compile -- see the Makefile.depend file in each sub-directory ("make depend"). - compiles and links everything ("make -k"). If you have any trouble at this stage take a look at: http://www.ivtools.org/ivtools/faq.html#SourceBuild ** Subsequent use of "make" will only do the "make -k" phase described ** above. To redo everything, either do a "make World", or do a "make ** clean" followed by a "make". The "make clean" deletes the files ** that suppress the make stateges, make.makefile, make.makefiles, ** make.depend, and make.make. 3. Testing: Each directory under ivtools-1.2/src that begins in lower case (except for "include" and "scripts") contains executables that exercise some particular functionality. "cd" to each particular directory, type "/a.out" and see what happens (the utils directory contains more than one executable, things named other than a.out). Quite a few directories have README's that go into further detail on how to use the programs. ivtools-1.2/src/glyphs contains sub-directories of glyph example programs. ivtools-1.2/src/glyphs/examples3.1 contains most of the simple example programs that were originally distributed with InterViews 3.1. There is also a src/tests directory, with one test program to date, y2k/y2ktest.c. This builds a small program that verifies the Date object of the Time class library has no problem with Y2K or Y2.038K, by allowing the user to enter "+" and "-" to increment/decrement the year past these boundaries. 4. Installation: "make install" is supported for all the libraries and a subset of the more utilitarian example programs: the four original InterViews programs (idraw, iclass, idemo, and dclock), the four idraw derived programs (drawtool, netdraw, flipbook, and comdraw) and the two comterp programs (comterp and glyphterp). In addition the scripts in src/scripts and utilities in src/utils get installed. "make uninstall" is supported as well. When relative install is enabled (--enable-install-relative for the configure script), the binaries are installed in ivtools-1.2/bin/, the libraries are installed in ivtools-1.2/lib/, and the run-time X resource and config files are installed in ivtools-1.2/lib/ivtools. When relative install is disabled (the default for the configure script) the binaries are installed as stripped executables in `prefix`/bin the libraries are installed in `prefix`/lib, and the run-time X resource and config files are installed in `prefix`/lib/ivtools. note: idemo, comterp, glyphterp, and comdraw have config files that must be installed (either relative or non-relative) for the program to find them at runtime. drawtool relies on several scripts and utilities for accessing graphics and image files that must be installed as well for them to work. ivtools-1.2.11a1/MANIFEST000066400000000000000000002140471214471147700146660ustar00rootroot00000000000000sivtools-1.2/CHANGES ivtools-1.2/CHANGES-0.4 ivtools-1.2/CHANGES-0.5 ivtools-1.2/CHANGES-0.6 ivtools-1.2/CHANGES-0.7 ivtools-1.2/CHANGES-0.8 ivtools-1.2/CHANGES-0.9 ivtools-1.2/CHANGES-1.0 ivtools-1.2/CHANGES-1.1 ivtools-1.2/COPYING ivtools-1.2/COPYRIGHT ivtools-1.2/INSTALL ivtools-1.2/Imakefile ivtools-1.2/MANIFEST ivtools-1.2/MANIFEST.comterp ivtools-1.2/MANIFEST.perceps ivtools-1.2/Makefile ivtools-1.2/README ivtools-1.2/README.cygwin ivtools-1.2/README.ivmkcm ivtools-1.2/VERSION ivtools-1.2/aclocal.m4 ivtools-1.2/comtop.tgz ivtools-1.2/config/Imakefile ivtools-1.2/config/InterViews/Imakefile ivtools-1.2/config/InterViews/Makefile ivtools-1.2/config/InterViews/TIFF.def ivtools-1.2/config/InterViews/arch.def ivtools-1.2/config/InterViews/cxx.def ivtools-1.2/config/InterViews/iv-DGUX.cf ivtools-1.2/config/InterViews/iv-Mips.cf ivtools-1.2/config/InterViews/iv-aix.cf ivtools-1.2/config/InterViews/iv-alpha.cf ivtools-1.2/config/InterViews/iv-apollo.cf ivtools-1.2/config/InterViews/iv-att.cf ivtools-1.2/config/InterViews/iv-bsd.cf ivtools-1.2/config/InterViews/iv-convex.cf ivtools-1.2/config/InterViews/iv-cray.cf ivtools-1.2/config/InterViews/iv-cygwin.cf ivtools-1.2/config/InterViews/iv-darwin.cf ivtools-1.2/config/InterViews/iv-freebsd.cf ivtools-1.2/config/InterViews/iv-generic.cf ivtools-1.2/config/InterViews/iv-hp.cf ivtools-1.2/config/InterViews/iv-ibm.cf ivtools-1.2/config/InterViews/iv-linux.cf ivtools-1.2/config/InterViews/iv-luna.cf ivtools-1.2/config/InterViews/iv-m4330.cf ivtools-1.2/config/InterViews/iv-macII.cf ivtools-1.2/config/InterViews/iv-moto.cf ivtools-1.2/config/InterViews/iv-netbsd.cf ivtools-1.2/config/InterViews/iv-pegasus.cf ivtools-1.2/config/InterViews/iv-sgi.cf ivtools-1.2/config/InterViews/iv-sony.cf ivtools-1.2/config/InterViews/iv-stellar.cf ivtools-1.2/config/InterViews/iv-stratus.cf ivtools-1.2/config/InterViews/iv-sun.cf ivtools-1.2/config/InterViews/iv-ultrix.cf ivtools-1.2/config/InterViews/iv-x386.cf ivtools-1.2/config/InterViews/local.def ivtools-1.2/config/InterViews/params.def ivtools-1.2/config/InterViews/rules.def ivtools-1.2/config/InterViews/xparams.cf ivtools-1.2/config/Makefile ivtools-1.2/config/alpha3.0-gcc.mk ivtools-1.2/config/alpha3.2-gcc.mk ivtools-1.2/config/alpha4-gcc.mk ivtools-1.2/config/arch.def ivtools-1.2/config/config.defs.in ivtools-1.2/config/config.mk ivtools-1.2/config/config.null.mk ivtools-1.2/config/darwin-gcc.mk ivtools-1.2/config/default-gcc.mk ivtools-1.2/config/freebsd-gcc.mk ivtools-1.2/config/freebsd2.1-gcc.mk ivtools-1.2/config/gcc.def ivtools-1.2/config/hpux-gcc.mk ivtools-1.2/config/hpux10.20-gcc.mk ivtools-1.2/config/irix5-gcc.mk ivtools-1.2/config/irix6-gcc.mk ivtools-1.2/config/linux-gcc.mk ivtools-1.2/config/local.def ivtools-1.2/config/m88k-sysv3-gcc.mk ivtools-1.2/config/m88k-sysv4-gcc.mk ivtools-1.2/config/makevars.def ivtools-1.2/config/netbsd-gcc.mk ivtools-1.2/config/params.def ivtools-1.2/config/rules.def ivtools-1.2/config/sco3.2.4-gcc.mk ivtools-1.2/config/site.def.ALPHA ivtools-1.2/config/site.def.CYGWIN ivtools-1.2/config/site.def.DARWIN ivtools-1.2/config/site.def.FREEBSD ivtools-1.2/config/site.def.HP800 ivtools-1.2/config/site.def.LINUX ivtools-1.2/config/site.def.NETBSD ivtools-1.2/config/site.def.SGI ivtools-1.2/config/site.def.SUN4 ivtools-1.2/config/solaris-gcc.mk ivtools-1.2/config/sunos4-gcc.mk ivtools-1.2/config/template ivtools-1.2/configure ivtools-1.2/configure.in ivtools-1.2/configure.notes ivtools-1.2/sourceforge.102203.xml ivtools-1.2/src/AceDispatch/Imakefile ivtools-1.2/src/AceDispatch/Makefile ivtools-1.2/src/AceDispatch/ace_dispatcher.c ivtools-1.2/src/AceDispatch/ace_dispatcher.h ivtools-1.2/src/AceDispatch/ace_iohandler.c ivtools-1.2/src/AceDispatch/ace_iohandler.h ivtools-1.2/src/AttrGlyph/Imakefile ivtools-1.2/src/AttrGlyph/Makefile ivtools-1.2/src/AttrGlyph/attredit.c ivtools-1.2/src/AttrGlyph/attredit.h ivtools-1.2/src/Attribute/Imakefile ivtools-1.2/src/Attribute/Makefile ivtools-1.2/src/Attribute/_comterp.h ivtools-1.2/src/Attribute/_comutil.h ivtools-1.2/src/Attribute/alist.c ivtools-1.2/src/Attribute/alist.h ivtools-1.2/src/Attribute/aliterator.c ivtools-1.2/src/Attribute/aliterator.h ivtools-1.2/src/Attribute/attribute.c ivtools-1.2/src/Attribute/attribute.h ivtools-1.2/src/Attribute/attrlist.c ivtools-1.2/src/Attribute/attrlist.h ivtools-1.2/src/Attribute/attrvalue.c ivtools-1.2/src/Attribute/attrvalue.h ivtools-1.2/src/Attribute/classid.h ivtools-1.2/src/Attribute/commodule.c ivtools-1.2/src/Attribute/commodule.h ivtools-1.2/src/Attribute/lexscan.c ivtools-1.2/src/Attribute/lexscan.h ivtools-1.2/src/Attribute/paramlist.c ivtools-1.2/src/Attribute/paramlist.h ivtools-1.2/src/ComGlyph/Imakefile ivtools-1.2/src/ComGlyph/Makefile ivtools-1.2/src/ComGlyph/attrdialog.c ivtools-1.2/src/ComGlyph/attrdialog.h ivtools-1.2/src/ComGlyph/comtextedit.c ivtools-1.2/src/ComGlyph/comtextedit.h ivtools-1.2/src/ComGlyph/comtextview.c ivtools-1.2/src/ComGlyph/comtextview.h ivtools-1.2/src/ComGlyph/terpdialog.c ivtools-1.2/src/ComGlyph/terpdialog.h ivtools-1.2/src/ComTerp/Imakefile ivtools-1.2/src/ComTerp/Makefile ivtools-1.2/src/ComTerp/_comterp.h ivtools-1.2/src/ComTerp/_comutil.h ivtools-1.2/src/ComTerp/assignfunc.c ivtools-1.2/src/ComTerp/assignfunc.h ivtools-1.2/src/ComTerp/bitfunc.c ivtools-1.2/src/ComTerp/bitfunc.h ivtools-1.2/src/ComTerp/boolfunc.c ivtools-1.2/src/ComTerp/boolfunc.h ivtools-1.2/src/ComTerp/bquotefunc.c ivtools-1.2/src/ComTerp/bquotefunc.h ivtools-1.2/src/ComTerp/charfunc.c ivtools-1.2/src/ComTerp/charfunc.h ivtools-1.2/src/ComTerp/comfunc.c ivtools-1.2/src/ComTerp/comfunc.h ivtools-1.2/src/ComTerp/comhandler.c ivtools-1.2/src/ComTerp/comhandler.h ivtools-1.2/src/ComTerp/commodule.h ivtools-1.2/src/ComTerp/comterp.c ivtools-1.2/src/ComTerp/comterp.h ivtools-1.2/src/ComTerp/comterpserv.c ivtools-1.2/src/ComTerp/comterpserv.h ivtools-1.2/src/ComTerp/comvalue.c ivtools-1.2/src/ComTerp/comvalue.h ivtools-1.2/src/ComTerp/condfunc.c ivtools-1.2/src/ComTerp/condfunc.h ivtools-1.2/src/ComTerp/ctrlfunc.c ivtools-1.2/src/ComTerp/ctrlfunc.h ivtools-1.2/src/ComTerp/debugfunc.c ivtools-1.2/src/ComTerp/debugfunc.h ivtools-1.2/src/ComTerp/dotfunc.c ivtools-1.2/src/ComTerp/dotfunc.h ivtools-1.2/src/ComTerp/helpfunc.c ivtools-1.2/src/ComTerp/helpfunc.h ivtools-1.2/src/ComTerp/iofunc.c ivtools-1.2/src/ComTerp/iofunc.h ivtools-1.2/src/ComTerp/lexscan.h ivtools-1.2/src/ComTerp/listfunc.c ivtools-1.2/src/ComTerp/listfunc.h ivtools-1.2/src/ComTerp/mathfunc.c ivtools-1.2/src/ComTerp/mathfunc.h ivtools-1.2/src/ComTerp/numfunc.c ivtools-1.2/src/ComTerp/numfunc.h ivtools-1.2/src/ComTerp/parser.c ivtools-1.2/src/ComTerp/parser.h ivtools-1.2/src/ComTerp/postfunc.c ivtools-1.2/src/ComTerp/postfunc.h ivtools-1.2/src/ComTerp/randfunc.c ivtools-1.2/src/ComTerp/randfunc.h ivtools-1.2/src/ComTerp/scanner.c ivtools-1.2/src/ComTerp/scanner.h ivtools-1.2/src/ComTerp/statfunc.c ivtools-1.2/src/ComTerp/statfunc.h ivtools-1.2/src/ComTerp/strmfunc.c ivtools-1.2/src/ComTerp/strmfunc.h ivtools-1.2/src/ComTerp/symbolfunc.c ivtools-1.2/src/ComTerp/symbolfunc.h ivtools-1.2/src/ComTerp/typefunc.c ivtools-1.2/src/ComTerp/typefunc.h ivtools-1.2/src/ComTerp/xformfunc.c ivtools-1.2/src/ComTerp/xformfunc.h ivtools-1.2/src/ComUnidraw/Imakefile ivtools-1.2/src/ComUnidraw/Makefile ivtools-1.2/src/ComUnidraw/comeditor.c ivtools-1.2/src/ComUnidraw/comeditor.h ivtools-1.2/src/ComUnidraw/comterp-acehandler.c ivtools-1.2/src/ComUnidraw/comterp-acehandler.h ivtools-1.2/src/ComUnidraw/comterp-iohandler.c ivtools-1.2/src/ComUnidraw/comterp-iohandler.h ivtools-1.2/src/ComUnidraw/dialogfunc.c ivtools-1.2/src/ComUnidraw/dialogfunc.h ivtools-1.2/src/ComUnidraw/grdotfunc.c ivtools-1.2/src/ComUnidraw/grdotfunc.h ivtools-1.2/src/ComUnidraw/grfunc.c ivtools-1.2/src/ComUnidraw/grfunc.h ivtools-1.2/src/ComUnidraw/grlistfunc.c ivtools-1.2/src/ComUnidraw/grlistfunc.h ivtools-1.2/src/ComUnidraw/groupfunc.c ivtools-1.2/src/ComUnidraw/groupfunc.h ivtools-1.2/src/ComUnidraw/grstatfunc.c ivtools-1.2/src/ComUnidraw/grstatfunc.h ivtools-1.2/src/ComUnidraw/grstrmfunc.c ivtools-1.2/src/ComUnidraw/grstrmfunc.h ivtools-1.2/src/ComUnidraw/highlightfunc.c ivtools-1.2/src/ComUnidraw/highlightfunc.h ivtools-1.2/src/ComUnidraw/nfunc.c ivtools-1.2/src/ComUnidraw/nfunc.h ivtools-1.2/src/ComUnidraw/pixelfunc.c ivtools-1.2/src/ComUnidraw/pixelfunc.h ivtools-1.2/src/ComUnidraw/plotfunc.c ivtools-1.2/src/ComUnidraw/plotfunc.h ivtools-1.2/src/ComUnidraw/unifunc.c ivtools-1.2/src/ComUnidraw/unifunc.h ivtools-1.2/src/ComUtil/Imakefile ivtools-1.2/src/ComUtil/Makefile ivtools-1.2/src/ComUtil/_lexscan.c ivtools-1.2/src/ComUtil/_parser.c ivtools-1.2/src/ComUtil/_scanner.c ivtools-1.2/src/ComUtil/atox.c ivtools-1.2/src/ComUtil/comerr.c ivtools-1.2/src/ComUtil/comterp.arg ivtools-1.2/src/ComUtil/comterp.ci ivtools-1.2/src/ComUtil/comterp.err ivtools-1.2/src/ComUtil/comterp.h ivtools-1.2/src/ComUtil/comutil.arg ivtools-1.2/src/ComUtil/comutil.ci ivtools-1.2/src/ComUtil/comutil.h ivtools-1.2/src/ComUtil/dmm.c ivtools-1.2/src/ComUtil/errfile.c ivtools-1.2/src/ComUtil/errsys.c ivtools-1.2/src/ComUtil/funcptrs.c ivtools-1.2/src/ComUtil/mblock.c ivtools-1.2/src/ComUtil/optable.c ivtools-1.2/src/ComUtil/popen2.c ivtools-1.2/src/ComUtil/symbols.c ivtools-1.2/src/ComUtil/txtutil.c ivtools-1.2/src/ComUtil/types.c ivtools-1.2/src/ComUtil/util.c ivtools-1.2/src/ComUtil/util.h ivtools-1.2/src/ComUtil/xdll.c ivtools-1.2/src/Dispatch/Imakefile ivtools-1.2/src/Dispatch/Makefile ivtools-1.2/src/Dispatch/dispatcher.c ivtools-1.2/src/Dispatch/iohandler.c ivtools-1.2/src/Dispatch/iostreamb.c ivtools-1.2/src/Dispatch/netinet_in.h ivtools-1.2/src/Dispatch/rpcbuf.c ivtools-1.2/src/Dispatch/rpchdr.c ivtools-1.2/src/Dispatch/rpcpeer.c ivtools-1.2/src/Dispatch/rpcreader.c ivtools-1.2/src/Dispatch/rpcregistry.c ivtools-1.2/src/Dispatch/rpcservice.c ivtools-1.2/src/Dispatch/rpcstream.c ivtools-1.2/src/Dispatch/rpcwriter.c ivtools-1.2/src/DrawServ/Imakefile ivtools-1.2/src/DrawServ/Makefile ivtools-1.2/src/DrawServ/ackback-handler.c ivtools-1.2/src/DrawServ/ackback-handler.h ivtools-1.2/src/DrawServ/drawcatalog.c ivtools-1.2/src/DrawServ/drawcatalog.h ivtools-1.2/src/DrawServ/drawclasses.h ivtools-1.2/src/DrawServ/drawcmds.c ivtools-1.2/src/DrawServ/drawcmds.h ivtools-1.2/src/DrawServ/drawcomps.c ivtools-1.2/src/DrawServ/drawcomps.h ivtools-1.2/src/DrawServ/drawcreator.c ivtools-1.2/src/DrawServ/drawcreator.h ivtools-1.2/src/DrawServ/draweditor.c ivtools-1.2/src/DrawServ/draweditor.h ivtools-1.2/src/DrawServ/drawfunc.c ivtools-1.2/src/DrawServ/drawfunc.h ivtools-1.2/src/DrawServ/drawimport.c ivtools-1.2/src/DrawServ/drawimport.h ivtools-1.2/src/DrawServ/drawkit.c ivtools-1.2/src/DrawServ/drawkit.h ivtools-1.2/src/DrawServ/drawlink.c ivtools-1.2/src/DrawServ/drawlink.h ivtools-1.2/src/DrawServ/drawlinkcomp.c ivtools-1.2/src/DrawServ/drawlinkcomp.h ivtools-1.2/src/DrawServ/drawlinklist.c ivtools-1.2/src/DrawServ/drawlinklist.h ivtools-1.2/src/DrawServ/drawserv.c ivtools-1.2/src/DrawServ/drawserv.h ivtools-1.2/src/DrawServ/drawserv-handler.c ivtools-1.2/src/DrawServ/drawserv-handler.h ivtools-1.2/src/DrawServ/drawviews.c ivtools-1.2/src/DrawServ/drawviews.h ivtools-1.2/src/DrawServ/grid.c ivtools-1.2/src/DrawServ/grid.h ivtools-1.2/src/DrawServ/gridlist.c ivtools-1.2/src/DrawServ/gridlist.h ivtools-1.2/src/DrawServ/linkselection.c ivtools-1.2/src/DrawServ/linkselection.h ivtools-1.2/src/DrawServ/rcdialog.c ivtools-1.2/src/DrawServ/rcdialog.h ivtools-1.2/src/DrawServ/sid.c ivtools-1.2/src/DrawServ/sid.h ivtools-1.2/src/FrameUnidraw/Imakefile ivtools-1.2/src/FrameUnidraw/Makefile ivtools-1.2/src/FrameUnidraw/framecatalog.c ivtools-1.2/src/FrameUnidraw/framecatalog.h ivtools-1.2/src/FrameUnidraw/frameclasses.h ivtools-1.2/src/FrameUnidraw/framecmds.c ivtools-1.2/src/FrameUnidraw/framecmds.h ivtools-1.2/src/FrameUnidraw/framecomps.c ivtools-1.2/src/FrameUnidraw/framecomps.h ivtools-1.2/src/FrameUnidraw/framecreator.c ivtools-1.2/src/FrameUnidraw/framecreator.h ivtools-1.2/src/FrameUnidraw/frameeditor.c ivtools-1.2/src/FrameUnidraw/frameeditor.h ivtools-1.2/src/FrameUnidraw/framefile.c ivtools-1.2/src/FrameUnidraw/framefile.h ivtools-1.2/src/FrameUnidraw/framefunc.c ivtools-1.2/src/FrameUnidraw/framefunc.h ivtools-1.2/src/FrameUnidraw/frameimport.c ivtools-1.2/src/FrameUnidraw/frameimport.h ivtools-1.2/src/FrameUnidraw/framekit.c ivtools-1.2/src/FrameUnidraw/framekit.h ivtools-1.2/src/FrameUnidraw/frameps.c ivtools-1.2/src/FrameUnidraw/frameps.h ivtools-1.2/src/FrameUnidraw/framescripts.c ivtools-1.2/src/FrameUnidraw/framescripts.h ivtools-1.2/src/FrameUnidraw/framestates.c ivtools-1.2/src/FrameUnidraw/framestates.h ivtools-1.2/src/FrameUnidraw/frameviewer.c ivtools-1.2/src/FrameUnidraw/frameviewer.h ivtools-1.2/src/FrameUnidraw/frameviews.c ivtools-1.2/src/FrameUnidraw/frameviews.h ivtools-1.2/src/GraphUnidraw/Imakefile ivtools-1.2/src/GraphUnidraw/Makefile ivtools-1.2/src/GraphUnidraw/edgecomp.c ivtools-1.2/src/GraphUnidraw/edgecomp.h ivtools-1.2/src/GraphUnidraw/graphcatalog.c ivtools-1.2/src/GraphUnidraw/graphcatalog.h ivtools-1.2/src/GraphUnidraw/graphclasses.h ivtools-1.2/src/GraphUnidraw/graphcmds.c ivtools-1.2/src/GraphUnidraw/graphcmds.h ivtools-1.2/src/GraphUnidraw/graphcomp.c ivtools-1.2/src/GraphUnidraw/graphcomp.h ivtools-1.2/src/GraphUnidraw/graphcreator.c ivtools-1.2/src/GraphUnidraw/graphcreator.h ivtools-1.2/src/GraphUnidraw/graphdata.c ivtools-1.2/src/GraphUnidraw/graphdata.h ivtools-1.2/src/GraphUnidraw/graphdialog.c ivtools-1.2/src/GraphUnidraw/graphdialog.h ivtools-1.2/src/GraphUnidraw/grapheditor.c ivtools-1.2/src/GraphUnidraw/grapheditor.h ivtools-1.2/src/GraphUnidraw/graphexport.c ivtools-1.2/src/GraphUnidraw/graphexport.h ivtools-1.2/src/GraphUnidraw/graphimport.c ivtools-1.2/src/GraphUnidraw/graphimport.h ivtools-1.2/src/GraphUnidraw/graphkit.c ivtools-1.2/src/GraphUnidraw/graphkit.h ivtools-1.2/src/GraphUnidraw/graphtools.c ivtools-1.2/src/GraphUnidraw/graphtools.h ivtools-1.2/src/GraphUnidraw/nodecomp.c ivtools-1.2/src/GraphUnidraw/nodecomp.h ivtools-1.2/src/IV-2_6/Imakefile ivtools-1.2/src/IV-2_6/Makefile ivtools-1.2/src/IV-2_6/adjuster2_6.c ivtools-1.2/src/IV-2_6/banner.c ivtools-1.2/src/IV-2_6/border2_6.c ivtools-1.2/src/IV-2_6/box2_6.c ivtools-1.2/src/IV-2_6/button2_6.c ivtools-1.2/src/IV-2_6/compeditor.c ivtools-1.2/src/IV-2_6/control.c ivtools-1.2/src/IV-2_6/deck2_6.c ivtools-1.2/src/IV-2_6/dialog2_6.c ivtools-1.2/src/IV-2_6/filebrowser.c ivtools-1.2/src/IV-2_6/filechooser.c ivtools-1.2/src/IV-2_6/frame.c ivtools-1.2/src/IV-2_6/glue2_6.c ivtools-1.2/src/IV-2_6/interactor.c ivtools-1.2/src/IV-2_6/matcheditor.c ivtools-1.2/src/IV-2_6/menu2_6.c ivtools-1.2/src/IV-2_6/message.c ivtools-1.2/src/IV-2_6/painter.c ivtools-1.2/src/IV-2_6/panner2_6.c ivtools-1.2/src/IV-2_6/perspective.c ivtools-1.2/src/IV-2_6/rubband.c ivtools-1.2/src/IV-2_6/rubcurve.c ivtools-1.2/src/IV-2_6/rubgroup.c ivtools-1.2/src/IV-2_6/rubline.c ivtools-1.2/src/IV-2_6/rubrect.c ivtools-1.2/src/IV-2_6/rubverts.c ivtools-1.2/src/IV-2_6/scene.c ivtools-1.2/src/IV-2_6/scrollbar2_6.c ivtools-1.2/src/IV-2_6/scroller2_6.c ivtools-1.2/src/IV-2_6/sensor.c ivtools-1.2/src/IV-2_6/shape.c ivtools-1.2/src/IV-2_6/strbrowser.c ivtools-1.2/src/IV-2_6/strchooser.c ivtools-1.2/src/IV-2_6/streditor.c ivtools-1.2/src/IV-2_6/subject.c ivtools-1.2/src/IV-2_6/textbuffer.c ivtools-1.2/src/IV-2_6/textdisplay.c ivtools-1.2/src/IV-2_6/texteditor.c ivtools-1.2/src/IV-2_6/tform2_6.c ivtools-1.2/src/IV-2_6/tray.c ivtools-1.2/src/IV-2_6/viewport.c ivtools-1.2/src/IV-2_6/world.c ivtools-1.2/src/IV-2_6/xbitmap2_6.c ivtools-1.2/src/IV-2_6/xevent2_6.c ivtools-1.2/src/IV-2_6/xinter.c ivtools-1.2/src/IV-2_6/xpainter.c ivtools-1.2/src/IV-2_6/xpattern.c ivtools-1.2/src/IV-X11/Imakefile ivtools-1.2/src/IV-X11/Makefile ivtools-1.2/src/IV-X11/glcontext.c ivtools-1.2/src/IV-X11/wtable.h ivtools-1.2/src/IV-X11/xbitmap.c ivtools-1.2/src/IV-X11/xbrush.c ivtools-1.2/src/IV-X11/xcanvas.c ivtools-1.2/src/IV-X11/xcolor.c ivtools-1.2/src/IV-X11/xcursor.c ivtools-1.2/src/IV-X11/xdrag.c ivtools-1.2/src/IV-X11/xevent.c ivtools-1.2/src/IV-X11/xfont.c ivtools-1.2/src/IV-X11/xraster.c ivtools-1.2/src/IV-X11/xreqerr.c ivtools-1.2/src/IV-X11/xselection.c ivtools-1.2/src/IV-X11/xwindow.c ivtools-1.2/src/IV-common/Imakefile ivtools-1.2/src/IV-common/Makefile ivtools-1.2/src/IV-common/listimpl.c ivtools-1.2/src/IV-common/math.c ivtools-1.2/src/IV-common/memory.c ivtools-1.2/src/IV-common/regexp.c ivtools-1.2/src/IV-common/resource.c ivtools-1.2/src/IV-common/string.c ivtools-1.2/src/IV-common/textbuffer.c ivtools-1.2/src/IV-common/tform2_6.c ivtools-1.2/src/IV-common/transformer.c ivtools-1.2/src/IV/Imakefile ivtools-1.2/src/IV/InterViews.defaults ivtools-1.2/src/IV/Makefile ivtools-1.2/src/IVGlyph/Imakefile ivtools-1.2/src/IVGlyph/Makefile ivtools-1.2/src/IVGlyph/bdfltform.c ivtools-1.2/src/IVGlyph/bdfltform.h ivtools-1.2/src/IVGlyph/bdtable.c ivtools-1.2/src/IVGlyph/bdtable.h ivtools-1.2/src/IVGlyph/bdvalue.c ivtools-1.2/src/IVGlyph/bdvalue.h ivtools-1.2/src/IVGlyph/boolform.c ivtools-1.2/src/IVGlyph/boolform.h ivtools-1.2/src/IVGlyph/charfield.c ivtools-1.2/src/IVGlyph/charfield.h ivtools-1.2/src/IVGlyph/dragedit.c ivtools-1.2/src/IVGlyph/dragedit.h ivtools-1.2/src/IVGlyph/enumform.c ivtools-1.2/src/IVGlyph/enumform.h ivtools-1.2/src/IVGlyph/exportchooser.c ivtools-1.2/src/IVGlyph/exportchooser.h ivtools-1.2/src/IVGlyph/fieldedit.c ivtools-1.2/src/IVGlyph/fieldedit.h ivtools-1.2/src/IVGlyph/figure.c ivtools-1.2/src/IVGlyph/figure.h ivtools-1.2/src/IVGlyph/gdialogs.c ivtools-1.2/src/IVGlyph/gdialogs.h ivtools-1.2/src/IVGlyph/globals.c ivtools-1.2/src/IVGlyph/globals.h ivtools-1.2/src/IVGlyph/grabber.bm ivtools-1.2/src/IVGlyph/grabberMask.bm ivtools-1.2/src/IVGlyph/idraw.c ivtools-1.2/src/IVGlyph/idraw.h ivtools-1.2/src/IVGlyph/importchooser.c ivtools-1.2/src/IVGlyph/importchooser.h ivtools-1.2/src/IVGlyph/namestate.c ivtools-1.2/src/IVGlyph/namestate.h ivtools-1.2/src/IVGlyph/observables.c ivtools-1.2/src/IVGlyph/observables.h ivtools-1.2/src/IVGlyph/odialogs.c ivtools-1.2/src/IVGlyph/odialogs.h ivtools-1.2/src/IVGlyph/ofilechooser.c ivtools-1.2/src/IVGlyph/ofilechooser.h ivtools-1.2/src/IVGlyph/printchooser.c ivtools-1.2/src/IVGlyph/printchooser.h ivtools-1.2/src/IVGlyph/saveaschooser.c ivtools-1.2/src/IVGlyph/saveaschooser.h ivtools-1.2/src/IVGlyph/scrollable.c ivtools-1.2/src/IVGlyph/scrollable.h ivtools-1.2/src/IVGlyph/strchooser.c ivtools-1.2/src/IVGlyph/strchooser.h ivtools-1.2/src/IVGlyph/stredit.c ivtools-1.2/src/IVGlyph/stredit.h ivtools-1.2/src/IVGlyph/strlist.c ivtools-1.2/src/IVGlyph/strlist.h ivtools-1.2/src/IVGlyph/textbuff.c ivtools-1.2/src/IVGlyph/textbuff.h ivtools-1.2/src/IVGlyph/textedit.c ivtools-1.2/src/IVGlyph/textedit.h ivtools-1.2/src/IVGlyph/texteditor.c ivtools-1.2/src/IVGlyph/texteditor.h ivtools-1.2/src/IVGlyph/textform.c ivtools-1.2/src/IVGlyph/textform.h ivtools-1.2/src/IVGlyph/textview.c ivtools-1.2/src/IVGlyph/textview.h ivtools-1.2/src/IVGlyph/textwindow.c ivtools-1.2/src/IVGlyph/textwindow.h ivtools-1.2/src/IVGlyph/toolbutton.c ivtools-1.2/src/IVGlyph/toolbutton.h ivtools-1.2/src/IVGlyph/valuator.c ivtools-1.2/src/IVGlyph/valuator.h ivtools-1.2/src/Imakefile ivtools-1.2/src/InterViews/Imakefile ivtools-1.2/src/InterViews/Makefile ivtools-1.2/src/InterViews/action.c ivtools-1.2/src/InterViews/adjust.c ivtools-1.2/src/InterViews/aggr.c ivtools-1.2/src/InterViews/align.c ivtools-1.2/src/InterViews/alloctbl.c ivtools-1.2/src/InterViews/arrcomp.c ivtools-1.2/src/InterViews/background.c ivtools-1.2/src/InterViews/bevel.c ivtools-1.2/src/InterViews/border.c ivtools-1.2/src/InterViews/box.c ivtools-1.2/src/InterViews/browser.c ivtools-1.2/src/InterViews/button.c ivtools-1.2/src/InterViews/character.c ivtools-1.2/src/InterViews/composition.c ivtools-1.2/src/InterViews/compositor.c ivtools-1.2/src/InterViews/debug.c ivtools-1.2/src/InterViews/deck.c ivtools-1.2/src/InterViews/dialogs.c ivtools-1.2/src/InterViews/fbrowser.c ivtools-1.2/src/InterViews/fchooser.c ivtools-1.2/src/InterViews/field.c ivtools-1.2/src/InterViews/geometry.c ivtools-1.2/src/InterViews/glyph.c ivtools-1.2/src/InterViews/group.c ivtools-1.2/src/InterViews/handler.c ivtools-1.2/src/InterViews/hit.c ivtools-1.2/src/InterViews/image.c ivtools-1.2/src/InterViews/input.c ivtools-1.2/src/InterViews/kit.c ivtools-1.2/src/InterViews/label.c ivtools-1.2/src/InterViews/layout.c ivtools-1.2/src/InterViews/lrmarker.c ivtools-1.2/src/InterViews/menu.c ivtools-1.2/src/InterViews/mf_dialogs.c ivtools-1.2/src/InterViews/mf_kit.c ivtools-1.2/src/InterViews/mono_kit.c ivtools-1.2/src/InterViews/monoglyph.c ivtools-1.2/src/InterViews/observe.c ivtools-1.2/src/InterViews/ol_dialogs.c ivtools-1.2/src/InterViews/ol_kit.c ivtools-1.2/src/InterViews/page.c ivtools-1.2/src/InterViews/patch.c ivtools-1.2/src/InterViews/place.c ivtools-1.2/src/InterViews/polyglyph.c ivtools-1.2/src/InterViews/printer.c ivtools-1.2/src/InterViews/psfont.c ivtools-1.2/src/InterViews/regexp.c ivtools-1.2/src/InterViews/resource.c ivtools-1.2/src/InterViews/rule.c ivtools-1.2/src/InterViews/scrbox.c ivtools-1.2/src/InterViews/session.c ivtools-1.2/src/InterViews/shadow.c ivtools-1.2/src/InterViews/simpcomp.c ivtools-1.2/src/InterViews/slider.c ivtools-1.2/src/InterViews/smf_kit.c ivtools-1.2/src/InterViews/stencil.c ivtools-1.2/src/InterViews/stepper.c ivtools-1.2/src/InterViews/style.c ivtools-1.2/src/InterViews/superpose.c ivtools-1.2/src/InterViews/target.c ivtools-1.2/src/InterViews/telltale.c ivtools-1.2/src/InterViews/texcomp.c ivtools-1.2/src/InterViews/tformsetter.c ivtools-1.2/src/InterViews/tiff.c ivtools-1.2/src/InterViews/tile.c ivtools-1.2/src/InterViews/transformer.c ivtools-1.2/src/InterViews/xymarker.c ivtools-1.2/src/IueServ/Imakefile ivtools-1.2/src/IueServ/Makefile ivtools-1.2/src/IueServ/exportfunc.c ivtools-1.2/src/IueServ/exportfunc.h ivtools-1.2/src/IueServ/ipfunc.c ivtools-1.2/src/IueServ/ipfunc.h ivtools-1.2/src/IueServ/iueclasses.h ivtools-1.2/src/IueServ/iuecomps.c ivtools-1.2/src/IueServ/iuecomps.h ivtools-1.2/src/IueServ/iuefunc.c ivtools-1.2/src/IueServ/iuefunc.h ivtools-1.2/src/IueServ/iuehandler.c ivtools-1.2/src/IueServ/iuehandler.h ivtools-1.2/src/IueServ/roifunc.c ivtools-1.2/src/IueServ/roifunc.h ivtools-1.2/src/Makefile ivtools-1.2/src/OS/Imakefile ivtools-1.2/src/OS/Makefile ivtools-1.2/src/OS/directory.c ivtools-1.2/src/OS/file.c ivtools-1.2/src/OS/host.c ivtools-1.2/src/OS/listimpl.c ivtools-1.2/src/OS/math.c ivtools-1.2/src/OS/memory.c ivtools-1.2/src/OS/string.c ivtools-1.2/src/OS/ustring.c ivtools-1.2/src/OverlayUnidraw/Imakefile ivtools-1.2/src/OverlayUnidraw/Makefile ivtools-1.2/src/OverlayUnidraw/aceimport.c ivtools-1.2/src/OverlayUnidraw/aceimport.h ivtools-1.2/src/OverlayUnidraw/algebra3.h ivtools-1.2/src/OverlayUnidraw/annotate.c ivtools-1.2/src/OverlayUnidraw/annotate.h ivtools-1.2/src/OverlayUnidraw/attrtool.c ivtools-1.2/src/OverlayUnidraw/attrtool.h ivtools-1.2/src/OverlayUnidraw/clipline.c ivtools-1.2/src/OverlayUnidraw/clipline.h ivtools-1.2/src/OverlayUnidraw/cliplinepoly.c ivtools-1.2/src/OverlayUnidraw/cliplinepoly.h ivtools-1.2/src/OverlayUnidraw/clippoly.c ivtools-1.2/src/OverlayUnidraw/clippoly.h ivtools-1.2/src/OverlayUnidraw/grayraster.c ivtools-1.2/src/OverlayUnidraw/grayraster.h ivtools-1.2/src/OverlayUnidraw/grloctool.c ivtools-1.2/src/OverlayUnidraw/grloctool.h ivtools-1.2/src/OverlayUnidraw/indexmixins.c ivtools-1.2/src/OverlayUnidraw/indexmixins.h ivtools-1.2/src/OverlayUnidraw/leafwalker.c ivtools-1.2/src/OverlayUnidraw/leafwalker.h ivtools-1.2/src/OverlayUnidraw/ovabout.c ivtools-1.2/src/OverlayUnidraw/ovabout.h ivtools-1.2/src/OverlayUnidraw/ovadjuster.c ivtools-1.2/src/OverlayUnidraw/ovadjuster.h ivtools-1.2/src/OverlayUnidraw/ovarrow.c ivtools-1.2/src/OverlayUnidraw/ovarrow.h ivtools-1.2/src/OverlayUnidraw/ovcamcmds.c ivtools-1.2/src/OverlayUnidraw/ovcamcmds.h ivtools-1.2/src/OverlayUnidraw/ovcatalog.c ivtools-1.2/src/OverlayUnidraw/ovcatalog.h ivtools-1.2/src/OverlayUnidraw/ovchainview.c ivtools-1.2/src/OverlayUnidraw/ovchainview.h ivtools-1.2/src/OverlayUnidraw/ovclasses.h ivtools-1.2/src/OverlayUnidraw/ovclip.c ivtools-1.2/src/OverlayUnidraw/ovclip.h ivtools-1.2/src/OverlayUnidraw/ovcmds.c ivtools-1.2/src/OverlayUnidraw/ovcmds.h ivtools-1.2/src/OverlayUnidraw/ovcomps.c ivtools-1.2/src/OverlayUnidraw/ovcomps.h ivtools-1.2/src/OverlayUnidraw/ovcreator.c ivtools-1.2/src/OverlayUnidraw/ovcreator.h ivtools-1.2/src/OverlayUnidraw/ovctrl.c ivtools-1.2/src/OverlayUnidraw/ovctrl.h ivtools-1.2/src/OverlayUnidraw/ovdamage.c ivtools-1.2/src/OverlayUnidraw/ovdamage.h ivtools-1.2/src/OverlayUnidraw/ovdialog.c ivtools-1.2/src/OverlayUnidraw/ovdialog.h ivtools-1.2/src/OverlayUnidraw/ovdoer.c ivtools-1.2/src/OverlayUnidraw/ovdoer.h ivtools-1.2/src/OverlayUnidraw/oved.c ivtools-1.2/src/OverlayUnidraw/oved.h ivtools-1.2/src/OverlayUnidraw/ovellipse.c ivtools-1.2/src/OverlayUnidraw/ovellipse.h ivtools-1.2/src/OverlayUnidraw/ovexport.c ivtools-1.2/src/OverlayUnidraw/ovexport.h ivtools-1.2/src/OverlayUnidraw/ovfile.c ivtools-1.2/src/OverlayUnidraw/ovfile.h ivtools-1.2/src/OverlayUnidraw/ovfixview.c ivtools-1.2/src/OverlayUnidraw/ovfixview.h ivtools-1.2/src/OverlayUnidraw/ovgdialog.c ivtools-1.2/src/OverlayUnidraw/ovgdialog.h ivtools-1.2/src/OverlayUnidraw/ovhull.c ivtools-1.2/src/OverlayUnidraw/ovhull.h ivtools-1.2/src/OverlayUnidraw/ovimport.c ivtools-1.2/src/OverlayUnidraw/ovimport.h ivtools-1.2/src/OverlayUnidraw/ovipcmds.c ivtools-1.2/src/OverlayUnidraw/ovipcmds.h ivtools-1.2/src/OverlayUnidraw/ovkit.c ivtools-1.2/src/OverlayUnidraw/ovkit.h ivtools-1.2/src/OverlayUnidraw/ovline.c ivtools-1.2/src/OverlayUnidraw/ovline.h ivtools-1.2/src/OverlayUnidraw/ovmanips.c ivtools-1.2/src/OverlayUnidraw/ovmanips.h ivtools-1.2/src/OverlayUnidraw/ovpage.c ivtools-1.2/src/OverlayUnidraw/ovpage.h ivtools-1.2/src/OverlayUnidraw/ovpainter.c ivtools-1.2/src/OverlayUnidraw/ovpainter.h ivtools-1.2/src/OverlayUnidraw/ovpanner.c ivtools-1.2/src/OverlayUnidraw/ovpanner.h ivtools-1.2/src/OverlayUnidraw/ovpolygon.c ivtools-1.2/src/OverlayUnidraw/ovpolygon.h ivtools-1.2/src/OverlayUnidraw/ovprecise.c ivtools-1.2/src/OverlayUnidraw/ovprecise.h ivtools-1.2/src/OverlayUnidraw/ovprint.c ivtools-1.2/src/OverlayUnidraw/ovprint.h ivtools-1.2/src/OverlayUnidraw/ovpspict.c ivtools-1.2/src/OverlayUnidraw/ovpspict.h ivtools-1.2/src/OverlayUnidraw/ovpsview.c ivtools-1.2/src/OverlayUnidraw/ovpsview.h ivtools-1.2/src/OverlayUnidraw/ovraster.c ivtools-1.2/src/OverlayUnidraw/ovraster.h ivtools-1.2/src/OverlayUnidraw/ovrect.c ivtools-1.2/src/OverlayUnidraw/ovrect.h ivtools-1.2/src/OverlayUnidraw/ovrestimage.c ivtools-1.2/src/OverlayUnidraw/ovrestimage.h ivtools-1.2/src/OverlayUnidraw/ovselect.c ivtools-1.2/src/OverlayUnidraw/ovselect.h ivtools-1.2/src/OverlayUnidraw/ovselection.c ivtools-1.2/src/OverlayUnidraw/ovselection.h ivtools-1.2/src/OverlayUnidraw/ovshowhide.c ivtools-1.2/src/OverlayUnidraw/ovshowhide.h ivtools-1.2/src/OverlayUnidraw/ovspline.c ivtools-1.2/src/OverlayUnidraw/ovspline.h ivtools-1.2/src/OverlayUnidraw/ovstates.c ivtools-1.2/src/OverlayUnidraw/ovstates.h ivtools-1.2/src/OverlayUnidraw/ovstencil.c ivtools-1.2/src/OverlayUnidraw/ovstencil.h ivtools-1.2/src/OverlayUnidraw/ovtext.c ivtools-1.2/src/OverlayUnidraw/ovtext.h ivtools-1.2/src/OverlayUnidraw/ovunidraw.c ivtools-1.2/src/OverlayUnidraw/ovunidraw.h ivtools-1.2/src/OverlayUnidraw/ovvars.c ivtools-1.2/src/OverlayUnidraw/ovvars.h ivtools-1.2/src/OverlayUnidraw/ovvertices.c ivtools-1.2/src/OverlayUnidraw/ovvertices.h ivtools-1.2/src/OverlayUnidraw/ovviewer.c ivtools-1.2/src/OverlayUnidraw/ovviewer.h ivtools-1.2/src/OverlayUnidraw/ovviews.c ivtools-1.2/src/OverlayUnidraw/ovviews.h ivtools-1.2/src/OverlayUnidraw/paramlist.h ivtools-1.2/src/OverlayUnidraw/phold.h ivtools-1.2/src/OverlayUnidraw/ptinpoly.c ivtools-1.2/src/OverlayUnidraw/ptinpoly.h ivtools-1.2/src/OverlayUnidraw/rastercmds.c ivtools-1.2/src/OverlayUnidraw/rastercmds.h ivtools-1.2/src/OverlayUnidraw/scriptview.c ivtools-1.2/src/OverlayUnidraw/scriptview.h ivtools-1.2/src/OverlayUnidraw/setattrbyexpr.c ivtools-1.2/src/OverlayUnidraw/setattrbyexpr.h ivtools-1.2/src/OverlayUnidraw/slctbyattr.c ivtools-1.2/src/OverlayUnidraw/slctbyattr.h ivtools-1.2/src/OverlayUnidraw/textfile.c ivtools-1.2/src/OverlayUnidraw/textfile.h ivtools-1.2/src/TIFF/Copyright ivtools-1.2/src/TIFF/HOWTO ivtools-1.2/src/TIFF/Imakefile ivtools-1.2/src/TIFF/Makefile ivtools-1.2/src/TIFF/README ivtools-1.2/src/TIFF/VERSION ivtools-1.2/src/TIFF/machdep.h ivtools-1.2/src/TIFF/mkg3states.c ivtools-1.2/src/TIFF/mkspans.c ivtools-1.2/src/TIFF/prototypes.h ivtools-1.2/src/TIFF/t4.h ivtools-1.2/src/TIFF/tif_aux.c ivtools-1.2/src/TIFF/tif_ccittrle.c ivtools-1.2/src/TIFF/tif_close.c ivtools-1.2/src/TIFF/tif_compat.c ivtools-1.2/src/TIFF/tif_compress.c ivtools-1.2/src/TIFF/tif_dir.c ivtools-1.2/src/TIFF/tif_dirinfo.c ivtools-1.2/src/TIFF/tif_dirread.c ivtools-1.2/src/TIFF/tif_dirwrite.c ivtools-1.2/src/TIFF/tif_dumpmode.c ivtools-1.2/src/TIFF/tif_error.c ivtools-1.2/src/TIFF/tif_fax3.c ivtools-1.2/src/TIFF/tif_fax3.h ivtools-1.2/src/TIFF/tif_fax4.c ivtools-1.2/src/TIFF/tif_flush.c ivtools-1.2/src/TIFF/tif_getimage.c ivtools-1.2/src/TIFF/tif_jpeg.c ivtools-1.2/src/TIFF/tif_lzw.c ivtools-1.2/src/TIFF/tif_machdep.c ivtools-1.2/src/TIFF/tif_next.c ivtools-1.2/src/TIFF/tif_open.c ivtools-1.2/src/TIFF/tif_packbits.c ivtools-1.2/src/TIFF/tif_print.c ivtools-1.2/src/TIFF/tif_read.c ivtools-1.2/src/TIFF/tif_strip.c ivtools-1.2/src/TIFF/tif_swab.c ivtools-1.2/src/TIFF/tif_thunder.c ivtools-1.2/src/TIFF/tif_tile.c ivtools-1.2/src/TIFF/tif_version.c ivtools-1.2/src/TIFF/tif_warning.c ivtools-1.2/src/TIFF/tif_write.c ivtools-1.2/src/TIFF/tiffcompat.h ivtools-1.2/src/TIFF/tiffioP.h ivtools-1.2/src/Time/Date.c ivtools-1.2/src/Time/Date.h ivtools-1.2/src/Time/Imakefile ivtools-1.2/src/Time/Makefile ivtools-1.2/src/Time/Time.c ivtools-1.2/src/Time/Time_.h ivtools-1.2/src/Time/obstime.c ivtools-1.2/src/Time/obstime.h ivtools-1.2/src/Time/timeglyph.c ivtools-1.2/src/Time/timeglyph.h ivtools-1.2/src/TopoFace/Imakefile ivtools-1.2/src/TopoFace/Makefile ivtools-1.2/src/TopoFace/fgeomobjs.c ivtools-1.2/src/TopoFace/fgeomobjs.h ivtools-1.2/src/TopoFace/topoedge.c ivtools-1.2/src/TopoFace/topoedge.h ivtools-1.2/src/TopoFace/topoedgelist.c ivtools-1.2/src/TopoFace/topoedgelist.h ivtools-1.2/src/TopoFace/topoelt.c ivtools-1.2/src/TopoFace/topoelt.h ivtools-1.2/src/TopoFace/topoface.c ivtools-1.2/src/TopoFace/topoface.h ivtools-1.2/src/TopoFace/toponode.c ivtools-1.2/src/TopoFace/toponode.h ivtools-1.2/src/UniIdraw/Imakefile ivtools-1.2/src/UniIdraw/Makefile ivtools-1.2/src/UniIdraw/idarrow.c ivtools-1.2/src/UniIdraw/idarrow.h ivtools-1.2/src/UniIdraw/idarrowhead.c ivtools-1.2/src/UniIdraw/idarrowhead.h ivtools-1.2/src/UniIdraw/idarrows.c ivtools-1.2/src/UniIdraw/idarrows.h ivtools-1.2/src/UniIdraw/idcatalog.c ivtools-1.2/src/UniIdraw/idcatalog.h ivtools-1.2/src/UniIdraw/idclasses.h ivtools-1.2/src/UniIdraw/idcmds.c ivtools-1.2/src/UniIdraw/idcmds.h ivtools-1.2/src/UniIdraw/idcomp.c ivtools-1.2/src/UniIdraw/idcomp.h ivtools-1.2/src/UniIdraw/idcreator.c ivtools-1.2/src/UniIdraw/idcreator.h ivtools-1.2/src/UniIdraw/iddialogs.c ivtools-1.2/src/UniIdraw/iddialogs.h ivtools-1.2/src/UniIdraw/ided.c ivtools-1.2/src/UniIdraw/ided.h ivtools-1.2/src/UniIdraw/idkybd.c ivtools-1.2/src/UniIdraw/idkybd.h ivtools-1.2/src/UniIdraw/idvars.c ivtools-1.2/src/UniIdraw/idvars.h ivtools-1.2/src/UniIdraw/idversion.h ivtools-1.2/src/Unidraw-common/Imakefile ivtools-1.2/src/Unidraw-common/Makefile ivtools-1.2/src/Unidraw-common/component.c ivtools-1.2/src/Unidraw-common/compview.c ivtools-1.2/src/Unidraw-common/geomobjs.c ivtools-1.2/src/Unidraw-common/iterator.c ivtools-1.2/src/Unidraw-common/uarray.c ivtools-1.2/src/Unidraw-common/uhash.c ivtools-1.2/src/Unidraw-common/ulist.c ivtools-1.2/src/Unidraw-common/umap.c ivtools-1.2/src/Unidraw/Imakefile ivtools-1.2/src/Unidraw/Makefile ivtools-1.2/src/Unidraw/align.c ivtools-1.2/src/Unidraw/brushcmd.c ivtools-1.2/src/Unidraw/catalog.c ivtools-1.2/src/Unidraw/catcmds.c ivtools-1.2/src/Unidraw/cglue.c ivtools-1.2/src/Unidraw/clipboard.c ivtools-1.2/src/Unidraw/colorcmd.c ivtools-1.2/src/Unidraw/command.c ivtools-1.2/src/Unidraw/component.c ivtools-1.2/src/Unidraw/compview.c ivtools-1.2/src/Unidraw/connect.c ivtools-1.2/src/Unidraw/connector.c ivtools-1.2/src/Unidraw/creator.c ivtools-1.2/src/Unidraw/csolver.c ivtools-1.2/src/Unidraw/ctrlinfo.c ivtools-1.2/src/Unidraw/damage.c ivtools-1.2/src/Unidraw/data.c ivtools-1.2/src/Unidraw/datas.c ivtools-1.2/src/Unidraw/dialogs.c ivtools-1.2/src/Unidraw/edit.c ivtools-1.2/src/Unidraw/editor.c ivtools-1.2/src/Unidraw/editorinfo.c ivtools-1.2/src/Unidraw/ellipse.c ivtools-1.2/src/Unidraw/ellipses.c ivtools-1.2/src/Unidraw/externview.c ivtools-1.2/src/Unidraw/font.c ivtools-1.2/src/Unidraw/geomobjs.c ivtools-1.2/src/Unidraw/globals.c ivtools-1.2/src/Unidraw/graphic.c ivtools-1.2/src/Unidraw/grblock.c ivtools-1.2/src/Unidraw/grcomp.c ivtools-1.2/src/Unidraw/grcomptool.c ivtools-1.2/src/Unidraw/grid.c ivtools-1.2/src/Unidraw/grview.c ivtools-1.2/src/Unidraw/gvupdater.c ivtools-1.2/src/Unidraw/import.c ivtools-1.2/src/Unidraw/iterator.c ivtools-1.2/src/Unidraw/keymap.c ivtools-1.2/src/Unidraw/kybd.c ivtools-1.2/src/Unidraw/line.c ivtools-1.2/src/Unidraw/lines.c ivtools-1.2/src/Unidraw/link.c ivtools-1.2/src/Unidraw/macro.c ivtools-1.2/src/Unidraw/magnify.c ivtools-1.2/src/Unidraw/manip.c ivtools-1.2/src/Unidraw/manips.c ivtools-1.2/src/Unidraw/move.c ivtools-1.2/src/Unidraw/nop.c ivtools-1.2/src/Unidraw/pad.c ivtools-1.2/src/Unidraw/patcmd.c ivtools-1.2/src/Unidraw/path.c ivtools-1.2/src/Unidraw/picture.c ivtools-1.2/src/Unidraw/pin.c ivtools-1.2/src/Unidraw/polygon.c ivtools-1.2/src/Unidraw/polygons.c ivtools-1.2/src/Unidraw/pspaint.c ivtools-1.2/src/Unidraw/psview.c ivtools-1.2/src/Unidraw/rastercomp.c ivtools-1.2/src/Unidraw/rasterrect.c ivtools-1.2/src/Unidraw/rect.c ivtools-1.2/src/Unidraw/reshape.c ivtools-1.2/src/Unidraw/rotate.c ivtools-1.2/src/Unidraw/scale.c ivtools-1.2/src/Unidraw/select.c ivtools-1.2/src/Unidraw/selection.c ivtools-1.2/src/Unidraw/slot.c ivtools-1.2/src/Unidraw/spline.c ivtools-1.2/src/Unidraw/splines.c ivtools-1.2/src/Unidraw/statevar.c ivtools-1.2/src/Unidraw/statevars.c ivtools-1.2/src/Unidraw/stateview.c ivtools-1.2/src/Unidraw/stateviews.c ivtools-1.2/src/Unidraw/stencilcomp.c ivtools-1.2/src/Unidraw/stretch.c ivtools-1.2/src/Unidraw/struct.c ivtools-1.2/src/Unidraw/text.c ivtools-1.2/src/Unidraw/tool.c ivtools-1.2/src/Unidraw/transfn.c ivtools-1.2/src/Unidraw/transfns.c ivtools-1.2/src/Unidraw/transforms.c ivtools-1.2/src/Unidraw/uarray.c ivtools-1.2/src/Unidraw/uctrl.c ivtools-1.2/src/Unidraw/uctrls.c ivtools-1.2/src/Unidraw/uhash.c ivtools-1.2/src/Unidraw/ulabel.c ivtools-1.2/src/Unidraw/ulist.c ivtools-1.2/src/Unidraw/umap.c ivtools-1.2/src/Unidraw/unidraw.c ivtools-1.2/src/Unidraw/upage.c ivtools-1.2/src/Unidraw/ustencil.c ivtools-1.2/src/Unidraw/vertices.c ivtools-1.2/src/Unidraw/verts.c ivtools-1.2/src/Unidraw/viewcmds.c ivtools-1.2/src/Unidraw/viewer.c ivtools-1.2/src/comdraw/Imakefile ivtools-1.2/src/comdraw/Makefile ivtools-1.2/src/comdraw/README ivtools-1.2/src/comdraw/main.c ivtools-1.2/src/comterp_/Imakefile ivtools-1.2/src/comterp_/Makefile ivtools-1.2/src/comterp_/README ivtools-1.2/src/comterp_/main.c ivtools-1.2/src/comtest/Imakefile ivtools-1.2/src/comtest/Makefile ivtools-1.2/src/comtest/main.c ivtools-1.2/src/dclock/Imakefile ivtools-1.2/src/dclock/Makefile ivtools-1.2/src/dclock/clocktime.c ivtools-1.2/src/dclock/clocktime.h ivtools-1.2/src/dclock/data.c ivtools-1.2/src/dclock/data.h ivtools-1.2/src/dclock/dclock.c ivtools-1.2/src/dclock/dclock.h ivtools-1.2/src/dclock/dface.c ivtools-1.2/src/dclock/dface.h ivtools-1.2/src/dclock/digit.c ivtools-1.2/src/dclock/digit.h ivtools-1.2/src/dclock/segment.c ivtools-1.2/src/dclock/segment.h ivtools-1.2/src/drawserv_/Imakefile ivtools-1.2/src/drawserv_/Makefile ivtools-1.2/src/drawserv_/main.c ivtools-1.2/src/drawtool/Imakefile ivtools-1.2/src/drawtool/Makefile ivtools-1.2/src/drawtool/README ivtools-1.2/src/drawtool/main.c ivtools-1.2/src/flipbook/Imakefile ivtools-1.2/src/flipbook/Makefile ivtools-1.2/src/flipbook/README ivtools-1.2/src/flipbook/main.c ivtools-1.2/src/glyphs/Imakefile ivtools-1.2/src/glyphs/Makefile ivtools-1.2/src/glyphs/README ivtools-1.2/src/glyphs/bdvtable/Imakefile ivtools-1.2/src/glyphs/bdvtable/Makefile ivtools-1.2/src/glyphs/bdvtable/main.c ivtools-1.2/src/glyphs/examples3.1/Imakefile ivtools-1.2/src/glyphs/examples3.1/Makefile ivtools-1.2/src/glyphs/examples3.1/README ivtools-1.2/src/glyphs/examples3.1/box1/Imakefile ivtools-1.2/src/glyphs/examples3.1/box1/Makefile ivtools-1.2/src/glyphs/examples3.1/box1/main.c ivtools-1.2/src/glyphs/examples3.1/box2/Imakefile ivtools-1.2/src/glyphs/examples3.1/box2/Makefile ivtools-1.2/src/glyphs/examples3.1/box2/main.c ivtools-1.2/src/glyphs/examples3.1/box3/Imakefile ivtools-1.2/src/glyphs/examples3.1/box3/Makefile ivtools-1.2/src/glyphs/examples3.1/box3/main.c ivtools-1.2/src/glyphs/examples3.1/box4/Imakefile ivtools-1.2/src/glyphs/examples3.1/box4/Makefile ivtools-1.2/src/glyphs/examples3.1/box4/main.c ivtools-1.2/src/glyphs/examples3.1/box5/Imakefile ivtools-1.2/src/glyphs/examples3.1/box5/Makefile ivtools-1.2/src/glyphs/examples3.1/box5/main.c ivtools-1.2/src/glyphs/examples3.1/button1/Imakefile ivtools-1.2/src/glyphs/examples3.1/button1/Makefile ivtools-1.2/src/glyphs/examples3.1/button1/main.c ivtools-1.2/src/glyphs/examples3.1/button2/Imakefile ivtools-1.2/src/glyphs/examples3.1/button2/Makefile ivtools-1.2/src/glyphs/examples3.1/button2/jello.tif ivtools-1.2/src/glyphs/examples3.1/button2/main.c ivtools-1.2/src/glyphs/examples3.1/button3/Imakefile ivtools-1.2/src/glyphs/examples3.1/button3/Makefile ivtools-1.2/src/glyphs/examples3.1/button3/main.c ivtools-1.2/src/glyphs/examples3.1/bvalue/Imakefile ivtools-1.2/src/glyphs/examples3.1/bvalue/Makefile ivtools-1.2/src/glyphs/examples3.1/bvalue/main.c ivtools-1.2/src/glyphs/examples3.1/circle/Imakefile ivtools-1.2/src/glyphs/examples3.1/circle/Makefile ivtools-1.2/src/glyphs/examples3.1/circle/main.c ivtools-1.2/src/glyphs/examples3.1/drag/Imakefile ivtools-1.2/src/glyphs/examples3.1/drag/Makefile ivtools-1.2/src/glyphs/examples3.1/drag/main.c ivtools-1.2/src/glyphs/examples3.1/fonts/Imakefile ivtools-1.2/src/glyphs/examples3.1/fonts/Makefile ivtools-1.2/src/glyphs/examples3.1/fonts/main.c ivtools-1.2/src/glyphs/examples3.1/himom/Imakefile ivtools-1.2/src/glyphs/examples3.1/himom/Makefile ivtools-1.2/src/glyphs/examples3.1/himom/main.c ivtools-1.2/src/glyphs/examples3.1/image/Imakefile ivtools-1.2/src/glyphs/examples3.1/image/Makefile ivtools-1.2/src/glyphs/examples3.1/image/main.c ivtools-1.2/src/glyphs/examples3.1/ips/Imakefile ivtools-1.2/src/glyphs/examples3.1/ips/Makefile ivtools-1.2/src/glyphs/examples3.1/ips/figure.c ivtools-1.2/src/glyphs/examples3.1/ips/figure.h ivtools-1.2/src/glyphs/examples3.1/ips/idraw.c ivtools-1.2/src/glyphs/examples3.1/ips/idraw.h ivtools-1.2/src/glyphs/examples3.1/ips/main.c ivtools-1.2/src/glyphs/examples3.1/menu/Imakefile ivtools-1.2/src/glyphs/examples3.1/menu/Makefile ivtools-1.2/src/glyphs/examples3.1/menu/main.c ivtools-1.2/src/glyphs/examples3.1/patch/Imakefile ivtools-1.2/src/glyphs/examples3.1/patch/Makefile ivtools-1.2/src/glyphs/examples3.1/patch/main.c ivtools-1.2/src/glyphs/examples3.1/plot/Axis.c ivtools-1.2/src/glyphs/examples3.1/plot/Axis.h ivtools-1.2/src/glyphs/examples3.1/plot/Graph.c ivtools-1.2/src/glyphs/examples3.1/plot/Graph.h ivtools-1.2/src/glyphs/examples3.1/plot/Imakefile ivtools-1.2/src/glyphs/examples3.1/plot/Makefile ivtools-1.2/src/glyphs/examples3.1/plot/Plot.c ivtools-1.2/src/glyphs/examples3.1/plot/Plot.h ivtools-1.2/src/glyphs/examples3.1/plot/README ivtools-1.2/src/glyphs/examples3.1/plot/main.c ivtools-1.2/src/glyphs/examples3.1/plot/rpc_read.c ivtools-1.2/src/glyphs/examples3.1/plot/rpc_read.h ivtools-1.2/src/glyphs/examples3.1/preview/Imakefile ivtools-1.2/src/glyphs/examples3.1/preview/Makefile ivtools-1.2/src/glyphs/examples3.1/preview/input ivtools-1.2/src/glyphs/examples3.1/preview/main.c ivtools-1.2/src/glyphs/examples3.1/print/Imakefile ivtools-1.2/src/glyphs/examples3.1/print/Makefile ivtools-1.2/src/glyphs/examples3.1/print/main.c ivtools-1.2/src/glyphs/examples3.1/rubband/Imakefile ivtools-1.2/src/glyphs/examples3.1/rubband/Makefile ivtools-1.2/src/glyphs/examples3.1/rubband/main.c ivtools-1.2/src/glyphs/examples3.1/sendplot/Imakefile ivtools-1.2/src/glyphs/examples3.1/sendplot/Makefile ivtools-1.2/src/glyphs/examples3.1/sendplot/main.c ivtools-1.2/src/glyphs/examples3.1/sendplot/rpc_write.c ivtools-1.2/src/glyphs/examples3.1/sendplot/rpc_write.h ivtools-1.2/src/glyphs/examples3.1/zoomer/Imakefile ivtools-1.2/src/glyphs/examples3.1/zoomer/Makefile ivtools-1.2/src/glyphs/examples3.1/zoomer/main.c ivtools-1.2/src/glyphs/formdemo/Imakefile ivtools-1.2/src/glyphs/formdemo/Makefile ivtools-1.2/src/glyphs/formdemo/main.c ivtools-1.2/src/glyphs/gclock/Imakefile ivtools-1.2/src/glyphs/gclock/Makefile ivtools-1.2/src/glyphs/gclock/main.c ivtools-1.2/src/glyphs/meter/Imakefile ivtools-1.2/src/glyphs/meter/Makefile ivtools-1.2/src/glyphs/meter/main.c ivtools-1.2/src/glyphs/morpher/Imakefile ivtools-1.2/src/glyphs/morpher/Makefile ivtools-1.2/src/glyphs/morpher/README ivtools-1.2/src/glyphs/morpher/balls ivtools-1.2/src/glyphs/morpher/glypheditor.c ivtools-1.2/src/glyphs/morpher/glypheditor.h ivtools-1.2/src/glyphs/morpher/glyphviewer.c ivtools-1.2/src/glyphs/morpher/glyphviewer.h ivtools-1.2/src/glyphs/morpher/icons/cont_play ivtools-1.2/src/glyphs/morpher/icons/fast_forward ivtools-1.2/src/glyphs/morpher/icons/fast_reverse ivtools-1.2/src/glyphs/morpher/icons/forward_pause ivtools-1.2/src/glyphs/morpher/icons/forward_play ivtools-1.2/src/glyphs/morpher/icons/new-record ivtools-1.2/src/glyphs/morpher/icons/panel ivtools-1.2/src/glyphs/morpher/icons/pause ivtools-1.2/src/glyphs/morpher/icons/record ivtools-1.2/src/glyphs/morpher/icons/reverse_pause ivtools-1.2/src/glyphs/morpher/icons/reverse_play ivtools-1.2/src/glyphs/morpher/main.c ivtools-1.2/src/glyphs/morpher/man.0 ivtools-1.2/src/glyphs/morpher/man.1 ivtools-1.2/src/glyphs/morpher/morpher.c ivtools-1.2/src/glyphs/morpher/morpher.h ivtools-1.2/src/glyphs/morpher/rect ivtools-1.2/src/glyphs/radiogroup/Imakefile ivtools-1.2/src/glyphs/radiogroup/Makefile ivtools-1.2/src/glyphs/radiogroup/main.c ivtools-1.2/src/glyphs/scrollable/Imakefile ivtools-1.2/src/glyphs/scrollable/Makefile ivtools-1.2/src/glyphs/scrollable/main.c ivtools-1.2/src/glyphs/scrollfield/Imakefile ivtools-1.2/src/glyphs/scrollfield/Makefile ivtools-1.2/src/glyphs/scrollfield/main.c ivtools-1.2/src/glyphs/strchooser/Imakefile ivtools-1.2/src/glyphs/strchooser/Makefile ivtools-1.2/src/glyphs/strchooser/main.c ivtools-1.2/src/glyphs/timestamp/Imakefile ivtools-1.2/src/glyphs/timestamp/Makefile ivtools-1.2/src/glyphs/timestamp/main.c ivtools-1.2/src/glyphterp/Imakefile ivtools-1.2/src/glyphterp/Makefile ivtools-1.2/src/glyphterp/main.c ivtools-1.2/src/graphdraw/Imakefile ivtools-1.2/src/graphdraw/Makefile ivtools-1.2/src/graphdraw/README ivtools-1.2/src/graphdraw/main.c ivtools-1.2/src/html/Imakefile ivtools-1.2/src/html/Makefile ivtools-1.2/src/html/README ivtools-1.2/src/html/getman31.sh ivtools-1.2/src/html/getrefman31.sh ivtools-1.2/src/html/perceps.pl ivtools-1.2/src/html/templates/CLASS.html.tmpl ivtools-1.2/src/html/templates/Imakefile ivtools-1.2/src/html/templates/Makefile ivtools-1.2/src/html/templates/bug_m.flt ivtools-1.2/src/html/templates/dr_m.flt ivtools-1.2/src/html/templates/err_m.flt ivtools-1.2/src/html/templates/in_m.flt ivtools-1.2/src/html/templates/includeflt.flt ivtools-1.2/src/html/templates/index.html.tmpl ivtools-1.2/src/html/templates/linkflt.flt ivtools-1.2/src/html/templates/other.html.tmpl ivtools-1.2/src/html/templates/out_m.flt ivtools-1.2/src/html/templates/ret_m.flt ivtools-1.2/src/html/templates/smindex.html.tmpl ivtools-1.2/src/html/templates/time.flt ivtools-1.2/src/iclass/Imakefile ivtools-1.2/src/iclass/Makefile ivtools-1.2/src/iclass/classbuffer.c ivtools-1.2/src/iclass/classbuffer.h ivtools-1.2/src/iclass/classeditor.c ivtools-1.2/src/iclass/classeditor.h ivtools-1.2/src/iclass/classinfo.c ivtools-1.2/src/iclass/classinfo.h ivtools-1.2/src/iclass/dialogs.c ivtools-1.2/src/iclass/dialogs.h ivtools-1.2/src/iclass/direct.c ivtools-1.2/src/iclass/direct.h ivtools-1.2/src/iclass/globals.c ivtools-1.2/src/iclass/globals.h ivtools-1.2/src/iclass/iclass.c ivtools-1.2/src/iclass/iclass.h ivtools-1.2/src/iclass/main.c ivtools-1.2/src/idemo/Idemo.defaults ivtools-1.2/src/idemo/Imakefile ivtools-1.2/src/idemo/Makefile ivtools-1.2/src/idemo/main.c ivtools-1.2/src/idraw/Imakefile ivtools-1.2/src/idraw/Makefile ivtools-1.2/src/idraw/README ivtools-1.2/src/idraw/main.c ivtools-1.2/src/include/Dispatch/Imakefile ivtools-1.2/src/include/Dispatch/Makefile ivtools-1.2/src/include/Dispatch/_defines.h ivtools-1.2/src/include/Dispatch/_undefs.h ivtools-1.2/src/include/Dispatch/dispatcher.h ivtools-1.2/src/include/Dispatch/dp.h ivtools-1.2/src/include/Dispatch/enter-scope.h ivtools-1.2/src/include/Dispatch/iocallback.h ivtools-1.2/src/include/Dispatch/iohandler.h ivtools-1.2/src/include/Dispatch/iostreamb.h ivtools-1.2/src/include/Dispatch/leave-scope.h ivtools-1.2/src/include/Dispatch/rpcbuf.h ivtools-1.2/src/include/Dispatch/rpchdr.h ivtools-1.2/src/include/Dispatch/rpcpeer.h ivtools-1.2/src/include/Dispatch/rpcreader.h ivtools-1.2/src/include/Dispatch/rpcregistry.h ivtools-1.2/src/include/Dispatch/rpcservice.h ivtools-1.2/src/include/Dispatch/rpcstream.h ivtools-1.2/src/include/Dispatch/rpcwriter.h ivtools-1.2/src/include/IV-2_6/Imakefile ivtools-1.2/src/include/IV-2_6/InterViews/Imakefile ivtools-1.2/src/include/IV-2_6/InterViews/Makefile ivtools-1.2/src/include/IV-2_6/InterViews/adjuster.h ivtools-1.2/src/include/IV-2_6/InterViews/alignment.h ivtools-1.2/src/include/IV-2_6/InterViews/banner.h ivtools-1.2/src/include/IV-2_6/InterViews/border.h ivtools-1.2/src/include/IV-2_6/InterViews/box.h ivtools-1.2/src/include/IV-2_6/InterViews/button.h ivtools-1.2/src/include/IV-2_6/InterViews/compeditor.h ivtools-1.2/src/include/IV-2_6/InterViews/control.h ivtools-1.2/src/include/IV-2_6/InterViews/deck.h ivtools-1.2/src/include/IV-2_6/InterViews/defs.h ivtools-1.2/src/include/IV-2_6/InterViews/dialog.h ivtools-1.2/src/include/IV-2_6/InterViews/filebrowser.h ivtools-1.2/src/include/IV-2_6/InterViews/filechooser.h ivtools-1.2/src/include/IV-2_6/InterViews/frame.h ivtools-1.2/src/include/IV-2_6/InterViews/glue.h ivtools-1.2/src/include/IV-2_6/InterViews/ihandler.h ivtools-1.2/src/include/IV-2_6/InterViews/interactor.h ivtools-1.2/src/include/IV-2_6/InterViews/iwindow.h ivtools-1.2/src/include/IV-2_6/InterViews/matcheditor.h ivtools-1.2/src/include/IV-2_6/InterViews/menu.h ivtools-1.2/src/include/IV-2_6/InterViews/message.h ivtools-1.2/src/include/IV-2_6/InterViews/minmax.h ivtools-1.2/src/include/IV-2_6/InterViews/paint.h ivtools-1.2/src/include/IV-2_6/InterViews/painter.h ivtools-1.2/src/include/IV-2_6/InterViews/panner.h ivtools-1.2/src/include/IV-2_6/InterViews/perspective.h ivtools-1.2/src/include/IV-2_6/InterViews/rubband.h ivtools-1.2/src/include/IV-2_6/InterViews/rubcurve.h ivtools-1.2/src/include/IV-2_6/InterViews/rubgroup.h ivtools-1.2/src/include/IV-2_6/InterViews/rubline.h ivtools-1.2/src/include/IV-2_6/InterViews/rubrect.h ivtools-1.2/src/include/IV-2_6/InterViews/rubverts.h ivtools-1.2/src/include/IV-2_6/InterViews/scene.h ivtools-1.2/src/include/IV-2_6/InterViews/scrollbar.h ivtools-1.2/src/include/IV-2_6/InterViews/scroller.h ivtools-1.2/src/include/IV-2_6/InterViews/sensor.h ivtools-1.2/src/include/IV-2_6/InterViews/shape.h ivtools-1.2/src/include/IV-2_6/InterViews/strbrowser.h ivtools-1.2/src/include/IV-2_6/InterViews/strchooser.h ivtools-1.2/src/include/IV-2_6/InterViews/streditor.h ivtools-1.2/src/include/IV-2_6/InterViews/subject.h ivtools-1.2/src/include/IV-2_6/InterViews/textbuffer.h ivtools-1.2/src/include/IV-2_6/InterViews/textdisplay.h ivtools-1.2/src/include/IV-2_6/InterViews/texteditor.h ivtools-1.2/src/include/IV-2_6/InterViews/textstyle.h ivtools-1.2/src/include/IV-2_6/InterViews/tray.h ivtools-1.2/src/include/IV-2_6/InterViews/viewport.h ivtools-1.2/src/include/IV-2_6/InterViews/world.h ivtools-1.2/src/include/IV-2_6/Makefile ivtools-1.2/src/include/IV-2_6/_enter.h ivtools-1.2/src/include/IV-2_6/_leave.h ivtools-1.2/src/include/IV-2_6/_names.h ivtools-1.2/src/include/IV-3_1/Imakefile ivtools-1.2/src/include/IV-3_1/InterViews ivtools-1.2/src/include/IV-X11/Imakefile ivtools-1.2/src/include/IV-X11/Makefile ivtools-1.2/src/include/IV-X11/Xdefs.h ivtools-1.2/src/include/IV-X11/Xext.h ivtools-1.2/src/include/IV-X11/Xlib.h ivtools-1.2/src/include/IV-X11/Xundefs.h ivtools-1.2/src/include/IV-X11/Xutil.h ivtools-1.2/src/include/IV-X11/xbitmap.h ivtools-1.2/src/include/IV-X11/xbrush.h ivtools-1.2/src/include/IV-X11/xcanvas.h ivtools-1.2/src/include/IV-X11/xcolor.h ivtools-1.2/src/include/IV-X11/xcursor.h ivtools-1.2/src/include/IV-X11/xdisplay.h ivtools-1.2/src/include/IV-X11/xdrag.h ivtools-1.2/src/include/IV-X11/xevent.h ivtools-1.2/src/include/IV-X11/xfont.h ivtools-1.2/src/include/IV-X11/xpainter.h ivtools-1.2/src/include/IV-X11/xpattern.h ivtools-1.2/src/include/IV-X11/xraster.h ivtools-1.2/src/include/IV-X11/xselection.h ivtools-1.2/src/include/IV-X11/xwindow.h ivtools-1.2/src/include/IV-look/Imakefile ivtools-1.2/src/include/IV-look/Makefile ivtools-1.2/src/include/IV-look/bevel.h ivtools-1.2/src/include/IV-look/browser.h ivtools-1.2/src/include/IV-look/button.h ivtools-1.2/src/include/IV-look/choice.h ivtools-1.2/src/include/IV-look/dialogs.h ivtools-1.2/src/include/IV-look/fbrowser.h ivtools-1.2/src/include/IV-look/fchooser.h ivtools-1.2/src/include/IV-look/field.h ivtools-1.2/src/include/IV-look/kit.h ivtools-1.2/src/include/IV-look/menu.h ivtools-1.2/src/include/IV-look/mf_dialogs.h ivtools-1.2/src/include/IV-look/mf_kit.h ivtools-1.2/src/include/IV-look/mono_kit.h ivtools-1.2/src/include/IV-look/ol_dialogs.h ivtools-1.2/src/include/IV-look/ol_kit.h ivtools-1.2/src/include/IV-look/slider.h ivtools-1.2/src/include/IV-look/smf_kit.h ivtools-1.2/src/include/IV-look/stepper.h ivtools-1.2/src/include/IV-look/telltale.h ivtools-1.2/src/include/Imakefile ivtools-1.2/src/include/InterViews/Bitmaps/Imakefile ivtools-1.2/src/include/InterViews/Bitmaps/Makefile ivtools-1.2/src/include/InterViews/Bitmaps/big_checkmark.bm ivtools-1.2/src/include/InterViews/Bitmaps/checkmark.bm ivtools-1.2/src/include/InterViews/Bitmaps/chkbox.bm ivtools-1.2/src/include/InterViews/Bitmaps/chkboxBoth.bm ivtools-1.2/src/include/InterViews/Bitmaps/chkboxChosen.bm ivtools-1.2/src/include/InterViews/Bitmaps/chkboxHit.bm ivtools-1.2/src/include/InterViews/Bitmaps/dfast.bm ivtools-1.2/src/include/InterViews/Bitmaps/dfastMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/dmover.bm ivtools-1.2/src/include/InterViews/Bitmaps/dmoverHit.bm ivtools-1.2/src/include/InterViews/Bitmaps/dmoverMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/enlarge.bm ivtools-1.2/src/include/InterViews/Bitmaps/enlargeHit.bm ivtools-1.2/src/include/InterViews/Bitmaps/enlargeMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/hand.bm ivtools-1.2/src/include/InterViews/Bitmaps/handMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/ldfast.bm ivtools-1.2/src/include/InterViews/Bitmaps/ldfastMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/lfast.bm ivtools-1.2/src/include/InterViews/Bitmaps/lfastMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/lmover.bm ivtools-1.2/src/include/InterViews/Bitmaps/lmoverHit.bm ivtools-1.2/src/include/InterViews/Bitmaps/lmoverMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/lufast.bm ivtools-1.2/src/include/InterViews/Bitmaps/lufastMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/page.bm ivtools-1.2/src/include/InterViews/Bitmaps/pageBoth.bm ivtools-1.2/src/include/InterViews/Bitmaps/pageChosen.bm ivtools-1.2/src/include/InterViews/Bitmaps/pageHit.bm ivtools-1.2/src/include/InterViews/Bitmaps/radio.bm ivtools-1.2/src/include/InterViews/Bitmaps/radioBoth.bm ivtools-1.2/src/include/InterViews/Bitmaps/radioChosen.bm ivtools-1.2/src/include/InterViews/Bitmaps/radioHit.bm ivtools-1.2/src/include/InterViews/Bitmaps/radioMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/rdfast.bm ivtools-1.2/src/include/InterViews/Bitmaps/rdfastMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/reducer.bm ivtools-1.2/src/include/InterViews/Bitmaps/reducerHit.bm ivtools-1.2/src/include/InterViews/Bitmaps/reducerMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/rfast.bm ivtools-1.2/src/include/InterViews/Bitmaps/rfastMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/rmover.bm ivtools-1.2/src/include/InterViews/Bitmaps/rmoverHit.bm ivtools-1.2/src/include/InterViews/Bitmaps/rmoverMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/rufast.bm ivtools-1.2/src/include/InterViews/Bitmaps/rufastMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/ufast.bm ivtools-1.2/src/include/InterViews/Bitmaps/ufastMask.bm ivtools-1.2/src/include/InterViews/Bitmaps/umover.bm ivtools-1.2/src/include/InterViews/Bitmaps/umoverHit.bm ivtools-1.2/src/include/InterViews/Bitmaps/umoverMask.bm ivtools-1.2/src/include/InterViews/Imakefile ivtools-1.2/src/include/InterViews/Makefile ivtools-1.2/src/include/InterViews/_defines.h ivtools-1.2/src/include/InterViews/_enter.h ivtools-1.2/src/include/InterViews/_leave.h ivtools-1.2/src/include/InterViews/_names.h ivtools-1.2/src/include/InterViews/_undefs.h ivtools-1.2/src/include/InterViews/action.h ivtools-1.2/src/include/InterViews/adjust.h ivtools-1.2/src/include/InterViews/aggr.h ivtools-1.2/src/include/InterViews/align.h ivtools-1.2/src/include/InterViews/alloctbl.h ivtools-1.2/src/include/InterViews/arraycomp.h ivtools-1.2/src/include/InterViews/background.h ivtools-1.2/src/include/InterViews/bitmap.h ivtools-1.2/src/include/InterViews/boolean.h ivtools-1.2/src/include/InterViews/border.h ivtools-1.2/src/include/InterViews/box.h ivtools-1.2/src/include/InterViews/brush.h ivtools-1.2/src/include/InterViews/canvas.h ivtools-1.2/src/include/InterViews/character.h ivtools-1.2/src/include/InterViews/color.h ivtools-1.2/src/include/InterViews/composition.h ivtools-1.2/src/include/InterViews/compositor.h ivtools-1.2/src/include/InterViews/coord.h ivtools-1.2/src/include/InterViews/cursor.h ivtools-1.2/src/include/InterViews/debug.h ivtools-1.2/src/include/InterViews/deck.h ivtools-1.2/src/include/InterViews/dialog.h ivtools-1.2/src/include/InterViews/display.h ivtools-1.2/src/include/InterViews/drag.h ivtools-1.2/src/include/InterViews/enter-scope.h ivtools-1.2/src/include/InterViews/event.h ivtools-1.2/src/include/InterViews/font.h ivtools-1.2/src/include/InterViews/geometry.h ivtools-1.2/src/include/InterViews/glcontext.h ivtools-1.2/src/include/InterViews/glue.h ivtools-1.2/src/include/InterViews/glyph.h ivtools-1.2/src/include/InterViews/group.h ivtools-1.2/src/include/InterViews/handler.h ivtools-1.2/src/include/InterViews/hit.h ivtools-1.2/src/include/InterViews/image.h ivtools-1.2/src/include/InterViews/input.h ivtools-1.2/src/include/InterViews/iv.h ivtools-1.2/src/include/InterViews/label.h ivtools-1.2/src/include/InterViews/layout.h ivtools-1.2/src/include/InterViews/leave-scope.h ivtools-1.2/src/include/InterViews/lrmarker.h ivtools-1.2/src/include/InterViews/monoglyph.h ivtools-1.2/src/include/InterViews/observe.h ivtools-1.2/src/include/InterViews/page.h ivtools-1.2/src/include/InterViews/patch.h ivtools-1.2/src/include/InterViews/pattern.h ivtools-1.2/src/include/InterViews/place.h ivtools-1.2/src/include/InterViews/polyglyph.h ivtools-1.2/src/include/InterViews/printer.h ivtools-1.2/src/include/InterViews/psfont.h ivtools-1.2/src/include/InterViews/raster.h ivtools-1.2/src/include/InterViews/regexp.h ivtools-1.2/src/include/InterViews/reqerr.h ivtools-1.2/src/include/InterViews/resource.h ivtools-1.2/src/include/InterViews/rule.h ivtools-1.2/src/include/InterViews/scrbox.h ivtools-1.2/src/include/InterViews/selection.h ivtools-1.2/src/include/InterViews/session.h ivtools-1.2/src/include/InterViews/shadow.h ivtools-1.2/src/include/InterViews/simplecomp.h ivtools-1.2/src/include/InterViews/stencil.h ivtools-1.2/src/include/InterViews/style.h ivtools-1.2/src/include/InterViews/superpose.h ivtools-1.2/src/include/InterViews/target.h ivtools-1.2/src/include/InterViews/telltale.h ivtools-1.2/src/include/InterViews/texcomp.h ivtools-1.2/src/include/InterViews/tformsetter.h ivtools-1.2/src/include/InterViews/tiff.h ivtools-1.2/src/include/InterViews/tile.h ivtools-1.2/src/include/InterViews/transformer.h ivtools-1.2/src/include/InterViews/window.h ivtools-1.2/src/include/InterViews/xymarker.h ivtools-1.2/src/include/Makefile ivtools-1.2/src/include/OS/Imakefile ivtools-1.2/src/include/OS/Makefile ivtools-1.2/src/include/OS/_defines.h ivtools-1.2/src/include/OS/_undefs.h ivtools-1.2/src/include/OS/directory.h ivtools-1.2/src/include/OS/enter-scope.h ivtools-1.2/src/include/OS/file.h ivtools-1.2/src/include/OS/host.h ivtools-1.2/src/include/OS/leave-scope.h ivtools-1.2/src/include/OS/list.h ivtools-1.2/src/include/OS/math.h ivtools-1.2/src/include/OS/memory.h ivtools-1.2/src/include/OS/os.h ivtools-1.2/src/include/OS/string.h ivtools-1.2/src/include/OS/strtable.h ivtools-1.2/src/include/OS/table.h ivtools-1.2/src/include/OS/table2.h ivtools-1.2/src/include/OS/types.h ivtools-1.2/src/include/OS/ustring.h ivtools-1.2/src/include/TIFF/Imakefile ivtools-1.2/src/include/TIFF/Makefile ivtools-1.2/src/include/TIFF/format.h ivtools-1.2/src/include/TIFF/tiff.h ivtools-1.2/src/include/TIFF/tiffio.h ivtools-1.2/src/include/Unidraw/Commands/Imakefile ivtools-1.2/src/include/Unidraw/Commands/Makefile ivtools-1.2/src/include/Unidraw/Commands/align.h ivtools-1.2/src/include/Unidraw/Commands/brushcmd.h ivtools-1.2/src/include/Unidraw/Commands/catcmds.h ivtools-1.2/src/include/Unidraw/Commands/colorcmd.h ivtools-1.2/src/include/Unidraw/Commands/command.h ivtools-1.2/src/include/Unidraw/Commands/data.h ivtools-1.2/src/include/Unidraw/Commands/datas.h ivtools-1.2/src/include/Unidraw/Commands/dirty.h ivtools-1.2/src/include/Unidraw/Commands/edit.h ivtools-1.2/src/include/Unidraw/Commands/font.h ivtools-1.2/src/include/Unidraw/Commands/import.h ivtools-1.2/src/include/Unidraw/Commands/macro.h ivtools-1.2/src/include/Unidraw/Commands/nop.h ivtools-1.2/src/include/Unidraw/Commands/patcmd.h ivtools-1.2/src/include/Unidraw/Commands/struct.h ivtools-1.2/src/include/Unidraw/Commands/transforms.h ivtools-1.2/src/include/Unidraw/Commands/viewcmds.h ivtools-1.2/src/include/Unidraw/Components/Imakefile ivtools-1.2/src/include/Unidraw/Components/Makefile ivtools-1.2/src/include/Unidraw/Components/cglue.h ivtools-1.2/src/include/Unidraw/Components/component.h ivtools-1.2/src/include/Unidraw/Components/compview.h ivtools-1.2/src/include/Unidraw/Components/connector.h ivtools-1.2/src/include/Unidraw/Components/csolver.h ivtools-1.2/src/include/Unidraw/Components/ellipse.h ivtools-1.2/src/include/Unidraw/Components/externview.h ivtools-1.2/src/include/Unidraw/Components/grcomp.h ivtools-1.2/src/include/Unidraw/Components/grview.h ivtools-1.2/src/include/Unidraw/Components/gvupdater.h ivtools-1.2/src/include/Unidraw/Components/line.h ivtools-1.2/src/include/Unidraw/Components/link.h ivtools-1.2/src/include/Unidraw/Components/pad.h ivtools-1.2/src/include/Unidraw/Components/pin.h ivtools-1.2/src/include/Unidraw/Components/polygon.h ivtools-1.2/src/include/Unidraw/Components/psformat.h ivtools-1.2/src/include/Unidraw/Components/psview.h ivtools-1.2/src/include/Unidraw/Components/rastercomp.h ivtools-1.2/src/include/Unidraw/Components/rect.h ivtools-1.2/src/include/Unidraw/Components/slot.h ivtools-1.2/src/include/Unidraw/Components/spline.h ivtools-1.2/src/include/Unidraw/Components/stencilcomp.h ivtools-1.2/src/include/Unidraw/Components/text.h ivtools-1.2/src/include/Unidraw/Components/vertices.h ivtools-1.2/src/include/Unidraw/Graphic/Imakefile ivtools-1.2/src/include/Unidraw/Graphic/Makefile ivtools-1.2/src/include/Unidraw/Graphic/damage.h ivtools-1.2/src/include/Unidraw/Graphic/ellipses.h ivtools-1.2/src/include/Unidraw/Graphic/geomobjs.h ivtools-1.2/src/include/Unidraw/Graphic/graphic.h ivtools-1.2/src/include/Unidraw/Graphic/grblock.h ivtools-1.2/src/include/Unidraw/Graphic/lines.h ivtools-1.2/src/include/Unidraw/Graphic/picture.h ivtools-1.2/src/include/Unidraw/Graphic/polygons.h ivtools-1.2/src/include/Unidraw/Graphic/pspaint.h ivtools-1.2/src/include/Unidraw/Graphic/rasterrect.h ivtools-1.2/src/include/Unidraw/Graphic/splines.h ivtools-1.2/src/include/Unidraw/Graphic/ulabel.h ivtools-1.2/src/include/Unidraw/Graphic/ustencil.h ivtools-1.2/src/include/Unidraw/Graphic/util.h ivtools-1.2/src/include/Unidraw/Graphic/verts.h ivtools-1.2/src/include/Unidraw/Imakefile ivtools-1.2/src/include/Unidraw/Makefile ivtools-1.2/src/include/Unidraw/Tools/Imakefile ivtools-1.2/src/include/Unidraw/Tools/Makefile ivtools-1.2/src/include/Unidraw/Tools/connect.h ivtools-1.2/src/include/Unidraw/Tools/grcomptool.h ivtools-1.2/src/include/Unidraw/Tools/magnify.h ivtools-1.2/src/include/Unidraw/Tools/move.h ivtools-1.2/src/include/Unidraw/Tools/reshape.h ivtools-1.2/src/include/Unidraw/Tools/rotate.h ivtools-1.2/src/include/Unidraw/Tools/scale.h ivtools-1.2/src/include/Unidraw/Tools/select.h ivtools-1.2/src/include/Unidraw/Tools/stretch.h ivtools-1.2/src/include/Unidraw/Tools/tool.h ivtools-1.2/src/include/Unidraw/_defines.h ivtools-1.2/src/include/Unidraw/_undefs.h ivtools-1.2/src/include/Unidraw/catalog.h ivtools-1.2/src/include/Unidraw/classes.h ivtools-1.2/src/include/Unidraw/clipboard.h ivtools-1.2/src/include/Unidraw/creator.h ivtools-1.2/src/include/Unidraw/ctrlinfo.h ivtools-1.2/src/include/Unidraw/dialogs.h ivtools-1.2/src/include/Unidraw/editor.h ivtools-1.2/src/include/Unidraw/editorinfo.h ivtools-1.2/src/include/Unidraw/enter-scope.h ivtools-1.2/src/include/Unidraw/globals.h ivtools-1.2/src/include/Unidraw/grid.h ivtools-1.2/src/include/Unidraw/iterator.h ivtools-1.2/src/include/Unidraw/keymap.h ivtools-1.2/src/include/Unidraw/kybd.h ivtools-1.2/src/include/Unidraw/leave-scope.h ivtools-1.2/src/include/Unidraw/manip.h ivtools-1.2/src/include/Unidraw/manips.h ivtools-1.2/src/include/Unidraw/path.h ivtools-1.2/src/include/Unidraw/selection.h ivtools-1.2/src/include/Unidraw/statevar.h ivtools-1.2/src/include/Unidraw/statevars.h ivtools-1.2/src/include/Unidraw/stateview.h ivtools-1.2/src/include/Unidraw/stateviews.h ivtools-1.2/src/include/Unidraw/transfn.h ivtools-1.2/src/include/Unidraw/transfns.h ivtools-1.2/src/include/Unidraw/uarray.h ivtools-1.2/src/include/Unidraw/uctrl.h ivtools-1.2/src/include/Unidraw/uctrls.h ivtools-1.2/src/include/Unidraw/uformat.h ivtools-1.2/src/include/Unidraw/uhash.h ivtools-1.2/src/include/Unidraw/ulist.h ivtools-1.2/src/include/Unidraw/umap.h ivtools-1.2/src/include/Unidraw/unidraw.h ivtools-1.2/src/include/Unidraw/upage.h ivtools-1.2/src/include/Unidraw/viewer.h ivtools-1.2/src/include/ivstd/Imakefile ivtools-1.2/src/include/ivstd/Makefile ivtools-1.2/src/include/ivstd/fstream.h ivtools-1.2/src/include/ivstd/iosfwd ivtools-1.2/src/include/ivstd/iostream.h ivtools-1.2/src/include/ivstd/leakchecker.h ivtools-1.2/src/include/ivstd/malloc.h ivtools-1.2/src/include/ivstd/math.h ivtools-1.2/src/include/ivstd/nan.h ivtools-1.2/src/include/ivstd/osfcn.h ivtools-1.2/src/include/ivstd/signal.h ivtools-1.2/src/include/ivstd/stdio.h ivtools-1.2/src/include/ivstd/stdlib.h ivtools-1.2/src/include/ivstd/stream.h ivtools-1.2/src/include/ivstd/string.h ivtools-1.2/src/include/ivstd/version.h ivtools-1.2/src/iueserv_/Imakefile ivtools-1.2/src/iueserv_/Makefile ivtools-1.2/src/iueserv_/README ivtools-1.2/src/iueserv_/main.c ivtools-1.2/src/ivtext/Imakefile ivtools-1.2/src/ivtext/Makefile ivtools-1.2/src/ivtext/README ivtools-1.2/src/ivtext/main.c ivtools-1.2/src/ivxt/Imakefile ivtools-1.2/src/ivxt/Xd.h ivtools-1.2/src/ivxt/Xud.h ivtools-1.2/src/ivxt/glyphwidget.h ivtools-1.2/src/ivxt/glyphwidgetP.h ivtools-1.2/src/ivxt/main.c ivtools-1.2/src/ivxt/widgetwindow.c ivtools-1.2/src/ivxt/widgetwindow.h ivtools-1.2/src/ivxt/xtintrinsic.h ivtools-1.2/src/ivxt/xtsession.c ivtools-1.2/src/ivxt/xtsession.h ivtools-1.2/src/ivxt/xtudsession.c ivtools-1.2/src/ivxt/xtudsession.h ivtools-1.2/src/man/Imakefile ivtools-1.2/src/man/Makefile ivtools-1.2/src/man/man1/Imakefile ivtools-1.2/src/man/man1/Makefile ivtools-1.2/src/man/man1/comdraw.1 ivtools-1.2/src/man/man1/comterp.1 ivtools-1.2/src/man/man1/dclock.1 ivtools-1.2/src/man/man1/drawtool.1 ivtools-1.2/src/man/man1/flipbook.1 ivtools-1.2/src/man/man1/graphdraw.1 ivtools-1.2/src/man/man1/iclass.1 ivtools-1.2/src/man/man1/idraw.1 ivtools-1.2/src/man/man1/ivmkmf.1 ivtools-1.2/src/man/man3/Adjuster.3 ivtools-1.2/src/man/man3/Banner.3 ivtools-1.2/src/man/man3/BasicDialog.3 ivtools-1.2/src/man/man3/Border.3 ivtools-1.2/src/man/man3/Box2_6.3 ivtools-1.2/src/man/man3/BrushCmd.3 ivtools-1.2/src/man/man3/Button2_6.3 ivtools-1.2/src/man/man3/CGlue.3 ivtools-1.2/src/man/man3/CSolver.3 ivtools-1.2/src/man/man3/Catalog.3 ivtools-1.2/src/man/man3/Clipboard.3 ivtools-1.2/src/man/man3/ColorCmd.3 ivtools-1.2/src/man/man3/Command.3 ivtools-1.2/src/man/man3/CompletionEditor.3 ivtools-1.2/src/man/man3/Component.3 ivtools-1.2/src/man/man3/ComponentView.3 ivtools-1.2/src/man/man3/ConnectTool.3 ivtools-1.2/src/man/man3/Connector.3 ivtools-1.2/src/man/man3/Control.3 ivtools-1.2/src/man/man3/ControlInfo.3 ivtools-1.2/src/man/man3/Creator.3 ivtools-1.2/src/man/man3/Damage.3 ivtools-1.2/src/man/man3/Data.3 ivtools-1.2/src/man/man3/Deck2_6.3 ivtools-1.2/src/man/man3/Dialog.3 ivtools-1.2/src/man/man3/Dispatcher.3 ivtools-1.2/src/man/man3/Editor.3 ivtools-1.2/src/man/man3/EditorInfo.3 ivtools-1.2/src/man/man3/EllipseComp.3 ivtools-1.2/src/man/man3/ExternView.3 ivtools-1.2/src/man/man3/FileBrowser.3 ivtools-1.2/src/man/man3/FileChooser.3 ivtools-1.2/src/man/man3/FontCmd.3 ivtools-1.2/src/man/man3/Frame.3 ivtools-1.2/src/man/man3/GVUpdater.3 ivtools-1.2/src/man/man3/Glue2_6.3 ivtools-1.2/src/man/man3/Graphic.3 ivtools-1.2/src/man/man3/GraphicBlock.3 ivtools-1.2/src/man/man3/GraphicComp.3 ivtools-1.2/src/man/man3/GraphicCompTool.3 ivtools-1.2/src/man/man3/GraphicView.3 ivtools-1.2/src/man/man3/Grid.3 ivtools-1.2/src/man/man3/IOCallback.3 ivtools-1.2/src/man/man3/IOHandler.3 ivtools-1.2/src/man/man3/Imakefile ivtools-1.2/src/man/man3/ImportCmd.3 ivtools-1.2/src/man/man3/Interactor.3 ivtools-1.2/src/man/man3/Iterator.3 ivtools-1.2/src/man/man3/KeyMap.3 ivtools-1.2/src/man/man3/LineComp.3 ivtools-1.2/src/man/man3/LinkComp.3 ivtools-1.2/src/man/man3/MacroCmd.3 ivtools-1.2/src/man/man3/MagnifyTool.3 ivtools-1.2/src/man/man3/Manipulator.3 ivtools-1.2/src/man/man3/MatchEditor.3 ivtools-1.2/src/man/man3/Menu2_6.3 ivtools-1.2/src/man/man3/Message.3 ivtools-1.2/src/man/man3/MoveTool.3 ivtools-1.2/src/man/man3/NOPCmd.3 ivtools-1.2/src/man/man3/PadComp.3 ivtools-1.2/src/man/man3/Page.3 ivtools-1.2/src/man/man3/Painter.3 ivtools-1.2/src/man/man3/Panner.3 ivtools-1.2/src/man/man3/Path.3 ivtools-1.2/src/man/man3/Pattern.3 ivtools-1.2/src/man/man3/PatternCmd.3 ivtools-1.2/src/man/man3/Perspective.3 ivtools-1.2/src/man/man3/Picture.3 ivtools-1.2/src/man/man3/PinComp.3 ivtools-1.2/src/man/man3/PolygonComp.3 ivtools-1.2/src/man/man3/PostScriptView.3 ivtools-1.2/src/man/man3/RasterComp.3 ivtools-1.2/src/man/man3/RasterRect.3 ivtools-1.2/src/man/man3/RectComp.3 ivtools-1.2/src/man/man3/Regexp.3 ivtools-1.2/src/man/man3/ReqErr.3 ivtools-1.2/src/man/man3/ReshapeTool.3 ivtools-1.2/src/man/man3/Resource.3 ivtools-1.2/src/man/man3/RotateTool.3 ivtools-1.2/src/man/man3/RpcHdr.3 ivtools-1.2/src/man/man3/RpcPeer.3 ivtools-1.2/src/man/man3/RpcReader.3 ivtools-1.2/src/man/man3/RpcRegistry.3 ivtools-1.2/src/man/man3/RpcService.3 ivtools-1.2/src/man/man3/RpcWriter.3 ivtools-1.2/src/man/man3/Rubband.3 ivtools-1.2/src/man/man3/ScaleTool.3 ivtools-1.2/src/man/man3/Scene.3 ivtools-1.2/src/man/man3/Scroller.3 ivtools-1.2/src/man/man3/SelectTool.3 ivtools-1.2/src/man/man3/Selection.3 ivtools-1.2/src/man/man3/Sensor.3 ivtools-1.2/src/man/man3/Shape.3 ivtools-1.2/src/man/man3/SlotComp.3 ivtools-1.2/src/man/man3/SplineComp.3 ivtools-1.2/src/man/man3/StateVar.3 ivtools-1.2/src/man/man3/StateVarView.3 ivtools-1.2/src/man/man3/StencilComp.3 ivtools-1.2/src/man/man3/StrBrowser.3 ivtools-1.2/src/man/man3/StrChooser.3 ivtools-1.2/src/man/man3/StretchTool.3 ivtools-1.2/src/man/man3/StringEditor.3 ivtools-1.2/src/man/man3/Subject.3 ivtools-1.2/src/man/man3/TextBuffer.3 ivtools-1.2/src/man/man3/TextComp.3 ivtools-1.2/src/man/man3/TextDisplay.3 ivtools-1.2/src/man/man3/TextEditor.3 ivtools-1.2/src/man/man3/Tool.3 ivtools-1.2/src/man/man3/TransferFunct.3 ivtools-1.2/src/man/man3/Tray.3 ivtools-1.2/src/man/man3/UArray.3 ivtools-1.2/src/man/man3/UControl.3 ivtools-1.2/src/man/man3/UHashTable.3 ivtools-1.2/src/man/man3/ULabel.3 ivtools-1.2/src/man/man3/UList.3 ivtools-1.2/src/man/man3/UMap.3 ivtools-1.2/src/man/man3/UStencil.3 ivtools-1.2/src/man/man3/Unidraw.3 ivtools-1.2/src/man/man3/UnidrawIntro.3 ivtools-1.2/src/man/man3/Vertices.3 ivtools-1.2/src/man/man3/VerticesComp.3 ivtools-1.2/src/man/man3/Viewer.3 ivtools-1.2/src/man/man3/Viewport.3 ivtools-1.2/src/man/man3/World.3 ivtools-1.2/src/man/man3/align.3 ivtools-1.2/src/man/man3/catcmds.3 ivtools-1.2/src/man/man3/classes.3 ivtools-1.2/src/man/man3/datas.3 ivtools-1.2/src/man/man3/edit.3 ivtools-1.2/src/man/man3/ellipses.3 ivtools-1.2/src/man/man3/geomobjs.3 ivtools-1.2/src/man/man3/globals.3 ivtools-1.2/src/man/man3/iostreamb.3 ivtools-1.2/src/man/man3/kybd.3 ivtools-1.2/src/man/man3/lines.3 ivtools-1.2/src/man/man3/manips.3 ivtools-1.2/src/man/man3/polygons.3 ivtools-1.2/src/man/man3/pspaint.3 ivtools-1.2/src/man/man3/rpcbuf.3 ivtools-1.2/src/man/man3/rpcstream.3 ivtools-1.2/src/man/man3/splines.3 ivtools-1.2/src/man/man3/statevars.3 ivtools-1.2/src/man/man3/stateviews.3 ivtools-1.2/src/man/man3/struct.3 ivtools-1.2/src/man/man3/transfns.3 ivtools-1.2/src/man/man3/transforms.3 ivtools-1.2/src/man/man3/uctrls.3 ivtools-1.2/src/man/man3/viewcmds.3 ivtools-1.2/src/man/refman3.1/refman.PS ivtools-1.2/src/scripts/Imakefile ivtools-1.2/src/scripts/Makefile ivtools-1.2/src/scripts/bsdinst.sh ivtools-1.2/src/scripts/chgsuffix.sh ivtools-1.2/src/scripts/cntsrclines.bash ivtools-1.2/src/scripts/config.guess ivtools-1.2/src/scripts/config.sub ivtools-1.2/src/scripts/cpu.sh ivtools-1.2/src/scripts/install-sh ivtools-1.2/src/scripts/ivcd.cpp ivtools-1.2/src/scripts/ivct.cpp ivtools-1.2/src/scripts/ivds.cpp ivtools-1.2/src/scripts/ivdt.cpp ivtools-1.2/src/scripts/ivfb.cpp ivtools-1.2/src/scripts/ivgd.cpp ivtools-1.2/src/scripts/ivgetjpg.bash ivtools-1.2/src/scripts/ivmkmf.cpp ivtools-1.2/src/scripts/ivtiftopnm.bash ivtools-1.2/src/scripts/mkdirhier.sh ivtools-1.2/src/scripts/mkgif89a.bash ivtools-1.2/src/scripts/mkgif89ac.bash ivtools-1.2/src/scripts/pnmtopgm.sh ivtools-1.2/src/tests/Imakefile ivtools-1.2/src/tests/Makefile ivtools-1.2/src/tests/y2k/Imakefile ivtools-1.2/src/tests/y2k/Makefile ivtools-1.2/src/tests/y2k/y2ktest.cc ivtools-1.2/src/utils/Imakefile ivtools-1.2/src/utils/Makefile ivtools-1.2/src/utils/downloader.cc ivtools-1.2/src/utils/downloader.h ivtools-1.2/src/utils/ftp.cc ivtools-1.2/src/utils/ftp.h ivtools-1.2/src/utils/http.cc ivtools-1.2/src/utils/http.h ivtools-1.2/src/utils/ivdl.cc ivtools-1.2/src/utils/ivtmpnam.c ivtools-1.2/src/utils/parse.h ivtools-1.2/src/utils/readwrite.h ivtools-1.2/src/utils/sockets.cc ivtools-1.2/src/utils/sockets.h ivtools-1.2/src/utils/stdcmapppm.c ivtools-1.2/src/utils/thrower.cc ivtools-1.2/src/utils/thrower.h ivtools-1.2.11a1/MANIFEST.comterp000066400000000000000000000174071214471147700163370ustar00rootroot00000000000000Imakefile MANIFEST.comterp Makefile config/Imakefile config/InterViews/Imakefile config/InterViews/TIFF.def config/InterViews/arch.def config/InterViews/cxx.def config/InterViews/iv-DGUX.cf config/InterViews/iv-Mips.cf config/InterViews/iv-aix.cf config/InterViews/iv-alpha.cf config/InterViews/iv-apollo.cf config/InterViews/iv-att.cf config/InterViews/iv-bsd.cf config/InterViews/iv-convex.cf config/InterViews/iv-cray.cf config/InterViews/iv-cygwin.cf config/InterViews/iv-freebsd.cf config/InterViews/iv-generic.cf config/InterViews/iv-hp.cf config/InterViews/iv-ibm.cf config/InterViews/iv-linux.cf config/InterViews/iv-luna.cf config/InterViews/iv-m4330.cf config/InterViews/iv-macII.cf config/InterViews/iv-moto.cf config/InterViews/iv-netbsd.cf config/InterViews/iv-pegasus.cf config/InterViews/iv-sgi.cf config/InterViews/iv-sony.cf config/InterViews/iv-stellar.cf config/InterViews/iv-stratus.cf config/InterViews/iv-sun.cf config/InterViews/iv-ultrix.cf config/InterViews/iv-x386.cf config/InterViews/local.def config/InterViews/params.def config/InterViews/rules.def config/InterViews/xparams.cf config/alpha3.0-gcc.mk config/alpha3.2-gcc.mk config/alpha4-gcc.mk config/arch.def config/config.defs.in config/config.mk config/config.null.mk config/default-gcc.mk config/freebsd-gcc.mk config/freebsd2.1-gcc.mk config/gcc.def config/hpux-gcc.mk config/hpux10.20-gcc.mk config/irix5-gcc.mk config/irix6-gcc.mk config/linux-gcc.mk config/local.def config/m88k-sysv3-gcc.mk config/m88k-sysv4-gcc.mk config/makevars.def config/netbsd-gcc.mk config/params.def config/rules.def config/sco3.2.4-gcc.mk config/site.def.ALPHA config/site.def.CYGWIN config/site.def.FREEBSD config/site.def.HP800 config/site.def.LINUX config/site.def.NETBSD config/site.def.SGI config/site.def.SUN4 config/solaris-gcc.mk config/sunos4-gcc.mk config/template configure configure.in configure.notes src/Attribute/Imakefile src/Attribute/_comterp.h src/Attribute/_comutil.h src/Attribute/alist.c src/Attribute/alist.h src/Attribute/aliterator.c src/Attribute/aliterator.h src/Attribute/attribute.c src/Attribute/attribute.h src/Attribute/attrlist.c src/Attribute/attrlist.h src/Attribute/attrvalue.c src/Attribute/attrvalue.h src/Attribute/classid.h src/Attribute/commodule.c src/Attribute/commodule.h src/Attribute/lexscan.c src/Attribute/lexscan.h src/Attribute/paramlist.c src/Attribute/paramlist.h src/ComTerp/Imakefile src/ComTerp/_comterp.h src/ComTerp/_comutil.h src/ComTerp/assignfunc.c src/ComTerp/assignfunc.h src/ComTerp/bitfunc.c src/ComTerp/bitfunc.h src/ComTerp/boolfunc.c src/ComTerp/boolfunc.h src/ComTerp/bquotefunc.c src/ComTerp/bquotefunc.h src/ComTerp/charfunc.c src/ComTerp/charfunc.h src/ComTerp/comfunc.c src/ComTerp/comfunc.h src/ComTerp/comhandler.c src/ComTerp/comhandler.h src/ComTerp/commodule.h src/ComTerp/comterp.c src/ComTerp/comterp.h src/ComTerp/comterpserv.c src/ComTerp/comterpserv.h src/ComTerp/comvalue.c src/ComTerp/comvalue.h src/ComTerp/condfunc.c src/ComTerp/condfunc.h src/ComTerp/ctrlfunc.c src/ComTerp/ctrlfunc.h src/ComTerp/debugfunc.c src/ComTerp/debugfunc.h src/ComTerp/dotfunc.c src/ComTerp/dotfunc.h src/ComTerp/helpfunc.c src/ComTerp/helpfunc.h src/ComTerp/iofunc.c src/ComTerp/iofunc.h src/ComTerp/lexscan.h src/ComTerp/listfunc.c src/ComTerp/listfunc.h src/ComTerp/mathfunc.c src/ComTerp/mathfunc.h src/ComTerp/numfunc.c src/ComTerp/numfunc.h src/ComTerp/parser.c src/ComTerp/parser.h src/ComTerp/postfunc.c src/ComTerp/postfunc.h src/ComTerp/randfunc.c src/ComTerp/randfunc.h src/ComTerp/scanner.c src/ComTerp/scanner.h src/ComTerp/statfunc.c src/ComTerp/statfunc.h src/ComTerp/strmfunc.c src/ComTerp/strmfunc.h src/ComTerp/symbolfunc.c src/ComTerp/symbolfunc.h src/ComTerp/typefunc.c src/ComTerp/typefunc.h src/ComTerp/xformfunc.c src/ComTerp/xformfunc.h src/ComUtil/Imakefile src/ComUtil/_lexscan.c src/ComUtil/_parser.c src/ComUtil/_scanner.c src/ComUtil/atox.c src/ComUtil/comerr.c src/ComUtil/comterp.arg src/ComUtil/comterp.ci src/ComUtil/comterp.err src/ComUtil/comterp.h src/ComUtil/comutil.arg src/ComUtil/comutil.ci src/ComUtil/comutil.h src/ComUtil/dmm.c src/ComUtil/errfile.c src/ComUtil/errsys.c src/ComUtil/funcptrs.c src/ComUtil/mblock.c src/ComUtil/optable.c src/ComUtil/symbols.c src/ComUtil/txtutil.c src/ComUtil/types.c src/ComUtil/util.c src/ComUtil/util.h src/ComUtil/xdll.c src/IV-common/Imakefile src/IV-common/listimpl.c src/IV-common/math.c src/IV-common/memory.c src/IV-common/regexp.c src/IV-common/resource.c src/IV-common/string.c src/IV-common/textbuffer.c src/IV-common/tform2_6.c src/IV-common/transformer.c src/Imakefile src/TopoFace/Imakefile src/TopoFace/fgeomobjs.c src/TopoFace/fgeomobjs.h src/TopoFace/topoedge.c src/TopoFace/topoedge.h src/TopoFace/topoedgelist.c src/TopoFace/topoedgelist.h src/TopoFace/topoelt.c src/TopoFace/topoelt.h src/TopoFace/topoface.c src/TopoFace/topoface.h src/TopoFace/toponode.c src/TopoFace/toponode.h src/Unidraw-common/Imakefile src/Unidraw-common/component.c src/Unidraw-common/compview.c src/Unidraw-common/geomobjs.c src/Unidraw-common/iterator.c src/Unidraw-common/uarray.c src/Unidraw-common/uhash.c src/Unidraw-common/ulist.c src/Unidraw-common/umap.c src/comterp_/Imakefile src/comterp_/README src/comterp_/main.c src/comtest/Imakefile src/comtest/main.c src/include/IV-2_6/Imakefile src/include/IV-2_6/InterViews/Imakefile src/include/IV-2_6/InterViews/alignment.h src/include/IV-2_6/InterViews/defs.h src/include/IV-2_6/InterViews/minmax.h src/include/IV-2_6/InterViews/textbuffer.h src/include/IV-2_6/InterViews/textstyle.h src/include/IV-2_6/_enter.h src/include/IV-2_6/_leave.h src/include/IV-2_6/_names.h src/include/IV-3_1/Imakefile src/include/IV-3_1/InterViews src/include/Imakefile src/include/InterViews/Imakefile src/include/InterViews/_defines.h src/include/InterViews/_enter.h src/include/InterViews/_leave.h src/include/InterViews/_names.h src/include/InterViews/_undefs.h src/include/InterViews/boolean.h src/include/InterViews/coord.h src/include/InterViews/enter-scope.h src/include/InterViews/iv.h src/include/InterViews/leave-scope.h src/include/InterViews/regexp.h src/include/InterViews/resource.h src/include/InterViews/transformer.h src/include/OS/Imakefile src/include/OS/_defines.h src/include/OS/_undefs.h src/include/OS/enter-scope.h src/include/OS/leave-scope.h src/include/OS/list.h src/include/OS/math.h src/include/OS/memory.h src/include/OS/os.h src/include/OS/string.h src/include/OS/strtable.h src/include/OS/table.h src/include/OS/types.h src/include/Unidraw/Components/Imakefile src/include/Unidraw/Components/component.h src/include/Unidraw/Components/compview.h src/include/Unidraw/Graphic/Imakefile src/include/Unidraw/Graphic/geomobjs.h src/include/Unidraw/Graphic/util.h src/include/Unidraw/Imakefile src/include/Unidraw/_defines.h src/include/Unidraw/_undefs.h src/include/Unidraw/catalog.h src/include/Unidraw/classes.h src/include/Unidraw/creator.h src/include/Unidraw/enter-scope.h src/include/Unidraw/globals.h src/include/Unidraw/iterator.h src/include/Unidraw/leave-scope.h src/include/Unidraw/uarray.h src/include/Unidraw/uformat.h src/include/Unidraw/uhash.h src/include/Unidraw/ulist.h src/include/Unidraw/umap.h src/include/Unidraw/unidraw.h src/include/ivstd/Imakefile src/include/ivstd/fstream.h src/include/ivstd/iosfwd src/include/ivstd/math.h src/include/ivstd/osfcn.h src/include/ivstd/signal.h src/include/ivstd/stdio.h src/include/ivstd/string.h src/include/ivstd/version.h src/scripts/Imakefile src/scripts/bsdinst.sh src/scripts/chgsuffix.sh src/scripts/cntsrclines.bash src/scripts/config.guess src/scripts/config.sub src/scripts/cpu.sh src/scripts/install-sh src/scripts/ivcd.cpp src/scripts/ivct.cpp src/scripts/ivds.cpp src/scripts/ivdt.cpp src/scripts/ivfb.cpp src/scripts/ivgd.cpp src/scripts/ivgetjpg.bash src/scripts/ivmkmf.cpp src/scripts/mkdirhier.sh src/scripts/mkgif89a.bash src/scripts/mkgif89ac.bash src/scripts/ivtiftopnm.bash src/scripts/pnmtopgm.sh ivtools-1.2.11a1/MANIFEST.perceps000066400000000000000000000346231214471147700163260ustar00rootroot00000000000000AceDispatch/ace_dispatcher.h AceDispatch/ace_iohandler.h AttrGlyph/attredit.h Attribute/_comterp.h Attribute/_comutil.h Attribute/alist.c Attribute/alist.h Attribute/aliterator.h Attribute/attribute.h Attribute/attrlist.h Attribute/attrvalue.h Attribute/commodule.h Attribute/lexscan.h Attribute/paramlist.h ComGlyph/attrdialog.h ComGlyph/comtextedit.h ComGlyph/comtextview.h ComGlyph/terpdialog.h ComTerp/_comterp.h ComTerp/_comutil.h ComTerp/assignfunc.h ComTerp/bitfunc.h ComTerp/boolfunc.h ComTerp/bquotefunc.h ComTerp/charfunc.c ComTerp/charfunc.h ComTerp/comfunc.h ComTerp/comhandler.h ComTerp/commodule.h ComTerp/comterp.h ComTerp/comterpserv.h ComTerp/comvalue.h ComTerp/condfunc.h ComTerp/ctrlfunc.h ComTerp/debugfunc.h ComTerp/dotfunc.h ComTerp/helpfunc.h ComTerp/iofunc.h ComTerp/lexscan.h ComTerp/listfunc.h ComTerp/mathfunc.h ComTerp/numfunc.h ComTerp/parser.h ComTerp/postfunc.h ComTerp/randfunc.h ComTerp/scanner.h ComTerp/statfunc.h ComTerp/strmfunc.h ComTerp/symbolfunc.h ComTerp/typefunc.h ComTerp/xformfunc.h ComUnidraw/comeditor.h ComUnidraw/comterp-acehandler.h ComUnidraw/comterp-iohandler.h ComUnidraw/dialogfunc.h ComUnidraw/grdotfunc.h ComUnidraw/grfunc.h ComUnidraw/grlistfunc.h ComUnidraw/groupfunc.h ComUnidraw/grstatfunc.h ComUnidraw/grstrmfunc.h ComUnidraw/highlightfunc.h ComUnidraw/nfunc.h ComUnidraw/pixelfunc.h ComUnidraw/plotfunc.h ComUnidraw/unifunc.h ComUtil/comterp.h ComUtil/comutil.h ComUtil/util.h Dispatch/netinet_in.h DrawServ/ackback-handler.h DrawServ/drawcatalog.h DrawServ/drawclasses.h DrawServ/drawcmds.h DrawServ/drawcomps.h DrawServ/drawcreator.h DrawServ/draweditor.h DrawServ/drawfunc.h DrawServ/drawkit.h DrawServ/drawimport.h DrawServ/drawlink.h DrawServ/drawlinkcomp.h DrawServ/drawlinklist.h DrawServ/drawserv.h DrawServ/drawserv-handler.h DrawServ/drawviews.h DrawServ/grid.h DrawServ/gridlist.h DrawServ/linkselection.h FrameUnidraw/framecatalog.h FrameUnidraw/frameclasses.h FrameUnidraw/framecmds.h FrameUnidraw/framecomps.h FrameUnidraw/framecreator.h FrameUnidraw/frameeditor.h FrameUnidraw/framefile.h FrameUnidraw/framefunc.h FrameUnidraw/frameimport.h FrameUnidraw/framekit.h FrameUnidraw/frameps.h FrameUnidraw/framescripts.h FrameUnidraw/framestates.h FrameUnidraw/frameviewer.h FrameUnidraw/frameviews.h GraphUnidraw/edgecomp.h GraphUnidraw/graphcatalog.h GraphUnidraw/graphclasses.h GraphUnidraw/graphcmds.h GraphUnidraw/graphcomp.h GraphUnidraw/graphcreator.h GraphUnidraw/graphdata.h GraphUnidraw/graphdialog.h GraphUnidraw/grapheditor.h GraphUnidraw/graphexport.h GraphUnidraw/graphimport.h GraphUnidraw/graphkit.h GraphUnidraw/graphtools.h GraphUnidraw/nodecomp.h IV-X11/wtable.h IVGlyph/bdfltform.h IVGlyph/bdtable.h IVGlyph/bdvalue.h IVGlyph/boolform.h IVGlyph/charfield.h IVGlyph/dragedit.h IVGlyph/enumform.h IVGlyph/exportchooser.h IVGlyph/fieldedit.h IVGlyph/figure.h IVGlyph/gdialogs.h IVGlyph/idraw.h IVGlyph/importchooser.h IVGlyph/namestate.h IVGlyph/observables.h IVGlyph/odialogs.h IVGlyph/ofilechooser.h IVGlyph/printchooser.h IVGlyph/saveaschooser.h IVGlyph/scrollable.h IVGlyph/strchooser.h IVGlyph/stredit.h IVGlyph/strlist.h IVGlyph/textbuff.h IVGlyph/textedit.h IVGlyph/texteditor.h IVGlyph/textform.h IVGlyph/textview.h IVGlyph/textwindow.h IVGlyph/toolbutton.h IVGlyph/valuator.h IueServ/exportfunc.h IueServ/ipfunc.h IueServ/iueclasses.h IueServ/iuecomps.h IueServ/iuefunc.h IueServ/iuehandler.h IueServ/roifunc.h OverlayUnidraw/aceimport.h OverlayUnidraw/annotate.h OverlayUnidraw/attrtool.h OverlayUnidraw/grayraster.h OverlayUnidraw/grloctool.h OverlayUnidraw/indexmixins.h OverlayUnidraw/leafwalker.h OverlayUnidraw/leakchecker.h OverlayUnidraw/ovabout.h OverlayUnidraw/ovadjuster.h OverlayUnidraw/ovarrow.h OverlayUnidraw/ovcamcmds.h OverlayUnidraw/ovcatalog.h OverlayUnidraw/ovchainview.h OverlayUnidraw/ovclasses.h OverlayUnidraw/ovclip.h OverlayUnidraw/ovcmds.h OverlayUnidraw/ovcomps.h OverlayUnidraw/ovcreator.h OverlayUnidraw/ovctrl.h OverlayUnidraw/ovdamage.h OverlayUnidraw/ovdialog.h OverlayUnidraw/ovdoer.h OverlayUnidraw/oved.h OverlayUnidraw/ovellipse.h OverlayUnidraw/ovexport.h OverlayUnidraw/ovfile.h OverlayUnidraw/ovfixview.h OverlayUnidraw/ovgdialog.h OverlayUnidraw/ovhull.h OverlayUnidraw/ovimport.h OverlayUnidraw/ovipcmds.h OverlayUnidraw/ovkit.h OverlayUnidraw/ovline.h OverlayUnidraw/ovmanips.h OverlayUnidraw/ovpage.h OverlayUnidraw/ovpainter.h OverlayUnidraw/ovpanner.h OverlayUnidraw/ovpolygon.h OverlayUnidraw/ovprecise.h OverlayUnidraw/ovprint.h OverlayUnidraw/ovpspict.h OverlayUnidraw/ovpsview.h OverlayUnidraw/ovraster.h OverlayUnidraw/ovrect.h OverlayUnidraw/ovrestimage.h OverlayUnidraw/ovselect.h OverlayUnidraw/ovselection.h OverlayUnidraw/ovshowhide.h OverlayUnidraw/ovspline.h OverlayUnidraw/ovstates.h OverlayUnidraw/ovstencil.h OverlayUnidraw/ovtext.h OverlayUnidraw/ovunidraw.h OverlayUnidraw/ovvars.h OverlayUnidraw/ovvertices.h OverlayUnidraw/ovviewer.h OverlayUnidraw/ovviews.h OverlayUnidraw/paramlist.h OverlayUnidraw/ptinpoly.h OverlayUnidraw/rastercmds.h OverlayUnidraw/scriptview.h OverlayUnidraw/setattrbyexpr.h OverlayUnidraw/slctbyattr.h OverlayUnidraw/textfile.h TIFF/machdep.h TIFF/prototypes.h TIFF/t4.h TIFF/tif_fax3.h TIFF/tiffcompat.h TIFF/tiffioP.h Time/Date.h Time/Time_.h Time/obstime.h Time/timeglyph.h TopoFace/fgeomobjs.h TopoFace/topoedge.h TopoFace/topoedgelist.h TopoFace/topoelt.h TopoFace/topoface.h TopoFace/toponode.h UniIdraw/idarrow.h UniIdraw/idarrowhead.h UniIdraw/idarrows.h UniIdraw/idcatalog.h UniIdraw/idclasses.h UniIdraw/idcmds.h UniIdraw/idcomp.h UniIdraw/idcreator.h UniIdraw/iddialogs.h UniIdraw/ided.h UniIdraw/idkybd.h UniIdraw/idvars.h UniIdraw/idversion.h include/Dispatch/_defines.h include/Dispatch/_undefs.h include/Dispatch/dispatcher.h include/Dispatch/dp.h include/Dispatch/enter-scope.h include/Dispatch/iocallback.h include/Dispatch/iohandler.h include/Dispatch/iostreamb.h include/Dispatch/leave-scope.h include/Dispatch/rpcbuf.h include/Dispatch/rpchdr.h include/Dispatch/rpcpeer.h include/Dispatch/rpcreader.h include/Dispatch/rpcregistry.h include/Dispatch/rpcservice.h include/Dispatch/rpcstream.h include/Dispatch/rpcwriter.h include/IV-2_6/InterViews/adjuster.h include/IV-2_6/InterViews/alignment.h include/IV-2_6/InterViews/banner.h include/IV-2_6/InterViews/border.h include/IV-2_6/InterViews/box.h include/IV-2_6/InterViews/button.h include/IV-2_6/InterViews/compeditor.h include/IV-2_6/InterViews/control.h include/IV-2_6/InterViews/deck.h include/IV-2_6/InterViews/defs.h include/IV-2_6/InterViews/dialog.h include/IV-2_6/InterViews/filebrowser.h include/IV-2_6/InterViews/filechooser.h include/IV-2_6/InterViews/frame.h include/IV-2_6/InterViews/glue.h include/IV-2_6/InterViews/ihandler.h include/IV-2_6/InterViews/interactor.h include/IV-2_6/InterViews/iwindow.h include/IV-2_6/InterViews/matcheditor.h include/IV-2_6/InterViews/menu.h include/IV-2_6/InterViews/message.h include/IV-2_6/InterViews/minmax.h include/IV-2_6/InterViews/paint.h include/IV-2_6/InterViews/painter.h include/IV-2_6/InterViews/panner.h include/IV-2_6/InterViews/perspective.h include/IV-2_6/InterViews/rubband.h include/IV-2_6/InterViews/rubcurve.h include/IV-2_6/InterViews/rubgroup.h include/IV-2_6/InterViews/rubline.h include/IV-2_6/InterViews/rubrect.h include/IV-2_6/InterViews/rubverts.h include/IV-2_6/InterViews/scene.h include/IV-2_6/InterViews/scrollbar.h include/IV-2_6/InterViews/scroller.h include/IV-2_6/InterViews/sensor.h include/IV-2_6/InterViews/shape.h include/IV-2_6/InterViews/strbrowser.h include/IV-2_6/InterViews/strchooser.h include/IV-2_6/InterViews/streditor.h include/IV-2_6/InterViews/subject.h include/IV-2_6/InterViews/textbuffer.h include/IV-2_6/InterViews/textdisplay.h include/IV-2_6/InterViews/texteditor.h include/IV-2_6/InterViews/textstyle.h include/IV-2_6/InterViews/tray.h include/IV-2_6/InterViews/viewport.h include/IV-2_6/InterViews/world.h include/IV-2_6/_enter.h include/IV-2_6/_leave.h include/IV-2_6/_names.h include/IV-X11/Xdefs.h include/IV-X11/Xext.h include/IV-X11/Xlib.h include/IV-X11/Xundefs.h include/IV-X11/Xutil.h include/IV-X11/xbitmap.h include/IV-X11/xbrush.h include/IV-X11/xcanvas.h include/IV-X11/xcolor.h include/IV-X11/xcursor.h include/IV-X11/xdisplay.h include/IV-X11/xdrag.h include/IV-X11/xevent.h include/IV-X11/xfont.h include/IV-X11/xpainter.h include/IV-X11/xpattern.h include/IV-X11/xraster.h include/IV-X11/xselection.h include/IV-X11/xwindow.h include/IV-look/bevel.h include/IV-look/browser.h include/IV-look/button.h include/IV-look/choice.h include/IV-look/dialogs.h include/IV-look/fbrowser.h include/IV-look/fchooser.h include/IV-look/field.h include/IV-look/kit.h include/IV-look/menu.h include/IV-look/mf_dialogs.h include/IV-look/mf_kit.h include/IV-look/mono_kit.h include/IV-look/ol_dialogs.h include/IV-look/ol_kit.h include/IV-look/slider.h include/IV-look/smf_kit.h include/IV-look/stepper.h include/IV-look/telltale.h include/InterViews/_defines.h include/InterViews/_enter.h include/InterViews/_leave.h include/InterViews/_names.h include/InterViews/_undefs.h include/InterViews/action.h include/InterViews/adjust.h include/InterViews/aggr.h include/InterViews/align.h include/InterViews/alloctbl.h include/InterViews/arraycomp.h include/InterViews/background.h include/InterViews/bitmap.h include/InterViews/boolean.h include/InterViews/border.h include/InterViews/box.h include/InterViews/brush.h include/InterViews/canvas.h include/InterViews/character.h include/InterViews/color.h include/InterViews/composition.h include/InterViews/compositor.h include/InterViews/coord.h include/InterViews/cursor.h include/InterViews/debug.h include/InterViews/deck.h include/InterViews/dialog.h include/InterViews/display.h include/InterViews/drag.h include/InterViews/enter-scope.h include/InterViews/event.h include/InterViews/font.h include/InterViews/geometry.h include/InterViews/glcontext.h include/InterViews/glue.h include/InterViews/glyph.h include/InterViews/group.h include/InterViews/handler.h include/InterViews/hit.h include/InterViews/image.h include/InterViews/input.h include/InterViews/iv.h include/InterViews/label.h include/InterViews/layout.h include/InterViews/leave-scope.h include/InterViews/lrmarker.h include/InterViews/monoglyph.h include/InterViews/observe.h include/InterViews/page.h include/InterViews/patch.h include/InterViews/pattern.h include/InterViews/place.h include/InterViews/polyglyph.h include/InterViews/printer.h include/InterViews/psfont.h include/InterViews/raster.h include/InterViews/regexp.h include/InterViews/reqerr.h include/InterViews/resource.h include/InterViews/rule.h include/InterViews/scrbox.h include/InterViews/selection.h include/InterViews/session.h include/InterViews/shadow.h include/InterViews/simplecomp.h include/InterViews/stencil.h include/InterViews/style.h include/InterViews/superpose.h include/InterViews/target.h include/InterViews/telltale.h include/InterViews/texcomp.h include/InterViews/tformsetter.h include/InterViews/tiff.h include/InterViews/tile.h include/InterViews/transformer.h include/InterViews/window.h include/InterViews/xymarker.h include/OS/_defines.h include/OS/_undefs.h include/OS/directory.h include/OS/enter-scope.h include/OS/file.h include/OS/host.h include/OS/leave-scope.h include/OS/list.h include/OS/math.h include/OS/memory.h include/OS/os.h include/OS/string.h include/OS/strtable.h include/OS/table.h include/OS/table2.h include/OS/types.h include/OS/ustring.h include/TIFF/format.h include/TIFF/tiff.h include/TIFF/tiffio.h include/Unidraw/Commands/align.h include/Unidraw/Commands/brushcmd.h include/Unidraw/Commands/catcmds.h include/Unidraw/Commands/colorcmd.h include/Unidraw/Commands/command.h include/Unidraw/Commands/data.h include/Unidraw/Commands/datas.h include/Unidraw/Commands/dirty.h include/Unidraw/Commands/edit.h include/Unidraw/Commands/font.h include/Unidraw/Commands/import.h include/Unidraw/Commands/macro.h include/Unidraw/Commands/nop.h include/Unidraw/Commands/patcmd.h include/Unidraw/Commands/struct.h include/Unidraw/Commands/transforms.h include/Unidraw/Commands/viewcmds.h include/Unidraw/Components/cglue.h include/Unidraw/Components/component.h include/Unidraw/Components/compview.h include/Unidraw/Components/connector.h include/Unidraw/Components/csolver.h include/Unidraw/Components/ellipse.h include/Unidraw/Components/externview.h include/Unidraw/Components/grcomp.h include/Unidraw/Components/grview.h include/Unidraw/Components/gvupdater.h include/Unidraw/Components/line.h include/Unidraw/Components/link.h include/Unidraw/Components/pad.h include/Unidraw/Components/pin.h include/Unidraw/Components/polygon.h include/Unidraw/Components/psformat.h include/Unidraw/Components/psview.h include/Unidraw/Components/rastercomp.h include/Unidraw/Components/rect.h include/Unidraw/Components/slot.h include/Unidraw/Components/spline.h include/Unidraw/Components/stencilcomp.h include/Unidraw/Components/text.h include/Unidraw/Components/vertices.h include/Unidraw/Graphic/damage.h include/Unidraw/Graphic/ellipses.h include/Unidraw/Graphic/geomobjs.h include/Unidraw/Graphic/graphic.h include/Unidraw/Graphic/grblock.h include/Unidraw/Graphic/lines.h include/Unidraw/Graphic/picture.h include/Unidraw/Graphic/polygons.h include/Unidraw/Graphic/pspaint.h include/Unidraw/Graphic/rasterrect.h include/Unidraw/Graphic/splines.h include/Unidraw/Graphic/ulabel.h include/Unidraw/Graphic/ustencil.h include/Unidraw/Graphic/util.h include/Unidraw/Graphic/verts.h include/Unidraw/Tools/connect.h include/Unidraw/Tools/grcomptool.h include/Unidraw/Tools/magnify.h include/Unidraw/Tools/move.h include/Unidraw/Tools/reshape.h include/Unidraw/Tools/rotate.h include/Unidraw/Tools/scale.h include/Unidraw/Tools/select.h include/Unidraw/Tools/stretch.h include/Unidraw/Tools/tool.h include/Unidraw/_defines.h include/Unidraw/_undefs.h include/Unidraw/catalog.h include/Unidraw/classes.h include/Unidraw/clipboard.h include/Unidraw/creator.h include/Unidraw/ctrlinfo.h include/Unidraw/dialogs.h include/Unidraw/editor.h include/Unidraw/editorinfo.h include/Unidraw/enter-scope.h include/Unidraw/globals.h include/Unidraw/grid.h include/Unidraw/iterator.h include/Unidraw/keymap.h include/Unidraw/kybd.h include/Unidraw/leave-scope.h include/Unidraw/manip.h include/Unidraw/manips.h include/Unidraw/path.h include/Unidraw/selection.h include/Unidraw/statevar.h include/Unidraw/statevars.h include/Unidraw/stateview.h include/Unidraw/stateviews.h include/Unidraw/transfn.h include/Unidraw/transfns.h include/Unidraw/uarray.h include/Unidraw/uctrl.h include/Unidraw/uctrls.h include/Unidraw/uformat.h include/Unidraw/uhash.h include/Unidraw/ulist.h include/Unidraw/umap.h include/Unidraw/unidraw.h include/Unidraw/upage.h include/Unidraw/viewer.h ivtools-1.2.11a1/Makefile.am000066400000000000000000001025751214471147700155730ustar00rootroot00000000000000## To Do: Document all this stuff. ## Miscellaneous Notes ## Cannot put the main Makefile.am in src/Makefile.am because targets ## like drawtool clash with pre-existing directories of the same name. ## Maybe there is a way to push these generated executables in a ## subdirectory? ## Various source files linked into the same target library sometimes ## require different options, in some cases in such a way that these ## options cannot be combined into a single set of options that works ## for all the files. This is addressed by breaking up such libraries ## into a few "convenience libtool libraries", each made of files ## compiled with identical options, and then combined to form the ## final library. ## But unless the libFOO_la_SOURCES has a .cc file in it directly, as ## opposed to only indirectly via convenience libraries, it will be ## relinked during installation using gcc rather than g++, causing an ## error. So the first part of each broken-into-parts library is the ## library itself. ## Removed linkage against external jpeg library, as it was not used. ## Pending Issues: ## Do ## TIFF/tiff.h TIFF/tiffio.h TIFF/format.h ## really belong in the installed include files, even when using an ## external tiff library? ## Snatch the source code for refman.PS from the ivtools-doc CVS repo. ## Comterp is compiled with ACE cpp options, but not linked to ACE. ## Release 1.2.10 added options -D_XOPEN_SOURCE -DLEAKCHECK, perhaps ## we should adjust Makefile.am to incorporate them. ACLOCAL_AMFLAGS = -I m4 ### Non-architecture-specific support file location pkgdatadir = $(datadir)/$(PACKAGE) EXTRA_LTLIBRARIES = lib_LTLIBRARIES = # These must occur in *dependency order* to avoid an *install time* # link error of this sort: # # /usr/bin/ld: cannot find -lAttribute # collect2: ld returned 1 exit status # libtool: install: error: relink `libComTerp.la' with the above command before installing it # # This is a longstanding known and undocumented bug. I would like to # take this opportunity to thank the authors of the autotools suite. # # An appropriate ordering can be generated by running the script # src/scripts/tsort-libs lib_LTLIBRARIES += libIV.la lib_LTLIBRARIES += libUnidraw.la lib_LTLIBRARIES += libComUtil.la lib_LTLIBRARIES += libAttribute.la lib_LTLIBRARIES += libIVGlyph.la lib_LTLIBRARIES += libComTerp.la lib_LTLIBRARIES += libAttrGlyph.la lib_LTLIBRARIES += libComGlyph.la lib_LTLIBRARIES += libTopoFace.la lib_LTLIBRARIES += libUniIdraw.la lib_LTLIBRARIES += libOverlayUnidraw.la lib_LTLIBRARIES += libComUnidraw.la lib_LTLIBRARIES += libFrameUnidraw.la lib_LTLIBRARIES += libGraphUnidraw.la lib_LTLIBRARIES += libUnidraw-common.la lib_LTLIBRARIES += libTime.la lib_LTLIBRARIES += libIV-common.la lib_LTLIBRARIES += libDrawServ.la if HAVE_LIBACE lib_LTLIBRARIES += libAceDispatch.la endif LIBVER = -version-info $(LIB_IV_VER) libAceDispatch_la_LDFLAGS = $(LIBVER) libAttrGlyph_la_LDFLAGS = $(LIBVER) libAttribute_la_LDFLAGS = $(LIBVER) libComGlyph_la_LDFLAGS = $(LIBVER) libComTerp_la_LDFLAGS = $(LIBVER) libComUnidraw_la_LDFLAGS = $(LIBVER) libComUtil_la_LDFLAGS = $(LIBVER) libDrawServ_la_LDFLAGS = $(LIBVER) libFrameUnidraw_la_LDFLAGS = $(LIBVER) libGraphUnidraw_la_LDFLAGS = $(LIBVER) libIVGlyph_la_LDFLAGS = $(LIBVER) libIV_common_la_LDFLAGS = $(LIBVER) libIV_la_LDFLAGS = $(LIBVER) libOverlayUnidraw_la_LDFLAGS = $(LIBVER) libTime_la_LDFLAGS = $(LIBVER) libTopoFace_la_LDFLAGS = $(LIBVER) libUniIdraw_la_LDFLAGS = $(LIBVER) libUnidraw_common_la_LDFLAGS = $(LIBVER) libUnidraw_la_LDFLAGS = $(LIBVER) if HAVE_LIBACE ACEDISPATCH_LA = libAceDispatch.la else ACEDISPATCH_LA = endif libAceDispatch_la_LIBADD = libIV.la $(ACE_LD) libAttrGlyph_la_LIBADD = libAttribute.la libIVGlyph.la libUnidraw.la libIV.la libAttribute_la_LIBADD = libUnidraw.la libIV.la libComUtil.la libComGlyph_la_LIBADD = libAttribute.la libComTerp.la libIVGlyph.la libIV.la libComUtil.la libComTerp_la_LIBADD = libAttribute.la libUnidraw.la libIV.la $(ACE_LD) libComUtil.la $(MATH_LD) libComUnidraw_la_LIBADD = libAttribute.la libComGlyph.la libComTerp.la libIVGlyph.la libOverlayUnidraw.la libUniIdraw.la libUnidraw.la libIV.la $(ACE_LD) libComUtil.la $(X11_LD) libComUtil_la_LIBADD = libDrawServ_la_LIBADD = libAttribute.la libComTerp.la libComUnidraw.la libFrameUnidraw.la libGraphUnidraw.la libIVGlyph.la libOverlayUnidraw.la libTopoFace.la libUniIdraw.la libUnidraw.la libIV.la libComUtil.la $(ACE_LD) libFrameUnidraw_la_LIBADD = libAttribute.la libComGlyph.la libComTerp.la libComUnidraw.la libIVGlyph.la libOverlayUnidraw.la libUniIdraw.la libUnidraw.la libIV.la libComUtil.la libGraphUnidraw_la_LIBADD = libAttribute.la libComTerp.la libComUnidraw.la libIVGlyph.la libOverlayUnidraw.la libTopoFace.la libUniIdraw.la libUnidraw.la libIV.la libComUtil.la libIVGlyph_la_LIBADD = libIV.la $(X11_LD) libIV_common_la_LIBADD = libIV_la_LIBADD = $(TIFF_LD) $(XEXT_LD) $(X11_LD) $(MATH_LD) libOverlayUnidraw_la_LIBADD = libAttrGlyph.la libAttribute.la libComGlyph.la libComTerp.la libIVGlyph.la libTopoFace.la libUniIdraw.la libUnidraw.la libIV.la $(ACE_LD) libComUtil.la $(CLIPPOLY_LD) $(X11_LD) $(MATH_LD) libTime_la_LIBADD = libIVGlyph.la libIV.la libTopoFace_la_LIBADD = libUnidraw.la libIV.la libUniIdraw_la_LIBADD = libUnidraw.la libIV.la libUnidraw_common_la_LIBADD = libIV.la libUnidraw_la_LIBADD = libIV.la $(X11_LD) IVSTD_INCLUDES = -Isrc -Isrc/include -Isrc/include/ivstd IV2_6_INCLUDES = -Div2_6_compatible -Isrc -Isrc/include/IV-2_6 -Isrc/include -Isrc/include/ivstd ### libComTerp libComTerp_parts = libComTerpPART1.la libComTerpPART2.la libComTerp_la_LIBADD += $(libComTerp_parts) EXTRA_LTLIBRARIES += $(libComTerp_parts) libComTerp_la_SOURCES = src/ComTerp/comhandler.cc \ src/ComTerp/comterpserv.cc src/ComTerp/ctrlfunc.cc libComTerp_la_CPPFLAGS = \ $(ACE_INLINE_CPPFLAGS) \ -Dcplusplus_2_1 $(IVSTD_INCLUDES) libComTerpPART1_la_SOURCES = src/ComTerp/assignfunc.cc \ src/ComTerp/bitfunc.cc src/ComTerp/boolfunc.cc \ src/ComTerp/bquotefunc.cc src/ComTerp/charfunc.cc \ src/ComTerp/comfunc.cc src/ComTerp/comvalue.cc src/ComTerp/condfunc.cc \ src/ComTerp/debugfunc.cc src/ComTerp/dotfunc.cc \ src/ComTerp/helpfunc.cc src/ComTerp/iofunc.cc src/ComTerp/listfunc.cc \ src/ComTerp/mathfunc.cc src/ComTerp/numfunc.cc src/ComTerp/parser.cc \ src/ComTerp/postfunc.cc src/ComTerp/randfunc.cc src/ComTerp/scanner.cc \ src/ComTerp/statfunc.cc src/ComTerp/strmfunc.cc \ src/ComTerp/symbolfunc.cc src/ComTerp/typefunc.cc \ src/ComTerp/xformfunc.cc libComTerpPART1_la_CPPFLAGS = \ $(ACE_CPPFLAGS) -Dcplusplus_2_1 $(IVSTD_INCLUDES) libComTerpPART2_la_SOURCES = src/ComTerp/comterp.cc libComTerpPART2_la_CPPFLAGS = \ -Div2_6_incompatible -Isrc/include \ $(ACE_CPPFLAGS) -Dcplusplus_2_1 $(IVSTD_INCLUDES) ### libIV_common libIV_common_la_SOURCES = src/OS/listimpl.cc src/OS/math.cc \ src/OS/memory.cc src/InterViews/regexp.cc src/InterViews/resource.cc \ src/OS/string.cc src/IV-2_6/textbuffer.cc src/IV-2_6/tform2_6.cc \ src/InterViews/transformer.cc libIV_common_la_CPPFLAGS = \ -Dcplusplus_2_1 $(IVSTD_INCLUDES) ### libTime libTime_la_SOURCES = src/Time/Date.cc src/Time/obstime.cc \ src/Time/Time.cc src/Time/timeglyph.cc libTime_la_CPPFLAGS = \ -Dcplusplus_2_1 $(IVSTD_INCLUDES) ### libIVGlyph libIVGlyph_la_SOURCES = src/IVGlyph/bdfltform.cc \ src/IVGlyph/bdtable.cc src/IVGlyph/bdvalue.cc src/IVGlyph/boolform.cc \ src/IVGlyph/charfield.cc src/IVGlyph/dragedit.cc \ src/IVGlyph/enumform.cc src/IVGlyph/exportchooser.cc \ src/IVGlyph/fieldedit.cc src/IVGlyph/figure.cc src/IVGlyph/gdialogs.cc \ src/IVGlyph/globals.cc src/IVGlyph/idraw.cc \ src/IVGlyph/importchooser.cc src/IVGlyph/namestate.cc \ src/IVGlyph/observables.cc src/IVGlyph/odialogs.cc \ src/IVGlyph/ofilechooser.cc src/IVGlyph/printchooser.cc \ src/IVGlyph/saveaschooser.cc src/IVGlyph/scrollable.cc \ src/IVGlyph/strchooser.cc src/IVGlyph/stredit.cc \ src/IVGlyph/strlist.cc src/IVGlyph/textbuff.cc src/IVGlyph/textedit.cc \ src/IVGlyph/texteditor.cc src/IVGlyph/textform.cc \ src/IVGlyph/textview.cc src/IVGlyph/textwindow.cc \ src/IVGlyph/toolbutton.cc src/IVGlyph/valuator.cc libIVGlyph_la_CPPFLAGS = \ -Dcplusplus_2_1 $(IVSTD_INCLUDES) ### libDrawServ libDrawServ_parts = libDrawServPART1.la libDrawServPART2.la libDrawServ_la_LIBADD += $(libDrawServ_parts) EXTRA_LTLIBRARIES += $(libDrawServ_parts) libDrawServ_la_SOURCES = src/DrawServ/ackback-handler.cc \ src/DrawServ/drawfunc.cc src/DrawServ/drawlink.cc \ src/DrawServ/drawserv-handler.cc libDrawServ_la_CPPFLAGS = \ -Dcplusplus_2_1 $(ACE_INLINE_CPPFLAGS) $(IV2_6_INCLUDES) libDrawServPART1_la_SOURCES = src/DrawServ/drawcatalog.cc \ src/DrawServ/drawcmds.cc src/DrawServ/drawcomps.cc \ src/DrawServ/drawcreator.cc src/DrawServ/draweditor.cc \ src/DrawServ/drawlinkcomp.cc src/DrawServ/drawlinklist.cc \ src/DrawServ/drawserv.cc src/DrawServ/drawviews.cc \ src/DrawServ/grid.cc src/DrawServ/gridlist.cc \ src/DrawServ/linkselection.cc src/DrawServ/sid.cc libDrawServPART1_la_CPPFLAGS = \ -Dcplusplus_2_1 $(ACE_CPPFLAGS) $(IV2_6_INCLUDES) libDrawServPART2_la_SOURCES = src/DrawServ/drawimport.cc \ src/DrawServ/drawkit.cc src/DrawServ/rcdialog.cc libDrawServPART2_la_CPPFLAGS = \ -Dcplusplus_2_1 -Div2_6_incompatible \ -Isrc/include $(ACE_CPPFLAGS) $(IV2_6_INCLUDES) ### libUnidraw libUnidraw_common_la_SOURCES = src/Unidraw/component.cc \ src/Unidraw/compview.cc src/Unidraw/geomobjs.cc \ src/Unidraw/iterator.cc src/Unidraw/uarray.cc src/Unidraw/uhash.cc \ src/Unidraw/ulist.cc src/Unidraw/umap.cc libUnidraw_common_la_CPPFLAGS = \ -Dcplusplus_2_1 -DUnidrawCommon $(IVSTD_INCLUDES) ### libComUnidraw libComUnidraw_parts = libComUnidrawPART1.la libComUnidraw_la_LIBADD += $(libComUnidraw_parts) EXTRA_LTLIBRARIES += $(libComUnidraw_parts) libComUnidraw_la_SOURCES = src/ComUnidraw/comeditor.cc \ src/ComUnidraw/comterp-iohandler.cc src/ComUnidraw/dialogfunc.cc \ src/ComUnidraw/grdotfunc.cc src/ComUnidraw/grfunc.cc \ src/ComUnidraw/grlistfunc.cc src/ComUnidraw/groupfunc.cc \ src/ComUnidraw/grstatfunc.cc src/ComUnidraw/grstrmfunc.cc \ src/ComUnidraw/highlightfunc.cc src/ComUnidraw/nfunc.cc \ src/ComUnidraw/pixelfunc.cc src/ComUnidraw/plotfunc.cc \ src/ComUnidraw/unifunc.cc libComUnidraw_la_CPPFLAGS = \ -Dcplusplus_2_1 $(ACE_CPPFLAGS) $(IV2_6_INCLUDES) libComUnidrawPART1_la_SOURCES = src/ComUnidraw/comterp-acehandler.cc libComUnidrawPART1_la_CPPFLAGS = \ -Dcplusplus_2_1 $(ACE_INLINE_CPPFLAGS) \ -Div2_6_incompatible -Isrc/include $(IV2_6_INCLUDES) ### libComGlyph libComGlyph_la_SOURCES = src/ComGlyph/attrdialog.cc \ src/ComGlyph/comtextedit.cc src/ComGlyph/comtextview.cc \ src/ComGlyph/terpdialog.cc libComGlyph_la_CPPFLAGS = \ -Dcplusplus_2_1 -Div2_6_incompatible -Isrc/include $(IVSTD_INCLUDES) ### libIV libIV_parts = libIVPART1.la libIVPART2.la libIVPART3.la libIVPART4.la libIV_la_LIBADD += $(libIV_parts) EXTRA_LTLIBRARIES += $(libIV_parts) libIV_la_SOURCES = src/InterViews/session.cc libIV_la_CPPFLAGS = \ -Dcplusplus_2_1 \ -DABSLIBALLDIR='"$(pkgdatadir)"' \ -DRELLIBALLDIR='"lib/$(PACKAGE)"' \ -DX_LIBDIR='"$(libdir)"' \ -Isrc/IV $(IVSTD_INCLUDES) libIVPART1_la_SOURCES = src/InterViews/psfont.cc libIVPART1_la_CPPFLAGS = \ -Dcplusplus_2_1 \ -Dps_metrics_dir='"$(PSFontDir)"' \ -Isrc/IV $(IVSTD_INCLUDES) libIVPART2_la_SOURCES = src/InterViews/dialogs.cc src/InterViews/kit.cc libIVPART2_la_CPPFLAGS = \ -Dcplusplus_2_1 -Dsgi_motif_kit -Dmotif_kit -Ddefault_kit=SMFKit \ -Isrc/IV $(IVSTD_INCLUDES) libIVPART3_la_SOURCES = src/Dispatch/dispatcher.cc \ src/Dispatch/iohandler.cc src/IV-2_6/adjuster2_6.cc \ src/IV-2_6/banner.cc src/IV-2_6/border2_6.cc src/IV-2_6/box2_6.cc \ src/IV-2_6/button2_6.cc src/IV-2_6/compeditor.cc src/IV-2_6/control.cc \ src/IV-2_6/deck2_6.cc src/IV-2_6/dialog2_6.cc \ src/IV-2_6/filebrowser.cc src/IV-2_6/filechooser.cc \ src/IV-2_6/frame.cc src/IV-2_6/glue2_6.cc src/IV-2_6/interactor.cc \ src/IV-2_6/matcheditor.cc src/IV-2_6/menu2_6.cc src/IV-2_6/message.cc \ src/IV-2_6/painter.cc src/IV-2_6/panner2_6.cc \ src/IV-2_6/perspective.cc src/IV-2_6/rubband.cc src/IV-2_6/rubcurve.cc \ src/IV-2_6/rubgroup.cc src/IV-2_6/rubline.cc src/IV-2_6/rubrect.cc \ src/IV-2_6/rubverts.cc src/IV-2_6/scene.cc src/IV-2_6/scrollbar2_6.cc \ src/IV-2_6/scroller2_6.cc src/IV-2_6/sensor.cc src/IV-2_6/shape.cc \ src/IV-2_6/strbrowser.cc src/IV-2_6/strchooser.cc \ src/IV-2_6/streditor.cc src/IV-2_6/subject.cc src/IV-2_6/textbuffer.cc \ src/IV-2_6/textdisplay.cc src/IV-2_6/texteditor.cc \ src/IV-2_6/tform2_6.cc src/IV-2_6/tray.cc src/IV-2_6/viewport.cc \ src/IV-2_6/world.cc src/IV-2_6/xbitmap2_6.cc src/IV-2_6/xevent2_6.cc \ src/IV-2_6/xinter.cc src/IV-2_6/xpainter.cc src/IV-2_6/xpattern.cc \ src/IV-X11/xbitmap.cc src/IV-X11/xbrush.cc src/IV-X11/xcanvas.cc \ src/IV-X11/xcolor.cc src/IV-X11/xcursor.cc src/IV-X11/xdrag.cc \ src/IV-X11/xevent.cc src/IV-X11/xfont.cc src/IV-X11/xraster.cc \ src/IV-X11/xreqerr.cc src/IV-X11/xselection.cc src/IV-X11/xwindow.cc \ src/InterViews/action.cc src/InterViews/adjust.cc \ src/InterViews/aggr.cc src/InterViews/align.cc \ src/InterViews/alloctbl.cc src/InterViews/arrcomp.cc \ src/InterViews/background.cc src/InterViews/bevel.cc \ src/InterViews/border.cc src/InterViews/box.cc \ src/InterViews/browser.cc src/InterViews/button.cc \ src/InterViews/character.cc src/InterViews/composition.cc \ src/InterViews/compositor.cc src/InterViews/debug.cc \ src/InterViews/deck.cc src/InterViews/fbrowser.cc \ src/InterViews/fchooser.cc src/InterViews/field.cc \ src/InterViews/geometry.cc src/InterViews/glyph.cc \ src/InterViews/group.cc src/InterViews/handler.cc \ src/InterViews/hit.cc src/InterViews/image.cc src/InterViews/input.cc \ src/InterViews/label.cc src/InterViews/layout.cc \ src/InterViews/lrmarker.cc src/InterViews/menu.cc \ src/InterViews/mf_dialogs.cc src/InterViews/mf_kit.cc \ src/InterViews/mono_kit.cc src/InterViews/monoglyph.cc \ src/InterViews/observe.cc src/InterViews/ol_dialogs.cc \ src/InterViews/ol_kit.cc src/InterViews/page.cc \ src/InterViews/patch.cc src/InterViews/place.cc \ src/InterViews/polyglyph.cc src/InterViews/printer.cc \ src/InterViews/regexp.cc src/InterViews/resource.cc \ src/InterViews/rule.cc src/InterViews/scrbox.cc \ src/InterViews/shadow.cc src/InterViews/simpcomp.cc \ src/InterViews/slider.cc src/InterViews/smf_kit.cc \ src/InterViews/stencil.cc src/InterViews/stepper.cc \ src/InterViews/style.cc src/InterViews/superpose.cc \ src/InterViews/target.cc src/InterViews/telltale.cc \ src/InterViews/texcomp.cc src/InterViews/tformsetter.cc \ src/InterViews/tile.cc src/InterViews/transformer.cc \ src/InterViews/xymarker.cc src/OS/directory.cc src/OS/file.cc \ src/OS/host.cc src/OS/listimpl.cc src/OS/math.cc src/OS/memory.cc \ src/OS/string.cc src/OS/ustring.cc libIVPART3_la_CPPFLAGS = \ -Dcplusplus_2_1 -Isrc/IV $(IVSTD_INCLUDES) libIVPART4_la_SOURCES = src/InterViews/tiff.cc libIVPART4_la_CPPFLAGS = \ -Dcplusplus_2_1 $(TIFF_LOC_CPPFLAG) -Isrc/IV $(IVSTD_INCLUDES) ### libUnidraw libUnidraw_la_SOURCES = src/Unidraw/align.cc src/Unidraw/brushcmd.cc \ src/Unidraw/catalog.cc src/Unidraw/catcmds.cc src/Unidraw/cglue.cc \ src/Unidraw/clipboard.cc src/Unidraw/colorcmd.cc \ src/Unidraw/command.cc src/Unidraw/component.cc \ src/Unidraw/compview.cc src/Unidraw/connect.cc \ src/Unidraw/connector.cc src/Unidraw/creator.cc src/Unidraw/csolver.cc \ src/Unidraw/ctrlinfo.cc src/Unidraw/damage.cc src/Unidraw/data.cc \ src/Unidraw/datas.cc src/Unidraw/dialogs.cc src/Unidraw/edit.cc \ src/Unidraw/editor.cc src/Unidraw/editorinfo.cc src/Unidraw/ellipse.cc \ src/Unidraw/ellipses.cc src/Unidraw/externview.cc src/Unidraw/font.cc \ src/Unidraw/geomobjs.cc src/Unidraw/globals.cc src/Unidraw/graphic.cc \ src/Unidraw/grblock.cc src/Unidraw/grcomp.cc src/Unidraw/grcomptool.cc \ src/Unidraw/grid.cc src/Unidraw/grview.cc src/Unidraw/gvupdater.cc \ src/Unidraw/import.cc src/Unidraw/iterator.cc src/Unidraw/keymap.cc \ src/Unidraw/kybd.cc src/Unidraw/line.cc src/Unidraw/lines.cc \ src/Unidraw/link.cc src/Unidraw/macro.cc src/Unidraw/magnify.cc \ src/Unidraw/manip.cc src/Unidraw/manips.cc src/Unidraw/move.cc \ src/Unidraw/nop.cc src/Unidraw/pad.cc src/Unidraw/patcmd.cc \ src/Unidraw/path.cc src/Unidraw/picture.cc src/Unidraw/pin.cc \ src/Unidraw/polygon.cc src/Unidraw/polygons.cc src/Unidraw/pspaint.cc \ src/Unidraw/psview.cc src/Unidraw/rastercomp.cc \ src/Unidraw/rasterrect.cc src/Unidraw/rect.cc src/Unidraw/reshape.cc \ src/Unidraw/rotate.cc src/Unidraw/scale.cc src/Unidraw/select.cc \ src/Unidraw/selection.cc src/Unidraw/slot.cc src/Unidraw/spline.cc \ src/Unidraw/splines.cc src/Unidraw/statevar.cc \ src/Unidraw/statevars.cc src/Unidraw/stateview.cc \ src/Unidraw/stateviews.cc src/Unidraw/stencilcomp.cc \ src/Unidraw/stretch.cc src/Unidraw/struct.cc src/Unidraw/text.cc \ src/Unidraw/tool.cc src/Unidraw/transfn.cc src/Unidraw/transfns.cc \ src/Unidraw/transforms.cc src/Unidraw/uarray.cc src/Unidraw/uctrl.cc \ src/Unidraw/uctrls.cc src/Unidraw/uhash.cc src/Unidraw/ulabel.cc \ src/Unidraw/ulist.cc src/Unidraw/umap.cc src/Unidraw/unidraw.cc \ src/Unidraw/upage.cc src/Unidraw/ustencil.cc src/Unidraw/vertices.cc \ src/Unidraw/verts.cc src/Unidraw/viewcmds.cc src/Unidraw/viewer.cc libUnidraw_la_CPPFLAGS = \ -Dcplusplus_2_1 $(IVSTD_INCLUDES) ### libAttrGlyph libAttrGlyph_la_SOURCES = src/AttrGlyph/attredit.cc libAttrGlyph_la_CPPFLAGS = \ -Dcplusplus_2_1 \ -DLibStdCPlusPlus2=0 -DLibStdCPlusPlus3=1 \ $(IVSTD_INCLUDES) ### libComUtil libComUtil_parts = libComUtilPART1.la libComUtil_la_LIBADD += $(libComUtil_parts) EXTRA_LTLIBRARIES += $(libComUtil_parts) libComUtil_la_SOURCES = src/ComUtil/atox.cc src/ComUtil/comerr.cc \ src/ComUtil/dmm.cc src/ComUtil/errfile.cc src/ComUtil/funcptrs.cc \ src/ComUtil/_lexscan.cc src/ComUtil/mblock.cc src/ComUtil/optable.cc \ src/ComUtil/_parser.cc src/ComUtil/popen2.cc src/ComUtil/_scanner.cc \ src/ComUtil/symbols.cc src/ComUtil/txtutil.cc src/ComUtil/types.cc \ src/ComUtil/util.cc src/ComUtil/xdll.cc libComUtil_la_CPPFLAGS = \ -D_POSIX_C_SOURCE $(IVSTD_INCLUDES) libComUtilPART1_la_SOURCES = src/ComUtil/errsys.cc # was hardwired: # -DABSLIBALLDIR=\"/usr/lib/ivtools/\" # -DRELLIBALLDIR=\"lib/ivtools/\" libComUtilPART1_la_CPPFLAGS = \ -DABSLIBALLDIR=\"$(pkgdatadir)/\" \ -DRELLIBALLDIR=\"lib/$(PACKAGE)/\" \ -D_POSIX_C_SOURCE $(IVSTD_INCLUDES) # NOTE: inconsistency in whether ABSLIBALLDIR has a trailing slash ### libTopoFace libTopoFace_la_SOURCES = src/TopoFace/fgeomobjs.cc \ src/TopoFace/topoedge.cc src/TopoFace/topoedgelist.cc \ src/TopoFace/topoelt.cc src/TopoFace/topoface.cc \ src/TopoFace/toponode.cc libTopoFace_la_CPPFLAGS = \ -Dcplusplus_2_1 $(IVSTD_INCLUDES) ### libUniIdraw libUniIdraw_la_SOURCES = src/UniIdraw/idarrow.cc \ src/UniIdraw/idarrowhead.cc src/UniIdraw/idarrows.cc \ src/UniIdraw/idcatalog.cc src/UniIdraw/idcmds.cc \ src/UniIdraw/idcomp.cc src/UniIdraw/idcreator.cc \ src/UniIdraw/iddialogs.cc src/UniIdraw/ided.cc src/UniIdraw/idkybd.cc \ src/UniIdraw/idvars.cc libUniIdraw_la_CPPFLAGS = \ -Dcplusplus_2_1 $(IV2_6_INCLUDES) ### libGraphUnidraw libGraphUnidraw_parts = libGraphUnidrawPART1.la libGraphUnidraw_la_LIBADD += $(libGraphUnidraw_parts) EXTRA_LTLIBRARIES += $(libGraphUnidraw_parts) libGraphUnidraw_la_SOURCES = src/GraphUnidraw/edgecomp.cc \ src/GraphUnidraw/graphcatalog.cc src/GraphUnidraw/graphcmds.cc \ src/GraphUnidraw/graphcomp.cc src/GraphUnidraw/graphcreator.cc \ src/GraphUnidraw/graphdata.cc src/GraphUnidraw/grapheditor.cc \ src/GraphUnidraw/graphtools.cc src/GraphUnidraw/nodecomp.cc libGraphUnidraw_la_CPPFLAGS = \ -Dcplusplus_2_1 $(IV2_6_INCLUDES) libGraphUnidrawPART1_la_SOURCES = src/GraphUnidraw/graphdialog.cc \ src/GraphUnidraw/graphimport.cc src/GraphUnidraw/graphexport.cc \ src/GraphUnidraw/graphkit.cc libGraphUnidrawPART1_la_CPPFLAGS = \ -Dcplusplus_2_1 \ -Div2_6_incompatible -Isrc/include $(IV2_6_INCLUDES) # libFrameUnidraw libFrameUnidraw_parts = libFrameUnidrawPART1.la libFrameUnidraw_la_LIBADD += $(libFrameUnidraw_parts) EXTRA_LTLIBRARIES += $(libFrameUnidraw_parts) libFrameUnidraw_la_SOURCES = src/FrameUnidraw/framecatalog.cc \ src/FrameUnidraw/framecmds.cc src/FrameUnidraw/framecomps.cc \ src/FrameUnidraw/framecreator.cc src/FrameUnidraw/frameeditor.cc \ src/FrameUnidraw/framefile.cc src/FrameUnidraw/framefunc.cc \ src/FrameUnidraw/frameps.cc src/FrameUnidraw/framescripts.cc \ src/FrameUnidraw/frameviewer.cc src/FrameUnidraw/frameviews.cc libFrameUnidraw_la_CPPFLAGS = \ -Dcplusplus_2_1 $(IV2_6_INCLUDES) libFrameUnidrawPART1_la_SOURCES = src/FrameUnidraw/frameimport.cc \ src/FrameUnidraw/framekit.cc src/FrameUnidraw/framestates.cc libFrameUnidrawPART1_la_CPPFLAGS = \ -Dcplusplus_2_1 -Div2_6_incompatible -Isrc/include $(IV2_6_INCLUDES) ### libOverlayUnidraw libOverlayUnidraw_parts = libOverlayUnidrawPART1.la libOverlayUnidrawPART2.la libOverlayUnidraw_la_LIBADD += $(libOverlayUnidraw_parts) EXTRA_LTLIBRARIES += $(libOverlayUnidraw_parts) libOverlayUnidraw_la_SOURCES = src/OverlayUnidraw/attrtool.cc \ src/OverlayUnidraw/clipline.cc src/OverlayUnidraw/grayraster.cc \ src/OverlayUnidraw/indexmixins.cc src/OverlayUnidraw/leafwalker.cc \ src/OverlayUnidraw/ovadjuster.cc src/OverlayUnidraw/ovarrow.cc \ src/OverlayUnidraw/ovcatalog.cc src/OverlayUnidraw/ovcomps.cc \ src/OverlayUnidraw/ovcreator.cc src/OverlayUnidraw/ovdamage.cc \ src/OverlayUnidraw/ovdialog.cc src/OverlayUnidraw/ovdoer.cc \ src/OverlayUnidraw/oved.cc src/OverlayUnidraw/ovellipse.cc \ src/OverlayUnidraw/ovfile.cc src/OverlayUnidraw/ovhull.cc \ src/OverlayUnidraw/ovline.cc src/OverlayUnidraw/ovmanips.cc \ src/OverlayUnidraw/ovpage.cc src/OverlayUnidraw/ovpainter.cc \ src/OverlayUnidraw/ovpanner.cc src/OverlayUnidraw/ovpolygon.cc \ src/OverlayUnidraw/ovprecise.cc src/OverlayUnidraw/ovpspict.cc \ src/OverlayUnidraw/ovpsview.cc src/OverlayUnidraw/ovraster.cc \ src/OverlayUnidraw/ovrect.cc src/OverlayUnidraw/ovrestimage.cc \ src/OverlayUnidraw/ovselect.cc src/OverlayUnidraw/ovselection.cc \ src/OverlayUnidraw/ovspline.cc src/OverlayUnidraw/ovstates.cc \ src/OverlayUnidraw/ovstencil.cc src/OverlayUnidraw/ovtext.cc \ src/OverlayUnidraw/ovunidraw.cc src/OverlayUnidraw/ovvars.cc \ src/OverlayUnidraw/ovvertices.cc src/OverlayUnidraw/ovviewer.cc \ src/OverlayUnidraw/ovviews.cc src/OverlayUnidraw/ptinpoly.cc \ src/OverlayUnidraw/rastercmds.cc src/OverlayUnidraw/scriptview.cc \ src/OverlayUnidraw/textfile.cc src/OverlayUnidraw/annotate.cc if HAVE_LIBCLIPPOLY libOverlayUnidraw_la_SOURCES += src/OverlayUnidraw/cliplinepoly.cc \ src/OverlayUnidraw/clippoly.cc src/OverlayUnidraw/ovclip.cc endif libOverlayUnidraw_la_CPPFLAGS = \ -Dcplusplus_2_1 $(ACE_CPPFLAGS) $(IV2_6_INCLUDES) libOverlayUnidrawPART1_la_SOURCES = src/OverlayUnidraw/grloctool.cc \ src/OverlayUnidraw/ovabout.cc src/OverlayUnidraw/ovcamcmds.cc \ src/OverlayUnidraw/ovchainview.cc src/OverlayUnidraw/ovcmds.cc \ src/OverlayUnidraw/ovctrl.cc src/OverlayUnidraw/ovexport.cc \ src/OverlayUnidraw/ovfixview.cc src/OverlayUnidraw/ovgdialog.cc \ src/OverlayUnidraw/ovimport.cc src/OverlayUnidraw/ovipcmds.cc \ src/OverlayUnidraw/ovkit.cc src/OverlayUnidraw/ovprint.cc \ src/OverlayUnidraw/ovshowhide.cc src/OverlayUnidraw/setattrbyexpr.cc \ src/OverlayUnidraw/slctbyattr.cc libOverlayUnidrawPART1_la_CPPFLAGS = \ -Dcplusplus_2_1 -Div2_6_incompatible $(ACE_CPPFLAGS) \ -Isrc/OverlayUnidraw -Isrc/include $(IV2_6_INCLUDES) libOverlayUnidrawPART2_la_SOURCES = src/OverlayUnidraw/aceimport.cc libOverlayUnidrawPART2_la_CPPFLAGS = \ -Dcplusplus_2_1 -Div2_6_incompatible -Isrc/include \ $(ACE_INLINE_CPPFLAGS) $(IV2_6_INCLUDES) if HAVE_LIBCLIPPOLY libOverlayUnidraw_la_CPPFLAGS += -DCLIPPOLY -I/usr/include/clippoly libOverlayUnidrawPART1_la_CPPFLAGS += -DCLIPPOLY -I/usr/include/clippoly libOverlayUnidrawPART2_la_CPPFLAGS += -DCLIPPOLY -I/usr/include/clippoly endif ### libAceDispatch libAceDispatch_la_SOURCES = src/AceDispatch/ace_dispatcher.cc \ src/AceDispatch/ace_iohandler.cc libAceDispatch_la_CPPFLAGS = \ -Dcplusplus_2_1 $(ACE_CPPFLAGS) $(IVSTD_INCLUDES) ### libAttribute libAttribute_la_SOURCES = src/Attribute/alist.cc \ src/Attribute/aliterator.cc src/Attribute/attribute.cc \ src/Attribute/attrlist.cc src/Attribute/attrvalue.cc \ src/Attribute/commodule.cc src/Attribute/lexscan.cc \ src/Attribute/paramlist.cc libAttribute_la_CPPFLAGS = \ -Dcplusplus_2_1 $(IVSTD_INCLUDES) ### libTIFF if HAVE_LIBTIFF # use external tiff library TIFF_LOC_CPPFLAG = -DEXTERN_TIFF else # build internal tiff library lib_LTLIBRARIES += libTIFF.la TIFF_LOC_CPPFLAG = endif libTIFF_la_SOURCES = src/TIFF/tif_aux.c src/TIFF/tif_ccittrle.c \ src/TIFF/tif_close.c src/TIFF/tif_compat.c src/TIFF/tif_compress.c \ src/TIFF/tif_dir.c src/TIFF/tif_dirinfo.c src/TIFF/tif_dirread.c \ src/TIFF/tif_dirwrite.c src/TIFF/tif_dumpmode.c src/TIFF/tif_error.c \ src/TIFF/tif_fax3.c src/TIFF/tif_fax4.c src/TIFF/tif_flush.c \ src/TIFF/tif_getimage.c src/TIFF/tif_jpeg.c src/TIFF/tif_lzw.c \ src/TIFF/tif_next.c src/TIFF/tif_open.c src/TIFF/tif_packbits.c \ src/TIFF/tif_print.c src/TIFF/tif_read.c src/TIFF/tif_strip.c \ src/TIFF/tif_swab.c src/TIFF/tif_thunder.c src/TIFF/tif_tile.c \ src/TIFF/tif_version.c src/TIFF/tif_warning.c src/TIFF/tif_write.c # Not in libTIFF: # src/TIFF/mkg3states.c src/TIFF/mkspans.c # src/TIFF/tif_machdep.c libTIFF_la_CPPFLAGS = -Isrc/TIFF -Isrc/include/TIFF -Isrc/include tif_fax3.$(OBJEXT) : g3states.h .libs/libTIFF_la-tif_fax3.lo: g3states.h g3states.h: mkg3states ./mkg3states > $@ mkg3states: src/TIFF/mkg3states.c $(CC) -o $@ $< ### libACE Support if HAVE_LIBACE ACE_CPPFLAGS = -DHAVE_ACE ACE_INLINE_CPPFLAGS = -D__ACE_INLINE__ $(ACE_CPPFLAGS) else ACE_CPPFLAGS = ACE_INLINE_CPPFLAGS = endif ### Support files pkgdata_DATA = src/ComUtil/comterp.err Idemo InterViews Idemo: src/idemo/Idemo.defaults cp $< $@ InterViews: src/IV/InterViews.defaults cp $< $@ ### binaries bin_SCRIPTS = ivgetjpg ivtiftopnm pnmtopgm ivgetjpg: src/scripts/ivgetjpg.bash cp $< $@ chmod a+x $@ ivtiftopnm: src/scripts/ivtiftopnm.bash cp $< $@ chmod a+x $@ pnmtopgm: src/scripts/pnmtopgm.sh cp $< $@ chmod a+x $@ bin_PROGRAMS = comdraw comterp comtest dclock drawserv drawtool \ flipbook gclock glyphterp graphdraw iclass idemo idraw ivtext ivtmpnam \ stdcmapppm comdraw_SOURCES = src/comdraw/main.cc comterp_SOURCES = src/comterp_/main.cc comtest_SOURCES = src/comtest/main.cc dclock_SOURCES = src/dclock/clocktime.cc src/dclock/clocktime.h \ src/dclock/data.cc src/dclock/data.h src/dclock/dclock.cc \ src/dclock/dclock.h src/dclock/dface.cc src/dclock/dface.h \ src/dclock/digit.cc src/dclock/digit.h src/dclock/segment.cc \ src/dclock/segment.h drawserv_SOURCES = src/drawserv_/main.cc drawtool_SOURCES = src/drawtool/main.cc flipbook_SOURCES = src/flipbook/main.cc gclock_SOURCES = src/glyphs/gclock/main.cc glyphterp_SOURCES = src/glyphterp/main.cc graphdraw_SOURCES = src/graphdraw/main.cc iclass_SOURCES = src/iclass/classbuffer.cc src/iclass/classbuffer.h \ src/iclass/classeditor.cc src/iclass/classeditor.h \ src/iclass/classinfo.cc src/iclass/classinfo.h src/iclass/dialogs.cc \ src/iclass/dialogs.h src/iclass/direct.cc src/iclass/direct.h \ src/iclass/globals.cc src/iclass/globals.h src/iclass/iclass.cc \ src/iclass/iclass.h src/iclass/main.cc idemo_SOURCES = src/idemo/main.cc idraw_SOURCES = src/idraw/main.cc ivtext_SOURCES = src/ivtext/main.cc ivtmpnam_SOURCES = src/utils/ivtmpnam.c # C stdcmapppm_SOURCES = src/utils/stdcmapppm.c # C AM_CPPFLAGS = -Isrc/include AM_CXXFLAGS = -Wno-write-strings -Wno-deprecated ## Giving per-object flags ensures that all the "main.o" files have ## different names. See info: (automake)Top > FAQ > Renamed Objects comdraw_CPPFLAGS = -Dcplusplus_2_1 $(ACE_INLINE_CPPFLAGS) $(IV2_6_INCLUDES) comterp_CPPFLAGS = -Dcplusplus_2_1 $(ACE_INLINE_CPPFLAGS) $(IVSTD_INCLUDES) comtest_CPPFLAGS = -Dcplusplus_2_1 $(ACE_CPPFLAGS) $(IVSTD_INCLUDES) dclock_CPPFLAGS = -Dcplusplus_2_1 $(IV2_6_INCLUDES) drawserv_CPPFLAGS = -Dcplusplus_2_1 $(ACE_INLINE_CPPFLAGS) $(IV2_6_INCLUDES) drawtool_CPPFLAGS = -Dcplusplus_2_1 $(ACE_INLINE_CPPFLAGS) $(IV2_6_INCLUDES) flipbook_CPPFLAGS = -Dcplusplus_2_1 $(ACE_CPPFLAGS) $(IV2_6_INCLUDES) gclock_CPPFLAGS = -Dcplusplus_2_1 -Isrc/glyphs $(IVSTD_INCLUDES) glyphterp_CPPFLAGS = -Dcplusplus_2_1 $(ACE_CPPFLAGS) $(IVSTD_INCLUDES) graphdraw_CPPFLAGS = -Dcplusplus_2_1 $(ACE_CPPFLAGS) $(IV2_6_INCLUDES) iclass_CPPFLAGS = -Dcplusplus_2_1 $(IV2_6_INCLUDES) idemo_CPPFLAGS = -Dcplusplus_2_1 $(IVSTD_INCLUDES) idraw_CPPFLAGS = -Dcplusplus_2_1 $(IV2_6_INCLUDES) ivtext_CPPFLAGS = -Dcplusplus_2_1 $(IVSTD_INCLUDES) ivtmpnam_CPPFLAGS = stdcmapppm_CPPFLAGS = # AM_LDFLAGS = comdraw_LDADD = libComUnidraw.la libComTerp.la libOverlayUnidraw.la libUnidraw.la $(ACEDISPATCH_LA) libIV.la $(ACE_LD) comterp_LDADD = libComTerp.la libTopoFace.la libUnidraw.la $(ACE_LD) comtest_LDADD = libAttribute.la libComTerp.la libComUtil.la dclock_LDADD = libIV.la drawserv_LDADD = libDrawServ.la libFrameUnidraw.la libGraphUnidraw.la libOverlayUnidraw.la libComUnidraw.la libUnidraw.la libComTerp.la $(ACEDISPATCH_LA) libIV.la $(ACE_LD) drawtool_LDADD = libAceDispatch.la libOverlayUnidraw.la libUnidraw.la libComTerp.la libIV.la $(ACE_LD) flipbook_LDADD = libFrameUnidraw.la libComUnidraw.la libOverlayUnidraw.la libUnidraw.la libComTerp.la $(ACEDISPATCH_LA) libIV.la $(ACE_LD) gclock_LDADD = libTime.la libIV.la glyphterp_LDADD= libIVGlyph.la libComGlyph.la libIV.la graphdraw_LDADD= libGraphUnidraw.la libComUnidraw.la libAceDispatch.la libComTerp.la libOverlayUnidraw.la libUnidraw.la libIV.la $(ACE_LD) iclass_LDADD = libIV.la idemo_LDADD = libIV.la idraw_LDADD = libUniIdraw.la libUnidraw.la ivtext_LDADD = libIVGlyph.la libIV.la ivtmpnam_LDADD = stdcmapppm_LDADD= ### directories to recurse into, for installation of include files SUBDIRS = src src/include ### man pages to install man_MANS = src/man/man1/drawtool.1 src/man/man1/iclass.1 \ src/man/man1/idraw.1 src/man/man1/comterp.1 src/man/man1/flipbook.1 \ src/man/man1/comdraw.1 src/man/man1/dclock.1 src/man/man1/graphdraw.1 \ src/man/man3/UArray.3 src/man/man3/RotateTool.3 \ src/man/man3/TextDisplay.3 src/man/man3/Banner.3 \ src/man/man3/TextComp.3 src/man/man3/ULabel.3 src/man/man3/Iterator.3 \ src/man/man3/KeyMap.3 src/man/man3/Dispatcher.3 \ src/man/man3/UHashTable.3 src/man/man3/GraphicView.3 \ src/man/man3/BasicDialog.3 src/man/man3/SlotComp.3 \ src/man/man3/ImportCmd.3 src/man/man3/UMap.3 src/man/man3/Scroller.3 \ src/man/man3/RpcService.3 src/man/man3/ScaleTool.3 \ src/man/man3/Message.3 src/man/man3/IOCallback.3 \ src/man/man3/PatternCmd.3 src/man/man3/Path.3 \ src/man/man3/ExternView.3 src/man/man3/ReqErr.3 src/man/man3/RpcHdr.3 \ src/man/man3/Tool.3 src/man/man3/lines.3 src/man/man3/Interactor.3 \ src/man/man3/FileChooser.3 src/man/man3/manips.3 \ src/man/man3/statevars.3 src/man/man3/EditorInfo.3 \ src/man/man3/CGlue.3 src/man/man3/align.3 src/man/man3/ellipses.3 \ src/man/man3/Editor.3 src/man/man3/UList.3 src/man/man3/Pattern.3 \ src/man/man3/iostreamb.3 src/man/man3/uctrls.3 \ src/man/man3/GraphicCompTool.3 src/man/man3/Command.3 \ src/man/man3/LinkComp.3 src/man/man3/splines.3 \ src/man/man3/SplineComp.3 src/man/man3/ComponentView.3 \ src/man/man3/MatchEditor.3 src/man/man3/pspaint.3 \ src/man/man3/rpcstream.3 src/man/man3/datas.3 src/man/man3/RpcReader.3 \ src/man/man3/Scene.3 src/man/man3/GraphicComp.3 \ src/man/man3/StretchTool.3 src/man/man3/Resource.3 \ src/man/man3/LineComp.3 src/man/man3/classes.3 src/man/man3/Tray.3 \ src/man/man3/Viewer.3 src/man/man3/Graphic.3 \ src/man/man3/MagnifyTool.3 src/man/man3/SelectTool.3 \ src/man/man3/CompletionEditor.3 src/man/man3/Painter.3 \ src/man/man3/TransferFunct.3 src/man/man3/Component.3 \ src/man/man3/Selection.3 src/man/man3/Frame.3 \ src/man/man3/Perspective.3 src/man/man3/viewcmds.3 \ src/man/man3/UnidrawIntro.3 src/man/man3/RpcRegistry.3 \ src/man/man3/Unidraw.3 src/man/man3/Page.3 src/man/man3/Viewport.3 \ src/man/man3/Vertices.3 src/man/man3/Regexp.3 src/man/man3/Clipboard.3 \ src/man/man3/Panner.3 src/man/man3/Picture.3 src/man/man3/transfns.3 \ src/man/man3/Damage.3 src/man/man3/StringEditor.3 \ src/man/man3/RpcWriter.3 src/man/man3/GraphicBlock.3 \ src/man/man3/GVUpdater.3 src/man/man3/RasterComp.3 \ src/man/man3/polygons.3 src/man/man3/stateviews.3 \ src/man/man3/Connector.3 src/man/man3/UControl.3 \ src/man/man3/Menu2_6.3 src/man/man3/World.3 src/man/man3/BrushCmd.3 \ src/man/man3/globals.3 src/man/man3/StrBrowser.3 src/man/man3/NOPCmd.3 \ src/man/man3/PolygonComp.3 src/man/man3/IOHandler.3 \ src/man/man3/Catalog.3 src/man/man3/RpcPeer.3 \ src/man/man3/EllipseComp.3 src/man/man3/UStencil.3 \ src/man/man3/StateVarView.3 src/man/man3/Dialog.3 \ src/man/man3/VerticesComp.3 src/man/man3/TextEditor.3 \ src/man/man3/kybd.3 src/man/man3/ConnectTool.3 src/man/man3/rpcbuf.3 \ src/man/man3/MacroCmd.3 src/man/man3/geomobjs.3 src/man/man3/struct.3 \ src/man/man3/edit.3 src/man/man3/RasterRect.3 src/man/man3/Control.3 \ src/man/man3/RectComp.3 src/man/man3/Border.3 src/man/man3/Shape.3 \ src/man/man3/PostScriptView.3 src/man/man3/FontCmd.3 \ src/man/man3/PinComp.3 src/man/man3/ColorCmd.3 src/man/man3/PadComp.3 \ src/man/man3/StrChooser.3 src/man/man3/Subject.3 \ src/man/man3/MoveTool.3 src/man/man3/ControlInfo.3 \ src/man/man3/catcmds.3 src/man/man3/Sensor.3 src/man/man3/Data.3 \ src/man/man3/Button2_6.3 src/man/man3/CSolver.3 src/man/man3/Creator.3 \ src/man/man3/ReshapeTool.3 src/man/man3/TextBuffer.3 \ src/man/man3/Grid.3 src/man/man3/StencilComp.3 src/man/man3/StateVar.3 \ src/man/man3/Box2_6.3 src/man/man3/Deck2_6.3 src/man/man3/Glue2_6.3 \ src/man/man3/Rubband.3 src/man/man3/Manipulator.3 \ src/man/man3/transforms.3 src/man/man3/FileBrowser.3 \ src/man/man3/Adjuster.3 ### other documentation if PS2PDF doc_DATA = refman.pdf refman.pdf: src/man/refman3.1/refman.PS $(ps2pdf) $< $@ else doc_DATA = src/man/refman3.1/refman.PS endif ivtools-1.2.11a1/README000066400000000000000000000432741214471147700144170ustar00rootroot00000000000000 README for ivtools 1.2 This directory contains a release of ivtools 1.2.11. You should read the rest of this file for information on what ivtools is and the INSTALL file for instructions on how to build it. The overall copyright and permission notice for ivtools can be found in the COPYRIGHT file in this directory. It is similar to the X11 copyright, otherwise known as non-copylefted freeware. * What is ivtools?: Online documentation (including an FAQ) is available for ivtools at: http://www.ivtools.org/ivtools/doc/ ivtools is a layered collection of application frameworks for building custom drawing editors and spatial data servers. It incorporates a backward compatible copy of the original InterViews and Unidraw class libraries and sample programs (from 3.2a.tar.Z), augmented with new class libraries and sample programs for a wide variety of generic spatial data applications. ivtools comprises four sets of interrelated capabilities useful to application programmers. The first set is the libraries and example programs borrowed whole from InterViews 3.1. The second set is for reusing and extending the light-weight glyph objects of InterViews 3.1 which embody a lot of the capability of TeX. The third set reuses and extends the Unidraw library (Unidraw is a major portion of the overall InterViews 3.1 release that provides an application framework for custom drawing editors). The fourth set adds a command interpreter and server mechanism to ivtools, and demonstrates these capabilities with text, glyph, and graphic front-ends. To get more of an overview of these layers you can read: http://www.ivtools.org/ivtools/ivtools-layers.html. These are the libraries and example programs borrowed straight from InterViews 3.1: IV library of InterView 3.1, InterViews 2.6, Dispatch, OS, and TIFF objects dclock digital clock with fading digits iclass C++ class browser idemo glyph demo These are the libraries and example programs that make up the glyph part of ivtools (programs in the glyphs directory): IVGlyph library of Glyph derived classes bdvtable bounded-value editing formdemo value-editing gclock glyph-based clock meter sliding meter radiogroup radio-buttons scrollable 2d scrollable glyph scrollfield 2d scrollable field-editor strchooser string chooser timestamp editable time glyph Plus a generally useful text display and editing program: ivtext emacs-like text editor Also all the glyph example programs from InterViews 3.1 have been added in an examples3.1 directory under the glyphs directory. These are the libraries and example programs that make up the Unidraw part of ivtools: Unidraw copy of Unidraw library from InterViews 3.1 UniIdraw librarification of 3.1 idraw OverlayUnidraw extended Unidraw/idraw framework TopoFace spatial network library (nodes, edges, faces) GraphUnidraw graph browser/editor library FrameUnidraw multi-frame display mechanism idraw idraw built on UniIdraw library drawtool extended version of idraw built on OverlayUnidraw graphdraw graph browser/editor integrated with drawtool flipbook flipbook multi-frame editor based on drawtool These are the libraries that make up the command interpreter part of ivtools: ComUtil command interpreter utility functions Attribute attribute property list mechanism AttrGlyph glyphs for Attribute library ComTerp command interpreter objects ComGlyph glyphs for ComTerp library ComUnidraw drawing editor with command interpreter DrawServ drawing server framework with support for graphs and frames. comtest test program comterp sample command interpreter glyphterp command interpreter user interface comdraw drawtool with command interpreter drawserv comdraw with both graphs and frames. Note: GraphUnidraw/graphdraw and FrameUnidraw/flipbook have been rearranged within the ivtools source tree to take advantage of the ComUnidraw framework layer, so they really could be listed in both of the previous sections. There is also a Time library with Date and Time classes borrowed from the NIH's class library, and an example program, ivxt, that shows how an Xt widget can be wrapped around an InterViews application. Finally, there is a collection of utilities (utils) and shell scripts (scripts) that augment the drawing editors of ivtools with minor capabilities. See the relevant directories and files for further information. A series of makefile targets support the checkin of sources to cvs/rcs, and their subsequent update and modification. This requires a copy of cvs available from the Free Software Foundation and ivmkcm-0.7.2 available through http://www.ivtools.org/ivmkcm/ * More ivtools details ivtools is known to build with many versions of gcc (up to gcc-4.3) and on a variety of Unix'es: SunOS 4.1 (MIT's X11R5), Solaris 2.6 (X11R6), Irix 5.2 (SGI's X11R5), Linux 1.2 (Slackware 3.0, XFree86 3.1), Linux 2.* (RedHat 4.0 thru 7.0, Debian 2.* and 3.*), NetBSD, FreeBSD, and Darwin (Mac OS X). There are contributed configs that are out of date for HPUX and Dec Alpha (though the HPUX contrib might almost have it right). It has been built on Windows NT 4.0 using Cygwin from Cygnus Solutions (see README.cygwin). You can find links to available binaries on the ivtools web page (http://www.ivtools.org) and ivtools download page (http://www.ivtools.org/ivtools/download.html) If you have a question about this software, desire to add code, found a bug, want to request a feature, or wonder how to get further assistance, please send e-mail to the general purpose ivtools mailing list, ivtools-user@lists.sourceforge.net. To subcribe to the mailing list, visit http://lists.sourceforge.net/mailman/listinfo/ivtools-user. Other ivtools related mailing lists can be found at: http://www.ivtools.org/ivtools/mailinglists.html Read about finding and generating all this from inline documentation below. A copy of the ivtools html documentation will be available for download as well: http://downloads.sourceforge.net/ivtools/ivtools-doc-1.2.tgz A SourceForge project page for ivtools can be found at: http://sourceforge.net/project/ivtools Read about other vector graphic free software at: http://sourceforge.net/foundry/vectorgraphics * Finding and Generating Inline Documentation Extensive documentation is embedded within the ivtools source tree, including most all of the documentation originally available for InterViews 3.1 and Unidraw. You can find all of it pre-extracted here: http://www.ivtools.org/ivtools/doc/ Here is a list of documentation: - README/man pages for executable programs Within most directories that contain an executable program (a main.c) you'll find a README that explains something about the program, how to use it, what it does, what arguments it takes. In the case of the drawing editors and command interpreters this README has been further processed into a man page, which can be found in its uninstalled state in the src/man/man1 directory or wherever you elect to install them. - HTML class documentation Many of the C++ class libraries of ivtools are documented using comments in the header files (the .h files) that can be extracted using PERCEPS, a Perl documentation generator for C++ (http://starship.python.net/crew/tbryan/PERCEPS/). See src/html/README for instructions on auto-generating these web pages yourself, or see the result on-line at: http://www.ivtools.org/ivtools/doc/classes/ - InterViews 3.1 and Unidraw man pages All the original man pages from InterViews 3.1 and Unidraw have been preserved, and can be found in src/man/man3, or where ever you elect to install them. They also can be browsed online at: http://www.ivtools.org/ivtools/doc/man3.1/ - InterViews 3.1 reference manual The original reference manual for InterViews 3.1 can be found in PostScript form at src/man/refman3.1/refman.PS. It is also found in page-indexable online form at: http://www.ivtools.org/ivtools/doc/refman3.1/ * Building on top of ivtools Copied from the ivtools FAQ: http://www.ivtools.org/ivtools/faq.html#standalonedevel Q: How do I set up a stand-alone program or source tree on top of ivtools for development purposes? A: If you are writing a stand-alone program that will exist in a single directory, simply copy an appropriate Imakefile and main.c from a InterViews or ivtools example program directory, modify accordingly, then use "ivmkmf -a" to generate the Makefile. Make sure you are using a fresh ivmkmf that corresponds to your installation of ivtools. An example of this is the comtop sample program, a stand-alone program separate from ivtools that builds on top of the comterp command interpreter mechanism. ** comtop.tgz is now part of the ivtools distribution ** If you are setting up an entire source tree with both class libraries and executable programs, you will want to get started by replicating an equivalent source tree (i.e. vhclmaps) and change or rename all directories or files as appropriate. ** read more on vhclmaps at http://www.ivtools.org/vhclmaps/ ** * Acknowledgements: Roster of ivtools programmers: Scott Johnston Jorge Gautier Brian Hogencamp Rick Kissh Eric Kahler InterViews 3.1 programmers that we know of: Mark Linton John Vlissides Paul Calder John Interrante Scott Stanton Steven Tang ivtools can be built to leverage a variety of separate third-party libraries: * clippoly from Klamer Schutte for polygon intersection (licensed under the LGPL) * ACE from Doug Schmidt for middleware networking frameworks (licensed similar to X Windows) * IUE (the Image Understanding Environment) from Amerinex (half public-domain, half licensed similar to X Windows) ivtools detects and uses at runtime a variety of third-party executables: * qhull from the University of Minnesota Geometry Center * pstoedit from Wolfgang Glunz * ghostscript from L. Peter Deutsch and Aladdin Systems * djpeg from the JPEG group * giftopnm from Jef Poskanzer's pbmplus toolkit (a copy of anytopnm from the same toolkit is incorporated into the scripts directory) OverlayUnidraw incorporates Version 3.1 of a "C++ Vector and Matrix Algebra routnes" (algebra3.h) from Jean-Francois Doue. HPUX (HP-800) config contributed by Neal Becker. ALPHA config contributed by Bruno Delfosse at Thomson CSF. A lot of feedback on Solaris 2.6 building from M. Rasit Eskicioglu at the University of Alberta. NetBSD port and other assistance from Todd Gruhn. Cygwin development environment for Windows NT from RedHat (Cygnus Solutions). Patches to iv-3.2a incorporated from the PDP++ distribution from Carnegie Mellon University Department of Psychiatry, Randall C. O'Reilly, et. al. Patches for Debian 2.0 packaging incorporated from Guenter Geiger. This work included the conversion of drawtool, flipbook, and graphdraw README's to man page format. Patch for iv-3.1 shift key handling from Doug Scott, the author of MiXViews. Certain InterViews libraries (Dispatch, IV, IV-2_6, IV-X11, InterViews, OS, TIFF, Unidraw) and example programs (iclass, idemo, idraw) are copied from the InterViews 3.1 sources. Here is the aggregrate copyright notice for that software package: /* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ The building of Unidraw with gcc-2.5.* (and subsequent versions) was enabled by a patch from Adam Zell. The TIFF library was written by Sam Leffler and published with this copyright and permission notice: /* * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ The strchooser example and StrChooser class were contributed by David B. Hollenbeck, as well as the glyph-based Motif-look pull-down menus of OverlayUnidraw. Here is his copyright notice: /* * Copyright (c) 1993 David B. Hollenbeck * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notice and this permission notice appear in * all copies of the software and related documentation, and (ii) the name of * David B. Hollenbeck may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of David B. Hollenbeck. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL DAVID B. HOLLENBECK BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ The scrollable example is based on code from Chen Wang The text-editor example program is by Jan Andersson of Torpa Konsult AB. Here is that copyright notice: // // Simple Text Editor // // // Copyright (C) 1993 Ellemtel Telecommunication Systems Labratories // // Permission is granted to any individual or institution to use, copy, // modify, and distribute this software, provided that this complete // copyright and permission notice is maintained, intact, in all copies // and supporting documentation. // // Ellemtel Telecommunication Systems Labratories make no representation // of the suitability of this software for any purpose. It is provided // "as is" without any expressed or implied warranty. // // Jan Andersson, Torpa Konsult AB // janne at torpa.se - 1993-08-29 The Date and Time classes in the Time library are borrowed from the NIHCL class library, written by K. E. Gorlen, Computer Sciences Laboratory, DCRT, National Institutes of Health, Bethesda, MD 20892, and published with this notice: THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A "UNITED STATES GOVERNMENT WORK". IT WAS WRITTEN AS A PART OF THE AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE. THIS MEANS IT CANNOT BE COPYRIGHTED. THIS SOFTWARE IS FREELY AVAILABLE TO THE PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY. The graylevel raster and painting mechanisms of OverlayUnidraw were originated by Richard B. Kissh under contract to Vectaport Inc, as well as the shared memory rasters and asychronous incremental download of rasters. The ComUtil library was originally developed at Triple Vision Inc. under NSF Grant ISI-8521259 (authors/contributors: Robert C. Fitch, Richard A. Fundakowski, Robert K. Graber, Scott E. Johnston). The ivdl URL downloading utility was developed by Eric F. Kahler under contract to Vectaport Inc. Keung Chi Ng of IET Inc. has provided a good deal of feedback on ivtools over the years, and has assisted in demonstrating the viability of the application frameworks by developing a variety of vertical applications on top of OverlayUnidraw, FrameUnidraw, and GraphUnidraw. The balance of ivtools has been developed by Vectaport Inc. (P.O. Box 7141, Redwood City, CA 94063), with additional support from IET Inc. (P.O. Box 112450, Campbell, CA 95011) in the form of ARPA subcontracts (DACA76-93-C-0025 and DACA76-97-C-0005), as well as directly employing Scott Johnston from April 1999 thru August 2000 and giving him the freedom to evolve ivtools and related open-source frameworks as part of his job. There was also support from Applied Sciences Inc, San Francisco, CA, in the form of a subcontract for a Phase II SBIR from NASA Ames. ivtools-1.2.11a1/README.cygwin000066400000000000000000000041241214471147700157050ustar00rootroot00000000000000Steps to building ivtools on Windows NT using Cygwin and X11R6.4: 1. Download and install Cygwin from: http://sourceware.cygnus.com/cygwin/ Use "less" for more. Use "type" for "which". Make a \bin (/bin) if necessary, and place a copy of sh.exe from the Cygwin distribrution there. Now you can launch a window with a bash shell by using the cygnus.bat provided with Cygwin. There is a very useful FAQ for Cygwin you may want to look at as well: http://sourceware.cygnus.com/cygwin/faq/ 2. Download and install Xlib binaries for X11R6.4 from: http://dao.gsfc.nasa.gov/software/grads/win32/X11R6.4/ Unpack in /usr (\usr) using the cygwin tar. Modify the cygnus.bat that came with Cygwin to include the directory /usr/X11R6.4/bin in the PATH environment variable. 3. (optional) Download and install an emacs binary (for Windows NT) from www.fsf.org. 4. Download ivtools-1.0.tgz or later: http://www.ivtools.org/pub/src/ivtools-1.0.tgz In a cygwin/bash window: tar xvfz ivtools-1.0.tgz # unpack and move to top directory cd ivtools-1.0 ./configure # configure for CYGWIN environment make World # make Makefile/Makefiles/depend/-k make install # may have trouble if directories # don't pre-exist. You can ignore # some of the error messages. At this point you should be able to verify that compiling and linking worked by executing the test program for the interpreter portion of ivtools: ivtools-1.0/src/comterp_/CYGWIN/a.out Type help to see information on available commands. 5. (optional) Then type these commands if you want a few extra small utilities that are used for over the network drawing editor import. They need to be built and installed by hand with the current Makefile setup. cd src/utils # workaround for a Makefile incompatibility make ivtmpnam;cd CYGWIN; install -c -m 755 ivtmpnam.exe /usr/local/bin make stdcmapppm;cd CYGWIN; install -c -m 755 stdcmapppm.exe /usr/local/bin 6. acquire an X server for Windows NT, and try things out. September 1999, Vectaport Inc. (instructions not actually verified for 1.0, let me know if they work) ivtools-1.2.11a1/README.ivmkcm000066400000000000000000000031711214471147700156740ustar00rootroot00000000000000ivmkcm is a set of Perl scripts that use CVS to manage source tree directories. The Makefile hierarchy of ivtools contains built-in targets described below that facilitate the hierarchical use of ivmkcm. You can acquire ivmkcm from http://www.ivtools.org/ivmkcm/. It is licensed under the GPL. This file documents the Makefile targets associated with ivmkcm, and gives information on how to use them. For further information on ivmkcm see the man pages that come in the tar file as well as on-line. make cmchkin Create a cm repository under the top-level directory (if none exists) and check in this directory and each sub-directory as its own package. The package name is defined by a PACKAGE makefile variable in the Imakefile. See the cmchkin man page for further details. make cmadd Add any new files in this directory (and each sub-directory) to the repository. The list of supported RepositoryFiles is defined in config/params.def and can be extended in config/local.def. See the cmadd man page for further details. make cmupdate Check the status of this directory (and each sub-directory) relative to the repository. See the cmupdate man page for further details. make cmcommit [CMMSG=message] [CMFLAGS=-q] Commit the changes in any files in this directory (and each sub-directory) to the repository. Creates a numbered commit file under cm/Patches in a directory of the same name. These files can be concatenated together to create external patches. See the cmcommit man page for further details. make cmtag CMARGS=tag Tag the repository files associated with this directory (and each sub-directory) with an arbitrary symbol. ivtools-1.2.11a1/VERSION000066400000000000000000000000171214471147700145730ustar00rootroot00000000000000Release 1.2.11 ivtools-1.2.11a1/autogen.sh000077500000000000000000000005541214471147700155320ustar00rootroot00000000000000#!/bin/sh set -e ## option --foreign engaged so these files are no longer mandatory # for f in NEWS AUTHORS ChangeLog; do # test -e "$f" || cp --verbose /dev/null "$f" # done mkdir --parent --verbose m4 autoreconf --install --symlink ## Use --force to recreate things that don't seem to require recreation: # autoreconf --install --symlink --make --force ivtools-1.2.11a1/comtop.tgz000066400000000000000000000075471214471147700155710ustar00rootroot00000000000000‹â1Ó6íksâFr¿¢_ÑÇæ*ÂÁ˜ÇÚ¾àØW,[ o¶.W”†E1HD0·•ÿ~Ý3#!lvÝË>înºRkI3ÓÝÓ=ÓÓ!¶¿ˆüåQ³wóºo^^ Ÿ}¨”Ë''/àœ>øKP­•«'Çǵµr¥ò R+ŸVŸAùÙg€8Œ¬àÙ¯þÌ #ß{W?ì6>ûŸƒ£  é/7ûfn òý÷¸evd-ý Ó³KØ‹:Þ°`ᆡë{ù‡¬6Ž-ÂÂwÜ)þuÜ0 ÜIa‹å9²ù¢™BèO£µ0þÙBB°¹1ߎÌ‹¬ˆ0SÇŠ,˜ºsÂÔðÓ–q°ôCˆkÆ6ÙÀ›Àòp8aZ»ÑÌ#˜2$¼ ü•ë ÞhfEøÒœø+ÆYÓôüȵñórÉPû.ÒD6±Ùeœ/â€øÑL<=Ëû 3Ë­L¢%\a¼$)ºÞ›Ýi·TˆCÏZà\ý)Ù›ùs‡!a&dFBw8ÇΊ!Ú£„–ñdîÚn´!~"Ëõè;ê(Uñ'Ðs®m$‚ —Ìv§®]„uàFóPŠ.áMgWîãÐ-¬;œ‚ ],L¦’Üc1¿0v#kâΉCÎFvIH&©e$fF¤êT—y+Ä÷|Ê0»'R!ÍÝ],ç.vA\´"6Éj^Z6¸êuZF-sÐì4Ìkht:ðªÑï7ºCÓÀ+sx}ã²ÑoÁ°‡ƒÍ zí!v1Š„Îì6;£–Ù½ä#Í뛎i´²zm¸6úÍ+|m¼4;æð54º-h›Ã®1”èöÀ¸5ºC\žýL¾4 c6^v h÷úˆå5 nŒ¦ÙèHNZfßhÛš½îÀøi„±ZëÆ%±"%¯¯®ÃAÉöq†ƒQgˆ³ Dí~ï:½ç}40Š8bØ Ñ7ýò=(âPYìç ü¯94{]êt‡}|å uËŽyit›íñÃ^ûŽrL}s@Ò놄 Çq"š®Á;®’ò¹0ú8ÿëGÜÞÕ ÉóHÓž)øÀç¿I˜Ìí8ÿ+Õ*ÿØå¤V®ÕŽéüQUçÿgŸ›½ëkÿ b- aµÐž2²¼xÀ.D£¦Ý4š?¢-sÙOÓž»S‡MÑ=èM~Eg¡é;¬åšÖ¸¹7›VÇ|9Àî¹ot|B$C£SþÖûæËÑÐïØ:šù6êš­~ãÑíuå7óV¾Y¸²ÂÖL×Ìðq:î$°:½ñ–q#©£ãs†8¾í­ q|{D¿eˆ3[8N§m¢mçtMcû¥v§ÆNŸäÓ¶S*¬¤‹øPдfs0j·ÍŸIB6ž»ýžàÖeëP§>>)ìþF(lhoX¤ -aë5nm¡¡và/Ýž[oBÝcëiìÙÅÃ{û»ï ïé5C?e΂':.ÐåHºhè1Îc\ l‰âbžŠ!>Ÿ³yÈChå¢U6ù ØQçÿ—¬ÿi‰nk@Ťô¸ë‹CüçxO×OP/Ú­=YÚ_"DSÚS"TUÊT…Íëƒ CÙª¯^}teh+ôlMíãKC⬠\jCXÊÔ…xäÿ¦6ôú=¥ lˆïÍ-=®º/íÖÇç,=wEÚò©³Ÿßý˜:ðymÛðºDC<®“c›<·Òì"Ío_5nq£idFX6;ôš?Ž›¾çñ¸‰Ï d÷.©òýõB}bŽìí`H•—:î÷{}$5õ» ëkñEä4ˆ£|V‘džÈ—Hô8î§zÄp±ne? ì ÄK g…4¸éNŠ€mXz ÒÙ¤›S¶‹½ù´lö‰F/w±‹YåøÌÞ»ÀÏÏ…„žÜ›ýž­ˆ@÷“bºTf±¹óýËG®³P®Ãt5¬g”¢ÒŸÔéá…Ž)BÕ¹vËÄúûW‘Ș¯M º½,ŠÊ©MÿýSŠö_ þ«Õ*òþ_õô¤FùßÚñiMÅ_ôþß§¼þG¨0¢SáÜSáÜŸÍý‰ÁÜÞX.üØ`î+ åIÍ©k~_ß5?WýÞàe㸕5Ùn8ó®(O–êuù ËމÏKÁ†Ìšëé§·t,¯|×t¼Ìaë<"ÿã P —£kZ (ì&®Žh¡IqGå :²‚sÇ6k?@Ó¹YLü¹D=I¼BÄ]êW¯§Yu½ °È ÒaöÜ ,Q— MRº~FÖŠ2ÛsܘèƒàÙŸB.ÄR# dâ\Ò[Ž£ç©!_8É(z'‹. LÝ{ÜŠÛ"g’ €KW“pÏ’ÏÏ9Ä(¾[҈𳢧ս\àŽÏƒÕL õx@=Ò¤CÉãGÉL­xÎkòeë4»ó“šÉx²ßb øZʲHƒô­ð·¢Ë2J® ¬ Úw"ÎYÐÙÄ«ø]×€âÈ~¸Ë-&-n‰¿¢F)Äv$ê² /߆ä×§t¸ûˆ”Çü\J-—]‰íQWlì—½Öë‡kÏœí)òC«+ %ò¬Ü,Ñéf!eƒ©£\]O$ ‘tŽ,|’û°  •Gˆ“sˆßô—ñ»\%ò¤ù#…J»é¶*•¨¾"0O‹¿ãe„q "#‚ÇÑíc\´è¶$¶¸³è¶üVŸâ7$í9ï`¸ú ?@ö~Ž«Y|{æ-·Q2ˆï†tÄŽ “Ñém£32.~€ª¥éêA¯$r­¹û¯í¢fI`×DQh´®–q8#•]ȹì~Ã8(‘674F.rÑZü ghœÕÕž‰ÿf_ þW«TdüW9©–+'üþwåTÅ*þSñŸŠÿTü§â¿4þ›Â_¤¯©å™5ž´çâ#l¿½£¾'9ŒúÄ=Ùr–¼'WÅêr›¥·¥ÞjâC]“©óHQ¸ý+7ˆbk<.LÃÁ³¶m…Û‰Äo„· 3ÎÒMÊcËù_Còz*äÍUe°B¾Ý*ËÞ•£-Ì/z­ý­c(0 3GùéëýâÑADÞñ¥è¿ã…åÏ£ÜßÏ’ßf;¸Oþ¤åJý—ûÛ[‰Ÿûþ÷)ÿýùǧ'eúýÿ‹ê±òÿ”ÿ§ü?åÿ)ÿOù{óÿ™»\¼.ðà~×¾»RÚÑÁŸ ÈöÑ´dâ9MãúA‰—Ò‹™_ èä?´·”³,/,ÇË»1z2Í|1¹©‘-NŒ) ýG/ ìùáÝçÏÿTOÒߟžÒù_©©ß}M÷¿• œå('àëHytјòÉ¥ÂñNhûUæ-û ¼p÷·pt`¦¿îói×¹ÞÊ¿ÃF49–Ç/Ê&WgýýŽEzz^lSIÉÙžI&eÉáŸÉ*¡“pŽVVÖͶÿ#´ˆ¶¤'Þeѵ¤eooJwáL$jèÖ'mn^|%9¢™\³.iT|%ñÑÝËä+ü°E'®óËífÓ¸AÍ^€–Ë\Õ¦JÛ64N¼ŽDè*¤@ (P @ (P @ (P @ (P @ |jø7<ÏÑaxivtools-1.2.11a1/configure.ac000066400000000000000000000070621214471147700160200ustar00rootroot00000000000000# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. # Header AC_PREREQ([2.67]) AC_INIT([InterViews Application Framework and Drawing Tools],[1.2.8],[johnston@vectaport.com],[ivtools],[http://www.ivtools.org]) dnl The foreign option allows the follow files to not exist: NEWS AUTHORS ChangeLog AM_INIT_AUTOMAKE([subdir-objects foreign]) AC_CONFIG_SRCDIR([src/Unidraw/path.cc]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) AC_LANG([C++]) # Checks for programs. AC_PROG_CXX AC_PROG_CC AM_PROG_CC_C_O AC_PROG_INSTALL ACLTX_PROG_PS2PDF(AC_MSG_WARN([Cannot find ps2pdf])) AM_CONDITIONAL([PS2PDF], [test x$ps2pdf != xno]) # Checks for libraries. AC_CHECK_LIB([m], [pow], [MATH_LD=-lm], AC_MSG_WARN([Cannot find math library])) AC_CHECK_LIB([X11], [XOpenDisplay], [X11_LD=-lX11], AC_MSG_ERROR([Cannot find X11 library])) AC_CHECK_LIB([Xext], [XextFindDisplay], [XEXT_LD=-lXext], AC_MSG_ERROR([Cannot find Xext library])) AC_CHECK_LIB([ACE], [ace_cleanup_destroyer], [ACE_LD=-lACE], AC_MSG_WARN([Cannot find ACE library])) AC_CHECK_LIB([tiff], [TIFFOpen], [TIFF_LD=-ltiff], AC_CHECK_LIB([TIFF], [TIFFOpen], [TIFF_LD=-lTIFF], AC_MSG_WARN([Cannot find tiff or TIFF library]))) AC_CHECK_LIB([clippoly], [clippoly_version], [CLIPPOLY_LD=-lclippoly], AC_MSG_WARN([Cannot find clippoly library])) AM_CONDITIONAL([HAVE_LIBACE], [test x${ACE_LD} != x]) AM_CONDITIONAL([HAVE_LIBTIFF], [test x${TIFF_LD} != x]) AM_CONDITIONAL([HAVE_LIBCLIPPOLY], [test x${CLIPPOLY_LD} != x]) AC_SUBST(X11_LD) AC_SUBST(XEXT_LD) AC_SUBST(ACE_LD) AC_SUBST(TIFF_LD) AC_SUBST(CLIPPOLY_LD) LT_INIT # Generated dynamic library version dnl This is not the approved way of versioning dynamic libraries dnl but we just want to generate version 1.2.8 dnl LIB_IV_VER=8:0:1 # generates 7.1.0 dnl LIB_IV_VER=2:8:2 # generates 0.2.8 dnl LIB_IV_VER=3:8:2 # generates 1.2.8 LIB_IV_VER=3:8:2 AC_SUBST(LIB_IV_VER) # Checks for header files. AC_PATH_X AC_PATH_XTRA AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h inttypes.h malloc.h \ memory.h netdb.h netinet/in.h stddef.h stdlib.h string.h strings.h \ sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h \ ace/Acceptor.h ace/ACE.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_INLINE AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_UID_T AH_TEMPLATE([sig_atomic_t], [Define to int if does not define.]) AC_CHECK_TYPES([sig_atomic_t], [], [AC_DEFINE([sig_atomic_t], [int])], [ #include ]) # Checks for library functions. AC_FUNC_ERROR_AT_LINE AC_FUNC_FORK AC_FUNC_MALLOC AC_FUNC_MMAP AC_FUNC_REALLOC AC_FUNC_STRTOD AC_CHECK_FUNCS([bzero floor getcwd gethostbyname gethostname \ gettimeofday isascii memchr memmove memset munmap pow realpath \ regcomp select socket sqrt strcasecmp strchr strcspn strdup strerror \ strncasecmp strrchr strstr strtol uname hypot hypotf]) # Checks for locations AC_CHECK_FILE([/usr/share/fonts/type1/gsfonts/a010015l.afm], [PSFontDir=/usr/share/fonts/type1/gsfonts], AC_CHECK_FILE([/usr/share/ghostscript/fonts/bchr.afm], [PSFontDir=/usr/share/ghostscript/fonts], AC_CHECK_FILE([/usr/lib/ghostscript/fonts/bchr.afm], [PSFontDir=/usr/lib/ghostscript/fonts], AC_CHECK_FILE([/usr/lib/ps/bchr.afm], [PSFontDir=/usr/lib/ps], AC_CHECK_FILE([/usr/lib/X11/fonts/Type1Adobe/afm/bchr.afm], [PSFontDir=/usr/lib/X11/fonts/Type1Adobe/afm], AC_MSG_ERROR([cannot find PS Font Directory])))))) AC_SUBST(PSFontDir) # Trailer AC_CONFIG_FILES([Makefile src/Makefile src/include/Makefile]) AC_OUTPUT ivtools-1.2.11a1/m4/000077500000000000000000000000001214471147700140455ustar00rootroot00000000000000ivtools-1.2.11a1/m4/acltx_prog_ps2pdf.m4000066400000000000000000000016531214471147700177340ustar00rootroot00000000000000dnl @synopsis ACLTX_PROG_PS2PDF([ACTION-IF-NOT-FOUND]) dnl dnl This macro find a ps2pdf application and set the variable ps2pdf to dnl the name of the application or to no if not found if dnl ACTION-IF-NOT-FOUND is not specified, configure fail when then dnl application is not found. dnl dnl It is possible to set manually the program to use using ps2pdf=... dnl dnl @category LaTeX dnl @author Boretti Mathieu dnl @version 2006-07-16 dnl @license LGPL AC_DEFUN([ACLTX_PROG_PS2PDF],[ AC_ARG_VAR(ps2pdf,[specify default ps2pdf application]) if test "$ac_cv_env_ps2pdf_set" = "set" ; then AC_MSG_CHECKING([Checking for ps2pdf]) ps2pdf="$ac_cv_env_ps2pdf_value"; AC_MSG_RESULT([$ps2pdf (from parameter)]) else AC_CHECK_PROGS(ps2pdf,[ps2pdf14 ps2pdf13 ps2pdf12 ps2pdf pstopdf],no) fi if test $ps2pdf = "no" ; then ifelse($#,0,[AC_MSG_ERROR([Unable to find the ps2pdf application])], $1) fi ]) ivtools-1.2.11a1/sourceforge.102203.xml000066400000000000000000007255111214471147700173330ustar00rootroot00000000000000 201159 nobody nobody 3 Open None drawserv can Import but not Open PostScript files 948739112 Bugs drawing editor None I created a graphic called aniline2 (a chemical struct) put a box around it and did: File::Export Graphics Clicked on PostScript Clicked on Export I could read it with File::Import Graphics I then did: File::Open Highlite aniline2 and hit return Highlite aniline2 and clicked on Open Both returned the error "Open Failed" Apparently there is a discrepancy between the routines used in "File::Open" and "File::Import Graphics" 948750424 johnston The original submission, by tgruhn@users.sourceforge.net, applies to using drawserv, but not necessarily drawtool or the other ivtools drawing editors. The specialized Open command of drawserv can handle the hybrid multi-frame/graph-network files generated by drawserv, but has not incorporated the recent extensions to drawtool\'s Open command which added support for opening PostScript files. summary drawserv can't Open PostScript files 950549404 johnston priority 5 950210995 johnston category_id 100100 950056009 johnston summary Files::Open doesn't work 948750424 johnston 208442 johnston nobody 7 Open None animated stretch not right in landscape mode 962146682 Bugs drawing editor None The opaque animation of the Stretch tool has a bug when the drawing editor is in landscape mode. priority 5 964283894 johnston 207599 johnston nobody 5 Open None can't opaque-move a drawtool file with raster while loading 961196774 Bugs drawing editor None A simple raster in a drawtool file: drawtool(raster("/tmp/test.ppm")) works fine when the incremental display mechanism is enabled, but you can't do an opaque-move of it while it is loading, because there is an unitialized transformer that causes problems. For now one of these is disabled, either the incremental display on local files or the opaque-move, but I don't remember which. 207600 johnston nobody 3 Open None possible comterp deadlock using remote command 961196914 Bugs command interpreter None Start a "comterp server 7777" and "comterp server 8888", then in the one listening on port 8888 enter the following to get a deadlock: remote(localhost 7777 "remote(localhost 8888 \"1+1\")") If the remote command was restructured to wait for incoming data via the Dispatcher (Reactor) this wouldn't be a problem. priority 5 961259195 johnston 207606 johnston nobody 5 Open None fix flipbook auto-slideshow disabled by incremental download 961198122 Bugs drawing editor None When incremental download from a URL was added to ivtools (around 0.7.3) the automatic slideshow mechanism of ivtools flipbook was disabled. This needs to be restored, as well as the downloading of entire ivtools documents by URL, which was disabled at the same time, i.e.: drawtool http://www.ivtools.org/ivtools/anteaters.drs does not work like it once did. 207723 johnston nobody 5 Open None text graphic could use STL vector<char> 961378387 Bugs C++ framework None The TextGraphic object could use the STL vector template (i.e. vector<char>) to workaround its current fixed size limitation (BUFSIZ=1024?). Any other sizeable text buffer could be replaced with a vector<char> capable of growing as needed. They are mostly used for reading input form files and streams for comterp, etc.. 207728 johnston nobody 5 Open None problem handling pnm files with one-line headers 961378741 Bugs drawing editor None There is a problem reading PNM files (i.e. PBM, PGM, or PPM) that have all their header information on one line, i.e. P6 1075 824 255 The standard supports this, but ivtools implementation of the standard does not. 207729 johnston nobody 5 Open None mouse-doc doesn't revert to Alter string 961378838 Bugs drawing editor None After a multi-point graphic is altered, the mouse-doc text line is reset to the mouse-doc text for the tool to draw that graphic, instead of the Alter tool mouse-doc text. 207725 johnston nobody 5 Closed None make consistent use of new ComTerpServState 961378578 Bugs command interpreter None Make consistent use of the new ComTerpServState stack mechanism, for any of the ComTerpServ run methods. 961455249 johnston http://www.geocrawler.com/lists/3/SourceForge/650/0/3912515/ Renamed ComTerpServState to ComTerpState in the process (since there were no member variables of ComTerpServ that were saved/restored). This was done quickly with #if 0 around the old code for saving state. There could be redundant state saving going on, which is harmless but inefficient. This made more multiple calls to a "run" command work on one command line for the first time. This is one more step leading up to the complete refactoring of ComTerp and ComTerpServ, the possible collapse of these two classes into one (and renamed to ??). status_id 1 961455249 johnston close_date 0 961455249 johnston 213077 johnston nobody 5 Open None right arrow disappearing from brush menu 967587197 Bugs drawing editor None With comdraw on RedHat 6.2 built with egcs-2.91.66 (19990314 egcs-1.1.2) the right arrow disappears from the brush menu when it is highlighted. 1010692601 johnston Logged In: YES user_id=406 still the same problem with gcc-3.0.1 201603 johnston johnston 7 Open None comterp in server mode can't handle multi-line tokens 949729594 Bugs command interpreter None The comterp run-from-file command (run) can't handle expressions longer than a single line. This is because it use ComTerpServ::s_fgets as the function pointer for reading input, a method that relies on a separate action to stuff a string in the input buffer. In theory this would be ok, in that the parser would hold on to the tokens of the incomplete expression scanned so far, and return control to the rest of the system to read in a new line. This is how the commands received over a socket work. But in practice this does not work yet for the run-from-file command. 950056540 johnston After fixing the multi-line comment I realized the more general description of the bug was a problem handling multi-line tokens when comterp is in server mode. The only other multi-line token I\'m aware of that the scanner supports is character strings, which can be continued with a back-slash across lines. This makes historical sense, in that the C functions for doing parsing and scanner were designed to use a function pointer with an fgets signature to retrieve new data as needed. This works fine for processing from a file or stdin, but the idea broke down for receiving multi-line expressions over a socket connection. This is because the socket is one of several handles the Dispatcher/Reactor waits on (calls select() with). And new mouse events have to get handled inbetween lines of incoming script. So to make things work, there is a need to return all the way out of the scanner/parser routines when waiting on a new line of text from a socket. This has been mostly done, but I\'m still working on the boundary cases of multi-line tokens. 949950227 johnston I originally thought the comterp run command was having problem with multi-line expressions. But that turned out not to be true. What it was having problems with is multi-line comments, C like comments that start with a /* on one line and end with a */ on some subsequent line. This happened because the lexical scanner would never return once it started processing a comment, something it needed to do to allow another string to be read from the socket or the file. There was a check in the scanner for end-of-string that should of kicked it out, but this was never traversed when \"comment\" was the current state. This has been fixed, and the whole thing will be committed as soon as I remove another problem I\'ve encountered, that of the closing / of a comment getting falsely interpreted as an extra divide operator on the following line. assigned_to 100 950211118 johnston priority 5 950211029 johnston summary comterp in server mode can't handle multi-line comments 950056540 johnston category_id 100100 950056540 johnston summary comterp run-from-file command can't handle multi-line exprs. 949950227 johnston 200905 johnston johnston 3 Closed Fixed doubly-nested parens in post-evaluated comterp expressions 947884808 Bugs command interpreter None There is a problem with too many parens around an expression supplied as an argument to a post-evaluation comterp command (i.e. for, while, if, cond, postfix, posteval, the assignment operators,...). For example: <p> <code>posteval((1))</code> <p> works, but: <p> <code>posteval(((1)))</code> <p> does not. Normal use of paren nesting now works in post-evaluated expressions, i.e. <code>posteval((1+2)*3)</code> works. 947885028 johnston There is a problem with too many parens around an expression supplied as an argument to a post-evaluation comterp command (i.e. for, while, if, cond, postfix, posteval, the assignment operators,...). For example: posteval((1)) works, but: posteval(((1))) does not. Normal use of paren nesting now works in post-evaluated expressions, i.e.: posteval((1+2)*3) now works. status_id 100 956854840 johnston resolution_id 100 956854840 johnston close_date 0 956854840 johnston priority 5 950210961 johnston assigned_to 100 950055976 johnston category_id 100100 950055976 johnston 201942 johnston johnston 7 Closed None consistently use socklen_t* for accept() args, etc.. 950549150 Bugs config and miscellaneous None The third argument to accept() in src/utils/sockets.cc should be of type socklen_t*. This will alleviate the problem of guessing whether it is signed or unsigned on different platforms. 969052365 johnston Fixed by: http://www.ivtools.org/pub/src/patches/ivtools-000916-johnston-099 First done by Guenter Geiger, the Debian packager of ivtools in his first ivtools release for woody. 951846141 johnston When accept() is called with int* or unsigned int* arguments instead of socklen_t* it gets lots of warnings compiling on different OS\'s that defined socklen_t as signed or unsigned. And it seems some versions of gcc have elevated this warning to an error. Just need to use socklen_t instead for the declaration of the variables passed as arguments. You also get a whole set of these warnings when using ACE-5 on NetBSD. status_id 100 969052365 johnston close_date 0 969052365 johnston priority 2 964283950 johnston summary use socklen_t* as type of 3rd arg to accept() in sockets.cc 951846141 johnston assigned_to 100 950550593 nobody priority 5 950549360 johnston 204886 johnston johnston 5 Closed Fixed problem with inner-parens on post-evaluated expressions 956783475 Bugs command interpreter None There is a problem with inner-parens on post-evaluated expressions, i.e. "(1+2)*3". Something to do with the BlankType ComValue left on the stack for the pair of parenthesis. 956855211 johnston This and #100905 fixed by removal of a recently introduced parser bug. patch ivtools-000427-johnston-039 956785783 johnston Only affects the body of control commands, like cond, for, while, etc.. Workaround for now is to flatten these expressions, which has the side-effect of providing more intermediate variables for debugging purposes :-). status_id 1 956855211 johnston resolution_id 100 956855211 johnston close_date 0 956855211 johnston assigned_to 100 956783564 johnston 207597 johnston nobody 7 Closed None comterp commands floor, ceil, and round 961196424 Bugs command interpreter feature request Add comterp commands for the traditional numeric operators floor, ceil(ing), and round. 962224589 johnston moved to task manager status_id 1 962224589 johnston close_date 0 962224589 johnston priority 5 961197283 johnston 207598 johnston nobody 5 Closed None comterp foreach command 961196549 Bugs command interpreter feature request Add a "foreach" command to comterp, to execute a parameterized block of code once per each member of a list. The chosen method for passing parameters to a block of code could be reused in a comterp command for defining comterp commands on the fly. 962224742 johnston moved to task manager status_id 1 962224742 johnston close_date 0 962224742 johnston 207601 johnston nobody 3 Closed None More keyboard shortcuts for drawing editor navigation 961197187 Bugs drawing editor feature request It would be nice to have more keyboard shortcuts for drawing editor navigation. Currently we have Ctrl-Z and Shift-Z as shortcuts for zoom-in and zoom-out. We could also use the arrow keys as keyboard shortcuts for panning (Shift for larger moves), Page-up and Page-down for next-screen-up and next-screen-down, and maybe Tab and Back-tab for next-screen-right and next-screen-left (Ctrl-F and Ctrl-B are reserved for frame-forward and frame-backward in ivtools flipbook). Home and End could be upper-left and lower-right respectively. 965846636 johnston Move to drawing editor task. status_id 1 965846636 johnston close_date 0 965846636 johnston priority 5 961259162 johnston 207605 johnston nobody 5 Closed None expose alpha-transparency via drawing editor GUI 961197932 Bugs drawing editor feature request Expose the alpha-transparency capability of the underlying Color object through the GUI of ivtools drawtool, etc.. This allows for the merging of the color of pixels to be painted with the color of its background. The capability is available under the hood (in Xlib) but not accessible via the GUI of the drawing editors or in the document format used by the drawing editors. 965846557 johnston Rewritten into a task, one that will probably get done via by an X extension: http://www.xfree86.org/~keithp/render/ This promises to make alpha-transparency available diretly in Xlib. status_id 1 965846557 johnston close_date 0 965846557 johnston 207726 johnston nobody 5 Closed None trace,step,pause commands 961378629 Bugs command interpreter feature request Add trace, step, and pause commands to comterp, to complement the recently implemented pause command for comdraw. 962224768 johnston moved to task manager 961568935 johnston http://www.geocrawler.com/lists/3/SourceForge/650/0/3919251/ add more trace output for non-post-evaluated commands. 961462542 johnston First draft of trace command: http://www.geocrawler.com/lists/3/SourceForge/650/0/3912941/ status_id 1 962224768 johnston close_date 0 962224768 johnston 227692 johnston nobody 5 Open None help(:all) returns null in comdraw text editor 978721097 Bugs drawing editor None help(:all) segfaults comdraw when entered into the comdraw text editor window (the panel at the bottom of the editor). It does not segfault when used from telnet or stdin. 992880268 johnston Logged In: YES user_id=406 This is because the maximum length of a symbol is 4K, and comterp uses the symbol table for returning strings on the stack. Easy fix is to increase this size. Probably want to look at memory mgmt. issues at the same time. 988755347 johnston Logged In: YES user_id=406 now it doesn't segfault, it just returns null without doing anything. summary help(:all) segfaults in comdraw text editor 988755402 johnston 209843 johnston nobody 5 Closed None save/restore of rasters imported from a command doesn't work 964045105 Bugs drawing editor None In preparation for a nice capability, the command line used when importing a raster via popen (from a pipe) is preserved instead of a pathname. But then, instead of re-executing the command upon a subsequent open, it tries to use it as a pathname and fails. This problem used to be avoided by simply saving the raster by value instead of by pathname. We need to either return to the old approach, make the new approach work full-up, or give the user control over which of the two approaches to use. The problem with full migration to the new approach (always re-executing the command line) is that it might fail when data files are moved or executables are renamed. I guess the default should be to try re-executing the command, then read the values if they are there, and have some control of whether the command and/or the values get written out at save time. status_id 1 964045190 johnston close_date 0 964045190 johnston 213016 nobody nobody 5 Closed None Comdraw dumps core when I load a program via the run() comma 967550149 Bugs None None Comdraw starts and runs fine. When I enter the following line for execution in the shell, it dumps core, and closes up shop. run("/a/b/c/load-widgets") #a, b, c are the dirs above the script "load-widgets 967699981 johnston Should be fixed by http://www.ivtools.org/pub/src/patches/ivtools-000830-johnston-096 967611498 johnston The run command in and of itself works in comdraw as far as I know. I will double-check this, and report back here. The problem could be with the script "/a/b/c/load-widgets" -- can you forward a copy? I'm assuming this bug is from tgruhn@users.sourceforge.net status_id 1 967699981 johnston close_date 0 967699981 johnston 213020 nobody nobody 5 Closed Works For Me Trash falls off of my graphics 967550358 Bugs None None When I make a sharp angle, and drag it about, spare pixels fall of the apex of the angle and clutter up the screen. Since it doesn't affect execution, I don't see this prob as a very high priority... 969910869 johnston No further information available from bug submitter. Assumed to be an X server bug (specifically a bug of a non Xfree86 server which fails to incorporate all upgrades to date). 967611729 johnston I need more information to determine where the problem lies. Please login if you can, or leave an e-mail address. Or is this another bug from tgruhn@users.sourceforge.net? I have seen something like this problem using the Xi Graphics commercial X server for Linux -- the same problem doesn't exist with the latest server from XFree86. This would indicate a server bug that never got patched out of the proprietary code. status_id 1 969910869 johnston resolution_id 100 969910869 johnston close_date 0 969910869 johnston 213125 johnston nobody 5 Closed None comdraw addtool command segfaults if path doesn't exist 967652386 Bugs drawing editor None The new comdraw addtool command segfaults if the pathname you supply it does not exist. 967700032 johnston Fixed by http://www.ivtools.org/pub/src/patches/ivtools-000830-johnston-096 status_id 1 967700032 johnston close_date 0 967700032 johnston 227573 johnston johnston 1 Closed None reincorporate GPL dual-licensing verbiage 978641899 Bugs config and miscellaneous None For whatever reason, the verbiage that introduced GPL dual-licensing to ivtools did not make it into the 0.9 tar file. 979692840 johnston fixed in ivtools-0.9.1 status_id 1 979692840 johnston close_date 0 979692840 johnston 227572 johnston johnston 9 Closed None version.h not revised for ivtools-0.9 978641785 Bugs config and miscellaneous None The contents of ivtools-0.9/src/include/ivstd/version.h is out of date in 0.9 release of ivtools. Calls for an ivtools-0.9.1. 979692875 johnston fixed in ivtools-0.9.1 status_id 1 979692875 johnston close_date 0 979692875 johnston priority 1 978641820 johnston assigned_to 100 978641820 johnston category_id 100100 978641820 johnston 427293 nobody nobody 5 Closed Wont Fix 0.9.3 wouldn't compile with RH7.1 990803342 Bugs config and miscellaneous None I've been happily using idraw since at least 1992, but just had a terrible time getting it installed under Redhat 7.1 on my 686 laptop. I tried the latest RPMs (0.8.3 and 0.8.4), but they both gave a Segmentation Fault at string.c:52. I then tried a build from the 0.9.3 source, but got lots of compile errors. Noting that RH7.1 ships with gcc 2.96 and reading the exchange here between Scott Johnston and Murry J. (http://sourceforge.net/tracker/?atid=300275&group_id=275&func=browse), I made the following changes: added "#include <string.h>" to: src/InterViews/field.c src/Time/timeglyph.c src/IVGlyph/bdvalue.c src/IVGlyph/printchooser.c src/ComGlyph/comtextview.c src/ComUnidraw/comeditor.c src/ComUnidraw/unifunc.c src/FrameUnidraw/framekit.c src/GraphUnidraw/graphimport.c src/DrawServ/drawcomps.c added "#include <stdlib.h>" to: src/Unidraw/gvupdater.c src/utils/ivdl.cc src/utils/thrower.cc to src/Dispatch/rpcbuf.c: - removed "unsigned" from name_len - removed first #if ( defined(__sun)... - added casts: (socklen_t*)(&name_len) After all this, I still get: /usr/local/src/ivtools-0.9/src/ComTerp/LINUX/../helpfunc.c:128: conditional expression between distinct pointer types `filebuf *' and `strstreambuf *' lacks a cast /usr/local/src/ivtools-0.9/src/ComTerp/LINUX/../helpfunc.c:128: no matching function for call to `ostream::ostream (void *)' and many errors in ovcomps like: /usr/local/src/ivtools-0.9/src/OverlayUnidraw/LINUX/../ovcomps.c: In method `void OverlayComp::AdjustBaseDir (const char *, const char *)': /usr/local/src/ivtools-0.9/src/OverlayUnidraw/LINUX/../ovcomps.c:64: too many arguments to function `char *realpath ()' BUT, idraw now works!!! I'm not a programmer, and this took me several days to get things working. If I didn't love idraw so much, I never would have bothered. Something is wrong when a software package is distributed (either ivtools or gcc 2.96 :) ) and can't run or compile on a supported platform. ...Steve 997116395 johnston Logged In: YES user_id=406 https://sourceforge.net/tracker/index.php?func=detail&aid=400986&group_id=275&atid=300275 This is a patch for getting ivtools compiled with the unofficial gcc-2.96. Good luck using it. I would suggest migrating forward or backward instead (to gcc-2.95.* or gcc-3.*) Scott Johnston 990897099 johnston Logged In: YES user_id=406 Steve, Well, which do you think has been changing more, gcc or idraw? :-) Frankly, it has been a constant struggle to keep an unchanging idraw compiling with the everchanging C++ front- end to gcc. I have written off RH 7.1 as a lost cause, although your posting here will serve as an instruction to those who have to use this compile that never got approved by the gcc steering committee. Instead, I will make every effort to get ivtools compiling smoothly on the soon-to-be-released gcc-3.0. I realize many of the changes required for that might be applicable to the RH7.1 compiler, and maybe I can close this bug item at that time. But without access to gcc-3.0 I have no idea which of the changes required by gcc-2.96 are permanent, and which are temporary. At this juncture I'd rather wait. status_id 1 997116395 johnston resolution_id 100 997116395 johnston close_date 0 997116395 johnston 207632 johnston nobody 5 Closed Fixed Preserve import command as component attribute 961259858 Bugs drawing editor feature request Preserve the command entered into the import dialog box when "from command" is checked as an attribute on the resultant component. This could subsequently be used to re-execute and re-load the component at a later date. Whether or not the component the contents of the component gets saved/restored by this command line or by the current values of the graphic would still be controlled by the "save by pathname" checkbox. 986511579 johnston Logged In: YES user_id=406 completed with ivtools-0.9.2 status_id 1 986511579 johnston resolution_id 100 986511579 johnston close_date 0 986511579 johnston 408629 johnston nobody 5 Closed Fixed problem with ComUtil relative install 984612014 Bugs config and miscellaneous None when configured with --enable-install-relative you get a problem installing src/ComUtil (which has individual application setting files to put somewhere). All the install target does is check for a symbolic link from src/include to $(TOP). For some reason this problem had been ignored, but showed up on FREEBSD when using --enable-install-relative. 986511619 johnston Logged In: YES user_id=406 fixed with ivtools-0.9.2 status_id 1 986511619 johnston resolution_id 100 986511619 johnston close_date 0 986511619 johnston 207596 johnston nobody 5 Open None pstoedit plugin only works from pathname 961196300 Bugs drawing editor None When pstoedit is as an import plugin by one of the ivtools drawing editors, it only works for PostScript files read from a pathname. Something like "ralcgm -d PostScript marks.cgm" doesn't work when "from command" is checked, because the code that invokes pstoedit assumes that the command string is a pathname. The workaround is to manually append pstoedit to the other command, i.e. "ralcgm -d PostScript marks.cgm | pstoedit -f idraw". But it would be nice to fix. 986511497 johnston Logged In: YES user_id=406 lowered priority because there is a workaround priority 9 986511497 johnston priority 5 970270409 johnston 209842 johnston johnston 9 Closed Fixed save/restore of rasters imported from a command doesn't work 964045017 Bugs drawing editor None In preparation for a nice capability, the command line used when importing a raster via popen (from a pipe) is preserved instead of a pathname. But then, instead of re-executing the command upon a subsequent open, it tries to use it as a pathname and fails. This problem used to be avoided by simply saving the raster by value instead of by pathname. We need to either return to the old approach, make the new approach work full-up, or give the user control over which of the two approaches to use. The problem with full migration to the new approach (always re-executing the command line) is that it might fail when data files are moved or executables are renamed. I guess the default should be to try re-executing the command, then read the values if they are there, and have some control of whether the command and/or the values get written out at save time. 986511432 johnston Logged In: YES user_id=406 Implemented (for the most part) with ivtools-0.9.2. status_id 1 986511432 johnston resolution_id 100 986511432 johnston close_date 0 986511432 johnston assigned_to 100 965852592 johnston priority 5 964045157 johnston 414576 johnston nobody 7 Open None problems with save/restore of text 986671910 Bugs drawing editor None FROM: Scott Johnston DATE: 04/07/2001 01:12:19 SUBJECT: RE: open+save makes resized text wander Hi -- > >I have a drawtool document with the following nasty property: If I read it in, make a null change (such as creating and then deleting some irrelevant object), and then write it out, the new file is significantly different from the original. In particular, text that was originally at point A has wandered to a new point B. > >Every time I save and re-open the document, the text has wandered farther. > >Here is a prescription for reproducibly creating such a document: > -- create some 18-point text e.g. "asdf" > -- draw a rectangle around it > -- align the centers of the rectangle and text > -- group the rectangle and text > -- change the fontsize to 24 > -- ungroup > -- re-align the centers > -- re-group > -- save > -- re-open and observe text is no longer centered > >Looking at the file (below) it appears that when the fontsize was changed, the "gs" statement was updated while the "text" statement was not. It seems this has something to do with the problem. Using a text editor to change the "18" to a "24" creates a well-behaved file. > >============ > >In my search for a workaround, I stumbled onto the following technique. It sometimes helps, but I can't guarantee it: > -- export the document in idraw-format > -- open the idraw version, and use it to > -- over-write the drawtool version > > >============================================ > >drawtool( > gs( :fillbg 1 :brush 65535,2 :fgcolor "Black",0,0,0 :bgcolor "White",1,1,1 :nonepat), > gs( :fillbg 0 :fgcolor "Black",0,0,0 :font "-*-helvetica-bold-r-normal-*-24-*-*-*-*-*-*-*","Helvetica-Bold",24 :graypat 0), > picture( > rectangle(164,277,270,341 :gs 0 :transform 1,-0,-0,1,12,33) > text(18,"asdf" :gs 1 :transform 1,0,0,1,204,345.5) > ) >) Looks like a problem updating the datum used for serializing the text graphic. Thanks for pointing this out. You could enter such information yourself directly into the sourceforge web pages, but I will incorporate what you have sent to the mailing list and me. Scott Johnston _______________________________________________ Ivtools-devel mailing list <EMAIL: PROTECTED> http://lists.sourceforge.net/lists/listinfo/ivtools-devel 986672048 johnston Logged In: YES user_id=406 See Also: http://www.geocrawler.com/lists/3/SourceForge/651/0/5504339/ 414577 johnston nobody 7 Closed Fixed add-custom-tool segmentation fault 986672133 Bugs drawing editor None FROM: John Denker DATE: 04/06/2001 12:58:34 SUBJECT: add-custom-tool segmentation fault Hi -- Here's a bug: -- start drawtool -- click on Tools -- click on Add Custom Tool -- dismiss the popup by hitting the Esc key -- observe segmentation fault _______________________________________________ Ivtools-devel mailing list <EMAIL: PROTECTED> http://lists.sourceforge.net/lists/listinfo/ivtools-devel status_id 1 988755229 johnston resolution_id 100 988755229 johnston close_date 0 988755229 johnston 213266 johnston nobody 8 Closed Fixed drawtool and up can't import XBM 967758355 Bugs drawing editor None drawtool (and all drawing editors derived from drawtool) can't import XBM files anymore. This must have got disabled when the import mechanism was evolved to handle URLs (back in 0.7.*). 990750523 johnston Logged In: YES user_id=406 fixed in repository on 5/24/01. See ivtools-patch mailing list for details. Will be in next release (0.9.4). status_id 1 990750523 johnston resolution_id 100 990750523 johnston close_date 0 990750523 johnston 440527 johnston johnston 8 Closed Fixed avoid shared memory with remote X server 994890234 Bugs C++ framework None The use of the X server shared memory extension needs to be avoided when the X server is remote from the X client. 994895529 johnston Logged In: YES user_id=406 fixed by calling XShmQueryExtension instead of XShmQueryVersion in src/IV-X11/xraster.c status_id 1 994895529 johnston resolution_id 100 994895529 johnston category_id 100 994895529 johnston assigned_to 100 994895529 johnston close_date 0 994895529 johnston 448615 nobody nobody 5 Open None install problem Solaris 8, gcc2.95.3 997143526 Bugs config and miscellaneous None In directory /src/x_utilities/ivtools-0.9/src/IVGlyph root@gepetto.seas.gwu.edu# /usr/ccs/bin/ld -o libIVGlyph.so.0.9.5~ *.o 2>&1 |> ld: warning: relocation error: R_SPARC_32: file figure.o: symbol .LLC24: .LLC24 figure.o I'm compiling on Solaris 2.8 using gcc 2.95.3 with all default compilers installed. No errors other than this. I did a make install before I noticed it and idraw was installed and comes up. I just didn't get drawtool and some of the other programs. Any pointers appreciated. 997847399 nobody Logged In: NO Scott Johnston said this problem had been reported with gcc-2.95.3 on NetBSD and that perhaps if I upgraded or downgraded the compiler it would help. I tried fresh installs of gcc-2.95.2, gcc-2.8.1 and gcc-3.0.0 and they all failed. At least gcc-2.8.1 said there was an internal compiler error. gcc-2.95.2 had the same issues as gcc-2.95.2. gcc-3.0.0 complained about all sorts of things so I didn't pursue it. I also looked at using the Sun Forte compilers but it looks like a non-trivial job. 997193378 johnston Logged In: YES user_id=406 This problem has been reported before on NetBSD. Something to do with gcc-2.95.3. There is no .LLC24 symbol in the ivtools source code. You may want to try upgrading or downgrading your gcc/libstdc++ environment and trying again. Scott Johnston 444456 nobody nobody 5 Open None Drawserv artifact 996065591 Bugs config and miscellaneous None I noticed that comdraw has the menu option File::Dump Canvas As Drawserv does *NOT* have it... 454331 johnston nobody 5 Open None PS twice-filtered by pstoedit 998511203 Bugs drawing editor None PostScript twice-filtered by pstoedit (-f idraw) can't be read by idraw. The problem stems from the fact that idraw format is PostScript made ready for black-and-white printers, although the color information is preserved for later retrieval by idraw. So when pstoedit/ghostscript interpret the idraw, they see only the gray-level raster, and output an idraw format file without the color-image information tucked into a comment. Fixing this might take hacking on pstoedit as well as ivtools (original raster support submitted by yours truly). The workaround is to avoid applying pstoedit to PostScript that is already in idraw format. 464645 johnston johnston 5 Closed Rejected 0 shouldn't equal nil in comterp 1001378481 Bugs command interpreter None 0==nil should return 0 0!=nil should return 1 Do before 1.0 1001447922 johnston Logged In: YES user_id=406 Changed my mind on this one. Actually, I probably made upmy mind on this a long time ago, and I had to revisit my reasoning. In the world of C 0==NULL, and comterp is supposed to mimic C where possible/desirable. This all came up because of the new stream concept, which terminate upon returning nil. The while loop checks for the "done" argument being nil or zero. But with a stream like this: s=0..100 and a while loop like this: while(v=next(s) print("%d " v)) the loop terminates on the first value, which is zero. One workaround for this was to use the type of the value returned from the stream (with backquotes to prevent their lookup as symbol variables): while(`type(v=next(s))!=`type(nil) print("%d " v)) I also decided to add a :nilchk option to the while loop, to ignore zero values when needed: while(v=next(s) print("%d " v) :nilchk) close_date 0 1001447923 johnston status_id 1 1001447922 johnston resolution_id 100 1001447922 johnston 469644 johnston nobody 6 Open None raster with :sub no longer works 1002658907 Bugs drawing editor None A raster in a drawtool document file can have a :sub xb,xe,yb,ye sub-image specification. This is one way of dealing with large images as described in http://www.ivtools.org/ivtools/largeimages.html Haven't tested this in a while, but nowadays there seems to be a problem with this mechanism. The sub-image gets rid in, but it is all black. 469627 johnston nobody 7 Open None multi-line text-editor expressions 1002655666 Bugs comdraw etc. None There is a problem with multi-line expressions entered into the text-editor window of comdraw/flipbook/graphdraw/drawserv. Although the parsing seems to work (you are prompted with ">" until the expression is closed), the evaluation doesn't seem to happen at all. 482648 johnston nobody 5 Open None extent bug with rotated group 1005950546 Bugs C++ framework None The computation of a composite-graphics extent (group) has a bug when the group or one of its members is rotated. You can see this by creating a large polygon, grouping it with a small graphic that overlays it, then rotating the combination. The only time the bounding box (represented by the selection handles) shrinks to the right size is when the degrees of rotation is 0 (and maybe 180). 501552 johnston nobody 5 Open None ACE+comdraw: multi-line comterp expr bug 1010620423 Bugs comdraw etc. None When built with ACE there is a problem with multi-line expressions (expressions that are automatically carried over to the next line because they are incomplete) in comterp. I assume the problem is the same for stdin or telnet connections. 420796 johnston johnston 5 Closed Fixed comdraw/graphdraw stdin problem 988827575 Bugs comdraw etc. None The interpreter associated with the stdin of comdraw and graphdraw only evaluates the first of any series of white-space separated expressions in a single line of text. This should be like all the other interactive interpreter interfaces (i.e. comterp/flipbook/drawserv) and loop over the expressions. This is also a problem with the keyboard command interpreter built into comdraw, etc.. 1010620055 johnston Logged In: YES user_id=406 The behavior of the stdin interpreter for comdraw, flipbook, graphdraw, and drawserv has been normalized (for the most part), with and without ACE. Now you get (almost) uniform support for multiple expressions on a single stdin command line. status_id 1 1010620055 johnston resolution_id 100 1010620055 johnston close_date 0 1010620055 johnston category_id 100900 1002655877 johnston 513560 johnston nobody 5 Open None rotated scaled rasters have edge errors 1012958035 Bugs C++ framework None Rasters that have been scaled and rotated have errors in rendering along their edges. Probably the application of affine transform has an off-by-one error when resampling values from the input image, so you either get a zero-value sample, or you don't sample as needed, or the output image is to large by one pixel, or something like that. 502006 johnston nobody 5 Open None hard to click on fat lines 1010692870 Bugs None None It is really hard to select fat lines with a single click. Seems the intersection code is not taking the actual width of the line (brush) into consideration. 482583 johnston nobody 5 Closed Fixed GraphicLoc tool values stale upon reuse 1005938411 Bugs drawing editor None The GraphicLoc tool pops-up a dialog box with stale values after the first use. These don't refresh themselves until after another click. 1011136609 johnston Logged In: YES user_id=406 fixed with 1.0.2 status_id 1 1011136609 johnston resolution_id 100 1011136609 johnston close_date 0 1011136609 johnston 207724 johnston nobody 7 Closed Fixed "Show Prev Frame" should take affect immediately 961378470 Bugs drawing editor None The "Show Prev Frame" and "Hide Prev Frame" commands under the Frame menu in ivtools flipbook should take affect right away, instead of waiting until after the next frame move. 1011294341 johnston Logged In: YES user_id=406 in cvs repository now, will be part of 1.0.2 release. status_id 1 1011294341 johnston resolution_id 100 1011294341 johnston summary "Show Prev Frame" should take affect immediately 1011294341 johnston close_date 0 1011294341 johnston priority 5 964283864 johnston 516708 johnston nobody 5 Open None X11 coordinate overflow 1013556591 Bugs drawing editor None Graphical coordinates can overflow when scaling up. This could be fixed by some combination of pre-scaling or clipping or ... 520682 johnston nobody 5 Open None drawserv -help 1014243729 Bugs None None drawserv needs a -help 223993 nobody nobody 5 Closed None HPUX 11 build problems 975630438 Bugs config and miscellaneous None While attempting to compile 0.8.4 on HPUX 11 the make system failed on a number of places. 1) During the creation of the make files it could not locate hp.cf thus it produced incorrect makefiles which could not be processed. Files contained hundreds of @@. 2) In attempting to build libraries it did not use libtool but instead tried to build it itself. The result was unable to link the shared libraries as it attempted to merge libstdc++.a which it not position independent. 3) Attempting to build static versions of the libraries referred back to the archecture dependent directories for the non-shared versions. Thus it was looking for libIV.a in the wrong directory. This required hand edits of the built makefiles to fix. 4) The remaining half of the nonshared makefiles contained references to the shared libraries thus placing a false dependency for libIV.sl even though libIV.a was already built. Thus compilation of the rest of the tools failed. Other problems * Numerious files referred to the select call which contained an architecture specific kludge for HPUX 8.0. All newer versions of HPUX will fail if the arguments are cast to int*. You would need a autoconf switch and not just activate the kludge on __hpux. * math.h contains the function round which returns a double. IVtools defines its own round which returns int. This results in an ambiguous overload. * several files used the rpc calls which passes an unsigned int* to an int*. Likely this also requires an autoconf. Conclusion, please take your current make system and burn it. take its charred remains, sprinkle with holy water, and have them launched into the sun. Nearly anything would be better. Using a standard build like libtool, automake, and autoconf would have saved me several days of my life. I still haven't managed to get it to compile correctly but instead decided to binary edit my compilation dated from 1993 to get it to work on current system. Electroshock theropy should be recommended to any poor souls who have had the misfortune of attempting to build your project from source. --Karl Nelson (kenelson@users.sourceforge.net) 1016731510 johnston Logged In: YES user_id=406 Can anyone test a build on HPUX? 1014244017 johnston Logged In: YES user_id=406 Some further changes will be incorporated into 1.0.2 for HPUX to reflect things done by one party who succeeded building ivtools. Not sure if this is the entire picture though. The outstanding problem is in building shared libraries. "gcc -shared" doesn't seem to do the right thing using the HPUX linker. Perhaps you need to explicitly use "/usr/bin/ld -r" instead (the -r to create relocatable object code, i.e. a library). 1010621479 johnston Logged In: YES user_id=406 The next release (1.0.1) will have revised config.sub and config.guess files, which may help some. I believe the @@ problem stems from using a non GNU make. Be sure to call it make, not gmake too, otherwise it will revert to the non-GNU make below the top-level directory of the source tree. You can disable building for RPC by define BuildRPCClasses to NO in either config/site.def.HP800 or config/local.def I would recommend building with shared libraries. The layered nature of ivtools makes it a poor choice for building static binaries. I would welcome a patch that cleans up the hpux conditional compilation, especially with regards to select. Perhaps hpux is no longer a special case. Perhaps these kludges could be isolated in an include file (under src/include/ivstd?). Any interested parties should get in touch. I am loath to make changes without someone volunteering to test them. I believe the type of various round() calls have been made explicit since migrating to gcc-3.0 and libstdc++-v3. Conclusion: I won't take my make system and burn it. I've been working on the problems you mentioned, and will continue to do so. There is nothing that can't be resolved if people cooperate. 976669115 johnston Thank you for your documenting problems with the HPUX build. A suitable warning will be added to the next release. Any volunteers willing to help resolve these problems please get in touch. status_id 1 1019237090 johnston summary Build system horribly broken on HPUX 11. 1019237090 johnston close_date 0 1019237090 johnston 622854 alexcher nobody 5 Closed Fixed Incorrect assunption about FontBBox 1034572981 Bugs None None There is a bug report filed against Ghostscript about a file generated by ivtools. In fact Ghostscript is OK. The sample file is incorrect. It assumes that FontBBox is an executable array. Although many fonts are designed this way there is no such requiriment in the spec Probably, different RH versions install different fonts. The file should be changed as following to work with both executable and literal arrays *** test.ps Mon Oct 14 00:02:53 2002 --- test-hacked.ps Mon Oct 14 00:53:20 2002 *************** *** 362,368 **** gsave fgred fggreen fgblue setrgbcolor /fontDict printFont printSize scalefont dup setfont def ! /descender fontDict begin 0 [FontBBox] 1 get FontMatrix end transform exch pop def /vertoffset 1 printSize sub descender sub def { 0 vertoffset moveto show --- 362,368 ---- gsave fgred fggreen fgblue setrgbcolor /fontDict printFont printSize scalefont dup setfont def ! /descender fontDict begin 0 /FontBBox load 1 get FontMatrix end transform exch pop def /vertoffset 1 printSize sub descender sub def { 0 vertoffset moveto show . 1036277168 johnston Logged In: YES user_id=406 ivtools copy of idraw modified as suggested. This increments the version number of the idraw format supported by ivtools to 13. Older versions can still be read, and will be upgraded to the new version when written out. This change is to support X11 fonts in RedHat that have changed from their classic static nature to dynamic executable fonts. It seems to be backward compatible (or rather compatible) with the normal version of these fonts. This change has been committed to the ivtools cvs repository, and will show up in the next release (either 1.0.7 or 1.1). 1034815717 johnston Logged In: YES user_id=406 Do you mean that one of the classic X fonts used by idraw has changed form from literal to executable under RedHat? Helvetica is available in both ways? 1034704841 alexcher Logged In: YES user_id=65750 The EPS header is incompatible with some fonts installed on Red Hat Linux. The PS interpreter make or version is not important. Unfortunately, the header doesn't use "bind" operator. So the work-around based on "Idion Recognition" is not possible. The only possible work-around is to change the fonts.. 1034698041 johnston Logged In: YES user_id=406 Alex, Thanks for illuminating us on this compatiblity problem between the decade-old idraw EPS format and newer versions of ghostscript. I've asked Raph if anything can be done about this. I will modify my version of idraw to support executable fonts, but there is little help to the academic users all over the world that have accumulated years of course notes in idraw format, and now find them unable to render in ghostscript (Adobe PostScript renderers do not have this problem). If you can see the way to removing this backward incompatibility from ghostscript many would appreciate it. Scott Johnston status_id 1 1036277168 johnston resolution_id 100 1036277168 johnston close_date 0 1036277168 johnston File Added 33018: test.ps 1034572981 alexcher 229542 johnston nobody 5 Open None "Precise Brush" clears dash pattern to solid. 980023788 Bugs drawing editor None The "Precise Brush" menu item under the Brush menu on ivtools drawtool (etc.) clears the dash pattern to solid. The work-around is to create integer-width dash patterned lines, then manually edit the :brush attribute in the ivtools drawtool document to have a floating point value. 1019599792 johnston Logged In: YES user_id=406 and visa-versa -- the dash pattern clears a precise brush width. summary "Precise Brush" clears dash pattern to solid. 1019599792 johnston 587201 nobody nobody 5 Open None ivtools compile/rpm problems 1027711081 Bugs None None I am running RedHat 7.2, but am using the gcc version 3.0.4 compiler. When I try to install the ivtools rpm, it sucessfully installs, but when I try to run idraw, I get the following error message: idraw: relocation error: /usr/local/lib/libUnidraw.so: undefined symbol: _ZNSt7codecvtIcc9mbstate_tE2idE What is the problem, and what needs to be done to get it fixed? I've also tried compiling it from source, but there are only 3-4 executables that sucessfully get made. All the others evidentally fail and get skipped right over. Thanks, Greg 1032538468 johnston Logged In: YES user_id=406 Note that there is no longer an RPM available for download from this site, but there is a SPEC file if you want to generate (or donate) your own. 1027878861 johnston Logged In: YES user_id=406 Greg, Here is the body of an e-mail I just sent you. Scott Johnston ------------------------------------------------------- >Scott, > > I get all kinds of compile probs with gcc 3.0.4. Only a couple of > programs actually sucessfully compile. Do you know why? In general, because RedHat/Cygnus keeps on changing g++ and libstdc++ in a non-backward-compatible fashion, in a continual attempt to approximate the ANSI C++ standard. :-) But do I know why in your particular case? No. It is either something that has changed between RedHat 6.2 I'm using and the RedHat 7.* you're probably using (I'm assuming you're on RedHat because of your attempt at installing the RPM), or something that changed between the gcc-3.0.1 I was using when I released ivtools-1.0.4, and the gcc-3.0.4 you are using. If you forward me a log of your attempted build I will be able to be more specific, and probably fix the problems in the near future. Alternately, you can could try building from the current sources in the ivtools cvs repository, where I've made changes necessary to keep things compiling with gcc-3.1. But this would require upgrading to gcc-3.1 first, because certain changes to the libstdc++ API are carefully managed with conditional compilation. >Also, the ivtools-1.0.4-1.i386.rpm gives me the following error message >when I try to install the rpm after installation and I relink all of the >libraries in /usr/local/lib and use ldconfig > >idraw: relocation error: /usr/local/lib/libUnidraw.so: undefined symbol: >_ZNSt7codecvtIcc9mbstate_tE2idE > >Is there a fix to this? I'm not using the gcc-2.96 compiler... > >Thanks, >Greg Sorry about that. I should document that my RPM's are generated on RedHat 6.2, and therefore probably only work on RedHat 6.2. If you ever get ivtools built, and know something about generating RPMs from SPEC files, I would be glad to get a version built on a more recent distribution. Scott Johnston http://www.ivtools.org p.s. cc your e-mail to ivtools-user@lists.sf.net or ivtools- devel@lists.sf.net to get a quicker response during the work week. 1027711298 nobody Logged In: NO Oh, and this is when I try to install the ivtools-1.0.4-1.i386.rpm, or compile the source code from ivtools-1.0.4.tgz. Thanks again, Greg 1027711280 nobody Logged In: NO Oh, and this is when I try to install the ivtools-1.0.4-1.i386.rpm, or compile the source code from ivtools-1.0.4.tgz. Thanks again, Greg 409886 johnston nobody 5 Closed Fixed drawtool can't read earliest legit idraw files 985048338 Bugs drawing editor None It seems some legitimate older idraw files don't have a %%Creator comment, and are therefore unreadable by the idraw reading code of drawtool. They work fine however in idraw. Here is an example: http://www.eos.ncsu.edu/eos/info/eos_info/idraw/fig1.idraw 1026844952 johnston Logged In: YES user_id=406 Improperly fixed for ivtools-1.0.3 which introduced a bug in importing idraw files into drawtool (all were filtered through pstoedit). Properly fixed after ivtools-1.0.4, to be included in ivtools-1.0.5. Although this file can be read by idraw, it is missing the required EPS comments to make it an idraw file, and should be treated as normal EPS/PostScript, and processed via pstoedit, which is what happens now. resolution_id 100 1026844952 johnston close_date 0 1026844952 johnston File Added 27154: ivtools-020716-johnston-057 1026844952 johnston status_id 1 1026844951 johnston summary drawtool can't read legit idraw files 986251018 johnston 573366 nobody nobody 5 Closed None cannot load shared object files 1024957776 Bugs config and miscellaneous None idraw idraw: error while loading shared libraries: libUniIdraw.so: cannot load shared object file: No such file or directory whereis libUniIdraw.so libUniIdraw: /usr/local/lib/libUniIdraw.so obviously the files are there but for some reason idraw (all the ivtools) are saying that its not there... I checked all my paths and they are correct any help? 1027443647 johnston Logged In: YES user_id=406 Status changed to Pending to reflect the need for more information to be of any help. 1025108283 johnston Logged In: YES user_id=406 Perhaps you need to add /usr/local/lib to your LD_LIBRARY_PATH environment variable. Or if you are getting this message after unpacking ivtools-1.0.3-1.i386.rpm, you probably want to switch to ivtools-1.0.3-2.i386.rpm (or the just released ivtools-1.0.4-1.i386.rpm), because these contain both the actual shared library (libUnidraw.so.1.0.3) and the symbolic link to it (libUnidraw.so). I will need some more information about your environment, and perhaps a name or e-mail address to contact you. This can be easily resolved with a little Q&A. status_id 1 1027443647 johnston close_date 0 1027443647 johnston category_id 100 1025108283 johnston 611700 johnston nobody 5 Open None poke and pokeline update problem 1032455934 Bugs comdraw etc. None The effect of poke and pokeline comdraw funcs does not show up even after a call to pflush and update. They do show up (at least pokeline does) after a zoom or pan that causes the whole drawing area to be refreshed. Why is that? 690330 johnston nobody 5 Open None space in pathnames defeats make 1045779116 Bugs config and miscellaneous None Having a space in a pathname defeats the make process, at least on Darwin. 631727 nobody nobody 5 Open None Gravity with Stretch Command 1036093526 Bugs drawing editor None When using idraw to prepare flowcharts and other block diagrams, I typically use the gravity feature to make the various visual objects "snap" to the grid. I have noticed that this works fine when I am initially creating the object. But, when I use the stretch command to resize the object, the object no longer fully snaps to the grid. For example, when resizing a rectangle with the stretch command, at least one of the corners of the rectangle usually no longer resides on a grid point after the operation. Also, there appears to be no easy way to get that corner back onto the grid I have seen this behavior with several versions of idraw and on several platforms. I think all objects should snap to the grid during all operations. 611266 dankelley nobody 6 Closed Fixed idraw-created ps files fail in latex 1032380889 Bugs drawing editor None Hi. A few years back I created some diagrams with idraw. The .ps files are included in latex files. For years, I've updated these latex files (course notes) slightly, and run latex/dvips and all was okay. But now I find that it's broken. Things like "ps2pdf", which call gnu-ghostscript-6.52, produces erros like the following. This happens with the idraw-created files, and so I tried using idraw to open the existing .ps files, and that won't work either. (That's why I'm posting this bug report here instead of to a ghostview site.) Is this something with which folks are familiar? I am not certain of the idraw that produced the files (one is attached), but the idraw I have right now, and which cannot open the attached file, is from ivtools-1.0. Thanks. Error: /rangecheck in --get-- Operand stack: --nostringval-- --nostringval-- --nostringval-- --nostringval-- descender 0 --nostringval-- 1 Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1 3 %oparray_pop 1 3 %oparray_pop 1 3 %oparray_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- --nostringval-- Dictionary stack: --dict:1038/1476(ro)(G)-- --dict:0/20(G)-- --dict:86/200(L)-- --dict:161/300(L)-- --dict:45/200(L)-- --dict:40/51(L)-- --dict:1/17(L)-- --dict:6/17(L)-- --dict:5/17(L)-- --dict:1/3(L)-- --dict:13/14(ro)(L)-- Current allocation mode is local 1036442481 johnston Logged In: YES user_id=406 Bug #622854 pinpointed the problem, and since then I've fixed it in the cvs repository: http://sourceforge.net/tracker/index.php?func=detail&aid= 622854&group_id=275&atid=100275 On RedHat certain classic X11 fonts have changed form, from a static array to an executable font. This requires a change in the font loading PostScript prologue code of the idraw EPS format. Once you have a revised version of idraw, you simpley have to open then save out each file to get correction applied. Thanks for pointing this out. I assume you were the one who brought this to the attention of the ghostscript people as well, which resulted in a solution arising. This change will be incorporated in the next release of ivtools, either 1.0.7 or 1.1. 1036434549 dankelley Logged In: YES user_id=31559 FYI, this error still occurs in redhat-8.0, to which I recently upgraded. (I'm working from pre-existing idraw-created files ... after removing some hand-inserted lines as in the msg from johnston dated 2002-08-18:18:13). The gs on redhat-8.0 is GNU Ghostscript 7.05 (2002-04-22) 1032386691 dankelley Logged In: YES user_id=31559 This is the sort of thoughtful, rapid, and generous reply for which open-source software should be famous. You've hit two nails on the head! Thanks _so_ much for the help. I really appreciate it, and especially the link to the ghostscript problem. Dan. PS: embarrasingly, I had forgotten that I had manually edited the .ps files. Really, that was silly of me to have posted asking for help before noticing that. So, double-thanks for double-help. 1032383598 johnston Logged In: YES user_id=406 I think you have two separate problems here. First, your idraw EPS files have been manually editied. If you remove the lines that begin with "% ORIG" you should be able to load the result into idraw (it worked for me). Yes, "% ORIG" is a legal PostScript comment, but it confuses the idraw EPS parser. Perhaps you might want to enter a feature request for making this work sometime in the future. Second, you seem to have run into a known problem with recent versions of Ghostscript interpreting the long-standing idraw EPS format. Although the problem is known, I'm not the one who knows what it is. You might check on ghostscript mailing lists, or send a query to the previous person who brought this up on ivtools mailing lists: http://sourceforge.net/mailarchive/forum.php?thread_id=1000584&forum_id=5712 His email address is johnh at isi.edu. He was going to bring it up with the ghoscript folks. I'd appreciate hearing back from either of you when you figure out the story. Scott Johnston close_date 1036434549 1036442481 johnston close_date 1032387380 1036434549 dankelley status_id 1 1032387380 johnston resolution_id 100 1032387380 johnston close_date 0 1032387380 johnston priority 5 1032380968 dankelley category_id 100 1032380954 dankelley File Added 31374: TS.ps 1032380889 dankelley 533195 johnston nobody 8 Open None empty parens could make empty list 1016731435 Bugs command interpreter None "()" could be a shortcut for "list()", so that "(),1,2" would return "{{},1,2}" (and "1,(),2" would return "{1,{},2}" etc.). 1038955271 johnston Logged In: YES user_id=406 Right now empty parens "()" is a segfault that needs to be fixed. priority 5 1038955271 johnston 612008 nobody nobody 5 Closed None ivtools-1.0.6. 1032507789 Bugs config and miscellaneous None Won't build on linux 7.3 SMP, dual pentium 3, gcc 3.2 configure script fails restore from .tar then configure i686 complains: *** multiple target patterns. Stop. 1038955112 johnston Logged In: YES user_id=406 Upload of extra information never occurred for almost 3 months, bug closed. 1032538370 johnston Logged In: YES user_id=406 Please upload a log of your problem. Hard to resolve anything without more input. Thanks. status_id 1 1038955112 johnston close_date 0 1038955112 johnston 627760 nobody nobody 5 Closed None ivtools 1.0.6 RED HAT 7.3 1035408001 Bugs None feature request HI, I COMPILE IVTOOLS 1.0.6 WITH REDHAT 7.3 ALL IS OK, MY APPICATION NO RUN CORRECT... ERROR OUT WITH GDB... ./gdb ged Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 1024 (LWP 30005)] 0x4072fb2f in rep__C7ivColorP14ivWindowVisual (this=0x817bbb0, wv=0x8177638) at /root/ivtools/ivtools-1.0/src/IV/LINUX/../../IV-X11/xcolor.c:39 39 implementPtrList(ColorRepList,ColorRep) WATHS IS THE PROBLEM ? PLEASE THANKS FOR YOUR HELPS, GERMAN 1038955199 johnston Logged In: YES user_id=406 This person is working on a custom version of morpher, and has taken his questions to the ivtools-user mailing list. status_id 1 1038955199 johnston close_date 0 1038955199 johnston 659974 felsenst nobody 5 Open None RedHat 8 installation/config problem 1041255850 Bugs config and miscellaneous None Not sure this counts as a "bug" but ... I am trying to bring Ivtools up on a new machine. I have RedHat 8.0 with the compilers that come with that. If I try to install the RPM for version 1.0.4, after I make sure it has the correct library paths, I end up still getting an error message when I try to run Idraw. (More in it in a moment). When instead I download the 1.0.7 sources and compile, I end up getting the same exact error. In both cases I reame the executable for Idraw "idraw.NEW" and my shell script "idraw". The script is: #!/bin/sh export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH export PATH=/usr/local/lib/:$PATH /usr/local/bin/idraw.NEW $1 This has worked fine for other installations but now it gives the error message: /usr/local/bin/idraw.NEW: relocation error: /usr/X11R6/lib/libXext.so.6: undefined symbol: _Xglobal_lock and does not run. Is maybe some symbol missing in the RedHat 8 X configuration that is needed? Or have I got X Windows misconfigured somehow? Thanks Joe Felsenstein joe@gs.washington.edu 1043492533 nobody Logged In: NO Scott (and others) -- In response to Scott's suggestion I tried renaming /usr/local/lib/libX11* to avoid library problems. This has solved the problem, and Idraw now works properly. Many thanks for the help Joe joe@removethispart.gs.washington.edu 1041534221 johnston Logged In: YES user_id=406 Joe, I think your problem lies in mixing X11 libraries from /usr/local/lib (libX11) and /usr/X11R6/lib (libXext). How do things look if you remove or rename /usr/local/lib/libX11* ? Scott p.s. apologies for the earlier disparaging comments on recent versions of RedHat. Maybe the reason I see only RedHat related problems is that is the only OS users of idraw are actively using. 1041514834 nobody Logged In: NO Scott -- One last piece of information. Here is what the "ldd" command discloses: libUniIdraw.so => /usr/local/lib/libUniIdraw.so (0x40013000) libUnidraw.so => /usr/local/lib/libUnidraw.so (0x40054000) libIV.so => /usr/local/lib/libIV.so (0x40167000) libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40329000) libX11.so.6 => /usr/local/lib/libX11.so.6 (0x40337000) libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x403cd000) libm.so.6 => /lib/i686/libm.so.6 (0x4047f000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x404a2000) libc.so.6 => /lib/i686/libc.so.6 (0x42000000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) undefined symbol: _xstat (/usr/local/lib/libX11.so.6) undefined symbol: _Xglobal_lock (/usr/X11R6/lib/libXext.so.6) undefined symbol: _XUnlockMutex_fn (/usr/X11R6/lib/libXext.so.6) undefined symbol: _XLockMutex_fn (/usr/X11R6/lib/libXext.so.6) /usr/local/bin/idraw.NEW: relocation error: /usr/X11R6/lib/libXext.so.6: undefined symbol: _Xglobal_lock Joe joe@gs.washington.edu 1041493941 nobody Logged In: NO Scott -- Further searching using the "nm" command (under sh) shows _Xglobal_lock is D ("in the initialized data section") for libX11.a. But no T. libX11.so.6.2 says it has no symbols. Joe (joe@gs.washington.edu) 1041492914 nobody Logged In: NO Scott -- I ran your script that looked in all the *.so* libraries, and all the *.a libraries, in /usr/X11R6/lib. None of them has this symbol! Joe 1041269592 johnston Logged In: YES user_id=406 Joe, Problems of this nature have been a fairly regular occurrence since RedHat 7.* and the advent of gcc-2.96. I am at a loss to explain how this symbol could be found at link time but not at run time. Either it wasn't found at link time (and no error message was printed), or different shared libraries are being found at link time versus run time. With a name like _Xglobal_lock I would assume you can find the symbol somewhere in /usr/X11R6/lib/. Try this command: # assuming sh or bash: for x in *.so.* do echo $x nm $x | grep "T _Xglobal_lock" done You may want to repeat that command for *.a as well. Does that find the symbol? If so, you may need to add whatever library it is in to the link command line. Get back in touch with me for details on how to do it. Another thing to investigate is exactly which libraries are being found at run time. Add this command to your execution script: ldd -r /usr/local/bin/idraw.NEW Good luck, Scott 779742 nobody nobody 5 Open None Problem with Color in TrueColor mode 1059501931 Bugs None None It's possible that the color are incorrect (blue is red and red is blue) in a truecolor display? in the file XWINDOWS.C of IV-X11 in the function WindowVisual::find_color(.....) you have if(bytesize_ { xc.pixel = ((red & 0xff00) << 8) | (green & 0xff00) | ((red & 0xff00) >> 8) } BUT if i change the >> for << and vice versa ex. if(bytesize_ { xc.pixel = ((red & 0xff00) >>8) | (green & 0xff00) | ((red & 0xff00) << 8) } everycolor are correct. Perhaps this is just a little mistake. But i don't know if on linux/Unix this correction is correct because my xserver is on Windows : Exceed of Hummingbird Vincent Choinière 1062528331 johnston Logged In: YES user_id=406 Funny, that bytesize_ clause was added specifically for an Windows X server, albeit the free one, not Exceed. I guess they have a different RGB ordering. This information is provided in the visual, but if you look at this code you'll see it is ignored. To fix the problem would require changing this code to pay attention to the masks that are part of the visual. I would have responded directly, but you left the bug without leaving an e-mail and without logging in. Scott Johnston 302051 nobody nobody 5 Closed None Configure problem 959303620 Support Requests Project and Site Statistics None 960018862 nobody Logged In: NO Browser: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt) Thank you very much for suporting. I changed PC to WindowsNT. Make command has no problem. Thank you again. Best Regards, Junji Sone 959736558 nobody Logged In: YES user_id=406 Browser: Mozilla/4.05 (Macintosh; I; PPC, Nav) In the Cygwin FAQ there is a section on creating a /c symbolic link to get at your c: drive: http://sourceware.cygnus.com/cygwin/faq/faq.html#SEC39 I think that might be your problem. You may want to review that FAQ for other helpful hints about Cygwin usage. I am revising http://www.ivtools.org/ivtools/README.cygwin.txt to include the FAQ URL: http://sourceware.cygnus.com/cygwin/faq/ Scott Johnston p.s. I still do not know how easy this all will be on Windows 95/98. I have no independent confirmation that it is doable. You would be the first. 959734048 nobody Logged In: NO Browser: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt) Thank you very much for responding. I progressed configuration. But end of configuration, configure said as follows. ======================================== "writing "ABSTOP = /usr/ivtools-0.8" /c: Can't open /c make: *** [CPU] Error 2 writing "CPU = " /c: Can't open /c make: *** [CPU] Error 2 now do a "make" ============================================ Then, I add CPU = i586 or CPU = i386 in config.mk. But make can not progress as following message. ================================== BASH.EXE-2.02$ make /c: Can't open /c make: [all] Error 2 (ignored) /c: Can't open /c make: [all] Error 2 (ignored) /c: Can't open /c make: [all] Error 2 (ignored) /c: Can't open /c make: [all] Error 2 (ignored) make subdirs /c: Can't open /c make: *** [all] Error 2 ========================================= I am very appriciate if you inform me about "/c" Best Regards, 959711539 nobody Logged In: YES user_id=406 Browser: Mozilla/4.05 (Macintosh; I; PPC, Nav) 959362451 nobody Logged In: YES user_id=406 Browser: Mozilla/4.05 (Macintosh; I; PPC, Nav) I'm sorry I can't e-mail you this, because you weren't logged in, and didn't provide an e-mail address. There should be a copy of default-gcc.mk in the config directory. I checked the CVS repository and recent tar files, and it is a zero-length file that needs to be there for your configuration to work. Maybe there is a problem with cygwin tar or the Windows 98 file system that disallows zero-length files. Perhaps you can create a file with a single space in it through some means, and that would work just as well. I also see that the "checking for X" test failed. If you are interested in using the X window applications of ivtools you need to acquire Xlib binaries and an X server for Windows as described in http://www.ivtools.org/ivtools/ README.cygwin.txt (same file as ivtools-0.8/README.cygwin). Without X you can probably build up through comterp, the stand-alone text-based command interpreter, but I have not tested this. Also I should mention that I have only successfully built ivtools with Cygwin on Windows NT. Theoretically it should be possible on Windows 98, but it is a completely different operating system (as different as Linux is from BSD), and you might encounter problems I'm unaware beyond these configuration problems. Good luck, Scott Johnston p.s. ivtools binaries are included in Debian 2.1 and 2.2 releases. If you have access to a Debian GNU/Linux machine you might try them out there. 959303620 nobody Logged In: NO Browser: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt) I am using DELL XPST700r (Pentium III) and Windows98, cygwin. cygwin is H-i586-cygwin32. I configure environment by ./configure, then I have error as follows checking how to run the C++ preprocessor... c++ -E checking for ranlib... ranlib checking how to run the C preprocessor... gcc -E checking for X... no checking for directory to install c++ include files... \\cygnus\\cygwin-b20\\H-i 586-cygwin32\\lib\\gcc-lib\\i586-cygwin32\\egcs-2.91.57 \\..\\..\\..\\..\\..\\inc lude\\g++\\ no config/default-gcc.mk this must be a new architecture. configure: error: please create config/default-gcc.mk. How can I make config/default-gcc.mk?. close_date 959711539 959736558 johnston close_date 0 959711539 johnston status_id 1 959711539 johnston 518059 johnston johnston 5 Closed None -comdraw_off 1013796039 Support Requests None None Add -comdraw_off to flipbook, graphdraw, and drawserv and document its use in .mime.types in the web pages. 1014243194 johnston Logged In: YES user_id=406 Changed to -stdin_off, and added to all the drawing editors. But there was no need to document it in the web pages, because the problem hanging on stdin when launching as a helper app was fixed a different way. status_id 1 1014243194 johnston close_date 0 1014243194 johnston 506516 nobody nobody 5 Closed None bug fix for horiz-vert multiline 1011630889 Support Requests None None I successfully compiled ivtools-1.0.1 using gcc-2.7.2 on my linux system but noticed a problem with the multiline feature in that it would not properly draw the second or any subsequent horizontal or vertical lines. It always returned to the coordinates of the very first point. I fixed this by adding the following lines to manips.c (line 356) in the Unidraw directory: _origx = e.x; _origy = e.y; so that this section of code now reads: if (e.button == LEFTMOUSE) { GetGrowingVertices()->AddVertex(e.x, e.y); _origx = e.x; _origy = e.y; } else if (e.button == MIDDLEMOUSE) { I don't know if anyone else has had this problem, but it makes idraw and drawtool much more usable programs for me. Thanks for a very useful set of programs. E.J. Neafsey eneafse@lumc.edu 1014243499 johnston Logged In: YES user_id=406 fixed in cvs, will be incorporated in 1.0.2, thanks for your input. status_id 1 1014243499 johnston close_date 0 1014243499 johnston 400986 mjj johnston 5 Closed None Patches for Solaris 2.5.1 using gcc 2.96 20000721 964662347 Patches None None 992880567 johnston Logged In: YES user_id=406 gcc-3.0 is out, and at the same time ivtools-0.9.4 contains all the modications necessary to compile with it. This patch is no longer necessary, but was probably useful to someone in the interim. Thanks. 976557104 johnston I have decided against including this patch into the forthcoming release of ivtools (0.9) because anything after gcc-2.95.? is considered experimental by the gcc steering committee. This patch will remain here for the use of any party experimenting with new versions of the compiler, and will probably be applied at a later date. 965423162 johnston Murray, Thanks for forwarding the diffs you needed for Solaris 2.5.1 and gcc 2.96 20000721. It seems this is an unstable version of the compiler (which happens now and again), so I will defer applying the diffs that might become unnecessary with the next version of gcc, as you suggested. I will root out that xor name collision. I've encountered that before. I would rather change the name of an unused method than add "-fms-extensions -fno-operator-names" to the gcc command line. I believe the support for declaring functions without type (which defaults to int) will be reinstated, as has happened many times before. To call this an MS-ism is inaccurate. The real disease is unnecessary ANSI compliance which breaks old quality code. I expected things like this to happen once Cygnus was bought by RedHat, and they haven't disappointed. I have a bug entry here at sourceforge for fixing up the arguments for getsockname and accept, once and for all. These need to use the correct typedef instead of int or unsigned int, and then each OS determines which they like. The ?: can't have a generic NULL pointer as one of its arguments? Oh well, I'll take these diffs, because they don't hurt that much. We'll go with the new directory for openwindows X11 config files. I'll get this all (or most of it) included before ivtools-0.8.4 Thanks for your efforts, Scott Johnston 964664629 mjj There is a couple of *real* hacks in graphkit.c and ovkit.c. The compiler I used (straight out of the CVS repository) appeared to have a bug whereby constant strings declared like this: static const char xxx[] = "..."; were referenced everywhere, but never actually emitted by the compiler. I got around this by putting asm statements in which defined the strings in the assembly code. I presume a future revision of the compiler will fix this. The essential part of this patch appears to be the use of the compiler arguments -fms-extensions -fno-operator-names There was a class method named "xor" which was being treated as the xor (^) operator by the new compiler - no-operator-names fixes this. Also, in the Solaris 2.5.1 X11 headers, a lot of functions are declared without a type. The new compiler by default forbids this and the only thing I could find that allowed this behaviour was the ms-extensions option. Oh yes, the Solaris 2.5.1 /usr/ccs/bin/ld dumped core on one library build so I changed to using gcc -shared. Other minor changes: 1. no ICE and SM libraries; len args for getsockname and accept were int instead of unsigned int (this should be config selectable); for some reason the string.h and stdlib.h headers didn't get included. I just went through and added explicit declarations for each error rather than figure out how to fix this - in hindsight I should have fixed it once at the source; the compiler barfed in the case of the ?: operator where the true and false cases had different classes, but direct assignment would work (with an if-else) because conversion was possible - I call this a compiler problem; the new compiler had a bug whereby a stabs record was emitted with an incorrect label causing an undefined reference at link time - only happened on one file (src/glyphs/examples3.1/morpher/figure.c) so I just compiled without "-g" for that file; the configure script had to be changed because the X11 config files are in /usr/openwin/lib/config not /usr/openwin/lib/X11/config. Hope this helps someone. Cheers! Murray... status_id 2 997116426 johnston close_date 992880567 997116426 johnston status_id 1 992880567 johnston close_date 0 992880567 johnston assigned_to 100 965423359 johnston 413485 johnston nobody 5 Open None preserve format for subsequent save 986320683 Feature Requests drawing editor None Preserve the known format of a file when it is Opened so that a subsequent Save/Save-As can default to outputting that format. Requires adding a format selection capability to the Save/Save-As dialog boxes. Requested by jsd@monmouth.com 991239102 johnston Logged In: YES user_id=406 More input from John Denker: One suggestion that would make things much more user friendly (whether or not bitmapped images are handled): -- Set the "filename of current file" according to the .idraw or .eps file that was opened. -- Set a flag somewhere to remember the format of the "current file" -- The objective is that we want ^S (save) to automatically re-write the file in the proper format. The user can cause this to happen (non-automatically!) in the current version, but this is laborious and error-prone. 207602 johnston nobody 5 Open None comterp rand func could preserve/select type of return value 961197446 Feature Requests None None The comterp "rand" func could preserve the type of its input arguments with a :x keyword, or select the type of the return value with one of the following: :d, :i, :f, :l, :s, :c (and :uc, :us, :ui, and :ul). category_id 100900 990569887 johnston artifact_group_id 100674 990569887 johnston 201917 tgruhn nobody 4 Open None Modified version/form of the comdraw -stripped option 950476767 Feature Requests None None When I invoke comdraw with the -stripped option all glyphs/widgets are removed from screen. I would be nice to somehow specify to -stripped that all widgets/top widgets/side widgets are to be stripped. This way one can install customised toolbars, and keep important features such as line style, font, exit, delete, export as/import as, etc. category_id 100901 990569824 johnston artifact_group_id 100674 990569824 johnston artifact_group_id 100100 950549323 johnston priority 5 950507566 johnston summary Modified version/form of the -stripped option 950507566 johnston category_id 100100 950507566 johnston 207631 johnston nobody 7 Open None make graphic file pathname an inspectable attribute 961259647 Feature Requests None None Make the pathname associated with a graphic file (image file, PostScript file, ivtools native format, etc..) an inspectable attribute, something that can be seen with the Attribute tool, and something that can be accessed in the command interpreter using the "." command: gr=at(select) print("%s\n" gr.path) category_id 100901 990569936 johnston artifact_group_id 100674 990569936 johnston priority 5 964283821 johnston 207633 johnston nobody 5 Open None use TextEditor for TextFileComp editing 961260086 Feature Requests None None Use the emacs-like TextEditor object for editing of a TextFileComp, the component that loads a text graphic from file. Regular text graphics are edited on the screen, but it might be a good idea to use a different method for these, to warn the user that they are altering a separate file. At the same time you might find a few bugs in the TextEditor object (having to do with the Load/Save/SaveAs menu which is on the right button) and remove them. 1033089227 johnston Logged In: YES user_id=406 Just added a Quit after Load/Save/SaveAs category_id 100901 990569963 johnston artifact_group_id 100674 990569963 johnston 207630 johnston nobody 5 Open None add --with-motif to configure script 961259383 Feature Requests None None Add a --with-motif=<motifdir> to the ./configure script, and if supplied, automatically build the ivxt example program. Currently this is done manually by editing src/Imakefile. And while you're at it, you might want to experiment with more Motif widgets in the wrapper around an ivtools drawing editor. When this was originally done by Rick Kissh using lesstif, there were problems with pull-down Motif menus, but buttons worked (or was it the other way around?). With a newer version of lesstif things might be better. category_id 100902 990569919 johnston artifact_group_id 100674 990569919 johnston 207558 johnston nobody 2 Open None arrowheads could be better 961114013 Feature Requests None None The arrowheads at the end of a line (or multi-line or ...) could be better, in that they don't significantly change appearance when the brush width goes from zero to four, and the trailing tips do not look optimally positioned when the line is at other than 90 degree angles. This patch: http://www.geocrawler.com/lists/3/SourceForge/650/0/3896283/ makes the arrowheads look a lot better when using a dashed-line brush, but more can be done. It is interesting to compare what gets drawn in the canvas with the appearance of the arrow in the ArrowVarView at the upper-left of the canvas. 1010692687 johnston Logged In: YES user_id=406 Also look at arrowheads with really thick lines (>20). category_id 100901 990569864 johnston artifact_group_id 100100 990569864 johnston priority 5 961114042 johnston 207486 johnston nobody 1 Open None move dialog boxes aside for File/DumpCanvas 961001486 Feature Requests None None The dialog boxes for the File/DumpCanvas menu item should come up to the side of the drawing editor, instead of centered over the drawing editor. The problem is the subsequent dump of the drawing canvas' X Window to a .xwd file includes that dialog box. It also includes the "File Already Exists" dialog box if one of those comes up. You can work-around this problem by moving the dialog boxes aside, so the urgency is low, but it would be nice not to have to do that. Other things to consider: 1) documenting/informing the user of the fact they can restart the drawing editor with the panner/zoomer/slider off if they want to not see that in the canvas dump (i.e. drawtool -zoff -poff -soff). 2) adding a "to command" checkbox on the DumpCanvas dialog box, to allow a Unix filter to be used for post-processing, like the Export Dialog box does. category_id 100901 990569839 johnston artifact_group_id 100674 990569839 johnston priority 5 961001585 johnston 413251 johnston nobody 2 Open None ::AdjustForZoom could be cached 986251672 Feature Requests None None OverlayView::AdjustForZoom is a method that resizes fixed-size graphics before doing a zoom, so that they will remain a constant size after the zoom. This is often a requirement for graphics on a map, or other iconic display where it doesn't make sense to zoom the icons as much as the rest of the graphics. This feature is rarely used, and it would be nice if it the existence of any non-identity value could be detected at the top of the graphics tree, instead of the current state which traverses the whole tree doing nothing at each leaf. There is a similar ::AdjustForPan mechanism for fixed location graphics, and it too is rarely used. Both of these have a small linear cost increase. Often I have worried that it had greater than a small proportional cost, when directly comparing the performance of idraw to drawtool. But after much investigation I find the biggest differences in drawing performances (when repeatedly zooming/de-zooming, an unnatural activity) can be traced to two things: 1) the double-buffering of drawtool, which doubles the drawing cost (but more than doubles the perceived cost, because the eye sees no progress until the very end), and 2) number of vertical lines in the current canvas. drawtool by default comes up with more lines than idraw (because the toolbox is taller given the default fonts), and that directly impacts the time to draw a complex graphic. category_id 100901 990570020 johnston artifact_group_id 113523 990570020 johnston 414573 johnston nobody 7 Open None import/open color raster PS from ivtools 986671463 Feature Requests None None brought up by jsd@monmouth.com: when you print or export in PostScript format with idraw format not selected (a checkbox on the print dialog box, a set of radio buttons on the export dialog box), you get PostScript that will work on a color printer, but can't be imported or re-opened by any ivtools drawing editor. If you select idraw format you get a file that can be printed on a B&W printer, and can be opened/imported by all the ivtools drawing editors. The reason is the extensions to idraw format that were made available when idraw format was deselected on the export or print dialog box. Normal idraw format stores the color data in a PostScript comment, and has a copy of a monochrome version of the image available for printing. The altered format stores the specific kind of raster data, color or gray-level, directly in executable PostScript, so you can print on both color and B&W printers. The solution is to move on to idraw format #14, which would add support for ColorRast and GrayRast idraw-format graphical objects to all the ivtools drawing editors. 990569764 johnston Logged In: YES user_id=406 Not selecting "idraw format" on the export or print dialog boxes gives you a color-printer ready EPS (this wasn't working until ivtools-0.9.4 or 5/22/01 in cvs). Selecting "idraw format" generates b&w-printer ready EPS with color data embedded in comments. So you can get color imagery out of and back into an ivtools drawing editor using idraw EPS. You just can't do it with the less restricted EPS format which is the default on the export and dialog boxes. category_id 100901 990569764 johnston 470715 johnston nobody 5 Open None three deep streams 1002924118 Feature Requests command interpreter None Comterp supports doubly-nested streams. It will take some more work to support triply-nested streams and more. 465824 johnston nobody 5 Open None xform command work on graphics too 1001627248 Feature Requests comdraw/drawserv None Make the comdraw xform command work on graphics as well as points. 207603 johnston nobody 7 Closed None expose fillbg flag via drawing editor GUI 961197755 Feature Requests drawing editor None Expose the "fillbg" (fill-background) flag so that it can be altered in the GUI's of ivtools drawtool, etc.. There is this capability under the hood that allows for partially transparent patterns, but you can only get at it with the :fillbg flag in the document format output by drawtool, etc.. 1007075057 johnston Logged In: YES user_id=406 Done 11/29/01, via a "None" color option under the background color menu. Committed to cvs repository, and will be part of 1.0.1 release. 1002652192 johnston Logged In: YES user_id=406 This could be done with the simple addition of a "None" color under the background color menu. 990575086 johnston Logged In: YES user_id=406 this could be done with the addition of a None color to the bgcolor menu. It should be the last one, to preserve the numbering of the others. status_id 1 1007075057 johnston category_id 100 1007075057 johnston close_date 0 1007075057 johnston priority 5 1002652192 johnston category_id 100901 990569904 johnston artifact_group_id 100674 990569904 johnston 501553 johnston nobody 5 Open None multiple and multi-line exprs in comdraw text editor 1010620585 Feature Requests comdraw/drawserv None Add support for multiple expressions per line and multiple lines per expression to the text editor box at the bottom of comdraw, etc.. summary multiple and multi-line exprs in text ed 1010620730 johnston 506622 johnston nobody 5 Open None save text commands between frames 1011645202 Feature Requests comdraw/drawserv None Now the text command window at the bottom of drawserv and flipbook is cleared every time the current frame changes. This was a design decision to support a unique annotation per frame, but is not that useful when this window is used for a command interpreter. The default should be to retain the contents of this window as frames are navigated. Current behavior should be an option. 516710 johnston nobody 5 Open None floating point graphics 1013556703 Feature Requests drawing editor None Graphics with floating point coordinates could co-exist with the original integer-based graphics. All intermediate transformations done to graphic coordinates are in floating point, and they are only reduced to integers when rendered to the screen. 534569 benh57 nobody 5 Closed None make install should respect DESTDIR 1017042374 Feature Requests None None I am attempting to build a Fink package for ivtools. Fink is a Mac OS X package manager - http://fink.sf.net/ - i have it working, but there is one problem. Fink lives in a /sw sub-heiarchy that has /usr, bin, etc. It also builds debs. So we use both --prefix and DESTDIR. Most packages build like so: configure --prefix=/sw make make install DESTDIR=/sw/src/root-ivtools-1.0.3-1/sw/ The install then goes into a deb, which users then install without having to compile. However, ivtools mixes the compile and install phases. DESTDIR is ignored. So i have to specify a "prefix" of my install directory, which sort-of works, but generates errors like: c++ -g -O2 -o a.out *.o -L/sw/src/ivtools-1.0.3-1/ivtools-1.0/src/Time/DARWIN -lTime -L/sw/src/ivtools-1.0.3-1/ivtools-1.0/src/IVGlyph/DARWIN -lIVGlyph -L/sw/src/ivtools-1.0.3-1/ivtools-1.0/src/IV/DARWIN -lIV -L/usr/X11R6/lib -lXext -lX11 -L/sw/src/root-ivtools-1.0.3-1/sw/lib -lstdc++ -lm /usr/bin/ld: warning -L: directory name (/sw/src/root-ivtools-1.0.3-1/sw/lib) does not exist Of course it does not yet exist, because i'm not installing at that point, just compiling. ivtools needs to respect separate prefix and DESTDIR and not mix the compile and install phases. 1018893938 johnston Logged In: YES user_id=406 The "--prefix" argument to configure is only for indicating the eventual installation directory. There is no need to specify the top-level directory of the source tree, since that is discovered at compile time. So if you did this: ./configure --prefix=/sw/src/root-ivtools-1.0.3-1/sw/ make make install things should work as you desire. Let me know if this is not the case. I just tested it again to be sure, and I see the desired behavior of compiling/linking locally without reference to the non-existent directories where installation will occur in the future. Thanks for your Fink packaging efforts. Please drop me a line when it is done so I can try it out. Scott Johnston P.S. You may want to take a look at the patch files that are part of the FreeBSD port of ivtools. These trim back the set of installed files to be the set useful to a non-developer. That would remove the ClipBoard.3 collission you wrote about earlier. status_id 1 1018893938 johnston close_date 0 1018893938 johnston 619842 johnston nobody 5 Open None add horizontal scrollbar to ivtext 1034017630 Feature Requests misc. and config None add horizontal scrollbar to ivtext (texteditor). 615698 johnston nobody 5 Closed None export all if no selection 1033161942 Feature Requests drawing editor None Export entire drawing if the current selection is empty. Useful for SVG export, and more intuitive then being told you have to always select something. 1034019360 johnston Logged In: YES user_id=406 ready to go as part of next release after ivtools-1.0.6 status_id 1 1034019360 johnston close_date 0 1034019360 johnston 631725 nobody nobody 5 Open None clipping 1036093306 Feature Requests comdraw/drawserv None As far as I can see there is no function for clipping to restrict the graphics output to a clipping rectangle. There could be a 'cliprect' command in comdraw to implement this. 1038953532 johnston Logged In: YES user_id=406 Could be done with a stack of clipping rectangles. 453916 johnston nobody 5 Open None add cap-style and join-style to idraw 14 998423476 Feature Requests drawing editor None Add support for selecting cap-style and join-style to the next version of idraw format PostScript (Version 13). 1038953609 johnston Logged In: YES user_id=406 13 already went out (to fix problem with RH executable X11 fonts). So change this to 14. summary add cap-style and join-style to idraw 13 1038953609 johnston 648084 johnston nobody 5 Closed None extract and insert graphic state 1038953790 Feature Requests command interpreter None Add tools (or commands) for extracting the graphic state from an existing graphic, and inserting the current graphic state into an existing graphic. Also could develop a graphic state stack at the same time. 1038953926 johnston Logged In: YES user_id=406 already listed under task manager. status_id 1 1038953926 johnston close_date 0 1038953926 johnston 648076 johnston nobody 5 Open None flipbook load multiple graphic files 1038953149 Feature Requests drawing editor None flipbook could load multiple graphics files when provided (via wildcard or not) on the command line, one per frame. new rendering capability true Capabilities that can be added to the painter objects for graphics and glyphs 16805 new rendering capability anti-aliasing The existing double-buffering mechanism for both graphics and glyphs could be extended to do anti-aliasing at the same time graphics are drawn to the offscreen pixmap. For graphics this would be an extension to (or derived from) OverlayViewer and OverlayPainter. For glyphs it would be an extension to the InterViews 3.1 Canvas. 0 5 0 964767600 964767600 johnston Open 46337 new rendering capability use double-buffering ext. to eliminate tearing Make use of X11's double-buffering extension. ivtools already uses double-buffering for rendering, but it not synched with the monitor's vertical retrace, which is something the double-buffering extension supports. Because of this you see tears in animations if they are moving when physically redrawn on the monitor. 0 5 0 1011600000 1011600000 johnston Open 52877 new rendering capability cheap transparency and anti-aliasing As an alternate to the ultimate solutions proposed elsewhere for anti-aliasing and transparency, one could cobble together a set of visual-pleasing tricks that get 80 to 90 percent of the way there. Instead of transparent vector graphics, one could rely on the None background color, and a more flexible selection mechanism for pattern stipple masks. Adequate resolution the eye has a hard time distinguishing true transparent graphics from semi-transparent ones. This trick is used in real-time video games all the time. And an easy and fairly cheap way to get anti-aliasing would be to render everything at 2x offscreen (using the existing double-buffering pixmap system), then reduce by 2 (replacing every 2x2 pixels with a 1 pixel average) before pixblt'ing (XCopyArea). Requires shared memory extension to be worth it. 60 5 0 1019545200 1019545200 johnston Open 16806 new rendering capability alpha-transparency Alpha-transparency could be added to the graphics rendering mechanism of ivtools, in much the same manner as anti-aliasing, by extending the existing mechanism for double-buffered graphics display. The Color object already has a placeholder for the alpha value. Like anti-aliasing, this is an essentially an image processing operation done to the offscreen pixmap used for double buffering. 95 5 0 964767600 964767600 johnston Open 52884 new rendering capability alpha blending lookup table a lookup table used to find the resultant color would speed things up a lot when doing alpha-blending of imagery. Could be computed once per alpha value used for a single image, or could be generated at startup for all possible combinations (assuming an 8 or 10 bit alpha value). 100 5 0 1019545200 1019545200 johnston Closed drawing editor extensions true Planned extensions to ivtools drawing editors 18615 drawing editor extensions wedge and arc graphics Fill in this oversight in the graphics primitives. It has been added many times to InterViews derivatives, just not this one. 0 5 0 968198400 968198400 johnston Open 19503 drawing editor extensions center when lauched on raster Center the display of a raster when an ivtools drawing editor is launched on a raster pathname. This could be as straightforward as adjusting the page-size to the raster extent. 0 5 0 970185600 970185600 johnston Open 34235 drawing editor extensions add built-in support for PNG Add built-in support for import and save/restore of PNG files by pathname, similar to current support for JPEG and GIF. Would require pngtopnm to work. 100 5 0 994662000 996044400 johnston Closed 18614 drawing editor extensions polygon clipped rasters Enhance the raster object so it can be clipped with a polygon. 85 5 0 968137200 968137200 johnston Open 17363 drawing editor extensions keyboard shortcuts for drawing navigation It would be nice to have more keyboard shortcuts for drawing editor navigation. Currently we have Ctrl-Z and Shift-Z as shortcuts for zoom-in and zoom-out. We could also use the arrow keys as keyboard shortcuts for panning (Shift for larger moves), Page-up and Page-down for next-screen-up and next-screen-down, and maybe Tab and Back-tab for next-screen-right and next-screen-left (Ctrl-F and Ctrl-B are reserved for frame-forward and frame-backward in ivtools flipbook). Home and End could be upper-left and lower-right respectively. 65 5 0 965718000 965718000 johnston Open 52875 drawing editor extensions Precise Dash Add an item to the Brush menu to enter a bitmap (hex number) for the dash pattern. 0 5 0 1019545200 1019545200 johnston Open 52876 drawing editor extensions Precise Zoom Implement a Precise Zoom that allows for values other than power of 2. Done by adjusting the top-level transformer as needed. Right now there are stoppers that force all magnification to a power of 2, for reasons not well remembered. 0 5 0 1019545200 1019545200 johnston Open 52878 drawing editor extensions gradient fills gradient 2-color fills using 3d planar strategy behind SMPTE wipes. Useful for raster blends as well. 0 5 0 1019545200 1019545200 johnston Open 52879 drawing editor extensions align to path mechanism to align characters or other compound graphics to a spline or multi-line. 0 5 0 1019545200 1019545200 johnston Open 52880 drawing editor extensions pattern editor Dialog box for editing pattern bitmap. 0 5 0 1019545200 1019545200 johnston Open 52881 drawing editor extensions color chooser dialog box for choosing colors from color wheel or square. 0 5 0 1019545200 1019545200 johnston Open 52885 drawing editor extensions "Dump Window As" extensions The File/"Dump Window As" could be extended to support other image formats, interactive clipping, and/or command execution similar to the export dialog box. 0 5 0 1019545200 1019545200 johnston Open 58570 drawing editor extensions SVG export SVG export to allow for externalization of alpha-transparency and/or polygon-clipped rasters. 30 5 0 1027407600 1027407600 johnston Open 52505 drawing editor extensions graphic state push and pull Add a command or tool to push the current drawing editor graphic state into graphics, and another command or tool pull a graphic state out of an existing graphic and make it the current drawing editor graphic state. 0 5 0 1019113200 1019113200 johnston Open new comdraw commands true tasks for adding new commands to comdraw, for graphics and viewer control. 18070 new comdraw commands cleartools command to empty custom toolbar A new cleartools command would empty the custom toolbar that gets populated by the recently added addtool command. Also a deltool command makes sense, one that accepts the compview returned by addtool. 0 5 0 967248000 967248000 johnston Open 29173 new comdraw commands save and export commands The functionality of the Save/SaveAs and Export dialog boxes (under the File menu) should be available as comdraw commands. 0 7 0 986281200 986281200 johnston Closed 30984 new comdraw commands coordinate conversion commands commands to convert to/from drawing and screen coordinates: stod and dtos. All of the graphic construction commands are in screen coordinates. Until they all accept drawing coordinates (which could be done with one global command), you would use these. 100 5 0 989218800 989218800 johnston Closed 30632 new comdraw commands open and print commands To round off the set of comdraw file mgmt commands, make an "open" and "print" command. 80 5 0 988700400 988700400 johnston Open InterViews synchronization true Synchronize ivtools with Neuron and PDP++ copy of InterViews 18934 InterViews synchronization synchronize with Neuron copy of InterViews Download the Neuron copy of InterViews, and diff against the original InterViews 3.1 source tree. Incorporate any bug fixes or interesting features found this way. http://neuron.duke.edu 0 5 0 968803200 968803200 johnston Open 18935 InterViews synchronization synchronize with PDP++ copy of InterViews Download the PDP++ version of InterViews, and diff against the original InterViews 3.1 source tree. Incorporate any bug fixes or enhancments as warranted. Their version of InterViews is related to the Neuron guys copy. http://www.cnbc.cmu.edu/PDP++/PDP++.html 95 1 0 968742000 968742000 johnston Open config/miscellaneous true configuration and miscellaneous tasks 24212 config/miscellaneous check for imake in configure script Test for an imake executable in the configure script. Alternately imake could be obsoleted if there was a way of making gcc (and its C pre-processor) do the same thing that imake does. 0 5 0 978595200 978595200 johnston Open 28217 config/miscellaneous tgeomobj.[ch] After geomobj.[ch] came fgeomob.[ch]. A final addition to this series would be tgeomobj.[ch] for a templated geomobj classes. The balance of ivtools (and vhclmaps) would remain with the type specific objects, but these would be handy for application programmers, especially if there was a surfeit of assignment conversion operations as needed to convert to the int or float variant. 0 5 0 985075200 985075200 johnston Open 32863 config/miscellaneous use snprintf Migrate all uses of sprintf to snprintf, to get protection from overwriting the output character buffer. 0 5 0 992242800 992242800 johnston Open 38753 config/miscellaneous add all parameters to program man pages Document all the parameters (that show up with a -help) on the various program man pages. 100 7 0 1000969200 1000969200 johnston Closed drawserv evolution true Evolve drawserv into vector-graphics groupware documentation and web pages true planned improvements to documentation and web pages 57648 documentation and web pages migrate pub/doc/unidrawpic.ps to ivtools dir Migrate pub/doc/unidrawpic.ps to ivtools html directory, and get rid pub/doc directory in the process (first verify that everything else in that directory lives elsewhere. 100 5 0 1026198000 1026198000 johnston Closed 58571 documentation and web pages document :popen Document the use of :popen somewhere, the keyword parameter to an ovfile object in a drawtool etc.. document that accepts a Unix command line from which the graphic file can be imported. 0 5 0 1027407600 1027407600 johnston Open 1.0 checklist true Checklist of things to do before a 1.0 release 39237 1.0 checklist fix bug in stream followed by semi-colon Fix comterp bug where a stream object followed by other commands (separated by semi-colons) causes the other commands to be ignored, i.e.: s=0..20;while(v=next(s) print("%d " v) :nilchk) doesn't work, but splitting them onto two lines does. 100 5 0 1001487600 1001487600 johnston Closed 39309 1.0 checklist upload pstoedit patch Upload the recent pstoedit patch (to version 3.30) that makes the idraw format work for smart12rgb image sources (the kind generated by a Netscape print operation). Make a link to it from the pstoedit web page. 100 5 0 1001574000 1001574000 johnston Closed 39343 1.0 checklist make the "," operator stream-like Make the comterp "," operator live up to its name, and act like a stream operator. Then things like 0..10,11,12 should create one flat stream. This requires revisiting/rethinking the use of the comma operator to construct arrays. 100 5 0 1001574000 1001574000 johnston Closed 39235 1.0 checklist flesh out program man pages Add all undocumented parameters (the ones that show up with a -help) to the man pages for drawtool, comdraw, flipbook, and drawserv. 100 5 0 1001487600 1001487600 johnston Closed 39239 1.0 checklist beta-testing recruit and work with beta-testers for a 1.0 pre-release -- hope to prebuild on RedHat, Debian, FreeBSD, NetBSD, Solaris, and what else? (HPUX?, AIX?, Irix?, OSF? Hurd?, SUSE? OS-X?) 100 5 0 1001487600 1001487600 johnston Closed 39236 1.0 checklist generate ivtools-doc-1.0.tgz Generate new tar file of documentation so that it is ready at the same time as a 1.0 release. 100 5 0 1001487600 1001487600 johnston Closed 39240 1.0 checklist publicity author and forward a press release to lwn.net, slashdot.org, freshmeat.net, comp.os.linux.announce, and where else? 100 5 0 1001487600 1001487600 johnston Closed 39238 1.0 checklist create/revise web pages of possible uses Create or revise web pages of possibles use to which ivtools can be put: - McCloud'ish Infinite Canvas usage - Structured HyperGraphics - Todd Gruhn's chemical/electrical widget drawing - nod to vhclmaps - netpbm - pstoedit - use of :popen in drawtool documents and more to come. 100 5 0 1001487600 1001487600 johnston Closed new comterp commands true new commands for the generic interpreter 15651 new comterp commands floor, ceil, and round commands Add comterp commands for the traditional numeric operators floor, ceil(ing), and round. Their docstring method would return: int|long=floor(num) int|long=ceil(num) int|long=round(num) 100 8 0 962150400 973036800 johnston Closed 16377 new comterp commands type and class commands Create a type and class command to return the symbols associated with the type of a value and the class of a value if its of object type. 100 5 0 963878400 963964800 johnston Closed 16379 new comterp commands scan command scan command to complement print command val=scan(fmtstr valstr) 0 5 0 963878400 963878400 johnston Closed 15653 new comterp commands trace, step, and pause commands Add trace, step, and pause commands to comterp, to complement the recently implemented pause command for comdraw. 90 5 0 962089200 972979200 johnston Open 24218 new comterp commands handle SIGINT for post-evaluated commands All the post-evaluated commands (like for, while, etc..) should detect and handle SIGINT (Ctrl-C) by returning early. 0 5 0 978595200 978595200 johnston Open 15652 new comterp commands comdef command Add a "foreach" command to comterp, to execute a parameterized block of code once per each member of a list. The chosen method for passing parameters to a block of code could be reused in a comterp command for defining comterp commands on the fly. 0 5 0 962089200 972979200 johnston Open 71 ivtools johnston true 947792465 take the copyleft survey Take the ivtools Copyleft Survey Take a look at the ivtools survey on applying some form of copyleft to the ivtools X11 style copyright, and register your opinion. http://sourceforge.net/survey/survey.php?group_id=275&survey_id=10018 72 ivtools johnston true 947697420 NetBSD port underway NetBSD port underway Thanks to the efforts of Todd Gruhn, it looks like we will soon have a NetBSD port completed. Anybody else want to repeat the process for OpenBSD or FreeBSD? 175 ivtools johnston true 948306724 ivtools-0.8 released ivtools-0.8 Released The first major release in over a year, ivtools-0.8 is now ready for download: http://sourceforge.net/download.php/ivtools/ivtools-0.8.tgz Changes since 0.7.10: New support for use as an embedded vector graphics shell, Lisp-like symbol assignment semantics added to the command interpreter, new back-by-one and forward-by-one commands added to the Struct menu of drawtool, better links between embedded class html and man pages, NetBSD port. Changes since 0.7: asynchronous download of rasters and other graphics file from URL's, use of X11 shared memory for raster display, fully-animated graphical transformations, in-line extractable class documentation, Cygwin Windows-NT port. Documentation tarball: http://sourceforge.net/download.php/ivtools/ivtools-doc-0.8.tgz 202 ivtools johnston true 948397708 NetBSD port completed NetBSD port completed Thanks to the efforts of Todd Gruhn, the NetBSD port of ivtools was completed in time for ivtools-0.8. Everything compiles and builds without a hitch. There is a glitch in the installation process, as NetBSD wants everything installed in /usr/local/lib/ivtools and /usr/local/bin/ivtools (instead of /usr/local/lib and /usr/local/bin). Take a look at this e-mail for further details: http://www.geocrawler.com/lists/3/SourceForge/651/0/3171654/ 296 ivtools johnston true 948830102 vhclmaps now at SourceForge too vhclmaps now at SourceForge too vhclmaps is a package of map-visualization and vehicle simulation software that builds on top of ivtools. Now this project is hosted at SourceForge as well: http://sourceforge.net/project/?group_id=1653 927 ivtools johnston true 951331713 www.ivtools.org www.ivtools.org The new home page for ivtools is http://www.ivtools.org Get a copy of the BSD/MIT licensed web pages at: http://sourceforge.net/project/filelist.php?group_id=275 3337 ivtools johnston true 960323191 pause command added to ivtools comdraw pause command added to ivtools comdraw A rather useful "pause" command has been added to ivtools comdraw (see latest version in the CVS repository). This can be embedded in comdraw scripts to suspend replay, and allow for arbitrary commands (or other user interface interactions) to occur until a stand-alone C/R is entered. It can also be used for debugging comdraw scripts, allowing the programmer to inspect (and modify) the value of any global or local variable before resuming execution of the script. This is the first of three script debugging commands planned for ivtools-0.9 (the other two: step and trace). Scott Johnston http://www.ivtools.org 3486 ivtools johnston true 960845619 ivtools-0.8.3: improved vector-graphic scripting language ivtools-0.8.3: improved vector-graphic scripting language ivtools-0.8.3 has many improvements to the vector-graphic scripting language embedded in ivtools comdraw, including a new global variable mechanism and a "pause" command useful for debugging comdraw scripts. The command interpreter used in comdraw is fully byte-compiled, supports C expression syntax, and has a full complement of control constructs implemented as regular commands with deferred execution of their body. This is done with an efficient and unique combination of pre-fix and post-fix evaluation of the expression tree that limits the runtime stack to linear growth, making use of the interpreter rather scaleable. Watch the comdraw web page below for soon-to-be-published sample scripts. E-mail me (johnston@users.sourceforge.net) if you have any ideas or requests for a sample comdraw script. Scott Johnston http://www.ivtools.org http://www.ivtools.org/ivtools/comdraw.html http://sourceforge.net/projects/ivtools/ 5662 ivtools johnston true 967067325 ivtools-0.8.4 builds on FreeBSD ivtools-0.8.4 builds on FreeBSD A new release of ivtools, 0.8.4 from http:/download.sourceforge.net/ivtools/ivtools-0.8.4.tgz now builds on FreeBSD (tested with bsd.compile.sourceforge.net). An interesting new feature is the ability to draw then import a custom toolbutton. With it you can plop down copies of its graphic where you want in a drawing. Useful for those drawing repetitive material, like children's schoolwork. http://www.ivtools.org http://sourceforge.net/projects/ivtools 10738 ivtools johnston false 977342169 ivtools-0.9 ready for download ivtools-0.9 ready for download A major new release of ivtools is now available: http://download.sourceforge.net/ivtools/ivtools-0.9.tgz Since 0.8 we've focused on extending the command set for the scripting language built in to the drawing editors, including the traditional debug commands of step, trace, and pause. 11985 ivtools johnston true 979931339 ivtools-0.9.1 with minor changes ivtools-0.9.1 with minor changes ivtools-0.9.1 is out with minor changes like incorporate verbiage for GPL dual licensing and fixing the version number reported by executables when they start running. http://sourceforge.net/ivtools/ivtools-0.9.1.tgz http://www.ivtools.org http://www.ivtools.org/ivtools/ivtools-0.9-CHANGES.txt 16140 ivtools johnston true 986508940 ivtools-0.9.2: save/restore by filter command ivtools-0.9.2: save/restore by filter command New feature: save graphics or rasters imported from Unix filter commands by writing only the command line to the ivtools document file. Subsequent opens rerun the commands, which regenerates the graphics or rasters. Now you can assemble arbitrary output from Unix commands into a layered graphic, single or multi-frame. Useful for displaying the state of video hardware, the content of image databases, or the output of image processing and analysis. This capability joins the existing save/restore by URL capability that made it possible to add hyperlinks to ivtools documents. Together they allow for the easy composition of completely arbitrary graphical displays computed and composed from the many possible resources you have available on the net and your machine. Build from source tested on RedHat (6.1), Debian (unstable), and FreeBSD (3.1) http://www.ivtools.org http://sourceforge.net/projects/ivtools 18759 ivtools johnston true 990213997 ivtools-0.9.3: save/export and coord conversion commands ivtools-0.9.3: save/export and coord conversion commands new save and export (keyboard) commands for comdraw, plus coordinate conversion (screen to drawing, drawing to screen). Help returned in keyboard command interpreter window. http://www.ivtools.org 20626 ivtools johnston true 992881275 ivtools-0.9.4 ready for gcc-3.0 ivtools-0.9.4 ready for gcc-3.0 A new release of ivtools, 0.9.4, is ready to be compiled and linked with gcc-3.0. The export/import drawing editor extensions have been rewritten where needed for libstdc++ v3. There are a few known problems I haven't been able to resolve (gdb doesn't yet work with the C++ generated by gcc-3.0), so if you rely on these mechanisms, especially when built with ACE, you probably want to stay with gcc-2.95.* for now. Other changes at: http://www.ivtools.org/ivtools/ivtools-0.9-CHANGES.txt Scott Johnston http://www.ivtools.org http://sourceforge.net/projects/ivtools 22969 ivtools johnston true 996166939 ivtools-0.9.5 adds PNG support ivtools-0.9.5 adds PNG support ivtools-0.9.5 adds PNG support to ivtools drawing editors (via the use of pngtopnm). Now PNG graphics can be imported, saved, and restored via pathname (or arbitrary Unix command line). This makes PNG graphics equally well supported as JPEG, GIF, and aribitrary PostScript. idraw-formatted PostScript, PBM/PGM/PPM, TIFF, and XBM are native formats of the ivtools drawing editors and don't require add-on filters (see http://www.ivtools.org/ivtools/drawtool.html for more detail). This release also does a lot of work on polishing the use of gcc-3.0 and libstdc++-v3, especially in conjunction with the ACE networking toolkit. There is one known problem in the incremental loading (and display) of rasters from a URL. This capability has worked fine for years. Perhaps the problem will be corrected in the next version of gcc. Or perhaps gdb will bulk up to the point you can use it to debug gcc-3.0 C++ programs, and I'll get it that way. Forward. Scott Johnston 24662 ivtools johnston true 998423296 ivtools-0.9.6: gcc-3.0.1 and bit-wise comterp operators ivtools-0.9.6: gcc-3.0.1 and bit-wise comterp operators ivtools-0.9.6 adds support for gcc-3.0.1, as well as bit-wise operators to comterp: &, |, ^, and ~. The "^" operator had been a shortcut for the "pow" command (raise a number to a power), so watch out for that backward compatibility in existing scripts. http://www.ivtools.org/ivtools/ivtools-0.9-CHANGES.txt http://sourceforge.net/projects/ivtools http://www.ivtools.org 6194 ivtools johnston true 968268552 ivtools adds GPL license ivtools adds GPL license As of September 6th 2000, ivtools is made available under the GPL as well as the original X11-style license. Patch submitters can do the same, or elect to apply only the GPL to their work. In that case I will gladly maintain an archive of GPL-only enhancements. This change is reflected in the ivtools cvs repository at SourceForge: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/ivtools-0.8/?cvsroot=ivtools as well as here: http://www.ivtools.org/ivtools/ivtools-0.8-COPYRIGHT.txt Scott Johnston http://www.ivtools.org http://sourceforge.net/projects/ivtools 28458 ivtools johnston true 1003357625 ivtools-0.9.7: on the verge of 1.0 ivtools-0.9.7: on the verge of 1.0 This is the last release in the 0.9 series for ivtools. The only changes between 0.9.7 and 1.0 will be those required to fix build problems in various environments. Grab a copy and try it out! This release includes major changes to the command interpreter embedded in ivtools, to finalize the semantics prior to a 1.0 release. It has been extended with an APL-like mechanism for auto-vectorization of normally scalar operators (i.e. a stream times a scalar yields a stream, which can then be used to compose other expressions). This turns conventional looping inside out, and is a natural fit for certain graphical and imaging algorithms. http://www.ivtools.org http://www.ivtools.org/ivtools/ivtools-0.9-CHANGES.txt http://sourceforge.net/projects/ivtools 28579 ivtools johnston true 1003510263 0.9.7 patch for building with gcc-3.0, on NetBSD, on Alpha 0.9.7 patch for building with gcc-3.0, on NetBSD, on Alpha Here is a patch for building ivtools-0.9.7 with gcc-3.0, or on NetBSD, or on Linux Alpha: http://www.ivtools.org/pub/src/patches/ivtools-011019-johnston-078 29749 ivtools johnston true 1004999934 ivtools-1.0 ivtools-1.0 ivtools-1.0 is now available. ivtools is a collection of vector-graphic editors derived from idraw with layered extensions for scripting, animation, and graph-editing. Seven years in the making, time to see what you can make with it: http://www.ivtools.org http://www.ivtools.org/ivtools/changelogs.html http://www.c2.com/cgi/wiki?IvTools http://sf.net/projects/ivtools http://sf.net/foundry/vectorgraphics 34284 ivtools johnston true 1010683128 waiting for ivtools-1.0.1? waiting for ivtools-1.0.1? Waiting for ivtools-1.0.1? Now your wait is over. It's here, with all the minor fixups you'd expect one release after the odometer rolled over, and a few new features as well: "None" background colors that make for semi-transparent patterns, comdraw raster commands for pixel poking and polygon clipping, etc.. Enjoy. http://www.ivtools.org http://sourceforge.net/projects/ivtools 34589 ivtools johnston true 1011028689 minor patch for 1.0.1 minor patch for 1.0.1 Here is a minor patch for ivtools-1.0.1 that keeps graphdraw compiling without ACE. It also changes the year in the CHANGES file to 2002 (I always goof that up the first time every year): http://www.ivtools.org/ivtools/ivtools-020110-johnston-019.txt 38790 ivtools johnston true 1015287450 ivtools-1.0.2 ready for XDarwin (Mac OS X) ivtools-1.0.2 ready for XDarwin (Mac OS X) ivtools-1.0.2 now builds from source on Mac OS X, the new Apple operating system derived from BSD with a Mach kernel. It relies on the 4.2.0 release of XFree86 available from either http://xdarwin.org or as a one-click installer direct from Apple: http://www.apple.com/downloads/macosx/unix_apps_utilities/ This release also refreshes the building of ivtools on Windows using Cygwin (see http://www.cygwin.com/xfree for a server). And it incorporates a lot of improvements to the HPUX build process as well. For a complete list of changes visit the changelog: http://www.ivtools.org/ivtools/ivtools-1.0-CHANGES.txt http://www.ivtools.org 39309 ivtools johnston false 1015879581 ivtools-1.0.3 with minor Darwin fix ivtools-1.0.3 with minor Darwin fix ivtools-1.0.3 has a minor fix for building on Darwin (MacOS X). Users of any other operating system who've already got ivtools-1.0.2 can ignore this release. 48176 ivtools johnston false 1025108777 ivtools-1.0.4: alpha-transparent rasters ivtools-1.0.4: alpha-transparent rasters ivtools-0.4 introduces a new, and newly optimized, mechanism for alpha-transparent rasters. Under Edit/ImageProcessing/AlphaTransparent you enter a value from 0.0 to 1.0 to apply to all rasters in the current selection. Values are save/restored in the drawing editor document, and this transformation can be undone/redone like most other operations in these drawing editors. The really good news is the alpha-transparent rendering mechanism has been optimized for TrueColor displays (X11 displays with 16 to 24 bits of colormap depth), which preserves expected interactivity once a raster is transparent. The not so good news is alpha-transparency is not exported to the idraw EPS format. Any volunteers for hacking idraw EPS to incorporate transparency? Show me how to do it in PostScript, and I'll do the rest in C++, and give you most of the credit :-). For more detail on the rest of the changes see: http://www.ivtools.org/ivtools/ivtools-1.0-CHANGES.txt http://www.ivtools.org http://sf.net/projects/ivtools 50859 ivtools johnston false 1027962395 make your own RPM with newly uploaded spec file make your own RPM with newly uploaded spec file Make your own RPM for ivtools with newly uploaded spec file. The current binary RPM for ivtools was generated on RedHat 6.2, and seems to only work on RedHat 6.2. Hopefully someone will generate (and donate) an RPM from RedHat 7.* (be sure not to use gcc-2.96 though). Scott 60770 ivtools johnston true 1038338918 ivtools Fink package available for Jaguar ivtools Fink package available for Jaguar ivtools-1.0.6 has now been packaged for Jaguar (MacOS X 10.2) using fink: http://fink.sf.net ivtools-1.2.11a1/src/000077500000000000000000000000001214471147700143145ustar00rootroot00000000000000ivtools-1.2.11a1/src/AceDispatch/000077500000000000000000000000001214471147700164645ustar00rootroot00000000000000ivtools-1.2.11a1/src/AceDispatch/ace_dispatcher.cc000066400000000000000000000104771214471147700217420ustar00rootroot00000000000000/* * Copyright (c) 1996 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifdef HAVE_ACE #include #include #include #include implementTable(TimerTable,IOHandler*,int) AceDispatcher::AceDispatcher() : Dispatcher() { _reactor = new ACE_Reactor(); _table = new TimerTable(1000); } AceDispatcher::AceDispatcher(ACE_Reactor* ar) : Dispatcher() { _reactor = ar; _table = new TimerTable(1000); } AceDispatcher::~AceDispatcher() { delete _reactor; delete _table; } void AceDispatcher::attach(int fd, DispatcherMask mask, IOHandler* handler) { if (mask == ReadMask) { // _rmask->setBit(fd); _reactor->register_handler((ACE_HANDLE)fd, new ACE_IO_Handler(handler), ACE_Event_Handler::READ_MASK); _rtable[fd] = handler; } else if (mask == WriteMask) { // _wmask->setBit(fd); _reactor->register_handler((ACE_HANDLE)fd, new ACE_IO_Handler(handler), ACE_Event_Handler::WRITE_MASK); _wtable[fd] = handler; } else if (mask == ExceptMask) { // _emask->setBit(fd); _reactor->register_handler((ACE_HANDLE)fd, new ACE_IO_Handler(handler), ACE_Event_Handler::EXCEPT_MASK); _etable[fd] = handler; } else { abort(); } if (_nfds < fd+1) { _nfds = fd+1; } } void AceDispatcher::detach(int fd) { // _rmask->clrBit(fd); _reactor->remove_handler((ACE_HANDLE)fd, ACE_Event_Handler::RWE_MASK); _rtable[fd] = nil; // _wmask->clrBit(fd); _wtable[fd] = nil; // _emask->clrBit(fd); _etable[fd] = nil; if (_nfds == fd+1) { while (_nfds > 0 && _rtable[_nfds-1] == nil && _wtable[_nfds-1] == nil && _etable[_nfds-1] == nil ) { _nfds--; } } } void AceDispatcher::startTimer(long sec, long usec, IOHandler* handler) { ACE_Time_Value delta(sec, usec); ACE_IO_Handler* ehandler = new ACE_IO_Handler(handler); int timer_id = _reactor->schedule_timer(ehandler, NULL, delta); _table->insert(handler, timer_id); } void AceDispatcher::stopTimer(IOHandler* handler) { int timer_id; if (_table->find_and_remove(timer_id, handler)) { _reactor->cancel_timer(timer_id); } } void AceDispatcher::dispatch() { _reactor->handle_events(); } boolean AceDispatcher::dispatch(long& sec, long& usec) { ACE_Time_Value* tv = new ACE_Time_Value(sec, usec); timeval curTime1; #if defined(svr4) && !defined(__GNUC__) gettimeofday(&curTime1); #else struct timezone curZone; gettimeofday(&curTime1, &curZone); #endif int nfound = _reactor->handle_events(tv); timeval curTime2; #if defined(svr4) && !defined(__GNUC__) gettimeofday(&curTime2); #else gettimeofday(&curTime2, &curZone); #endif ACE_Time_Value* t1 = new ACE_Time_Value(curTime1); ACE_Time_Value* t2 = new ACE_Time_Value(curTime2); ACE_Time_Value* elapsed = new ACE_Time_Value(); ACE_Time_Value* howlong = new ACE_Time_Value(); *elapsed = *t2 - *t1; if (*tv > *elapsed) { *howlong = *tv - *elapsed; } sec = howlong->sec(); usec = howlong->usec(); delete tv; delete t1; delete t2; delete elapsed; delete howlong; return nfound > 0; } #endif ivtools-1.2.11a1/src/AceDispatch/ace_dispatcher.h000066400000000000000000000045141214471147700215770ustar00rootroot00000000000000/* * Copyright (c) 1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef _ace_dispatcher_h #define _ace_dispatcher_h #ifdef HAVE_ACE #include #include #include #include #include class ACE_Reactor; declareTable(TimerTable,IOHandler*,int) // A Dispatcher implemented with an ACE_Reactor. Make sure that // Dispatcher::_instance is set to one of these when using InterViews // with ACE. class AceDispatcher : public Dispatcher { public: AceDispatcher(); AceDispatcher(ACE_Reactor*); virtual ~AceDispatcher(); ACE_Reactor* reactor() { return _reactor; } // virtual void link(int fd, DispatcherMask, IOHandler*); // virtual IOHandler* handler(int fd, DispatcherMask) const; // virtual void unlink(int fd); virtual void startTimer(long sec, long usec, IOHandler*); virtual void stopTimer(IOHandler*); // virtual boolean setReady(int fd, DispatcherMask); virtual void dispatch(); virtual boolean dispatch(long& sec, long& usec); protected: virtual void attach(int fd, DispatcherMask, IOHandler*); virtual void detach(int fd); ACE_Reactor* _reactor; TimerTable* _table; }; #endif #endif ivtools-1.2.11a1/src/AceDispatch/ace_iohandler.cc000066400000000000000000000034151214471147700215530ustar00rootroot00000000000000/* * Copyright (c) 1994 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifdef HAVE_ACE #include ACE_IO_Handler::ACE_IO_Handler(IOHandler* handler) : ACE_Event_Handler() { _iohandler = handler; } int ACE_IO_Handler::handle_input (ACE_HANDLE fd) { return _iohandler->inputReady(fd); } int ACE_IO_Handler::handle_output (ACE_HANDLE fd) { return _iohandler->outputReady(fd); } int ACE_IO_Handler::handle_exception (ACE_HANDLE fd) { return _iohandler->exceptionRaised(fd); } int ACE_IO_Handler::handle_timeout (const ACE_Time_Value &tv, const void *arg) { _iohandler->timerExpired(tv.sec(), tv.usec()); return 0; } #endif ivtools-1.2.11a1/src/AceDispatch/ace_iohandler.h000066400000000000000000000042521214471147700214150ustar00rootroot00000000000000/* * Copyright (c) 1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef _ace_iohandler_h #define _ace_iohandler_h #ifdef HAVE_ACE #include #include #include #include // An ACE wrapper around InterViews IOHandler. This makes possible // usage of InterViews IOHandlers with ACE_Dispatcher. class ACE_IO_Handler : public ACE_Event_Handler { public: ACE_IO_Handler(IOHandler*); IOHandler* iohandler() { return _iohandler; } virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE); // Called when input events occur (e.g., connection or data). virtual int handle_output (ACE_HANDLE fd = ACE_INVALID_HANDLE); // Called when output events are possible (e.g., flow control // abates). virtual int handle_exception (ACE_HANDLE fd = ACE_INVALID_HANDLE); // Called when execption events occur (e.g., SIGURG). virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0); // Called when timer expires. protected: IOHandler* _iohandler; }; #endif #endif ivtools-1.2.11a1/src/AttrGlyph/000077500000000000000000000000001214471147700162325ustar00rootroot00000000000000ivtools-1.2.11a1/src/AttrGlyph/attredit.cc000066400000000000000000000151251214471147700203650ustar00rootroot00000000000000/* * Copyright (c) 1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __GNUC__==2 && __GNUC_MINOR__<=7 #else #define STL_VECTOR #include #endif using std::vector; declareActionCallback(AttributeListEditor) implementActionCallback(AttributeListEditor) declareFieldEditorCallback(AttributeListEditor) implementFieldEditorCallback(AttributeListEditor) AttributeListEditor::AttributeListEditor(AttributeList* al) : Patch(nil) { _list = al; Resource::ref(_list); DialogKit& dk = *DialogKit::instance(); WidgetKit& wk = *WidgetKit::instance(); _namefe = dk.field_editor("", wk.style(), new FieldEditorCallback(AttributeListEditor) (this, &AttributeListEditor::fe_add, &AttributeListEditor::fe_clr)); _valfe = dk.field_editor("", wk.style(), new FieldEditorCallback(AttributeListEditor) (this, &AttributeListEditor::fe_add, &AttributeListEditor::fe_clr)); Style* s = new Style(wk.style()); s->attribute("rows", "10"); s->attribute("columns", "30"); _ete = new EivTextEditor(s, false); _ete->ref(); _ete->textview()->disable_caret(); build(); } AttributeListEditor::~AttributeListEditor() { // _ete->unref(); Resource::unref(_list); } AttributeList* AttributeListEditor::list() { return _list; } void AttributeListEditor::add() { const String* txt = _namefe->text(); if (txt->length() > 0) { char* buf = new char[strlen(_valfe->text()->string())+2]; sprintf(buf, "%s\n", _valfe->text()->string()); while(isspace(*buf) && *buf!='\0') buf++; int negate = *buf=='-'; int skip = negate || *buf=='+'; AttributeValue* av = ParamList::lexscan()->get_attrval(buf+skip, strlen(buf+skip)); if(negate) av->negate(); _list->add_attr(txt->string(), av); update_text(true); } } void AttributeListEditor::remove() { const String* txt = _namefe->text(); if (txt->length() > 0) { Attribute* attr; if (attr = _list->GetAttr(txt->string())) { _list->Remove(attr); update_text(true); } } } void AttributeListEditor::update_text(boolean update) { ALIterator i; #ifndef STL_VECTOR char buf[1024]; memset(buf, 0, 1024); #else vector vbuf; #endif for (_list->First(i); !_list->Done(i); _list->Next(i)) { Attribute* attr = _list->GetAttr(i); const char* name = attr->Name(); int namelen = name ? strlen(name) : 0; if (name) #ifndef STL_VECTOR strcat(buf, name); #else { const char* namep = name; while (*namep) { vbuf.push_back(*namep++); } } #endif int n; for (n = 15; n > namelen-1; n--) #ifndef STL_VECTOR strcat(buf, " "); #else vbuf.push_back(' '); #endif #ifndef STL_VECTOR strcat(buf, " "); #else vbuf.push_back(' '); #endif std::strstream valstr; valstr << *attr->Value() << '\0'; const char* val = valstr.str(); int vallen = val ? strlen(val) : 0; if (val) #ifndef STL_VECTOR strcat(buf, val); #else { const char* valp = val; while (*valp) { vbuf.push_back(*valp++); } } #endif for (n = 15; n > vallen; n--) #ifndef STL_VECTOR strcat(buf, " "); strcat(buf, "\n"); #else vbuf.push_back(' '); vbuf.push_back('\n'); #endif } #ifndef STL_VECTOR _ete->text(buf, update); #else vbuf.push_back('\0'); _ete->text(&vbuf[0] ? &vbuf[0] : "", update); #endif } void AttributeListEditor::build() { DialogKit& dk = *DialogKit::instance(); WidgetKit& wk = *WidgetKit::instance(); const LayoutKit& lk = *LayoutKit::instance(); PolyGlyph* _mainglyph = lk.vbox(); // _mainglyph->append(lk.hcenter(wk.label(_lab))); Glyph* glu = lk.vspace(5); PolyGlyph* _namebox = lk.vbox(); PolyGlyph* _valbox = lk.vbox(); InputHandler* ih = new InputHandler(nil, wk.style()); Coord wid = wk.font()->width("MMMMMMMMMMMMMMM", 15); Action* addaction = new ActionCallback(AttributeListEditor)( this, &AttributeListEditor::add ); Button* addbutton = wk.push_button("Add", addaction); Action* remaction = new ActionCallback(AttributeListEditor)( this, &AttributeListEditor::remove ); Button* rembutton = wk.push_button("Remove", remaction); _mainglyph->append( lk.hcenter( lk.hbox( lk.vcenter(addbutton), lk.hspace(10), lk.vcenter(rembutton) ) ) ); _mainglyph->append(lk.vspace(10)); _mainglyph->append( lk.hcenter( lk.hbox( lk.vcenter(lk.hfixed(wk.label("name"), wid)), lk.hspace(10), lk.vcenter(lk.hfixed(wk.label("value"), wid)) ) ) ); _mainglyph->append(lk.vspace(2)); _mainglyph->append( lk.hcenter( lk.hbox( lk.vcenter(lk.hfixed(_namefe, wid)), lk.hspace(10), lk.vcenter(lk.hfixed(_valfe, wid)) ) ) ); _mainglyph->append(lk.vspace(15)); update_text(false); _mainglyph->append(lk.hcenter(lk.hspace(300))); _mainglyph->append(lk.hcenter(_ete)); ih->body(wk.outset_frame(lk.margin(_mainglyph, 10))); body(ih); } void AttributeListEditor::fe_clr(FieldEditor* fe) { fe->field(""); } ivtools-1.2.11a1/src/AttrGlyph/attredit.h000066400000000000000000000035071214471147700202300ustar00rootroot00000000000000/* * Copyright (c) 1996 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef attredit_h #define attredit_h #include class AttributeList; class EivTextEditor; class FieldEditor; class AttributeListEditor : public Patch { public: AttributeListEditor(AttributeList*); virtual ~AttributeListEditor(); void add(); void fe_add(FieldEditor*) { add(); } void fe_clr(FieldEditor*); void remove(); AttributeList* list(); FieldEditor* focusable1() { return _namefe; } FieldEditor* focusable2() { return _valfe; } protected: void build(); void update_text(boolean); AttributeList* _list; FieldEditor* _namefe; FieldEditor* _valfe; EivTextEditor* _ete; }; #endif ivtools-1.2.11a1/src/Attribute/000077500000000000000000000000001214471147700162575ustar00rootroot00000000000000ivtools-1.2.11a1/src/Attribute/_comterp.h000066400000000000000000000001751214471147700202430ustar00rootroot00000000000000#ifndef __comterp_h #define __comterp_h // extern "C" { #include // } #endif /* !defined(__comterp_h) */ ivtools-1.2.11a1/src/Attribute/_comutil.h000066400000000000000000000025261214471147700202500ustar00rootroot00000000000000#ifndef __comutil_h #define __comutil_h // extern "C" { #include // } //: define methods for a class name and class symbol id. // adds ::class_name() and ::class_symid() based on 'name' to any // class definition. For use in servers built on ComTerp for generating a // unique id for a given type of component. #define CLASS_SYMID(name) \ public: \ static const char* class_name() {return name;}\ static int class_symid()\ { if (_symid<0) _symid=symbol_add((char*)class_name()); return _symid;} \ virtual int classid()\ { if (_symid<0) _symid=symbol_add((char*)class_name()); return _symid;} \ protected: \ static int _symid; //: define methods for a class name and class symbol id. // adds ::class_name() and ::class_symid() based on 'name' to any // class definition. For use in servers built on ComTerp for generating a // unique id for a given type of component. // Will eventually tie it to the Unidraw class inheritance system of ::IsA #define CLASS_SYMID2(name, uclass_id) \ public: \ static const char* class_name() {return name;}\ static int class_symid()\ { if (_symid<0) _symid=symbol_add((char*)class_name()); return _symid;} \ virtual int classid()\ { if (_symid<0) _symid=symbol_add((char*)class_name()); return _symid;} \ protected: \ static int _symid; #endif /* !defined(__comutil.h) */ ivtools-1.2.11a1/src/Attribute/alist.cc000066400000000000000000000052241214471147700177050ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * AList implementation -- cloned from UList */ //: flag for separate ALIterator class. // if defined a separate ALIterator and AList are used that // are identical to Iterator and UList, otherwise // ALIterator is really Iterator, and AList is really UList. #define ALITERATOR #include /*****************************************************************************/ AList::AList (void* p) { _next = this; _prev = this; _object = p; } AList::~AList () { AList* next = _next; if (next != this && next != nil) { Remove(this); delete next; } } void AList::Append (AList* e) { _prev->_next = e; e->_prev = _prev; e->_next = this; _prev = e; } void AList::Prepend (AList* e) { _next->_prev = e; e->_prev = this; e->_next = _next; _next = e; } void AList::Remove (AList* e) { e->_prev->_next = e->_next; e->_next->_prev = e->_prev; e->_prev = e->_next = nil; } void AList::Delete (void* p) { register AList* e; e = Find(p); if (e != nil) { Remove(e); delete e; } } AList* AList::Find (void* p) { register AList* e; for (e = _next; e != this; e = e->_next) { if (e->_object == p) { return e; } } return nil; } AList* AList::operator[] (int count) { AList* pos = First(); int i; for (i = 1; i < count && pos != End(); ++i) { pos = pos->Next(); } if (i == count) { return pos; } return nil; } ivtools-1.2.11a1/src/Attribute/alist.h000066400000000000000000000044641214471147700175540ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Alist - list object. */ #ifndef _alist_h #define _alist_h #include #include #ifdef ALITERATOR //: copy of UList for using Attribute library without Unidraw. class AList { public: AList(void* = nil); virtual ~AList(); boolean IsEmpty(); void Append(AList*); void Prepend(AList*); void Remove(AList*); void Delete(void*); AList* Find(void*); AList* First(); AList* Last(); AList* End(); AList* Next(); AList* Prev(); void* operator()(); AList* operator[](int count); protected: void* _object; AList* _next; AList* _prev; }; inline boolean AList::IsEmpty () { return _next == this; } inline AList* AList::First () { return _next; } inline AList* AList::Last () { return _prev; } inline AList* AList::End () { return this; } inline AList* AList::Next () { return _next; } inline AList* AList::Prev () { return _prev; } inline void* AList::operator() () { return _object; } #else #define AList _lib_iv(UList) #include #endif #include #endif ivtools-1.2.11a1/src/Attribute/aliterator.cc000066400000000000000000000030151214471147700207330ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ALIterator implementation. */ #define ALITERATOR #include ALIterator::ALIterator () { _value = nil; } ALIterator::ALIterator (ALIterator& i) { _value = i._value; } ALIterator& ALIterator::operator =(ALIterator& i) { _value = i._value; return *this; } void* ALIterator::GetValue () { return _value; } void ALIterator::SetValue (void* v) { _value = v; } ivtools-1.2.11a1/src/Attribute/aliterator.h000066400000000000000000000035231214471147700206010ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ALIterator - an object that marks a position in a data structure (cloned from Iterator) */ #ifndef _al_iterator_h #define _al_iterator_h #ifdef ALITERATOR #include #include //: copy of Iterator for using Attribute library without Unidraw. class ALIterator { public: ALIterator(); ALIterator(ALIterator&); ALIterator& operator =(ALIterator&); virtual void* GetValue(); virtual void SetValue(void*); protected: void* _value; }; #else #define ALIterator _lib_iv(Iterator) #include #endif #include #endif ivtools-1.2.11a1/src/Attribute/attribute.cc000066400000000000000000000043261214471147700205760ustar00rootroot00000000000000/* * Copyright (c) 1996 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include /*****************************************************************************/ int Attribute::_symid = -1; Attribute::Attribute(const char* name, AttributeValue* value) { if (name) symbolid = symbol_add((char *)name); else symbolid = -1; valueptr = value; } Attribute::Attribute(int symid, AttributeValue* value) { symbolid = symid; valueptr = value; } Attribute::Attribute(const Attribute& attr) { symbolid = attr.symbolid; if (symbolid != -1) // for reference count symbol_add(symbol_pntr(symbolid)); valueptr = new AttributeValue(*attr.valueptr); } Attribute::~Attribute() { if (0 && symbolid != -1) // need to rewrite symbol table symbol_del(symbolid); delete valueptr; } const char* Attribute::Name() { return symbol_pntr(symbolid); } void Attribute::Value(AttributeValue* value) { delete valueptr; valueptr = value; } AttributeValue* Attribute::Value() { return valueptr; } int Attribute::SymbolId() { return symbolid; } ivtools-1.2.11a1/src/Attribute/attribute.h000066400000000000000000000051671214471147700204440ustar00rootroot00000000000000/* * Copyright (c) 1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef _attribute_h #define _attribute_h #include #include class AttributeValue; class AttributeList; //: generic symbol/value pair. // Attribute consists of a symbol, represented by its index into a symbol table, // paired with a value, represented by an AttributeValue. Memory for the // AttributeValue is owned by the Attribute. class Attribute : public Resource { public: Attribute(const char* name =0, AttributeValue* value =0); // construct an attribute by generating a symbol id for the 'name' // character string, and accepting a pointer to an externally allocated 'value'. Attribute(int symid, AttributeValue* value =0); // construct an attribute with a symbol id instead of a character string, // and accepting a pointer to an externally allocated 'value'. Attribute(const Attribute&); // copy constructor. virtual ~Attribute(); // deallocate memory for internal AttributeValue. const char* Name(); // look up and return symbol string. void Value(AttributeValue*); // accept new pointer to an externally allocated AttributeValue, // deleting the old pointer. AttributeValue* Value(); // return a pointer to the internal AttributeValue. int SymbolId(); // return the id of the symbol in the symbol table. protected: int symbolid; AttributeValue* valueptr; friend class AttributeList; CLASS_SYMID("Attribute"); }; #endif ivtools-1.2.11a1/src/Attribute/attrlist.cc000066400000000000000000000344541214471147700204460ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 1996-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Implementation of AttributeList class. */ #include #include #include #include #include #include #include #include #include #include #include #include #ifdef LEAKCHECK LeakChecker* AttributeValueList::_leakchecker = nil; #endif /*****************************************************************************/ using std::cerr; int AttributeList::_symid = -1; AttributeList::AttributeList (AttributeList* s) { _alist = new AList; _count = 0; if (s != nil) { ALIterator i; for (s->First(i); !s->Done(i); s->Next(i)) { add_attr(new Attribute(*s->GetAttr(i))); } } } AttributeList::~AttributeList () { if (_alist) { ALIterator i; for (First(i); !Done(i); Next(i)) { Resource::unref(GetAttr(i)); } delete _alist; } } void AttributeList::add_attr(const char* name, AttributeValue& value) { add_attr(name, new AttributeValue(value)); } void AttributeList::add_attr(const char* name, AttributeValue* value) { Attribute* attr = new Attribute(name, value); if (add_attr(attr)) { attr->valueptr = nil; Resource::unref(attr); } } void AttributeList::add_attr(int symid, AttributeValue& value) { add_attr(symid, new AttributeValue(value)); } void AttributeList::add_attr(int symid, AttributeValue* value) { Attribute* attr = new Attribute(symid, value); if (add_attr(attr)) { attr->valueptr = nil; Resource::unref(attr); } } void AttributeList::add_attribute(Attribute* attr) { if (add_attr(attr)) { attr->valueptr = nil; Resource::unref(attr); } } int AttributeList::add_attr(Attribute* attr) { ALIterator i; for (First(i); !Done(i); Next(i)) { Attribute* old_attr = GetAttr(i); if (old_attr && attr->SymbolId() == old_attr->SymbolId()) { old_attr->Value(attr->Value()); return -1; } } InsertBefore(i, attr); Resource::ref(attr); return 0; } Attribute* AttributeList::GetAttr (const char* n) { ALIterator i; for (First(i); !Done(i); Next(i)) { Attribute* attr = GetAttr(i); if (strcmp(n, attr->Name()) == 0) return attr; } return nil; } Attribute* AttributeList::GetAttr (int symid) { ALIterator i; for (First(i); !Done(i); Next(i)) { Attribute* attr = GetAttr(i); if (symid == attr->SymbolId()) return attr; } return nil; } Attribute* AttributeList::Attr (AList* r) { return (Attribute*) (*r)(); } AList* AttributeList::Elem (ALIterator i) { return (AList*) i.GetValue(); } void AttributeList::Append (Attribute* v) { _alist->Append(new AList(v)); ++_count; } void AttributeList::Prepend (Attribute* v) { _alist->Prepend(new AList(v)); ++_count; } void AttributeList::InsertAfter (ALIterator i, Attribute* v) { Elem(i)->Prepend(new AList(v)); ++_count; } void AttributeList::InsertBefore (ALIterator i, Attribute* v) { Elem(i)->Append(new AList(v)); ++_count; } void AttributeList::Remove (ALIterator& i) { AList* doomed = Elem(i); Next(i); _alist->Remove(doomed); delete doomed; --_count; } void AttributeList::Remove (Attribute* p) { AList* temp; if ((temp = _alist->Find(p)) != nil) { _alist->Remove(temp); delete temp; --_count; } } Attribute* AttributeList::GetAttr (ALIterator i) { return Attr(Elem(i)); } void AttributeList::SetAttr (Attribute* gv, ALIterator& i) { i.SetValue(_alist->Find(gv)); } void AttributeList::First (ALIterator& i) { i.SetValue(_alist->First()); } void AttributeList::Last (ALIterator& i) { i.SetValue(_alist->Last()); } void AttributeList::Next (ALIterator& i) { i.SetValue(Elem(i)->Next()); } void AttributeList::Prev (ALIterator& i) { i.SetValue(Elem(i)->Prev()); } boolean AttributeList::Done (ALIterator i) { return Elem(i) == _alist->End(); } int AttributeList::Number () const { return _count; } boolean AttributeList::Includes (Attribute* e) { return _alist->Find(e) != nil; } boolean AttributeList::IsEmpty () { return _alist->IsEmpty(); } ostream& operator<< (ostream& out, const AttributeList& al) { AttributeList* attrlist = (AttributeList*)&al; if (al.Number()==0) { out << ""; return out; } ALIterator i; for (attrlist->First(i); !attrlist->Done(i); attrlist->Next(i)) { Attribute* attr = attrlist->GetAttr(i); out << " :" << attr->Name() << " "; AttributeValue* attrval = attr->Value(); #if 1 out << *attrval; #else char* string; switch(attr->Value()->type()) { case AttributeValue::SymbolType: out << attrval->symbol_ptr(); break; case AttributeValue::StringType: string = (char *) attrval->string_ptr(); out << "\"" << string << "\""; break; case AttributeValue::CharType: out << "'" << attrval->char_ref() << "'"; break; case AttributeValue::UCharType: out << "'" << attrval->char_ref() << "'"; break; case AttributeValue::IntType: out << attrval->int_ref(); break; case AttributeValue::UIntType: out << attrval->uint_ref(); break; case AttributeValue::ShortType: out << attrval->short_ref(); break; case AttributeValue::UShortType: out << attrval->ushort_ref(); break; case AttributeValue::LongType: out << attrval->long_ref(); break; case AttributeValue::ULongType: out << attrval->ulong_ref(); break; case AttributeValue::FloatType: out.form("%.6", attrval->float_val()); break; case AttributeValue::DoubleType: out << attrval->double_ref(); break; default: out << "Unknown type"; break; } #endif } return out; } void AttributeList::dump() { cerr << *this << "\n"; } AttributeValue* AttributeList::find(const char* name) { int id = symbol_find((char *)name); return find(id); } AttributeValue* AttributeList::find(int symid) { if (symid==-1) return nil; ALIterator i; for (First(i); !Done(i); Next(i)) { Attribute* attr = GetAttr(i); if (attr->SymbolId() == symid) { return attr->Value(); } } return nil; } AttributeList* AttributeList::merge(AttributeList* al) { if (al) { ALIterator it; for( al->First(it); !al->Done(it); al->Next(it)) add_attribute(new Attribute(*al->GetAttr(it))); } return this; } void AttributeList::clear() { ALIterator it; for( First(it); !Done(it); ) { Attribute* attr = GetAttr(it); Remove(it); Resource::unref(attr); } } /*****************************************************************************/ AttributeValueList::AttributeValueList (AttributeValueList* s) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValueList"); _leakchecker->create(); #endif _alist = new AList; _count = 0; _max_out = -1; if (s != nil) { ALIterator i; for (s->First(i); !s->Done(i); s->Next(i)) { Append(new AttributeValue(s->GetAttrVal(i))); } } _nested_insert = false; } AttributeValueList::~AttributeValueList () { #ifdef LEAKCHECK _leakchecker->destroy(); #endif if (_alist) { ALIterator i; for (First(i); !Done(i); Next(i)) { delete GetAttrVal(i); } delete _alist; } } AttributeValue* AttributeValueList::AttrVal (AList* r) { return (AttributeValue*) (*r)(); } AList* AttributeValueList::Elem (ALIterator i) { return (AList*) i.GetValue(); } void AttributeValueList::Append (AttributeValue* v) { _alist->Append(new AList(v)); ++_count; } void AttributeValueList::Prepend (AttributeValue* v) { _alist->Prepend(new AList(v)); ++_count; } void AttributeValueList::InsertAfter (ALIterator i, AttributeValue* v) { Elem(i)->Prepend(new AList(v)); ++_count; } void AttributeValueList::InsertBefore (ALIterator i, AttributeValue* v) { Elem(i)->Append(new AList(v)); ++_count; } void AttributeValueList::Remove (ALIterator& i) { AList* doomed = Elem(i); Next(i); _alist->Remove(doomed); delete doomed; --_count; } void AttributeValueList::Remove (AttributeValue* p) { AList* temp; if ((temp = _alist->Find(p)) != nil) { _alist->Remove(temp); delete temp; --_count; } } AttributeValue* AttributeValueList::GetAttrVal (ALIterator i) { return AttrVal (Elem(i)); } void AttributeValueList::SetAttrVal (AttributeValue* gv, ALIterator& i) { i.SetValue(_alist->Find(gv)); } void AttributeValueList::First (ALIterator& i) { i.SetValue(_alist->First()); } void AttributeValueList::Last (ALIterator& i) { i.SetValue(_alist->Last()); } void AttributeValueList::Next (ALIterator& i) { i.SetValue(Elem(i)->Next()); } void AttributeValueList::Prev (ALIterator& i) { i.SetValue(Elem(i)->Prev()); } boolean AttributeValueList::Done (ALIterator i) { return Elem(i) == _alist->End(); } const int AttributeValueList::Number () { return _count; } boolean AttributeValueList::Includes (AttributeValue* e) { return _alist->Find(e) != nil; } boolean AttributeValueList::IsEmpty () { return _alist->IsEmpty(); } ostream& operator<< (ostream& out, const AttributeValueList& al) { AttributeValueList* attrlist = (AttributeValueList*)&al; int maxout = attrlist->max_out(); ALIterator i; for (attrlist->First(i); !attrlist->Done(i) && maxout!=0;) { maxout--; AttributeValue* attrval = attrlist->GetAttrVal(i); char* string; switch(attrval->type()) { case AttributeValue::SymbolType: out << attrval->symbol_ptr(); break; case AttributeValue::StringType: string = (char *) attrval->string_ptr(); out << "\"" << string << "\""; break; case AttributeValue::CharType: out << "`\\" << std::setw(3) << std::setfill('0') << std::oct << (int)attrval->char_ref() << std::dec << "`" << std::resetiosflags(std::ios_base::basefield); break; case AttributeValue::UCharType: out << "`\\" << std::setw(3) << std::setfill('0') << std::oct << (unsigned int) attrval->uchar_ref() << std::dec << "`" << std::resetiosflags(std::ios_base::basefield); break; case AttributeValue::ShortType: out << attrval->short_ref(); break; case AttributeValue::UShortType: out << attrval->ushort_ref(); break; case AttributeValue::IntType: out << attrval->int_ref(); break; case AttributeValue::UIntType: out << attrval->uint_ref(); break; case AttributeValue::LongType: out << attrval->long_ref(); break; case AttributeValue::ULongType: out << attrval->ulong_ref(); break; case AttributeValue::FloatType: out << attrval->float_ref(); break; case AttributeValue::DoubleType: out << attrval->double_ref(); break; case AttributeValue::BooleanType: out << attrval->boolean_ref(); break; case AttributeValue::ArrayType: out << "{"; out << *attrval->array_ref(); out << "}"; break; default: out << "nil"; break; } attrlist->Next(i); if (!attrlist->Done(i)) out << ","; } if(maxout==0 && !attrlist->Done(i)) out << "..."; return out; } void AttributeValueList::clear() { ALIterator it; for( First(it); !Done(it); ) { AttributeValue* av = GetAttrVal(it); Remove(it); delete av; } } AttributeValue* AttributeValueList::Get(unsigned int index) { if (Number()<=index) return nil; ALIterator it; if(Number()<=index*2) { Last(it); for (int i=0; i=Number()) index=Number()-1; int i=0; while(i++Remove(doomed); delete doomed; Elem(i)->Append(new AList(av)); return removed; } boolean AttributeValueList::Equal(AttributeValueList* avl) { if(avl->Number()!=Number()) return false; ALIterator it, jt; avl->First(it); First(jt); while(!Done(jt)) { AttributeValue* av = avl->GetAttrVal(it); if (!GetAttrVal(jt)->equal(*av)) return false; avl->Next(it); Next(jt); } return true; } ivtools-1.2.11a1/src/Attribute/attrlist.h000066400000000000000000000234031214471147700203000ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 1996-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * AttributeList - a list of attributes */ #ifndef attr_list_h #define attr_list_h #include #include #include #include #ifndef ALITERATOR #define ALIterator _lib_iv(Iterator) #define AList _lib_iv(UList) #endif class ALIterator; class AList; #include class Attribute; class AttributeValue; class ParamStruct; //: list of Attribute objects, i.e. a property list. // An AttributeList is derived from Resource, so it is a reference-counted // object that can be freely shared between other objects. // // An AttributeList assumes responsibility for the memory of its member // Attribute objects, which in turn assume responsibility for the memory // of their member AttributeValue objects. class AttributeList : public Resource { public: AttributeList(AttributeList* = nil); // construct with optional AttributeList to copy. virtual ~AttributeList(); // do not call directly. Frees memory of associated Attribute objects. void add_attr(const char* name, AttributeValue& value); // add attribute by making copy of an AttributeValue. void add_attr(const char* name, AttributeValue* value); // add attribute by using pointer to AttributeValue, assuming responsibility void add_attr(int symid, AttributeValue& value); // add attribute by making copy of an AttributeValue. void add_attr(int symid, AttributeValue* value); // add attribute by using pointer to AttributeValue, assuming responsibility // for the memory. void add_attribute(Attribute* attr); // add complete Attribute object to the list, accepting responsibility // for the memory of the Attribute object. void First(ALIterator&); // set iterator to point to first Attribute in list. void Last(ALIterator&); // set iterator to point to last Attribute in list. void Next(ALIterator&); // set iterator to point to next Attribute in list. void Prev(ALIterator&); // set iterator to point to previous Attribute in list. boolean Done(ALIterator); // return true if iterator is pointing off the end of the list. // works for forward and backward traversals. boolean IsEmpty(); // true if no Attribute objects in list. int Number() const; // number of Attribute objects in list. Attribute* GetAttr(const char*); // get attribute by name. Attribute* GetAttr(int symid); // get attribute by symbol id. Attribute* GetAttr(ALIterator); // get attribute pointed to by iterator. void SetAttr(Attribute*, ALIterator&); // set attribute pointed to by iterator. boolean Includes(Attribute*); // check if list includes Attribute by pointer-comparison. void Remove(Attribute*); // remove Attribute from list, returning responsibility for freeing the // associated memory. AList* Elem(ALIterator); // return AList (UList) pointed to by ALIterator (Iterator). Attribute* Attr(AList*); // return attribute pointed to by AList (UList). AttributeList* merge(AttributeList*); // merge the contents of another AttributeList into this one, // replicating the AttributeValue as needed. protected: void Append(Attribute*); // append Attribute to end of list. Could cause duplicates. void Prepend(Attribute*); // append Attribute to front of list. Could cause duplicates. void InsertAfter(ALIterator, Attribute*); // append Attribute after position pointed by iterator. Could cause duplicates. void InsertBefore(ALIterator, Attribute*); // append Attribute before position pointed by iterator. Could cause duplicates. void Remove(ALIterator&); // remove Attribute pointed to by iterator from the list, // returning responsibility for freeing the associated memory. // This requires saving a pointer to the Attribute before calling this method. void clear(); // empty AttributeList, deleting all Attributes. public: friend ostream& operator << (ostream& s, const AttributeList&); // print list to ostream. void dump(); // utility method to call ostream output method. AttributeValue* find(const char*); // find AttributeValue by symbol. AttributeValue* find(int symid); // find AttributeValue by symbol id. protected: int add_attr(Attribute* attr); // add attribute, returning 0 if new, -1 if it already existed. // When -1 is returned you need to clear the valueptr of 'attr' before // deleting it. That's why this is protected. AList* _alist; unsigned int _count; CLASS_SYMID("AttributeList"); }; //: list of AttributeValue objects. // An AttributeValueList is derived from Resource, so it is a reference-counted // object that can be freely shared between other objects. // // An AttributeValueList assumes responsibility for the memory of its member // AttributeValue objects. class AttributeValueList : public Resource { public: AttributeValueList(AttributeValueList* = nil); // construct with optional AttributeValueList to copy. virtual ~AttributeValueList(); // do not call directly. Frees memory of associated AttributeValue objects. public: void First(ALIterator&); // set iterator to point to first AttributeValue in list. void Last(ALIterator&); // set iterator to point to last AttributeValue in list. void Next(ALIterator&); // set iterator to point to next AttributeValue in list. void Prev(ALIterator&); // set iterator to point to previous AttributeValue in list. boolean Done(ALIterator); // return true if iterator is pointing off the end of the list. // works for forward and backward traversals. boolean IsEmpty(); // true if no AttributeValue objects in list. const int Number(); // number of AttributeValue objects in list. void Append(AttributeValue*); // append AttributeValue to end of list. void Prepend(AttributeValue*); // append AttributeValue to front of list. void InsertAfter(ALIterator, AttributeValue*); // insert AttributeValue after position pointed to by iterator. void InsertBefore(ALIterator, AttributeValue*); // insert AttributeValue before position pointed to by iterator. void Remove(AttributeValue*); // remove AttributeValue from list, returning responsibility for freeing the // associated memory. void Remove(ALIterator&); // remove AttributeValue pointed to by iterator from the list, // returning responsibility for freeing the associated memory. // This requires saving a pointer to the AttributeValue before calling this method. AttributeValue* Replace(ALIterator&, AttributeValue*); // remove AttributeValue pointed to by iterator from the list, // returning responsibility for freeing the associated memory. // Then insert new AttributeValue in the same place. AttributeValue* GetAttrVal(ALIterator); // get AttributeValue pointed to by iterator. void SetAttrVal(AttributeValue*, ALIterator&); // set AttributeValue pointed to by iterator. boolean Includes(AttributeValue*); // check if list includes AttributeValue by pointer-comparison. AttributeValue* Get(unsigned int index); // retrieve value by index, return nil if not there AttributeValue* Set(unsigned int index, AttributeValue* av); // set value by index, increase list length if necessary with nil padding, // take responsibility for the memory (and return responsibility for old memory) void Insert(int index, AttributeValue* av); // insert value after index, use -1 to insert at beginning // take responsibility for the memory (and return responsibility for old memory) AList* Elem(ALIterator); // return AList (UList) pointed to by ALIterator (Iterator). AttributeValue* AttrVal(AList*); // return AttributeValue pointed to by AList (UList). friend ostream& operator << (ostream& s, const AttributeValueList&); // print list to ostream. void clear(); // empty AttributeValueList, deleting all AttributeValue's. void nested_insert(boolean flag) { _nested_insert = flag; } // set flag to insert in a nested fashion boolean nested_insert() { return _nested_insert; } // get flag to insert in a nested fashion int max_out() { return _max_out; } // get maximum to print void max_out(int num) { _max_out = num; } // set maximum to print boolean Equal(AttributeValueList* avl); protected: AList* _alist; unsigned int _count; boolean _nested_insert; int _max_out; #ifdef LEAKCHECK public: static LeakChecker* _leakchecker; #endif }; #endif ivtools-1.2.11a1/src/Attribute/attrvalue.cc000066400000000000000000001160241214471147700206010ustar00rootroot00000000000000/* * Copyright (c) 2001,2006 Scott E. Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #ifdef RESOURCE_COMPVIEW #include #include #endif #include #if !defined(solaris) #include #endif #include #include #include using namespace std; #ifdef LEAKCHECK LeakChecker* AttributeValue::_leakchecker = nil; #endif /*****************************************************************************/ int* AttributeValue::_type_syms = nil; AttributeValue::AttributeValue(ValueType valtype) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); type(valtype); } AttributeValue::AttributeValue(ValueType valtype, attr_value value) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); type(valtype); _v = value; ref_as_needed(); } AttributeValue::AttributeValue(AttributeValue& sv) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); type(UnknownType); *this = sv; } AttributeValue::AttributeValue(AttributeValue* sv) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); type(UnknownType); *this = *sv; dup_as_needed(); } AttributeValue::AttributeValue() { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); type(UnknownType); _command_symid = -1; } AttributeValue::AttributeValue(unsigned char v) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::UCharType; _v.ucharval = v; } AttributeValue::AttributeValue(char v) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::CharType; _v.charval = v; } AttributeValue::AttributeValue(unsigned short v) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::UShortType; _v.ushortval = v; } AttributeValue::AttributeValue(short v) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::ShortType; _v.shortval = v; } AttributeValue::AttributeValue(unsigned int v, ValueType type) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = type; if ( type >= CharType && type <= UShortType ) { switch (type) { case CharType: _v.charval = v; break; case UCharType: _v.ucharval = v; break; case ShortType: _v.shortval = v; break; case UShortType: _v.ushortval = v; break; } } else _v.dfunsval = v; } AttributeValue::AttributeValue(unsigned int kv, unsigned int kn, ValueType type) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = type; _v.keyval.keyid = kv; _v.keyval.keynarg = kn; } AttributeValue::AttributeValue(int v, ValueType type) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = type; if ( type >= CharType && type <= UShortType ) { switch (type) { case CharType: _v.charval = v; break; case UCharType: _v.ucharval = v; break; case ShortType: _v.shortval = v; break; case UShortType: _v.ushortval = v; break; } } else _v.dfintval = v; ref_as_needed(); // when used as a StringType constructor } AttributeValue::AttributeValue(unsigned long v) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::ULongType; _v.lnunsval = v; } AttributeValue::AttributeValue(long v) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::LongType; _v.lnintval = v; } AttributeValue::AttributeValue(float v) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::FloatType; _v.floatval = v; } AttributeValue::AttributeValue(double v) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::DoubleType; _v.doublval = v; } AttributeValue::AttributeValue(int classid, void* ptr) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::ObjectType; _v.objval.ptr = ptr; _v.objval.type = classid; _object_compview = false; if (classid==Attribute::class_symid()) Resource::ref((Attribute*)ptr); else if (classid==AttributeList::class_symid()) Resource::ref((AttributeList*)ptr); } AttributeValue::AttributeValue(ComponentView* view, int compid) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::ObjectType; _v.objval.ptr = view; _v.objval.type = compid; _object_compview = true; Resource::ref(view); } AttributeValue::AttributeValue(AttributeValueList* ptr) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::ArrayType; _v.arrayval.ptr = ptr; _v.arrayval.type = 0; Resource::ref(ptr); } AttributeValue::AttributeValue(void* comfuncptr, AttributeValueList* vallist) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::StreamType; _v.streamval.funcptr = comfuncptr; _v.streamval.listptr = vallist; Resource::ref(vallist); } AttributeValue::AttributeValue(const char* string) { #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("AttributeValue"); _leakchecker->create(); #endif clear(); _type = AttributeValue::StringType; _v.dfintval = symbol_add((char*)string); } AttributeValue::~AttributeValue() { #ifdef LEAKCHECK _leakchecker->destroy(); #endif unref_as_needed(); type(UnknownType); } void AttributeValue::clear() { unsigned char* buf = (unsigned char*)(void*)&_v; for (int i=0; iNumber(); else return 0; } int AttributeValue::list_len() { if (is_type(AttributeValue::ArrayType)) return array_val()->Number(); else return 0; } int AttributeValue::command_symid() { return _command_symid; } void AttributeValue::command_symid(int id, boolean alias) { _command_symid = (alias ? -1 : 1) * id; } ostream& operator<< (ostream& out, const AttributeValue& sv) { AttributeValue* svp = (AttributeValue*)&sv; const char* title; const char* symbol; int counter; #if 0 switch( svp->type() ) { case AttributeValue::KeywordType: out << "Keyword (" << symbol_pntr( svp->symbol_ref() ) << ")"; break; case AttributeValue::CommandType: title = "Command ("; symbol = symbol_pntr( svp->symbol_ref() ); out << title << symbol; counter = strlen(title) + strlen(symbol); while( ++counter < 32 ) out << ' '; out << ")"; break; case AttributeValue::SymbolType: out << "symbol (" << svp->symbol_ptr() << ")"; break; case AttributeValue::StringType: out << "string (" << svp->string_ptr() << ")"; break; case AttributeValue::BooleanType: out << "boolean (" << svp->boolean_ref() << ")"; break; case AttributeValue::CharType: out << "char (" << svp->char_ref() << ":" << (int)svp->char_ref() << ")"; break; case AttributeValue::UCharType: out << "uchar (" << svp->char_ref() << ":" << (int)svp->char_ref() << ")"; break; case AttributeValue::IntType: out << "int (" << svp->int_ref() << ")"; break; case AttributeValue::UIntType: if (svp->state()==AttributeValue::OctState) out << "uint (" << svp->uint_ref() << ")"; else if (svp->state()==AttributeValue::HexState) out << "uint (" << svp->uint_ref() << ")"; else out << "uint (" << svp->uint_ref() << ")"; break; case AttributeValue::LongType: out << "Long (" << svp->long_ref() << ")"; break; case AttributeValue::ULongType: out << "ulong (" << svp->ulong_ref() << ")"; break; case AttributeValue::FloatType: out << "float (" << svp->float_ref() << ")"; break; case AttributeValue::DoubleType: out << "double (" << svp->double_ref() << ")"; //printf("%9.2f\n", svp->double_ref()); break; case AttributeValue::EofType: out << "eof"; break; case AttributeValue::ArrayType: { out << "list of length " << svp->array_len(); ALIterator i; AttributeValueList* avl = svp->array_val(); avl->First(i); boolean first = true; while (!avl->Done(i)) { out << "\n\t" << *avl->GetAttrVal(i); avl->Next(i); } } break; case AttributeValue::BlankType: break; default: break; } #else switch(svp->type()) { case AttributeValue::KeywordType: out << "Keyword (" << symbol_pntr( svp->symbol_ref() ) << ")"; break; case AttributeValue::CommandType: title = "Command ("; symbol = symbol_pntr( svp->command_symid() ); out << title << symbol; counter = strlen(title) + strlen(symbol); while( ++counter < 32 ) out << ' '; out << ")"; break; case AttributeValue::SymbolType: out << svp->symbol_ptr(); break; case AttributeValue::StringType: { out << "\""; const char *ptr = svp->string_ptr(); while (*ptr) { switch (*ptr) { case '\t' : out << "\\t"; break; case '\n' : out << "\\n"; break; default : out << *ptr; }; ptr++; } out << "\""; } break; case AttributeValue::CharType: out << svp->char_ref(); break; case AttributeValue::UCharType: out << svp->char_ref(); break; case AttributeValue::IntType: out << svp->int_ref(); break; case AttributeValue::UIntType: if (svp->state()==AttributeValue::OctState) out << "0" << std::oct << svp->uint_ref() << std::dec; else if (svp->state()==AttributeValue::HexState) out << "0x" << std::hex << svp->uint_ref() << std::dec; else out << svp->uint_ref(); break; case AttributeValue::BooleanType: out << svp->uint_ref(); break; case AttributeValue::ShortType: out << svp->short_ref(); break; case AttributeValue::UShortType: if (svp->state()==AttributeValue::OctState) out << "0" << std::oct << svp->ushort_ref() << std::dec; else if (svp->state()==AttributeValue::HexState) out << "0x" << std::hex << svp->ushort_ref() << std::dec; else out << svp->ushort_ref(); break; case AttributeValue::LongType: out << svp->long_ref(); break; case AttributeValue::ULongType: if (svp->state()==AttributeValue::OctState) out << "0" << std::oct << svp->ulong_ref() << std::dec; else if (svp->state()==AttributeValue::HexState) out << "0x" << std::hex << svp->ulong_ref() << std::dec; else out << svp->ulong_ref(); break; case AttributeValue::FloatType: #if __GNUG__<3 out.form("%.6f", svp->float_val()); #else { const int bufsiz=256; char buffer[bufsiz]; snprintf(buffer, bufsiz, "%.6f", svp->float_val()); out << buffer; } #endif break; case AttributeValue::DoubleType: #if __GNUG__<3 out.form("%.6f", svp->double_val()); #else { const int bufsiz=256; char buffer[bufsiz]; snprintf(buffer, bufsiz, "%.6f", svp->double_val()); out << buffer; } #endif break; case AttributeValue::EofType: out << "eof"; break; case AttributeValue::ArrayType: { //out << "array of length " << svp->array_len(); ALIterator i; AttributeValueList* avl = svp->array_val(); avl->First(i); boolean first = true; while (!avl->Done(i)) { if (!first) out << ","; out << *avl->GetAttrVal(i); avl->Next(i); first = false; } } break; case AttributeValue::BlankType: break; case AttributeValue::ObjectType: out << "<" << symbol_pntr(svp->class_symid()) << ">"; break; case AttributeValue::StreamType: out << "stream_mode() << ">"; break; default: out << "nil"; break; } #endif return out; } void AttributeValue::negate() { switch (type()) { case AttributeValue::CharType: char_ref() = -char_val(); return; case AttributeValue::UCharType: char_ref() = -uchar_val(); type(CharType); return; case AttributeValue::ShortType: short_ref() = -short_val(); return; case AttributeValue::UShortType: short_ref() = -ushort_val(); type(ShortType); return; case AttributeValue::IntType: int_ref() = -int_val(); return ; case AttributeValue::UIntType: int_ref() = -uint_val(); type(IntType); return; case AttributeValue::LongType: long_ref() = -long_val(); return; case AttributeValue::ULongType: long_ref() = -ulong_ref(); type(LongType); return; case AttributeValue::FloatType: float_ref() = -float_val(); return; case AttributeValue::DoubleType: double_ref() = -double_val(); return; default: return; } } int AttributeValue::type_size(ValueType type) { switch (type) { case AttributeValue::UnknownType: return 0; case AttributeValue::CharType: return sizeof(char); case AttributeValue::UCharType: return sizeof(unsigned char); case AttributeValue::ShortType: return sizeof(short); case AttributeValue::UShortType: return sizeof(unsigned short); case AttributeValue::IntType: return sizeof(int); case AttributeValue::UIntType: return sizeof(unsigned int); case AttributeValue::LongType: return sizeof(long); case AttributeValue::ULongType: return sizeof(unsigned long); case AttributeValue::FloatType: return sizeof(float); case AttributeValue::DoubleType: return sizeof(double); default: return 0; } } void AttributeValue::assignval (const AttributeValue& av) { boolean preserve_flag = same_list(av); if (!preserve_flag) unref_as_needed(); void* v1 = &_v; const void* v2 = &av._v; memcpy(v1, v2, sizeof(_v)); _type = av._type; _command_symid = av._command_symid; if (!preserve_flag) ref_as_needed(); } boolean AttributeValue::is_attributelist() { return is_object() && class_symid() == AttributeList::class_symid(); } boolean AttributeValue::is_attribute() { return is_object() && class_symid() == Attribute::class_symid(); } void* AttributeValue::geta(int id) { if (is_object(id)) return obj_val(); else return nil; } int AttributeValue::type_symid() const { if (!_type_syms) { int i = 0; _type_syms = new int[((int)BlankType)+1]; _type_syms[i++] = symbol_add("UnknownType"); _type_syms[i++] = symbol_add("CharType"); _type_syms[i++] = symbol_add("UCharType"); _type_syms[i++] = symbol_add("ShortType"); _type_syms[i++] = symbol_add("UShortType"); _type_syms[i++] = symbol_add("IntType"); _type_syms[i++] = symbol_add("UIntType"); _type_syms[i++] = symbol_add("LongType"); _type_syms[i++] = symbol_add("ULongType"); _type_syms[i++] = symbol_add("FloatType"); _type_syms[i++] = symbol_add("DoubleType"); _type_syms[i++] = symbol_add("StringType"); _type_syms[i++] = symbol_add("SymbolType"); _type_syms[i++] = symbol_add("ListType"); _type_syms[i++] = symbol_add("StreamType"); _type_syms[i++] = symbol_add("CommandType"); _type_syms[i++] = symbol_add("KeywordType"); _type_syms[i++] = symbol_add("ObjectType"); _type_syms[i++] = symbol_add("EofType"); _type_syms[i++] = symbol_add("BooleanType"); _type_syms[i++] = symbol_add("OperatorType"); _type_syms[i++] = symbol_add("BlankType"); } if (type()>=UnknownType && type()<=BlankType) return _type_syms[(int)type()]; else return -1; } void AttributeValue::ref_as_needed() { if (_type == AttributeValue::ArrayType) Resource::ref(_v.arrayval.ptr); else if (_type == AttributeValue::StreamType) Resource::ref(_v.streamval.listptr); else if (_type == AttributeValue::StringType) symbol_reference(string_val()); else if (_type == AttributeValue::SymbolType) // never to be unreferenced symbol_reference(symbol_val()); #ifdef RESOURCE_COMPVIEW else if (_type == AttributeValue::ObjectType) { if (object_compview()) Resource::ref((ComponentView*)_v.objval.ptr); else if (obj_type_val()==AttributeList::class_symid()) Resource::ref((AttributeList*)_v.objval.ptr); else if (obj_type_val()==Attribute::class_symid()) Resource::ref((Attribute*)_v.objval.ptr); } #endif } void AttributeValue::dup_as_needed() { if (_type == AttributeValue::ArrayType) { AttributeValueList* avl = _v.arrayval.ptr; _v.arrayval.ptr = new AttributeValueList(avl); Resource::ref(_v.arrayval.ptr); Resource::unref(avl); } else if (_type == AttributeValue::StreamType) { AttributeValueList* avl = _v.streamval.listptr; _v.streamval.listptr = new AttributeValueList(avl); Resource::ref(_v.streamval.listptr); Resource::unref(avl); } #ifdef RESOURCE_COMPVIEW else if (_type == AttributeValue::ObjectType) { if (object_compview()) { ComponentView* oldview = (ComponentView*)_v.objval.ptr; Component* subject = oldview->GetSubject(); ComponentView* newview = oldview->Duplicate(); newview->SetSubject(subject); subject->Attach(newview); _v.objval.ptr = newview; Resource::ref(newview); Resource::unref(oldview); } else if (obj_type_val()==AttributeList::class_symid()) { AttributeList* al = (AttributeList*)_v.objval.ptr; _v.objval.ptr = new AttributeList(al); Resource::ref((AttributeList*)_v.objval.ptr); Resource::unref((AttributeList*)al); } else if (obj_type_val()==Attribute::class_symid()) { Attribute* al = (Attribute*)_v.objval.ptr; _v.objval.ptr = (void*) new Attribute(*al); Resource::ref((Attribute*)_v.objval.ptr); Resource::unref((Attribute*)al); } } #endif } void AttributeValue::unref_as_needed() { if (_type == AttributeValue::ArrayType) { Resource::unref(_v.arrayval.ptr); } else if (_type == AttributeValue::StreamType) Resource::unref(_v.streamval.listptr); else if (_type == AttributeValue::StringType) // only StringType, never for SymbolType symbol_del(string_val()); #ifdef RESOURCE_COMPVIEW else if (_type == AttributeValue::ObjectType) { if (object_compview()) Resource::unref((ComponentView*)_v.objval.ptr); else if (obj_type_val() == AttributeList::class_symid()) Resource::unref((AttributeList*)_v.objval.ptr); else if (obj_type_val() == Attribute::class_symid()) Resource::unref((Attribute*)_v.objval.ptr); } #endif } const boolean AttributeValue::same_list(const AttributeValue& av) { if (_type == AttributeValue::ArrayType) return _v.arrayval.ptr == av._v.arrayval.ptr; else if (_type == AttributeValue::StreamType) return _v.streamval.listptr == av._v.streamval.listptr; #ifdef RESOURCE_COMPVIEW else if (_type == AttributeValue::ObjectType) return _v.objval.ptr == av._v.objval.ptr && _object_compview == av._object_compview; #endif else if (_type == AttributeValue::StringType) return _v.symval.symid == av._v.symval.symid; else return false; } void AttributeValue::stream_list(AttributeValueList* list) { if (is_stream()) { Resource::unref(_v.streamval.listptr); _v.streamval.listptr = list; if (!list) stream_mode(0); else Resource::ref(list); } } int AttributeValue::stream_mode() { if (is_stream()) { if (!stream_list() || stream_list()->Number()==0) return 0; else return _stream_mode; } else return 0; } int AttributeValue::state() { if (!is_stream() && !is_object() && !is_command()) return _state; else return -1; } void AttributeValue::state(int val) { if (!is_stream() && !is_object() && !is_command()) _state = val; } boolean AttributeValue::is_object(int class_symid) { if (!is_type(ObjectType)) return false; if (this->class_symid() == class_symid) return true; return false; } #if 0 void AttributeValue::object_compview(boolean flag) { _object_compview = flag; if(flag) Resource::ref((ComponentView*)_v.objval.ptr); } #endif AttributeValue::AttributeValue(postfix_token* token) { clear(); void* v1 = &_v; void* v2 = &token->v; memcpy(v1, v2, sizeof(_v)); switch (token->type) { case TOK_STRING: type(StringType); symbol_reference(string_val()); break; case TOK_CHAR: type(CharType); break; case TOK_DFINT: type(IntType); break; case TOK_DFUNS: type(UIntType); break; case TOK_LNINT: type(LongType); break; case TOK_LNUNS: type(ULongType); break; case TOK_FLOAT: type(FloatType); break; case TOK_DOUBLE: type(DoubleType); break; case TOK_EOF: type(EofType); break; case TOK_COMMAND: type(SymbolType); symbol_reference(symbol_val()); _v.symval.globalflag=0; break; case TOK_KEYWORD: type(KeywordType); break; case TOK_BLANK: type(BlankType); break; default: type(UnknownType); break; } } boolean AttributeValue::equal(AttributeValue& av) { boolean result; if (av.type()==AttributeValue::UnknownType && type()!=AttributeValue::UnknownType) result = false; else if (av.type()==AttributeValue::BlankType && type()!=AttributeValue::BlankType) result = false; else { switch (type()) { case AttributeValue::CharType: result = char_val() == av.char_val(); break; case AttributeValue::UCharType: result = uchar_val() == av.uchar_val(); break; case AttributeValue::ShortType: result = short_val() == av.short_val(); break; case AttributeValue::UShortType: result = ushort_val() == av.ushort_val(); break; case AttributeValue::IntType: result = int_val() == av.int_val(); break; case AttributeValue::UIntType: result = uint_val() == av.uint_val(); break; case AttributeValue::LongType: result = long_val() == av.long_val(); break; case AttributeValue::ULongType: result = ulong_val() == av.ulong_val(); break; case AttributeValue::FloatType: result = float_val() == av.float_val(); break; case AttributeValue::DoubleType: result = double_val() == av.double_val(); break; case AttributeValue::StringType: case AttributeValue::SymbolType: result = strcmp(symbol_ptr(), av.symbol_ptr())==0; break; case AttributeValue::ArrayType: result = av.type() == AttributeValue::ArrayType && (array_val() == av.array_val() || array_val()->Equal(av.array_val())); break; case AttributeValue::ObjectType: if (!object_compview()) result = av.type() == AttributeValue::ObjectType && obj_val() == av.obj_val() && class_symid() == av.class_symid(); else result = av.type() == AttributeValue::ObjectType && class_symid() == av.class_symid() && av.object_compview() && ((ComponentView*)obj_val())->GetSubject() == ((ComponentView*)av.obj_val())->GetSubject(); break; default: result = is_type(AttributeValue::UnknownType) && av.is_type(AttributeValue::UnknownType) || is_type(AttributeValue::BlankType) && av.is_type(AttributeValue::BlankType); break; } } return result; } ivtools-1.2.11a1/src/Attribute/attrvalue.h000066400000000000000000000411031214471147700204360ustar00rootroot00000000000000/* * Copyright (c) 2001,2006 Scott E. Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(_attrvalue_h) #define _attrvalue_h #define RESOURCE_COMPVIEW #include #include #include #include #include #include // extern "C" { int symbol_add(const char*); int symbol_del(int); int symbol_reference(int); int symbol_find(const char*); const char* symbol_pntr(int); // } class AttributeValueList; class ComponentView; #include //: struct for symbol value, symid + global flag for symbol value // used in attr_value. typedef struct { unsigned int symid; boolean globalflag; } symval_struct; //: void* pointer plus object classid (see macro in OverlayUnidraw/ovcomps.h) // used in attr_value. typedef struct { void *ptr; unsigned int type; } objval_struct; //: pointer to list of values, plus optional type id. // used in attr_value. typedef struct { AttributeValueList *ptr; unsigned int type; } arrayval_struct; //: void* pointer to ComFunc object plus optional type id // used in attr_value. typedef struct { void *funcptr; AttributeValueList *listptr; } streamval_struct; //: keyword symbol id, plus number of arguments that follow. // used in attr_value. typedef struct { unsigned int keyid; unsigned int keynarg; } keyval_struct; //: union for AttributeValue typed data storage. typedef union attr_value_union { char charval; unsigned char ucharval; short shortval; unsigned short ushortval; int dfintval; unsigned int dfunsval; long lnintval; unsigned long lnunsval; float floatval; double doublval; symval_struct symval; objval_struct objval; arrayval_struct arrayval; streamval_struct streamval; keyval_struct keyval; } attr_value; typedef const char* const_char_ptr; //: multi-type attribute value object. class AttributeValue { public: enum ValueType { UnknownType, CharType, UCharType, ShortType, UShortType, IntType, UIntType, LongType, ULongType, FloatType, DoubleType, StringType, SymbolType, ArrayType, StreamType, CommandType, KeywordType, ObjectType, EofType, BooleanType, OperatorType, BlankType, ListType = ArrayType }; // enum for attribute value types. enum ValueState { UnknownState, OctState, HexState }; // enum for states AttributeValue(ValueType type); // construct with specified type and unitialized value. AttributeValue(ValueType type, attr_value value); // construct with specified type and value struct. AttributeValue(AttributeValue&); // copy constructor. AttributeValue(AttributeValue*); // deep copy constructor. AttributeValue(); // default constructor (UnknownType constructor). AttributeValue(postfix_token* token); // copy constructor from a postfix token generated by a scanner or parser. AttributeValue(char val); // CharType constructor. AttributeValue(unsigned char val); // UCharType constructor. AttributeValue(short val); // ShortType constructor. AttributeValue(unsigned short val); // UShortType constructor. AttributeValue(int val, ValueType type); // IntType constructor or any other int-like value. AttributeValue(unsigned int val, ValueType type); // UIntType constructor or any other unsigned-int-like value including SymbolType. AttributeValue(unsigned int keysym, unsigned int narg, ValueType=KeywordType); // KeywordType constructor (or can be used for ObjectType). AttributeValue(long val); // LongType constructor. AttributeValue(unsigned long val); // ULongType constructor. AttributeValue(float val); // FloatType constructor. AttributeValue(double); // DoubleType constructor. AttributeValue(int class_symid, void* objptr); // ObjectType constructor. AttributeValue(AttributeValueList* listptr); // ArrayType/ListType constructor. AttributeValue(void* comfunc, AttributeValueList* vallist); // StreamType constructor. AttributeValue(const char* val); // StringType constructor. AttributeValue(ComponentView* view, int compid); // ComponentView constructor. virtual ~AttributeValue(); // set to UnknownType and unref pointer if ArrayType/ListType or StreamType. void clear(); // clear bytes of multi-value union AttributeValue& operator= (const AttributeValue&); // copy assignment operator. ValueType type() const; // return type enum. void type(ValueType); // set type enum. int type_size() { return type_size(type()); } // return sizeof of value of this type. static int type_size(ValueType); // return sizeof of value of given type. int type_symid() const; // return symbol id corresponding to type void assignval (const AttributeValue&); // copy contents of AttributeValue char& char_ref(); // char by reference. unsigned char& uchar_ref(); // unsigned char by reference. short& short_ref(); // short by reference. unsigned short& ushort_ref(); // unsigned short by reference. int& int_ref(); // int by reference. unsigned int& uint_ref(); // unsigned int by reference. boolean& boolean_ref(); // boolean by reference. long& long_ref(); // long by reference. unsigned long& ulong_ref(); // unsigned long by reference. float& float_ref(); // float by reference. double& double_ref(); // double by reference. unsigned int& string_ref(); // string symbol id by reference. unsigned int& symbol_ref(); // symbol id by reference. void*& obj_ref(); // void* pointer to object by reference. unsigned int& obj_type_ref(); // classid of object by reference. AttributeValueList*& array_ref(); // values in list by reference. unsigned int& array_type_ref(); // type of values in list by reference AttributeValueList*& list_ref(); // values in list by reference. unsigned int& list_type_ref(); // type of values in list by reference unsigned int& keyid_ref(); // symbol id of keyword by reference. unsigned int& keynarg_ref(); // number of arguments after keyword by reference. char char_val(); // char by value. unsigned char uchar_val(); // unsigned char by value. short short_val(); // short by value. unsigned short ushort_val(); // unsigned short by value. int int_val(); // int by value. unsigned int uint_val(); // unsigned int by value. boolean boolean_val(); // boolean by value. long long_val(); // long by value. unsigned long ulong_val(); // unsigned long by value. float float_val(); // float by value. double double_val(); // double by value. unsigned int string_val(); // string symbol id by value. unsigned int symbol_val(); // symbol id by value. void* obj_val(); // void* pointer to object by value. unsigned int obj_type_val(); // classid of object by value. unsigned int& class_symid(); // classid of object by value. AttributeValueList* array_val(); // values in list by value. unsigned int array_type_val(); // type of values in list by value AttributeValueList* list_val(); // values in list by value. unsigned int list_type_val(); // type of values in list by value unsigned int keyid_val(); // symbol id of keyword by value. unsigned int keynarg_val(); // number of arguments after keyword by value. const char* string_ptr(); // lookup and return pointer to string associated with string. const char* symbol_ptr(); boolean global_flag(); // return true if a symbol and the global flag is set. void global_flag(boolean flag); // set global flag of a symbol int array_len(); // length of list of values when ArrayType/ListType. int list_len(); // length of list of values when ArrayType/ListType. int command_symid(); // symbol id of associated command name, for use with ComTerp. void command_symid(int, boolean alias=false); // set symbol id of associated command name, for use with ComTerp. boolean command_alias(); // returns true if command is an alias, not the first name. const boolean object_compview() { return is_object() && _object_compview; } // true if object is wrapped with a ComponentView #if 0 void object_compview(boolean flag); // true if object is wrapped with a ComponentView #endif int stream_mode(); // 0 = disabled, negative = internal, positive = external void stream_mode(int mode) { if (is_stream()) _stream_mode = mode; } // 0 = disabled, negative = internal, positive = external void* stream_func() { return is_stream() ? _v.streamval.funcptr : nil; } // return function pointer associated with stream object void stream_func(void* func) { if (is_stream()) _v.streamval.funcptr = func; } // set function pointer associated with stream object AttributeValueList* stream_list() { return is_stream() ? _v.streamval.listptr : nil; } // return pointer to AttributeValueList associated with stream object void stream_list(AttributeValueList* list); // set pointer to AttributeValueList associated with stream object int state(); // get generic state value useful for any type other than CommandType, ObjectType, or StreamType void state(int val); // set generic state value useful for any type other than CommandType, ObjectType, or StreamType void negate(); // negate numeric values. boolean is_true() { return type() != UnknownType && boolean_val(); } // returns true if !UnknownType && boolean_val() boolean is_false() { return !is_true(); } // returns true if !is_true() boolean is_type(ValueType t) { return type() == t; } // returns true if type() == 't'. boolean is_boolean() { return is_boolean(type()); } // returns true if BooleanType. boolean is_char() { return is_char(type()); } // returns true if CharType || UCharType. boolean is_short() { return is_short(type()); } // returns true if ShortType || UShortType. boolean is_int() { return is_int(type()); } // returns true if IntType || UIntType. boolean is_long() { return is_long(type()); } // returns true if LongType || ULongType. boolean is_float() { return is_float(type()); } // returns true if FloatType. boolean is_double() { return is_double(type()); } // returns true if DoubleType. boolean is_integer() { return is_integer(type()); } // returns true if is_char() || is_short() || is_int() || is_long(). boolean is_floatingpoint() { return is_floatingpoint(type()); } // returns true if is_float() || is_double(). boolean is_num() { return is_integer(type()) || is_floatingpoint(type()); } // returns true if is_integer() || is_floatingpoint(). boolean is_numeric() { return is_num(); } // same as AttributeValue::is_num(). boolean is_array() { return is_type(ArrayType); } // returns true if ArrayType/ListType. boolean is_list() { return is_type(ArrayType); } // returns true if ArrayType/ListType. boolean is_stream() { return is_type(StreamType); } // returns true if StreamType. boolean is_key() { return is_type(KeywordType); } // returns true if KeywordType. boolean is_unknown() { return is_type(UnknownType); } // returns true if UnknownType. boolean is_null() { return is_unknown(); } // returns true if UnknownType. boolean is_nil() { return is_unknown(); } // returns true if UnknownType. boolean is_known() { return !is_type(UnknownType); } // returns true if !UnknownType. boolean is_string() { return is_type(StringType) || is_type(SymbolType); } // returns true if StringType || SymbolType. boolean is_only_string() { return is_type(StringType); } // returns true if StringType boolean is_symbol() { return is_type(SymbolType); } // returns true if SymbolType. boolean is_command() { return is_type(CommandType); } // returns true if CommandType (for use of ComTerp). boolean is_object() { return is_type(ObjectType); } // returns true if ObjectType. boolean is_object(int class_symid); // returns true if ObjectType and class_symid matches or belongs to a parent class. static boolean is_boolean(ValueType t) { return t==BooleanType; } static boolean is_char(ValueType t) { return t==CharType || t==UCharType; } static boolean is_short(ValueType t) { return t==ShortType || t==UShortType; } static boolean is_int(ValueType t) { return t==IntType || t==UIntType; } static boolean is_long(ValueType t) { return t==LongType || t==ULongType; } static boolean is_float(ValueType t) { return t==FloatType; } static boolean is_double(ValueType t) { return t==DoubleType; } static boolean is_integer(ValueType t) { return is_char(t) || is_short(t) || is_int(t) | is_long(t); } static boolean is_floatingpoint(ValueType t) { return is_float(t) || is_double(t); } static boolean is_num(ValueType t) { return is_integer(t) || is_floatingpoint(t); } boolean is_blank() { return is_type(BlankType); } // returns true if BlankType. static boolean is_blank(ValueType t) { return t==BlankType; }; boolean is_attributelist(); // returns true if ObjectType with an AttributeList object. boolean is_attribute(); // returns true if ObjectType with an Attribute object. virtual void* geta(int type); // return a pointer if ObjectType matches or is a parent class friend ostream& operator << (ostream& s, const AttributeValue&); // output AttributeValue to ostream. void* value_ptr() { return &_v; } // returns void* pointer to value struct. void ref_as_needed(); // increment ref counters as needed void unref_as_needed(); // decrement ref counters as needed void dup_as_needed(); // duplicate lists then increment ref counters as needed const boolean same_list(const AttributeValue& av); // check if arrayval or streamval are the same boolean equal(AttributeValue& av); // return true if values of both are the same protected: ValueType _type; attr_value _v; union { int _command_symid; // used for CommandType. boolean _object_compview; // used for ObjectType. int _stream_mode; // used for StreamType int _state; // useful for any type other than CommandType, ObjectType, or StreamType }; static int* _type_syms; #ifdef LEAKCHECK public: static LeakChecker* _leakchecker; #endif }; //: for quick casting in debugger typedef class AttributeValue _AV; #endif /* !defined(_attrvalue_h) */ ivtools-1.2.11a1/src/Attribute/classid.h000066400000000000000000000001501214471147700200460ustar00rootroot00000000000000#ifndef _classid_h #define _classid_h #include #endif /* !defined(_classid_h) */ ivtools-1.2.11a1/src/Attribute/commodule.cc000066400000000000000000000055561214471147700205650ustar00rootroot00000000000000/* * Copyright (c) 1994-1996 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #define TITLE "ComTerpModule" #if BUFSIZ>1024 #undef BUFSIZ #define BUFSIZ 1024 #endif /*****************************************************************************/ int ComTerpModule::dmm_init = 0; ComTerpModule::ComTerpModule() { init(); } ComTerpModule::ComTerpModule(const char* path) { init(); _inptr = (void*)fopen(path, "r"); } ComTerpModule::ComTerpModule(FILE* fptr) { init(); _inptr = (void*)fptr; } ComTerpModule::ComTerpModule(void* inptr, infuncptr infunc, eoffuncptr eoffunc, errfuncptr errfunc) { init(); _inptr = inptr; _infunc = infunc; _eoffunc = eoffunc; _errfunc = errfunc; } ComTerpModule::~ComTerpModule() { /* Free memory associated with dmm system */ if (dmm_init && dmm_mblock_free() != 0) KANRET ("error in call to dmm_mblock_free"); delete _buffer; delete _token; } void ComTerpModule::init() { /* Initialize dmm system */ if (!dmm_init) { if(dmm_mblock_alloc(1000000L) != 0) KANRET("error in call to dmm_mblock_alloc"); dmm_init = 1; } _inptr = stdin; _infunc = (infuncptr)&fgets; _eoffunc = (eoffuncptr)&ffeof; _errfunc = (errfuncptr)&fferror; _outptr = stdout; _outfunc = (outfuncptr)&fputs; #if 0 _buffer = new char[BUFSIZ*BUFSIZ]; _bufsiz = BUFSIZ*BUFSIZ; _token = new char[BUFSIZ*BUFSIZ]; _toksiz = BUFSIZ*BUFSIZ; #else _buffer = new char[BUFSIZ*16]; _bufsiz = BUFSIZ*16; _token = new char[BUFSIZ*16]; _toksiz = BUFSIZ*16; #endif _linenum = 0; } void ComTerpModule::reset() { _buffer[0] = '\0'; _token[0] = '\0'; _linenum = 0; } ivtools-1.2.11a1/src/Attribute/commodule.h000066400000000000000000000063271214471147700204240ustar00rootroot00000000000000/* * Copyright (c) 1994-1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(_commodule_h) #define _commodule_h #include #include // extern "C" { #include // } //: pointer to fgets-like function. typedef char* (*infuncptr)(char*,int,void*); //: pointer to feof-like function. typedef int (*eoffuncptr)(void*); //: pointer to ferror-like function. typedef int (*errfuncptr)(void*); //: pointer to fputs-like function. typedef int (*outfuncptr)(const char*, void*); //: base class for C++ wrappers of Fischer-LeBlanc style compiler pipeline. // This lives here, instead of in the ComTerp library, so that the LexScan // derivative class can be used by the ParamList mechanism. class ComTerpModule { public: ComTerpModule(); // construct for stdin/stdout ComTerpModule(const char* path); // construct to read from 'path'. ComTerpModule(FILE* fptr); // construct to read from 'fptr'. ComTerpModule(void* inptr, infuncptr infunc, eoffuncptr eoffunc, errfuncptr errfunc); // construct to use arbitrary function pointers that are passed // an arbitrary void* pointer. virtual ~ComTerpModule(); void reset(); // re-allocate internal buffers and reset internal pointers. int infix_symid(const char*); // symbol id for binary infix operator int prefix_symid(const char*); // symbol id for unary prefix operator int postfix_symid(const char*); // symbol id for unary postfix operator void op_symid(const char*, int& infix, int& prefix, int& postfix); // symbol ids for binary infix, unary prefix and postfix for a given // operator string. protected: void init(); // allocate internal buffers and initialize internal pointers. void* _inptr; infuncptr _infunc; eoffuncptr _eoffunc; errfuncptr _errfunc; void* _outptr; outfuncptr _outfunc; protected: char* _buffer; int _bufsiz; unsigned _bufptr; char* _token; int _toksiz; unsigned _linenum; int _buffer_alloc; int _token_alloc; static int dmm_init; }; #endif /* !defined(_commodule_h) */ ivtools-1.2.11a1/src/Attribute/lexscan.cc000066400000000000000000000131521214471147700202250ustar00rootroot00000000000000/* * Copyright (c) 1994-1996 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include /*****************************************************************************/ LexScan::LexScan() : ComTerpModule() { init(); } LexScan::LexScan(const char* path) : ComTerpModule(path) { init(); } LexScan::LexScan(void* inptr, char*(*infunc)(char*,int,void*), int(*eoffunc)(void*), int(*errfunc)(void*)) : ComTerpModule(inptr, infunc, eoffunc, errfunc) { init(); } LexScan::~LexScan() { delete _tokbuf; } void LexScan::init() { _begcmt = (char*) "/*"; _endcmt = (char*) "*/"; _tokbuf = new char[_bufsiz]; } attr_value LexScan::get_next_token(unsigned int& toktype) { unsigned int toklen, tokstart; int status = lexscan (_inptr, _infunc, _eoffunc, _errfunc, NULL, NULL, _begcmt, _endcmt, '#', "//", _buffer, _bufsiz, &_bufptr, _token, _toksiz, &toklen, &toktype, &tokstart, &_linenum); attr_value retval; switch (toktype) { case TOK_IDENTIFIER: case TOK_STRING: retval.symval.symid = symbol_add(_token); break; case TOK_CHAR: retval.charval = *_token; break; case TOK_DFINT: retval.dfintval = *(int*)_token; break; case TOK_DFUNS: retval.dfunsval = *(unsigned int*)_token; break; case TOK_LNINT: retval.lnintval = *(long*)_token; break; case TOK_LNUNS: retval.lnunsval = *(unsigned long*)_token; break; case TOK_FLOAT: retval.floatval = *(float*)_token; break; case TOK_DOUBLE: retval.doublval = *(double*)_token; break; case TOK_OPERATOR: retval.symval.symid = symbol_add(_token); break; case TOK_EOL: break; case TOK_EOF: break; default: break; } return retval; } const char* LexScan::get_next_token_string(unsigned int& toktype) { unsigned int toklen, tokstart; int status = lexscan (_inptr, _infunc, _eoffunc, _errfunc, NULL, NULL, _begcmt, _endcmt, '#', "//", _buffer, _bufsiz, &_bufptr, _token, _toksiz, &toklen, &toktype, &tokstart, &_linenum); unsigned tok_buflen = _bufptr-tokstart; strncpy(_tokbuf, _buffer+tokstart, tok_buflen); _tokbuf[tok_buflen] = '\0'; return _tokbuf; } AttributeValue* LexScan::get_attrval(char* buf, unsigned int bufsiz) { static int nilsym = symbol_add("nil"); reset(); int n = Math::min((int)bufsiz,_bufsiz-2); memcpy(_buffer, buf, n); if (_buffer[n-1]!='\n') { _buffer[n] = '\n'; _buffer[n+1] = '\0'; } else _buffer[n] = '\0'; unsigned int toktype; attr_value tokval = get_next_token(toktype); AttributeValue::ValueType valtype; switch (toktype) { case TOK_IDENTIFIER: valtype = tokval.dfintval==nilsym ? AttributeValue::UnknownType : AttributeValue::SymbolType; break; case TOK_STRING: valtype = AttributeValue::StringType; break; case TOK_CHAR: valtype = AttributeValue::CharType; break; case TOK_DFINT: valtype = AttributeValue::IntType; break; case TOK_DFUNS: valtype = AttributeValue::UIntType; break; case TOK_LNINT: valtype = AttributeValue::LongType; break; case TOK_LNUNS: valtype = AttributeValue::ULongType; break; case TOK_FLOAT: valtype = AttributeValue::FloatType; break; case TOK_DOUBLE: valtype = AttributeValue::DoubleType; break; case TOK_EOF: valtype = AttributeValue::EofType; break; case TOK_OPERATOR: valtype = AttributeValue::OperatorType; break; default: valtype = AttributeValue::UnknownType; break; } return new AttributeValue(valtype, tokval); } const int LexScan::get_next_value(AttributeValue* attrval, char delim) { static int minus_symid = symbol_add("-"); static int plus_symid = symbol_add("+"); attr_value token; unsigned int toktype; int negate = 0; do { token = get_next_token(toktype); if(toktype == TOK_OPERATOR && token.symval.symid==minus_symid) { negate = 1; token = get_next_token(toktype); } else if(toktype == TOK_OPERATOR && token.symval.symid==plus_symid) { token = get_next_token(toktype); } } while(toktype == TOK_OPERATOR && *symbol_pntr(token.symval.symid)==delim); if (toktype==TOK_EOF) return 0; else if (toktype==TOK_EOL) return 2; else { AttributeValue tokval((AttributeValue::ValueType)toktype, token); if (negate) tokval.negate(); *attrval = tokval; return 1; } } ivtools-1.2.11a1/src/Attribute/lexscan.h000066400000000000000000000046611214471147700200740ustar00rootroot00000000000000/* * Copyright (c) 1994-1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(_lexscan_h) #define _lexscan_h #include #include class AttributeValue; //: Lexical scanner for C tokens, with C-style comment skipping. class LexScan : public ComTerpModule { public: LexScan(); // construct on stdin. LexScan(const char* path); // construct on 'path'. LexScan(void*, char*(*)(char*,int,void*), int(*)(void*), int(*)(void*)); // construct on arbitrary function pointers, with arbitrary void* // pointer to pass to them. ~LexScan(); void init(); // intialize comment delimeters and internal token buffer. attr_value get_next_token(unsigned int& toktype); // return token in structure ready for constructing an AttributeValue. const char* get_next_token_string(unsigned int& toktype); // return pointer to next token in internal buffer. AttributeValue* get_attrval(char* buf, unsigned int bufsiz); // return token in newly allocated AttributeValue. const int get_next_value(AttributeValue* attrval, char delim='\0'); // return AttributeValue that represents next token, skipping over delim and whitespace protected: char* _begcmt; char* _endcmt; char* _tokbuf; }; #endif /* !defined(_lexscan_h) */ ivtools-1.2.11a1/src/Attribute/paramlist.cc000066400000000000000000000613641214471147700205740ustar00rootroot00000000000000/* * Copyright (c) 1994-1996 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Implementation of ParamList class. */ #include #include #include #include #include #include #include #include #include #include #include #ifndef __APPLE__ #include #endif /*****************************************************************************/ using std::cerr; static const int BUFSIZE = 10000; static char textbuf[BUFSIZE]; static void Get_Line ( const char* s, int size, int begin, int& end, int& lineSize, int& nextBegin ) { int i = begin; while (i < size) { if (s[i] == '\n') { break; } else { ++i; } } end = i - 1; nextBegin = i + 1; lineSize = i - begin; } /*****************************************************************************/ ParamStruct::ParamStruct(const char* name, ParamFormat format, param_callback ifunc, int offset1, int offset2, int offset3, int offset4, int indirection) { _name = name ? strdup(name) : nil; _format = format; _ifunc = ifunc; _offset1 = offset1; _offset2 = offset2; _offset3 = offset3; _offset4 = offset4; _indirection = indirection; } ParamStruct::ParamStruct(ParamStruct& ps) { *this = ps; } ParamStruct::~ParamStruct() { delete _name; } void * ParamStruct::addr1(void* base) { if (_offset1<0) return nil; if (_indirection<0) return (char *) base + _offset1; else return *(char **)((char*)base+_indirection) + _offset1; } void * ParamStruct::addr2(void* base) { if (_offset2<0) return nil; if (_indirection<0) return (char *) base + _offset2; else return *(char **)((char*)base+_indirection) + _offset2; } void * ParamStruct::addr3(void* base) { if (_offset3<0) return nil; if (_indirection<0) return (char *) base + _offset3; else return *(char **)((char*)base+_indirection) + _offset3; } void * ParamStruct::addr4(void* base) { if (_offset4<0) return nil; if (_indirection<0) return (char *) base + _offset4; else return *(char **)((char*)base+_indirection) + _offset4; } /*****************************************************************************/ LexScan* ParamList::_lexscan = nil; ParamStruct* ParamList::_currstruct = nil; ParamList::ParamList (ParamList* s) { _alist = new AList; _count = 0; _required_count = 0; _optional_count = 0; _keyword_count = 0; _other_count = 0; if (s != nil) { ALIterator i; for (s->First(i); !s->Done(i); s->Next(i)) { insert(new ParamStruct(*GetStruct(i))); } } } ParamList::~ParamList () { delete _lexscan; ALIterator i; for (First(i); !Done(i); Next(i)) delete GetStruct(i); delete _alist; } LexScan* ParamList::lexscan() { if (!_lexscan) _lexscan = new LexScan(nil, nil, nil, nil); return _lexscan; } void ParamList::add_param(const char* name, ParamStruct::ParamFormat format, param_callback ifunc, void* base, void* addr1, void* addr2, void* addr3, void* addr4) { ParamStruct* ps = new ParamStruct( name, format, ifunc, addr1 ? (char *) addr1 - (char *) base : -1, addr2 ? (char *) addr2 - (char *) base : -1, addr3 ? (char *) addr3 - (char *) base : -1, addr4 ? (char *) addr4 - (char *) base : -1); insert(ps); } void ParamList::add_param_indirect( const char* name, ParamStruct::ParamFormat format, param_callback ifunc, void* base, void* offset, void* addr1, void* addr2, void* addr3, void* addr4) { ParamStruct* ps = new ParamStruct( name, format, ifunc, addr1 ? (char *) addr1 - *(char **) offset : -1, addr2 ? (char *) addr2 - *(char **) offset : -1, addr3 ? (char *) addr3 - *(char **) offset : -1, addr4 ? (char *) addr4 - *(char **) offset : -1, (char *) offset - (char *) base); insert(ps); } void ParamList::add_param_first(const char* name, ParamStruct::ParamFormat format, param_callback ifunc, void* base, void* addr1, void* addr2, void* addr3, void* addr4) { ParamStruct* ps = new ParamStruct( name, format, ifunc, addr1 ? (char *) addr1 - (char *) base : -1, addr2 ? (char *) addr2 - (char *) base : -1, addr3 ? (char *) addr3 - (char *) base : -1, addr4 ? (char *) addr4 - (char *) base : -1); insert_first(ps); } void ParamList::insert(ParamStruct* ps) { ALIterator i; for (First(i); !Done(i); Next(i)) { ParamStruct* ops = GetStruct(i); if (ps->format() == ParamStruct::other) break; if (ps->format() == ParamStruct::required && ops->format() != ParamStruct::required) break; if (ps->format() == ParamStruct::optional && ops->format() == ParamStruct::keyword) break; } InsertBefore(i, ps); _count++; if (ps->format() == ParamStruct::required) _required_count++; if (ps->format() == ParamStruct::optional) _optional_count++; if (ps->format() == ParamStruct::keyword) _keyword_count++; if (ps->format() == ParamStruct::other) _other_count++; } void ParamList::insert_first(ParamStruct* ps) { ALIterator i; for (First(i); !Done(i); Next(i)) { ParamStruct* ops = GetStruct(i); if (ps->format() == ParamStruct::other) break; if (ps->format() == ParamStruct::required) break; if (ps->format() == ParamStruct::keyword && ops->format() == ParamStruct::keyword) break; } InsertBefore(i, ps); _count++; if (ps->format() == ParamStruct::required) _required_count++; if (ps->format() == ParamStruct::optional) _optional_count++; if (ps->format() == ParamStruct::keyword) _keyword_count++; if (ps->format() == ParamStruct::other) _other_count++; } boolean ParamList::read_args(istream& in, void* base) { int curpar = 0; ALIterator i; First(i); if (_other_count > 0) Next(i); //other always stored first in list const char* token; char ch; /* look for opening ( */ skip_space(in); ch = in.get(); if (ch != '(') { return false; } /* required fixed format parameters */ while (curpar < _required_count) { skip_space(in); ParamStruct* ps = GetStruct(i); if ((*ps->ifunc())(in, ps->addr1(base), ps->addr2(base), ps->addr3(base), ps->addr4(base)) == -1) { cerr << "Error in required parameter " << ps->name() << "\n"; return false; } Next(i); curpar++; } /* optional fixed format parameters that have been supplied */ while (skip_space(in), in.good() && (ch = in.peek()) != ':' && (ch = in.peek()) != ')' && curpar < _required_count+_optional_count) { ParamStruct* ps = GetStruct(i); if ((*ps->ifunc())(in, ps->addr1(base), ps->addr2(base), ps->addr3(base), ps->addr4(base)) == -1) { cerr << "Error in optional parameter " << ps->name() << "\n"; return false; } Next(i); curpar++; } /* free format parameters, defaulted and otherwise */ while (skip_space(in), in.good() && (ch = in.get()) != ')') { if (ch == ':') { char keyword[BUFSIZE]; parse_token(in, keyword, BUFSIZE, ')'); ALIterator j(i); boolean match = false; while (!Done(j)) { if (strcmp(keyword, GetStruct(j)->name()) == 0) { ParamStruct* ps = GetStruct(j); skip_space(in); if ((*ps->ifunc())(in, ps->addr1(base), ps->addr2(base), ps->addr3(base), ps->addr4(base)) == -1) { cerr << "Error in keyword parameter " << ps->name() << "\n"; return false; } match = true; break; } else Next(j); } if (!match) { First(j); ParamStruct* ps = GetStruct(j); skip_space(in); if ((*ps->ifunc())(in, ps->addr1(base), ps->addr2(base), ps->addr3(base), keyword) == -1) { cerr << "Error in other parameter " << ps->name() << "\n"; return false; } } } } // last '\n' if ((ch=in.get()) != '\n') in.putback(ch); return true; } ParamStruct* ParamList::Struct (AList* r) { return (ParamStruct*) (*r)(); } AList* ParamList::Elem (ALIterator i) { return (AList*) i.GetValue(); } void ParamList::Append (ParamStruct* v) { _alist->Append(new AList(v)); ++_count; } void ParamList::Prepend (ParamStruct* v) { _alist->Prepend(new AList(v)); ++_count; } void ParamList::InsertAfter (ALIterator i, ParamStruct* v) { Elem(i)->Prepend(new AList(v)); ++_count; } void ParamList::InsertBefore (ALIterator i, ParamStruct* v) { Elem(i)->Append(new AList(v)); ++_count; } void ParamList::Remove (ALIterator& i) { AList* doomed = Elem(i); Next(i); _alist->Remove(doomed); delete doomed; --_count; } void ParamList::Remove (ParamStruct* p) { AList* temp; if ((temp = _alist->Find(p)) != nil) { _alist->Remove(temp); delete temp; --_count; } } ParamStruct* ParamList::GetStruct (ALIterator i) { _currstruct = Struct(Elem(i)); return _currstruct;} void ParamList::SetStruct (ParamStruct* gv, ALIterator& i) { i.SetValue(_alist->Find(gv)); } void ParamList::First (ALIterator& i) { i.SetValue(_alist->First()); } void ParamList::Last (ALIterator& i) { i.SetValue(_alist->Last()); } void ParamList::Next (ALIterator& i) { i.SetValue(Elem(i)->Next()); } void ParamList::Prev (ALIterator& i) { i.SetValue(Elem(i)->Prev()); } boolean ParamList::Done (ALIterator i) { return Elem(i) == _alist->End(); } int ParamList::Number () { return _count; } boolean ParamList::Includes (ParamStruct* e) { return _alist->Find(e) != nil; } boolean ParamList::IsEmpty () { return _alist->IsEmpty(); } int ParamList::read_int(istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { int f1, f2, f3, f4; char delim; if (addr1 && in.good()) { in >> f1; *(int*)addr1 = f1; if (addr2 && in.good()) { in >> delim >> f2; *(int*)addr2 = f2; if (addr3 && in.good()) { in >> delim >> f3; *(int*)addr3 = f3; if (addr4 && in.good()) { in >> delim >> f4; *(int*)addr4 = f4; } } } } return (in.good()||in.eof()) ? 0 : -1; } int ParamList::read_float(istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { float f1, f2, f3, f4; char delim; if (addr1 && in.good()) { in >> f1; *(float*)addr1 = f1; if (addr2 && in.good()) { in >> delim >> f2; *(float*)addr2 = f2; if (addr3 && in.good()) { in >> delim >> f3; *(float*)addr3 = f3; if (addr4 && in.good()) { in >> delim >> f4; *(float*)addr4 = f4; } } } } return (in.good()||in.eof()) ? 0 : -1; } int ParamList::read_double(istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { double f1, f2, f3, f4; char delim; if (addr1 && in.good()) { in >> f1; *(double*)addr1 = f1; if (addr2 && in.good()) { in >> delim >> f2; *(double*)addr2 = f2; if (addr3 && in.good()) { in >> delim >> f3; *(double*)addr3 = f3; if (addr4 && in.good()) { in >> delim >> f4; *(double*)addr4 = f4; } } } } return (in.good()||in.eof()) ? 0 : -1; } int ParamList::read_string(istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { char* s1, s2, s3, s4; char delim; char buffer[BUFSIZ]; if (addr1 && in.good()) { if (parse_string(in, buffer, BUFSIZ) == 0) *(char **)addr1 = strdup(buffer); if (addr2 && in.good()) { if (parse_string(in, buffer, BUFSIZ) == 0) *(char **)addr2 = strdup(buffer); if (addr3 && in.good()) { if (parse_string(in, buffer, BUFSIZ) == 0) *(char **)addr3 = strdup(buffer); if (addr4 && in.good()) { if (parse_string(in, buffer, BUFSIZ) == 0) *(char **)addr4 = strdup(buffer); } } } } return (in.good()||in.eof()) ? 0 : -1; } int ParamList::read_symbol(istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { char* s1, s2, s3, s4; char delim; char buffer[BUFSIZ]; if (addr1 && in.good()) { if (parse_token(in, buffer, BUFSIZ) == 0) *(int *)addr1 = symbol_add(buffer); if (addr2 && in.good()) { if (parse_token(in, buffer, BUFSIZ) == 0) *(int *)addr2 = symbol_add(buffer); if (addr3 && in.good()) { if (parse_token(in, buffer, BUFSIZ) == 0) *(int *)addr3 = symbol_add(buffer); if (addr4 && in.good()) { if (parse_token(in, buffer, BUFSIZ) == 0) *(int *)addr4 = symbol_add(buffer); } } } } return (in.good()||in.eof()) ? 0 : -1; } int ParamList::read_ints (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { int bufsiz = 1024; int n = 0; int* nums = new int[bufsiz]; char ch; do { if (n >= bufsiz) { int* newnums = new int[bufsiz*2]; for (int i=0; i> nums[n]; skip_space(in); n++; } while ((ch = in.get()) == ',' && in.good()); if (in.good()) in.putback(ch); *(int**)addr1 = nums; *(int*)addr2 = n; return (in.good()||in.eof()) ? 0 : -1; } int ParamList::read_floats (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { int bufsiz = 1024; int n = 0; float* nums = new float[bufsiz]; char ch; do { if (n >= bufsiz) { float* newnums = new float[bufsiz*2]; for (int i=0; i> nums[n]; skip_space(in); n++; } while ((ch = in.get()) == ',' && in.good()); if (in.good()) in.putback(ch); *(float**)addr1 = nums; *(int*)addr2 = n; return (in.good()||in.eof()) ? 0 : -1; } int ParamList::read_doubles (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { int bufsiz = 1024; int n = 0; double* nums = new double[bufsiz]; char ch; do { if (n >= bufsiz) { double* newnums = new double[bufsiz*2]; for (int i=0; i> nums[n]; skip_space(in); n++; } while ((ch = in.get()) == ',' && in.good()); if (in.good()) in.putback(ch); *(double**)addr1 = nums; *(int*)addr2 = n; return (in.good()||in.eof()) ? 0 : -1; } int ParamList::read_strings (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { int bufsiz = 32; int n = 0; char** strings = new char*[bufsiz]; char ch; do { if (n >= bufsiz) { char** newstrings = new char*[bufsiz*2]; for (int i=0; i= bufsiz) { Coord* newx = new Coord[bufsiz*2]; Coord* newy = new Coord[bufsiz*2]; for (int i=0; i> x[n] >> delim >> y[n] >> delim; else { in.putback(ch); in >> x[n] >> delim >> y[n]; } skip_space(in); n++; } while ((ch = in.get()) == ',' && in.good()); if (in.good()) in.putback(ch); return (in.good()||in.eof()) ? 0 : -1; } int ParamList::parse_fltpts (istream& in, float*& x, float*& y, int& n) { char delim; int bufsiz = 1024; n = 0; x = new float[bufsiz]; y = new float[bufsiz]; char ch; do { if (n >= bufsiz) { float* newx = new float[bufsiz*2]; float* newy = new float[bufsiz*2]; for (int i=0; i> x[n] >> delim >> y[n] >> delim; else { in.putback(ch); in >> x[n] >> delim >> y[n]; } skip_space(in); n++; } while ((ch = in.get()) == ',' && in.good()); if (in.good()) in.putback(ch); return (in.good()||in.eof()) ? 0 : -1; } int ParamList::parse_dblpts (istream& in, double*& x, double*& y, int& n) { char delim; int bufsiz = 1024; n = 0; x = new double[bufsiz]; y = new double[bufsiz]; char ch; do { if (n >= bufsiz) { double* newx = new double[bufsiz*2]; double* newy = new double[bufsiz*2]; for (int i=0; i> x[n] >> delim >> y[n] >> delim; else { in.putback(ch); in >> x[n] >> delim >> y[n]; } skip_space(in); n++; } while ((ch = in.get()) == ',' && in.good()); if (in.good()) in.putback(ch); return (in.good()||in.eof()) ? 0 : -1; } int ParamList::parse_text(istream& in, char* buffer, int buflen) { TextBuffer stext(buffer, 0, buflen); char null = '\0'; char c = ','; int dot = 0; while (c == ',') { while (c != '"' && in.get(c)); while (in.get(c) && c != '"') { if (c == '\\') { in.get(c); if (isdigit(c)) { char buf[4]; buf[0] = c; in.get(buf[1]); in.get(buf[2]); buf[3] = '\0'; c = ParamList::octal(buf); } else if (c == 'n') dot += stext.Insert(dot, "\\", 1); } dot += stext.Insert(dot, &c, 1); } in.get(c); if (c == ',') dot += stext.Insert(dot, "\n", 1); } in.putback(c); stext.Insert(stext.Length(), &null, 1); return (in.good()||in.eof()) ? 0 : -1; } char* ParamList::parse_textbuf(istream& in) { int buflen = BUFSIZ; char* buffer = new char[buflen]; char null = '\0'; char c = ','; int dot = 0; while (c == ',') { while (c != '"' && in.get(c)); while (in.get(c) && c != '"') { if (c == '\\') { in.get(c); if (isdigit(c)) { char buf[4]; buf[0] = c; in.get(buf[1]); in.get(buf[2]); buf[3] = '\0'; c = ParamList::octal(buf); } else if (c == 'n') { buffer[dot++] = '\\'; if (dot == buflen) { buflen *= 2; char* newbuf = new char[buflen]; memcpy(newbuf, buffer, dot); delete buffer; buffer = newbuf; } } } buffer[dot++] = c; if (dot == buflen) { buflen *= 2; char* newbuf = new char[buflen]; memcpy(newbuf, buffer, dot); delete buffer; buffer = newbuf; } } in.get(c); if (c == ',') { buffer[dot++] = '\n'; if (dot == buflen) { buflen *= 2; char* newbuf = new char[buflen]; memcpy(newbuf, buffer, dot); delete buffer; buffer = newbuf; } } } in.putback(c); buffer[dot] = '\0'; if (in.good()) return buffer; else { delete buffer; return nil; } } int ParamList::output_text(ostream& out, const char* text, int indent) { if (!text) { out << "(null)"; return out.good() ? 0 : -1; } int len = strlen(text); int beg, end, lineSize, nextBeg, ypos = 0; if (len == 0) out << "\"\""; else { for (beg = 0; beg < len; ) { Get_Line(text, len, beg, end, lineSize, nextBeg); const char* string = filter(&text[beg], end - beg + 1); out << "\"" << string << "\""; beg = nextBeg; if (beg < len) { out << "," << "\n"; for (int i = 0; i < indent; i++) out << " "; } } } return out.good() ? 0 : -1; } int ParamList::parse_pathname (istream& in, char* buf, int buflen, const char* dir) { char buf2[buflen]; if (parse_string(in, buf2, buflen) != 0) return -1; else if (buf2[0] != '/' && dir && !urltest(buf2)) { strncpy( buf, dir, buflen); strncat( buf+strlen(dir), buf2, buflen-strlen(dir)); } else { strcpy( buf, buf2 ); } return 0; } boolean ParamList::url_use_ok() { return bincheck("curl") || bincheck("wget") || bincheck("ivdl") || bincheck("w3c"); } boolean ParamList::urltest(const char* buf) { if (!buf) return false; static boolean file_url_ok = url_use_ok(); return strncasecmp("http://", buf, 7)==0 || strncasecmp("ftp://", buf, 6)==0 || file_url_ok && strncasecmp("file:/", buf, 6)==0 ; } int ParamList::bintest(const char* command) { char combuf[BUFSIZ]; sprintf( combuf, "sh -c \"wr=`which %s 2> /dev/null`; echo $wr\"", command ); FILE* fptr = popen(combuf, "r"); char testbuf[BUFSIZ]; fgets(testbuf, BUFSIZ, fptr); pclose(fptr); if (strncmp(testbuf+strlen(testbuf)-strlen(command)-1, command, strlen(command)) != 0) { return -1; } return 0; } boolean ParamList::bincheck(const char* command) { int status = bintest(command); return !status; } // octal converts a character to the string \ddd where d is an octal digit. char* ParamList::octal(unsigned char c, register char* p) { *p-- = '\0'; // backwards from terminating null... *p-- = (char)('0' + c%8); *p-- = (char)('0' + (c >>= 3)%8); *p-- = (char)('0' + (c >>= 3)%8); *p = '\\'; // ...to beginning backslash return p; } // octal converts a string of three octal digits to a character. char ParamList::octal(const char* p) { char c = *p - '0'; c = c*8 + *++p - '0'; c = c*8 + *++p - '0'; return c; } // filter escapes embedded special characters const char* ParamList::filter (const char* string, int len) { TextBuffer text(textbuf, 0, BUFSIZE); int dot; for (dot = 0; len--; string++) { char c = *string; if (!isascii(c) || iscntrl(c)) { char buf[5]; octal(c, &buf[sizeof(buf) - 1]); dot += text.Insert(dot, buf, sizeof(buf) - 1); } else { if (c == '\\' || c == '"') dot += text.Insert(dot, "\\", 1); dot += text.Insert(dot, string, 1); } } text.Insert(dot, "", 1); return text.Text(); } ivtools-1.2.11a1/src/Attribute/paramlist.h000066400000000000000000000322701214471147700204300ustar00rootroot00000000000000/* * Copyright (c) 1994-1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * ParamList - a list of parameter definition structures. */ #if !defined(param_list_h) #define param_list_h #include #include #include class ALIterator; class LexScan; class AList; #include //: signature of static methods for reading parameter data from an istream. typedef int (*param_callback)(istream&, void*, void*, void*, void*); class ParamList; //: parameter definition structure for ParamList. // structure for defining an argument to be read out of a serialized view // of an object written out for persistent storage or interprocess communication. class ParamStruct { public: enum ParamFormat { required, optional, keyword, other }; // type of parameter formats supported. Similar to Common Lisp. ParamStruct(const char* name, ParamFormat format, param_callback ifunc, int offset1, int offset2, int offset3, int offset4, int indirection = -1); // construct with 'name' and 'format', a pointer to a static method // with 'param_callback' signature, and up to 4 offsets relative to a // base pointer that will be used in constructing the contents of another // object during a de-serialization process (an istream constructor). // Also possible to specify an 'indirection' amount used when adding // offsets to the base. ParamStruct(ParamStruct&); // copy constructor. ~ParamStruct(); const char* name() {return _name;} // the name of the parameter -- keyword parameters do not need the ":". ParamFormat format() {return _format;} // parameter format type: required, optional, keyword, or other. param_callback ifunc() {return _ifunc;} // pointer to static method (or function) to invoke when parameter found // during de-serialization process. int offset1() {return _offset1;} // first offset from base. This one is always supplied, and might // be the only true offset if pointing to an array. int offset2() {return _offset2;} // second offset from base. Might really be an array length in a // certain usage. The 'ifunc' is free to interpret these as it wants. int offset3() {return _offset3;} // third offset from base. int offset4() {return _offset4;} // fourth offset from base. If this is not enough either an array can // can be passed by using the first two, or these can be ignored // all together and you can use fixed locations within the object being // deserialized. int indirection() {return _indirection;} // offset from base address used to retrieve another address (by indirection). // disabled if less than zero. void* addr1(void* base); // compute address by adding offset1() to 'base' or an indirect base // determined by the contents of 'base' + indirection(). void* addr2(void* base); // compute address by adding offset2() to 'base' or an indirect base // determined by the contents of 'base' + indirection(). void* addr3(void* base); // compute address by adding offset3() to 'base' or an indirect base // determined by the contents of 'base' + indirection(). void* addr4(void* base); // compute address by adding offset4() to 'base' or an indirect base // determined by the contents of 'base' + indirection(). protected: char* _name; ParamFormat _format; param_callback _ifunc; int _offset1; int _offset2; int _offset3; int _offset4; int _indirection; }; //: list of ParamStruct objects for de-serialization of a previously serialized object. // list of ParamStruct objects that defines the possible signature // of a serialized object, for use in de-serialization (istream constructors). //

// See OverlayScript and OverlayComp for an example of how this is used. // OverlayScript is a serializing view of an OverlayComp, and generates a variable // length, ASCII record (with arguments enclosed in parenthesis following the object // name) that describes the internal state of an OverlayComp. Then later, the // istream constructor of an OverlayComp uses the static ParamList object of its // class to reverse the process (called de-serialization), to set the internal state // of a newly constructed OverlayComp to mirror the internal state of the original // object. This mechanism can be used for any struct or C++ class that needs to be // saved out to disk for persistent storage, or transmitted over a socket. //

// Keep in mind that only relative addresses are used to construct the ParamStruct // objects that make up the ParamList, and the actual base address used to // resolve where to place data is different when the final object is constructed // (except for the very first time an object of a given class gets constructed -- // at that time the addresses used to build up the ParamList are the same ones // used to populate the object). class ParamList { public: ParamList(ParamList* = nil); // construct with optional ParamList to copy. virtual ~ParamList(); static LexScan* lexscan(); // construct default LexScan for use. void add_param( const char* name, ParamStruct::ParamFormat format, param_callback ifunc, void* base, void* addr1, void* addr2 = nil, void* addr3 = nil, void* addr4 = nil); // compose and insert ParamStruct, computing offsets 1 thru 4 by differing // against 'base'. void add_param_indirect( const char* name, ParamStruct::ParamFormat format, param_callback ifunc, void* base, void* offset, void* addr1, void* addr2 = nil, void* addr3 = nil, void* addr4 = nil); // compose and insert ParamStruct, computing offsets 1 thru 4 by differing // against the content of 'offset', and subtracting 'base' from 'offset' // to arrive at indirection offset to set in the ParamStruct (the offset from // the base address of the object being constructed where you will find // an address to add the other offsets to, to arrive a final address). void add_param_first( const char* name, ParamStruct::ParamFormat format, param_callback ifunc, void* base = (void*)0x1, void* addr1 = (void*)0x1, void* addr2 = nil, void* addr3 = nil, void* addr4 = nil); // compose and insert ParamStruct as far forward in the ParamList as possible // given its desired format type. In this manner a parameter handler can be // easily overriden. boolean read_args(istream& in, void* base); // work-horse method that assumes istream is positioned right before // the open-paren of the serialized object (the object name precedes // the open-paren). Handles the logic to parse first required, then // optional, then keyword arguments (or 'other' arugments, which means // pass the rest of the arguments on as is). Invokes all the function // pointers of type param_callback. /* static callback functions */ static int read_int(istream&, void* p0, void* p1=NULL, void* p2=NULL, void* p3=NULL); // param_callback to read up to four comma-separated integers from istream. static int read_float(istream&, void* p0, void* p1=NULL, void* p2=NULL, void* p3=NULL); // param_callback to read up to four comma-separated floats from istream. static int read_double(istream&, void* p0, void* p1=NULL, void* p2=NULL, void* p3=NULL); // param_callback to read up to four comma-separated doubles from istream. static int read_string(istream&, void* p0, void* p1=NULL, void* p2=NULL, void* p3=NULL); // param_callback to read up to four comma-separated character strings from istream. static int read_symbol(istream&, void* p0, void* p1=NULL, void* p2=NULL, void* p3=NULL); // param_callback to read up to four comma-separated character strings (as symbols) from istream. static int read_ints(istream&, void* p0, void* p1=NULL, void* p2=NULL, void* p3=NULL); // param_callback to read any number of comma-separated integers from istream. static int read_floats(istream&, void* p0, void* p1=NULL, void* p2=NULL, void* p3=NULL); // param_callback to read any number of comma-separated floats from istream. static int read_doubles(istream&, void* p0, void* p1=NULL, void* p2=NULL, void* p3=NULL); // param_callback to read any number of comma-separated doubles from istream. static int read_strings(istream&, void* p0, void* p1=NULL, void* p2=NULL, void* p3=NULL); // param_callback to read any number of comma-separated strings from istream. /* static functions for use in callbacks */ static int skip_space(istream& in); // skip whitespace in istream, for use of a param_callback. static int parse_token(istream& in, char* buffer, int buflen, const char delim = '('); // parse token from istream, for use of a param_callback. static int parse_token(istream& in, char* buffer, int buflen, const char* delim); // parse token from istream ended by one of a string of delimters, // for use of a param_callback. static int parse_string(istream& in, char* buffer, int buflen, boolean keep_backslashes=0); // parse string from istream, correctly handling embedded quotes prefixed // by back-slashes, for use of a param_callback. static int parse_points(istream&, Coord*&, Coord*&, int&); // parse parenthesized point list of integers from istream, for use of a param_callback. static int parse_fltpts(istream&, float*&, float*&, int&); // parse parenthesized point list of floats from istream, for use of a param_callback. static int parse_dblpts(istream&, double*&, double*&, int&); // parse parenthesized point list of doubles from istream, for use of a param_callback. static int parse_text(istream& in, char* buffer, int buflen); // parse text string, converting embedded octal constants, and handling // embedded quotes preceded by back-slashes, for use of a param_callback. static char* parse_textbuf(istream& in); // parse multi-line comma-separated set of character strings into a single buffer, // for use of a param_callback. static int output_text(ostream& out, const char* text, int indent=0); // output text in a format readable by parse_text(). static int parse_pathname(istream& in, char* buffer, int buflen, const char* dir); // parse pathname, expanding relative pathnames from 'dir', for use of a // param_callback. static boolean url_use_ok(); // test if url use ok for pathnames. Same as OpenFileChooser method. static boolean urltest(const char*); // test if pathname looks like a URL. Same as OpenFileChooser method. static int bintest(const char* name); // return 0 if executable can be found, otherwise -1. static boolean bincheck(const char* name); // return true if executable can be found. static const char* filter(const char* string, int len); // filter text buffer for octal constants. static char* octal(unsigned char c, register char* p); // convert a character to an octal string. static char octal(const char* p); // convert string of three octal digits to a character. static ParamStruct* CurrParamStruct() { return _currstruct; } // last ParamStruct from ::GetStruct protected: void insert(ParamStruct*); void insert_first(ParamStruct*); void First(ALIterator&); void Last(ALIterator&); void Next(ALIterator&); void Prev(ALIterator&); boolean Done(ALIterator); boolean IsEmpty(); int Number(); void Append(ParamStruct*); void Prepend(ParamStruct*); void InsertAfter(ALIterator, ParamStruct*); void InsertBefore(ALIterator, ParamStruct*); void Remove(ParamStruct*); void Remove(ALIterator&); ParamStruct* GetStruct(ALIterator); void SetStruct(ParamStruct*, ALIterator&); boolean Includes(ParamStruct*); ParamStruct* Struct(AList*); AList* Elem(ALIterator); protected: AList* _alist; int _count; int _required_count; int _optional_count; int _keyword_count; int _other_count; static LexScan* _lexscan; static ParamStruct* _currstruct; }; #include #endif /* !defined(_param_list_h) */ ivtools-1.2.11a1/src/ComGlyph/000077500000000000000000000000001214471147700160365ustar00rootroot00000000000000ivtools-1.2.11a1/src/ComGlyph/attrdialog.cc000066400000000000000000000145101214471147700205000ustar00rootroot00000000000000/* * Copyright 1995-1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ implementActionCallback(AttrDialogImpl) AttrDialog* AttrDialog::instance_ = nil; AttrDialog::AttrDialog(boolean session, int argc, char** argv, boolean init) : TerpDialog(session, argc, argv, false) { if (init) _init(nil, session, argc, argv); } AttrDialog::AttrDialog(ComTerpServ* comterp, boolean session, int argc, char** argv, boolean init) : TerpDialog(session, argc, argv, false) { if (init) _init(comterp, session, argc, argv); } void AttrDialog::_init(ComTerpServ* comterp, boolean session, int argc, char** argv) { impl_ = new AttrDialogImpl(); AttrDialogImpl& cdi = *(AttrDialogImpl*)impl_; cdi.kit_ = WidgetKit::instance(); cdi.initterp(comterp); focus(cdi.init(this, WidgetKit::instance()->style(), session, argc, argv)); } AttrDialog::~AttrDialog() { } AttrDialog& AttrDialog::instance() { if (!instance_) { Style* style; style = new Style(Session::instance()->style()); style->attribute("subcaption", "Evaluate Attribute Expressions"); style->attribute("open", "AttrExpr"); instance_ = new AttrDialog(); Resource::ref(instance_); } return *instance_; } void AttrDialog::instance(AttrDialog* instance) { if (instance_) Unref(instance_); Resource::ref(instance); instance_ = instance; } void AttrDialog::next_expr(const char* expr) { delete (((AttrDialogImpl*)impl_)->next_expr_); ((AttrDialogImpl*)impl_)->next_expr_ = strdup(expr); delete (((AttrDialogImpl*)impl_)->next_code_); ((AttrDialogImpl*)impl_)->next_code_ = comterpserv()->gen_code(expr, ((AttrDialogImpl*)impl_)->next_len_); } void AttrDialog::true_expr(const char* expr) { delete (((AttrDialogImpl*)impl_)->true_expr_); ((AttrDialogImpl*)impl_)->true_expr_ = strdup(expr); delete (((AttrDialogImpl*)impl_)->true_code_); ((AttrDialogImpl*)impl_)->true_code_ = comterpserv()->gen_code(expr, ((AttrDialogImpl*)impl_)->true_len_); } void AttrDialog::false_expr(const char* expr) { delete (((AttrDialogImpl*)impl_)->false_expr_); ((AttrDialogImpl*)impl_)->false_expr_ = strdup(expr); delete (((AttrDialogImpl*)impl_)->false_code_); ((AttrDialogImpl*)impl_)->false_code_ = comterpserv()->gen_code(expr, ((AttrDialogImpl*)impl_)->false_len_); } void AttrDialog::done_expr(const char* expr) { delete (((AttrDialogImpl*)impl_)->done_expr_); ((AttrDialogImpl*)impl_)->done_expr_ = strdup(expr); delete (((AttrDialogImpl*)impl_)->done_code_); ((AttrDialogImpl*)impl_)->done_code_ = comterpserv()->gen_code(expr, ((AttrDialogImpl*)impl_)->done_len_); } /*****************************************************************************/ AttrDialogImpl::AttrDialogImpl() { next_code_ = nil; true_code_ = nil; false_code_ = nil; next_expr_ = nil; true_expr_ = nil; false_expr_ = nil; next_len_ = 0; true_len_ = 0; false_len_ = 0; return; } InputHandler* AttrDialogImpl::init(TerpDialog* d, Style* s, boolean session, int argc, char** argv) { InputHandler* ih = TerpDialogImpl::init(d, s, session, argc, argv); _eval_button->action(new ActionCallback(AttrDialogImpl)(this, &AttrDialogImpl::eval)); return ih; } void AttrDialogImpl::eval() { char exprbuf[BUFSIZ]; const char* expr = expredit_->text(); if (expr[strlen(expr)-1] != '\n') sprintf(exprbuf, "%s\n", expr); else sprintf(exprbuf, "%s", expr); int exprlen; postfix_token* exprcode = terpserv_->gen_code(exprbuf, exprlen); ComValue retval = ComValue::nullval(); do { retval = terpserv_->run(exprcode, exprlen); const char* errmsg = terpserv_->errmsg(); if (*errmsg) { result_->textvalue(""); err_->textvalue(errmsg); return; } else { const int bufsiz = BUFSIZ; char buf[bufsiz]; std::strstream outstr(buf, bufsiz); outstr << retval; outstr.put('\0'); result_->textvalue(buf); err_->textvalue(""); if (true_code_ && false_code_) retval = retval.boolean_val() ? terpserv_->run(true_code_, true_len_) : terpserv_->run(false_code_, false_len_); } resultview_->update(result_); errview_->update(err_); if (next_code_) retval = terpserv_->run(next_code_, next_len_); } while (retval.boolean_val()); if (done_code_) retval = terpserv_->run(done_code_, done_len_); } ivtools-1.2.11a1/src/ComGlyph/attrdialog.h000066400000000000000000000053761214471147700203540ustar00rootroot00000000000000/* * Copyright (c) 1995-1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef attrdialog_h #define attrdialog_h #include #include #include class Action; class AttrDialogImpl; class NextAttrDialogFunc; class TrueAttrDialogFunc; class FalseAttrDialogFunc; class DoneAttrDialogFunc; class AttrDialog : public TerpDialog { public: AttrDialog(boolean session = false, int argc = -1, char** argv = nil, boolean init = true); AttrDialog(ComTerpServ* comterp, boolean session = false, int argc = -1, char** argv = nil, boolean init = true); virtual ~AttrDialog(); boolean cancel(); static AttrDialog& instance(); static void instance(AttrDialog*); void next_expr(const char*); void true_expr(const char*); void false_expr(const char*); void done_expr(const char*); protected: void _init(ComTerpServ* comterp, boolean session, int argc, char** argv); static AttrDialog* instance_; }; class AttrDialogImpl : public TerpDialogImpl { protected: friend class AttrDialog; AttrDialogImpl(); InputHandler* init(TerpDialog*, Style*, boolean session = false, int argc = -1, char** argv = nil); /* general buttons */ void eval(); /* script for iter, eval-true, and eval-false */ char* next_expr_; postfix_token* next_code_; int next_len_; char* true_expr_; postfix_token* true_code_; int true_len_; char* false_expr_; postfix_token* false_code_; int false_len_; char* done_expr_; postfix_token* done_code_; int done_len_; }; declareActionCallback(AttrDialogImpl) #endif ivtools-1.2.11a1/src/ComGlyph/comtextedit.cc000066400000000000000000000067431214471147700207100ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc * * Permission to use, copy, modify, distribute, and sell this software and its * related documentation and data files for any purpose is hereby granted * without fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice appear in * supporting documentation, and that the names of the copyright holders not * be used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. The copyright holders * make no representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ // layered on top of classes distributed with this license: // // Simple Text Editor Implementation // // Copyright (C) 1993 Ellemtel Telecommunication Systems Labratories // // Permission is granted to any individual or institution to use, copy, // modify, and distribute this software, provided that this complete // copyright and permission notice is maintained, intact, in all copies // and supporting documentation. // // Ellemtel Telecommunication Systems Labratories make no representation // of the suitability of this software for any purpose. It is provided // "as is" without any expressed or implied warranty. // // Jan Andersson, Torpa Konsult AB // janne@torpa.se - 1993-08-29 // #include #include #include #include #include #include #include #include #include #include #include #include ComTextEditor::ComTextEditor(Style* s, ComTerpServ* comterp, boolean active) : EivTextEditor() { const LayoutKit& layout = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); style_ = new Style("TextEditor", s); Resource::ref(style_); double rows = 24; (void) style_->find_attribute("rows", rows); double cols = 80; (void) style_->find_attribute("columns", cols); // create buffer and view EivTextBuffer* te_buffer = new EivTextBuffer(); te_view_ = new ComTE_View(style_, te_buffer, int(rows), int(cols), active); ((ComTE_View*)te_view_)->comterp(comterp); // attach adjustable and scrollbar te_adjustable_ = new TE_Adjustable(te_view_); te_view_->attach(te_adjustable_); sb_ = kit.vscroll_bar(te_adjustable_); Display* d = Session::instance()->default_display(); const Color* bg = Color::lookup(d, "#aaaaaa"); if (bg == nil) bg = new Color(0.7,0.7,0.7,1.0); body( new Background( layout.margin( layout.hbox( kit.inset_frame( layout.vcenter(layout.margin(te_view_, 2.0), 1.0) ), layout.hspace(4.0), sb_ ), 5.0), bg ) ); } ComTextEditor::~ComTextEditor() { } ComTE_View* ComTextEditor::comtextview() { return (ComTE_View*)te_view_; } ivtools-1.2.11a1/src/ComGlyph/comtextedit.h000066400000000000000000000042621214471147700205440ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc * * Permission to use, copy, modify, distribute, and sell this software and its * related documentation and data files for any purpose is hereby granted * without fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice appear in * supporting documentation, and that the names of the copyright holders not * be used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. The copyright holders * make no representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ // layered on top of classes distributed with this license: // // Simple Text Editor // // // Copyright (C) 1993 Ellemtel Telecommunication Systems Labratories // // Permission is granted to any individual or institution to use, copy, // modify, and distribute this software, provided that this complete // copyright and permission notice is maintained, intact, in all copies // and supporting documentation. // // Ellemtel Telecommunication Systems Labratories make no representation // of the suitability of this software for any purpose. It is provided // "as is" without any expressed or implied warranty. // // Jan Andersson, Torpa Konsult AB // janne@torpa.se - 1993-08-29 #ifndef com_texteditor_h #define com_texteditor_h #include class ComTE_View; class ComTerpServ; class Style; class ComTextEditor : public EivTextEditor { public: ComTextEditor(Style*, ComTerpServ* comterp=nil, boolean active=true); virtual ~ComTextEditor(); ComTE_View* comtextview(); }; #endif ivtools-1.2.11a1/src/ComGlyph/comtextview.cc000066400000000000000000000163361214471147700207340ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc * * Permission to use, copy, modify, distribute, and sell this software and its * related documentation and data files for any purpose is hereby granted * without fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice appear in * supporting documentation, and that the names of the copyright holders not * be used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. The copyright holders * make no representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ // layered on top of classes distributed with this license: // // Simple Text Editor Implementation // // Copyright (C) 1993 Ellemtel Telecommunication Systems Labratories // // Permission is granted to any individual or institution to use, copy, // modify, and distribute this software, provided that this complete // copyright and permission notice is maintained, intact, in all copies // and supporting documentation. // // Ellemtel Telecommunication Systems Labratories make no representation // of the suitability of this software for any purpose. It is provided // "as is" without any expressed or implied warranty. // // Jan Andersson, Torpa Konsult AB // janne@torpa.se - 1993-08-29 // #include #include #include #include #include #include #include #include #include #include #include using std::cerr; using std::cout; #define XK_MISCELLANY /* to get the keysym's we need */ #include // Note: Sun-specific keyboard symbols static TE_ViewKeySymInfo default_key_sym_map[] = { { XK_Down, &TE_View::down }, { XK_Up, &TE_View::up }, { XK_Left, &TE_View::left }, { XK_Right, &TE_View::right }, { XK_BackSpace, &TE_View::delete_backward }, { XK_Delete, &TE_View::delete_backward }, { XK_Return, (TE_ViewKeyFunc)&ComTE_View::newline }, { XK_Linefeed, (TE_ViewKeyFunc)&ComTE_View::newline }, { XK_KP_Enter, (TE_ViewKeyFunc)&ComTE_View::newline }, { XK_R9, &TE_View::page_up }, // PgUp { XK_R15, &TE_View::page_down }, // PgDn { XK_L6, &TE_View::copy }, // Copy (L6) { XK_L8, &TE_View::paste_buffer }, // Paste (L8) { XK_L9, &TE_View::find_selection_forward }, // Find (L9) { XK_L10, &TE_View::cut }, // Cut (L10) { XK_R7, &TE_View::beginning_of_text }, // Home { XK_R13, &TE_View::end_of_text }, // End { 0, nil } }; implementSelectionCallback(ComTE_View); implementActionCallback(ComTE_View); // TE View ComTE_View::ComTE_View(Style* s, EivTextBuffer* te_buffer, int rows, int cols, boolean active) : TE_View(s, te_buffer, rows, cols, active) { _continuation = false; _parendepth = 0; } ComTE_View::~ComTE_View() { } void ComTE_View::keystroke(const Event& e) { if (active_) { current_window_ = e.window(); // check if known key symbol unsigned long keysym = e.keysym(); for (TE_ViewKeySymInfo* k = &default_key_sym_map[0]; k->keysym != 0; k++) { if (keysym == k->keysym) { TE_ViewKeyFunc f = k->func; (this->*f)(); return; } } // map event to key signed char c; if (e.mapkey((char *)&c, 1) == 0) return; // check if known key map #ifndef __sgi /* avoid SGI gcc warning */ if (c >= 0) { // fix alt-V on linux/pc #else if (1) { #endif TE_ViewKeyFunc f = key_[c]; if (f != nil) { (this->*f)(); return; } } #ifndef __sgi /* avoid SGI gcc warning */ if (c >= 0 && (isspace(c) || !iscntrl(c))) #else if (isspace(c) || !iscntrl(c)) #endif insert_char(c); else cerr << "Unknown character - ignored!\n"; } } void ComTE_View::newline() { /* extract current line from text buffer */ beginning_of_line(); int mark = text_editor_->Dot(); end_of_line(); int dot = text_editor_->Dot(); int len = dot-mark; /* zero-length input happens when only a C/R was entered, which means unpause */ /* if pause is active */ if (!len && comterp()->npause()) { comterp()->npause()--; return; } char* buffer = new char [len+1]; te_buffer_->Copy(mark, buffer, len); buffer[len] = '\0'; /* if at the end of the buffer, just add a newline, otherwise, copy the whole line */ end_of_text(); if (dot != text_editor_->Dot()) insert_string(buffer, len); insert_char('\n'); /* run this line through comterp */ boolean old_brief = comterp()->brief(); comterp()->brief(1); cout << "\n" << comterp()->linenum()+1 << ": " << buffer << "\n"; /* strip # comments */ /* and keep track of paren depth at the same time */ boolean inquote = false; char* bufptr = buffer; while(*bufptr) { if (!inquote && (*bufptr== '(' || *bufptr=='[' || *bufptr =='{')) _parendepth++; else if (!inquote && (*bufptr== ')' || *bufptr==']' || *bufptr =='}')) _parendepth--; if (!inquote && *bufptr=='#') *bufptr = '\0'; else if (*bufptr=='"') { if (inquote) { if (*(bufptr-1)!= '\\') inquote = false; } else inquote = true; } ++bufptr; } /* check for trailing semi-colon that isn't in parens, and remove it */ bufptr = buffer + strlen(buffer) - 1; if (!_parendepth) { while(bufptr>=buffer) { char ch = *bufptr; if (ch==';') { *bufptr=' '; break; } else if (!isspace(ch)) break; bufptr--; } } /* remove the "> " prompt if there was one */ bufptr = buffer; if (_continuation) { if (buffer[0]=='>') { beginning_of_line(); backward_line(); delete_forward(); insert_char(' '); bufptr++; if (buffer[1]==' ') { delete_forward(); insert_char(' '); bufptr++; } } forward_line(); end_of_line(); } /* load and interpret if expression closed */ comterp()->load_string(bufptr); int status = comterp()->ComTerp::run(false /* !once */, true /* nested */); // comterp()->linenum()--; #if 0 ComValue result(comterp()->stack_top(1)); #else // don't evaluate ComValue result(comterp()->pop_stack(false)); #endif ostream* out = new std::strstream(); if (*comterp()->errmsg()) { *out << comterp()->errmsg() << "\n"; } else { if (status==0) { result.comterp(comterp()); *out << result << "\n"; _continuation = false; _parendepth=0; } else if (status==1) { insert_string("> ", 2); _continuation = true; } } out->put('\0'); out->flush(); std::strstream* sout = (std::strstream*)out; insert_string(sout->str(), strlen(sout->str())); comterp()->brief(old_brief); delete out; delete buffer; } ivtools-1.2.11a1/src/ComGlyph/comtextview.h000066400000000000000000000046471214471147700206000ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc * * Permission to use, copy, modify, distribute, and sell this software and its * related documentation and data files for any purpose is hereby granted * without fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice appear in * supporting documentation, and that the names of the copyright holders not * be used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. The copyright holders * make no representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ // layered on top of classes distributed with this license: // // Simple Text Editor Implementation // // Copyright (C) 1993 Ellemtel Telecommunication Systems Labratories // // Permission is granted to any individual or institution to use, copy, // modify, and distribute this software, provided that this complete // copyright and permission notice is maintained, intact, in all copies // and supporting documentation. // // Ellemtel Telecommunication Systems Labratories make no representation // of the suitability of this software for any purpose. It is provided // "as is" without any expressed or implied warranty. // // Jan Andersson, Torpa Konsult AB // janne@torpa.se - 1993-08-29 // #ifndef comtextview_h #define comtextview_h #include class ComTerpServ; class ComTE_View :public TE_View { public: ComTE_View(Style*, EivTextBuffer*, int rows, int cols, boolean active); ~ComTE_View(); virtual void keystroke(const Event&); void newline(); ComTerpServ* comterp() { return _comterp; } void comterp(ComTerpServ* cterp) { _comterp = cterp; } private: ComTerpServ* _comterp; boolean _continuation; int _parendepth; }; declareSelectionCallback(ComTE_View); declareActionCallback(ComTE_View); #endif ivtools-1.2.11a1/src/ComGlyph/terpdialog.cc000066400000000000000000000347541214471147700205140ustar00rootroot00000000000000/* * Copyright 1995-1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #define FUNC_CHOOSER #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ implementActionCallback(TerpDialogImpl) TerpDialog* TerpDialog::instance_ = nil; /*****************************************************************************/ TerpDialog::TerpDialog(boolean session, int argc, char** argv, boolean init) : Dialog(nil, WidgetKit::instance()->style()) { if (init) { impl_ = new TerpDialogImpl(); TerpDialogImpl& cdi = *impl_; cdi.kit_ = WidgetKit::instance(); cdi.initterp(); focus(cdi.init(this, WidgetKit::instance()->style(), session, argc, argv)); } } TerpDialog::~TerpDialog() { delete impl_; } void TerpDialog::comterpserv(ComTerpServ* terp) { delete impl_->terpserv_; impl_->terpserv_ = terp; } ComTerpServ* TerpDialog::comterpserv() { return impl_->terpserv_; } boolean TerpDialog::cancel() { return impl_->cancel_; } TerpDialog& TerpDialog::instance() { if (!instance_) { Style* style; style = new Style(Session::instance()->style()); style->attribute("subcaption", "Import graphic from file:"); style->attribute("open", "Import"); instance_ = new TerpDialog(); Resource::ref(instance_); } return *instance_; } void TerpDialog::instance(TerpDialog* instance) { if (instance_) Unref(instance_); Resource::ref(instance); instance_ = instance; } /*****************************************************************************/ TerpDialogImpl::TerpDialogImpl() { terpserv_ = nil; return; } InputHandler* TerpDialogImpl::init(TerpDialog* d, Style* s, boolean session, int argc, char** argv) { cancel_ = false; sign_ = 1; dialog_ = d; style_ = s; cancelsession_ = session; return build(argc, argv); } void TerpDialogImpl::initterp(ComTerpServ* comterp) { if (!comterp && !terpserv_) { terpserv_ = new ComTerpServ(BUFSIZ); terpserv_->add_defaults(); } else if (comterp) terpserv_ = comterp; } InputHandler* TerpDialogImpl::build(int argc, char** argv) { WidgetKit& kit = *kit_; const LayoutKit& layout = *LayoutKit::instance(); Style* s = style_; /* expression editor */ expredit_ = new EivTextEditor(kit.style()); if (argc > 1) expredit_->load(argv[argc-1]); /* result display */ result_ = new ObservableText(""); resultview_ = new TextObserver(result_, "Result: "); /* err display */ err_ = new ObservableText(""); errview_ = new TextObserver(err_, ""); /* function chooser */ #ifdef FUNC_CHOOSER func_choices_ = new StringList(); int nfunc_symids; int* func_symids = terpserv_->get_commands(nfunc_symids, true); for (int i=0; iappend(*func_str); } delete func_symids; func_chooser_ = new StrChooser(func_choices_, new String("Functions:"), MFKit::instance(), Session::instance()->style(), nil, true, (strchooser_callback)&TerpDialogImpl::insert_func, this); Resource::ref(func_chooser_); #endif /* variable chooser */ #ifdef VAR_CHOOSER var_choices_ = new StringList(); var_chooser_ = new StrChooser(var_choices_, new String("Variables"), MFKit::instance(), Session::instance()->style(), nil, true, (strchooser_callback)&TerpDialogImpl::insert_var, this); Resource::ref(var_chooser_); #endif /* number pad */ Action* and_ = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::and_op); Action* or_ = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::or_op); Action* negate = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::negate); Action* div = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::div); Action* mpy = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::mpy); Action* sub = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::sub); Action* add = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::add); Action* assign = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::assign); Action* point = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::point); Action* sign = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::sign); Action* parens = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::parens); Action* braces = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::braces); Action* zero = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::zero); Action* one = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::one); Action* two = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::two); Action* three = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::three); Action* four = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::four); Action* five = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::five); Action* six = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::six); Action* seven = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::seven); Action* eight = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::eight); Action* nine = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::nine); Action* clear = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::clear); Action* nothing = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::nothing); Style* button_style = new Style(Session::instance()->style()); button_style->attribute("minimumWidth", "48.0"); kit.push_style(); kit.style(button_style); Glyph* numpad = layout.vbox( layout.hbox( layout.vcenter(kit.push_button(kit.label("AC"), clear)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("()"), parens)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("{}"), braces)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("/"), div)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("&&"), and_)) ), layout.vspace(5.0), layout.hbox( layout.vcenter(kit.push_button(kit.label("7"), seven)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("8"), eight)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("9"), nine)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("*"), mpy)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("||"), or_)) ), layout.vspace(5.0), layout.hbox( layout.vcenter(kit.push_button(kit.label("4"), four)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("5"), five)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("6"), six)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("-"), sub)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("!"), negate)) ), layout.vspace(5.0), layout.hbox( layout.vcenter(kit.push_button(kit.label("1"), one)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("2"), two)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("3"), three)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("+"), add)) ), layout.vspace(5.0), layout.hbox( layout.vcenter(kit.push_button(kit.label("0"), zero)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("."), point)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("+/-"), sign)), layout.hspace(5.0), layout.vcenter(kit.push_button(kit.label("="), assign)) ) ); kit.pop_style(); /* general buttons */ Action* eval = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::eval); Action* cancel = new ActionCallback(TerpDialogImpl)(this, &TerpDialogImpl::cancel); _eval_button = kit.push_button(kit.label("Eval"), eval); _cancel_button = kit.push_button(kit.label("Cancel"), cancel); /* general layout */ Glyph* interior = layout.vbox( layout.hcenter(expredit_), layout.vspace(15.0), layout.hcenter(resultview_), layout.hcenter(errview_), layout.vspace(15.0), layout.hcenter(layout.hbox( #ifdef FUNC_CHOOSER func_chooser_, layout.hspace(30.0), #endif #ifdef VAR_CHOOSER var_chooser_, layout.hspace(15.0), #endif numpad)), layout.vspace(30.0), layout.hcenter(layout.hbox( layout.vcenter(_eval_button), layout.hspace(10.0), layout.vcenter(_cancel_button) )) ); dialog_->body(kit.outset_frame(layout.margin(interior, 10.0))); dialog_->append_input_handler(expredit_->focusable()); return expredit_->focusable(); } void TerpDialogImpl::and_op() { expredit_->insert_string("&&", 2); } void TerpDialogImpl::or_op() { expredit_->insert_string("||", 2); } void TerpDialogImpl::negate() { expredit_->insert_string("!", 1); } void TerpDialogImpl::div() { expredit_->insert_string("/", 1); } void TerpDialogImpl::mpy() { expredit_->insert_string("*", 1); } void TerpDialogImpl::sub() { expredit_->insert_string("-", 1); } void TerpDialogImpl::add() { expredit_->insert_string("+", 1); } void TerpDialogImpl::assign() { eval(); } void TerpDialogImpl::point() { expredit_->insert_string(".", 1); } void TerpDialogImpl::sign() { int i; char exprbuf[BUFSIZ]; const char* expr = expredit_->text(); if (sign_ > 0) { sprintf(exprbuf, "-%s", expr); exprbuf[strlen(exprbuf)] = '\0'; sign_ = -1; } else { for (i=1; itext(""); expredit_->insert_string(exprbuf, strlen(exprbuf)); } void TerpDialogImpl::parens() { expredit_->insert_string("()", 2); expredit_->textview()->backward_char(); } void TerpDialogImpl::braces() { expredit_->insert_string("{}", 2); expredit_->textview()->backward_char(); } void TerpDialogImpl::zero() { expredit_->insert_string("0", 1); } void TerpDialogImpl::one() { expredit_->insert_string("1", 1); } void TerpDialogImpl::two() { expredit_->insert_string("2", 1); } void TerpDialogImpl::three() { expredit_->insert_string("3", 1); } void TerpDialogImpl::four() { expredit_->insert_string("4", 1); } void TerpDialogImpl::five() { expredit_->insert_string("5", 1); } void TerpDialogImpl::six() { expredit_->insert_string("6", 1); } void TerpDialogImpl::seven() { expredit_->insert_string("7", 1); } void TerpDialogImpl::eight() { expredit_->insert_string("8", 1); } void TerpDialogImpl::nine() { expredit_->insert_string("9", 1); } void TerpDialogImpl::clear() { expredit_->text(""); clear_results(); } void TerpDialogImpl::clear_results() { result_->textvalue(""); resultview_->update(result_); err_->textvalue(""); errview_->update(err_); } void TerpDialogImpl::nothing() { } void TerpDialogImpl::eval() { char exprbuf[BUFSIZ]; const char* expr = expredit_->text(); if (expr[strlen(expr)-1] != '\n') sprintf(exprbuf, "%s\n", expr); else sprintf(exprbuf, "%s", expr); ComValue retval(terpserv_->run(exprbuf)); const char* errmsg = terpserv_->errmsg(); if (*errmsg) { result_->textvalue(""); err_->textvalue(errmsg); } else if (retval.type() == ComValue::UnknownType) { result_->textvalue("nil"); err_->textvalue(""); } else { char buf[BUFSIZ]; buf[0] = '\0'; std::ostrstream ostr(buf, BUFSIZ); ostr << retval; ostr << '\0'; result_->textvalue(buf); err_->textvalue(""); } resultview_->update(result_); errview_->update(err_); } void TerpDialogImpl::insert_func(void *base) { TerpDialogImpl* i = (TerpDialogImpl*)base; i->expredit_->text(""); if (i->func_chooser_->selected() > -1) { String func = i->func_choices_->item_ref(i->func_chooser_->selected()); char* funcstr = (char*)func.string(); i->expredit_->insert_string(funcstr, strlen(funcstr)); const int curspos = strlen(funcstr)-1; i->expredit_->select(curspos, curspos); } } void TerpDialogImpl::insert_var(void *base) { TerpDialogImpl* i = (TerpDialogImpl*)base; i->expredit_->text(""); if (i->var_chooser_->selected() > -1) { String var = i->var_choices_->item_ref(i->var_chooser_->selected()); char* varstr = (char*)var.string(); i->expredit_->insert_string(varstr, strlen(varstr)); } } void TerpDialogImpl::cancel() { cancel_ = true; if (cancelsession_) { Session& s = *Session::instance(); s.quit(); } else { dialog_->dismiss(false); } } ivtools-1.2.11a1/src/ComGlyph/terpdialog.h000066400000000000000000000066441214471147700203530ustar00rootroot00000000000000/* * Copyright (c) 1995-1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef terpdialog_h #define terpdialog_h #include class Action; class ComTerpServ; class TerpDialogImpl; class TerpDialog : public Dialog { public: TerpDialog(boolean session = false, int argc = -1, char** argv = nil, boolean init = true); virtual ~TerpDialog(); boolean cancel(); static TerpDialog& instance(); static void instance(TerpDialog*); void comterpserv(ComTerpServ*); ComTerpServ* comterpserv(); protected: TerpDialogImpl* impl_; static TerpDialog* instance_; }; class Button; class EivTextEditor; class ObservableText; class StringList; class StrChooser; class Style; class TextObserver; class WidgetKit; class TerpDialogImpl { protected: TerpDialogImpl(); friend class TerpDialog; WidgetKit* kit_; Style* style_; TerpDialog* dialog_; boolean cancel_; boolean cancelsession_; InputHandler* init(TerpDialog*, Style*, boolean session = false, int argc = -1, char** argv = nil); void initterp(ComTerpServ* = nil); InputHandler* build(int argc, char** argv); ComTerpServ* terpserv_; /* expression editor */ EivTextEditor* expredit_; /* results */ ObservableText* result_; TextObserver* resultview_; /* errors */ ObservableText* err_; TextObserver* errview_; /* function chooser */ StrChooser* func_chooser_; StringList * func_choices_; /* buttons */ Button* _eval_button; Button* _cancel_button; static void insert_func(void*); /* variable chooser */ StrChooser* var_chooser_; StringList * var_choices_; static void insert_var(void*); /* number pad */ int sign_; void and_op(); void or_op(); void negate(); void div(); void mpy(); void sub(); void add(); void assign(); void point(); void sign(); void parens(); void braces(); void zero(); void one(); void two(); void three(); void four(); void five(); void six(); void seven(); void eight(); void nine(); void clear(); void clear_results(); void nothing(); /* general buttons */ void eval(); void cancel(); }; #include declareActionCallback(TerpDialogImpl) #endif ivtools-1.2.11a1/src/ComTerp/000077500000000000000000000000001214471147700156655ustar00rootroot00000000000000ivtools-1.2.11a1/src/ComTerp/_comterp.h000066400000000000000000000001751214471147700176510ustar00rootroot00000000000000#ifndef __comterp_h #define __comterp_h // extern "C" { #include // } #endif /* !defined(__comterp_h) */ ivtools-1.2.11a1/src/ComTerp/_comutil.h000066400000000000000000000002001214471147700176410ustar00rootroot00000000000000#ifndef __comutil2_h #define __comutil2_h // extern "C" { #include // } #endif /* !defined(__comutil2_h) */ ivtools-1.2.11a1/src/ComTerp/assignfunc.cc000066400000000000000000000273101214471147700203370ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1997,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include using std::cerr; #define TITLE "AssignFunc" /*****************************************************************************/ int AssignFunc::_symid = -1; AssignFunc::AssignFunc(ComTerp* comterp) : ComFunc(comterp) { } void AssignFunc::execute() { ComValue operand1(stack_arg(0, true)); if (operand1.type() != ComValue::SymbolType) { operand1.assignval(stack_arg_post_eval(0, true /* no symbol or attribute lookup */)); } ComValue* operand2 = new ComValue(stack_arg_post_eval(1, true /* no symbol or attribute lookup */)); #ifdef POSTEVAL_EXPERIMENT if (operand2->is_attribute() || operand2->is_symbol()) lookup_symval(*operand2); #else if (operand2->is_attribute()) lookup_symval(*operand2); #endif if (operand1.type() == ComValue::SymbolType) { AttributeList* attrlist = comterp()->get_attributes(); if (attrlist) { Resource::ref(attrlist); Attribute* attr = new Attribute(operand1.symbol_val(), operand2); attrlist->add_attribute(attr); Unref(attrlist); } else if (operand1.global_flag()) { void* oldval = nil; comterp()->globaltable()->find_and_remove(oldval, operand1.symbol_val()); if (oldval) delete (ComValue*)oldval; comterp()->globaltable()->insert(operand1.symbol_val(), operand2); } else { void* oldval = nil; comterp()->localtable()->find_and_remove(oldval, operand1.symbol_val()); if (oldval) delete (ComValue*)oldval; comterp()->localtable()->insert(operand1.symbol_val(), operand2); } } else if (operand1.is_object(Attribute::class_symid())) { Attribute* attr = (Attribute*)operand1.obj_val(); attr->Value(operand2); } else { cerr << "assignment to something other than a symbol or attribute (" << symbol_pntr(operand1.type_symid()) << ") ignored\n"; print_stack_arg_post_eval(0); delete operand2; } reset_stack(); push_stack(*operand2); } ModAssignFunc::ModAssignFunc(ComTerp* comterp) : AssignFunc(comterp) { } void ModAssignFunc::execute() { ComValue operand1(stack_arg(0, true)); if (operand1.type() != ComValue::SymbolType) { operand1.assignval(stack_arg_post_eval(0, true /* no symbol lookup */)); } ComValue operand2(stack_arg_post_eval(1, true /* no symbol lookup */)); if (operand2.is_attribute()) lookup_symval(operand2); reset_stack(); if (operand1.type() == ComValue::SymbolType) { void* op1val = nil; _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val()); if (!op1val) { push_stack(ComValue::nullval()); return; } push_stack(*(ComValue*)op1val); delete (ComValue*)op1val; push_stack(operand2); ModFunc modfunc(comterp()); modfunc.exec(2,0); ComValue* result = new ComValue(pop_stack()); _comterp->localtable()->insert(operand1.symbol_val(), result); push_stack(*result); } } MpyAssignFunc::MpyAssignFunc(ComTerp* comterp) : AssignFunc(comterp) { } void MpyAssignFunc::execute() { ComValue operand1(stack_arg(0, true)); if (operand1.type() != ComValue::SymbolType) { operand1.assignval(stack_arg_post_eval(0, true /* no symbol lookup */)); } ComValue operand2(stack_arg_post_eval(1, true /* no symbol lookup */)); if (operand2.is_attribute()) lookup_symval(operand2); reset_stack(); if (operand1.type() == ComValue::SymbolType) { void* op1val = nil; _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val()); if (!op1val) { push_stack(ComValue::nullval()); return; } push_stack(*(ComValue*)op1val); delete (ComValue*)op1val; push_stack(operand2); MpyFunc mpyfunc(comterp()); mpyfunc.exec(2,0); ComValue* result = new ComValue(pop_stack()); _comterp->localtable()->insert(operand1.symbol_val(), result); push_stack(*result); } } AddAssignFunc::AddAssignFunc(ComTerp* comterp) : AssignFunc(comterp) { } void AddAssignFunc::execute() { ComValue operand1(stack_arg(0, true)); if (operand1.type() != ComValue::SymbolType) { operand1.assignval(stack_arg_post_eval(0, true /* no symbol lookup */)); } ComValue operand2(stack_arg_post_eval(1, true /* no symbol lookup */)); if (operand2.is_attribute()) lookup_symval(operand2); reset_stack(); if (operand1.type() == ComValue::SymbolType) { void* op1val = nil; _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val()); if (!op1val) { push_stack(ComValue::nullval()); return; } push_stack(*(ComValue*)op1val); delete (ComValue*)op1val; push_stack(operand2); AddFunc addfunc(comterp()); addfunc.exec(2,0); ComValue* result = new ComValue(pop_stack()); _comterp->localtable()->insert(operand1.symbol_val(), result); push_stack(*result); } } SubAssignFunc::SubAssignFunc(ComTerp* comterp) : AssignFunc(comterp) { } void SubAssignFunc::execute() { ComValue operand1(stack_arg(0, true)); if (operand1.type() != ComValue::SymbolType) { operand1.assignval(stack_arg_post_eval(0, true /* no symbol lookup */)); } ComValue operand2(stack_arg_post_eval(1, true /* no symbol lookup */)); if (operand2.is_attribute()) lookup_symval(operand2); reset_stack(); if (operand1.type() == ComValue::SymbolType) { void* op1val = nil; _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val()); if (!op1val) { push_stack(ComValue::nullval()); return; } push_stack(*(ComValue*)op1val); delete (ComValue*)op1val; push_stack(operand2); SubFunc subfunc(comterp()); subfunc.exec(2,0); ComValue* result = new ComValue(pop_stack()); _comterp->localtable()->insert(operand1.symbol_val(), result); push_stack(*result); } } DivAssignFunc::DivAssignFunc(ComTerp* comterp) : AssignFunc(comterp) { } void DivAssignFunc::execute() { ComValue operand1(stack_arg(0, true)); if (operand1.type() != ComValue::SymbolType) { operand1.assignval(stack_arg_post_eval(0, true /* no symbol lookup */)); } ComValue operand2(stack_arg_post_eval(1, true /* no symbol lookup */)); if (operand2.is_attribute()) lookup_symval(operand2); reset_stack(); if (operand1.type() == ComValue::SymbolType) { void* op1val = nil; _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val()); if (!op1val) { push_stack(ComValue::nullval()); return; } push_stack(*(ComValue*)op1val); delete (ComValue*)op1val; push_stack(operand2); DivFunc divfunc(comterp()); divfunc.exec(2,0); ComValue* result = new ComValue(pop_stack()); _comterp->localtable()->insert(operand1.symbol_val(), result); push_stack(*result); } } IncrFunc::IncrFunc(ComTerp* comterp) : AssignFunc(comterp) { } void IncrFunc::execute() { ComValue operand1(stack_arg(0, true)); if (operand1.type() != ComValue::SymbolType) { operand1.assignval(stack_arg_post_eval(0, true /* no symbol lookup */)); } reset_stack(); if (operand1.type() == ComValue::SymbolType) { void* op1val = nil; _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val()); if (!op1val) push_stack(ComValue::nullval()); else { push_stack(*(ComValue*)op1val); delete (ComValue*)op1val; ComValue one; one.type(ComValue::IntType); one.int_ref() = 1; push_stack(one); AddFunc addfunc(comterp()); addfunc.exec(2,0); ComValue* result = new ComValue(pop_stack()); _comterp->localtable()->insert(operand1.symbol_val(), result); push_stack(*result); } } else push_stack(ComValue::nullval()); } IncrAfterFunc::IncrAfterFunc(ComTerp* comterp) : AssignFunc(comterp) { } void IncrAfterFunc::execute() { ComValue operand1(stack_arg(0, true)); if (operand1.type() != ComValue::SymbolType) { operand1.assignval(stack_arg_post_eval(0, true /* no symbol lookup */)); } reset_stack(); if (operand1.type() == ComValue::SymbolType) { void* op1val = nil; _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val()); if (!op1val) push_stack(ComValue::nullval()); else { push_stack(*(ComValue*)op1val); ComValue one; one.type(ComValue::IntType); one.int_ref() = 1; push_stack(one); AddFunc addfunc(comterp()); addfunc.exec(2,0); ComValue* result = new ComValue(pop_stack()); _comterp->localtable()->insert(operand1.symbol_val(), result); push_stack(*(ComValue*)op1val); delete (ComValue*)op1val; } } else push_stack(ComValue::nullval()); } DecrFunc::DecrFunc(ComTerp* comterp) : AssignFunc(comterp) { } void DecrFunc::execute() { ComValue operand1(stack_arg(0,true)); if (operand1.type() != ComValue::SymbolType) { operand1.assignval(stack_arg_post_eval(0, true /* no symbol lookup */)); } reset_stack(); if (operand1.type() == ComValue::SymbolType) { void* op1val = nil; _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val()); if (!op1val) push_stack(ComValue::nullval()); else { push_stack(*(ComValue*)op1val); delete (ComValue*)op1val; ComValue one; one.type(ComValue::IntType); one.int_ref() = 1; push_stack(one); SubFunc subfunc(comterp()); subfunc.exec(2,0); ComValue* result = new ComValue(pop_stack()); _comterp->localtable()->insert(operand1.symbol_val(), result); push_stack(*result); } } else push_stack(ComValue::nullval()); } DecrAfterFunc::DecrAfterFunc(ComTerp* comterp) : AssignFunc(comterp) { } void DecrAfterFunc::execute() { ComValue operand1(stack_arg(0,true)); if (operand1.type() != ComValue::SymbolType) { operand1.assignval(stack_arg_post_eval(0, true /* no symbol lookup */)); } reset_stack(); if (operand1.type() == ComValue::SymbolType) { void* op1val = nil; _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val()); if (!op1val) push_stack(ComValue::nullval()); else { push_stack(*(ComValue*)op1val); ComValue one; one.type(ComValue::IntType); one.int_ref() = 1; push_stack(one); SubFunc subfunc(comterp()); subfunc.exec(2,0); ComValue* result = new ComValue(pop_stack()); _comterp->localtable()->insert(operand1.symbol_val(), result); push_stack(*(ComValue*)op1val); delete (ComValue*)op1val; } } else push_stack(ComValue::nullval()); } ivtools-1.2.11a1/src/ComTerp/assignfunc.h000066400000000000000000000073441214471147700202060ustar00rootroot00000000000000/* * Copyright (c) 1997,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(_assignfunc_h) #define _assignfunc_h #include class ComTerp; class ComValue; //: = (assign) operator. class AssignFunc : public ComFunc { public: AssignFunc(ComTerp*); virtual boolean post_eval() { return true; } virtual void execute(); virtual const char* docstring() { return "= is the assigment operator"; } CLASS_SYMID("AssignFunc"); }; //: %= (mod assign) operator . class ModAssignFunc : public AssignFunc { public: ModAssignFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "\%= is the mod assignment operator"; } }; //: *= (multiply assign) operator . class MpyAssignFunc : public AssignFunc { public: MpyAssignFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "*= is the multiply assignment operator"; } }; //: *= (add assign) operator . class AddAssignFunc : public AssignFunc { public: AddAssignFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "+= is the add assignment operator"; } }; //: += (subtract assign) operator . class SubAssignFunc : public AssignFunc { public: SubAssignFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "-= is the minus assignment operator"; } }; //: /= (divide assign) operator . class DivAssignFunc : public AssignFunc { public: DivAssignFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "/= is the minus assignment operator"; } }; //: ++(increment before) operator. class IncrFunc : public AssignFunc { public: IncrFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "++ is the increment-before operator (prefix) and the "; } }; //: (increment after)++ operator. class IncrAfterFunc : public AssignFunc { public: IncrAfterFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "increment-after as well (postfix)"; } }; //: --(decrement before) operator. class DecrFunc : public AssignFunc { public: DecrFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "-- is the decrement-before operator (prefix) and the "; } }; //: (decrement after)-- operator. class DecrAfterFunc : public AssignFunc { public: DecrAfterFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "decrement-after as well (postfix)"; } }; #endif /* !defined(_assignfunc_h) */ ivtools-1.2.11a1/src/ComTerp/bitfunc.cc000066400000000000000000000421511214471147700176310ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #define TITLE "BitFunc" /*****************************************************************************/ BitAndFunc::BitAndFunc(ComTerp* comterp) : NumFunc(comterp) { } void BitAndFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); switch (result.type()) { case ComValue::CharType: result.char_ref() = operand1.char_val() & operand2.char_val(); break; case ComValue::UCharType: result.uchar_ref() = operand1.uchar_val() & operand2.uchar_val(); break; case ComValue::ShortType: result.short_ref() = operand1.short_val() & operand2.short_val(); break; case ComValue::UShortType: result.ushort_ref() = operand1.ushort_val() & operand2.ushort_val(); break; case ComValue::IntType: result.int_ref() = operand1.int_val() & operand2.int_val(); break; case ComValue::UIntType: result.uint_ref() = operand1.uint_val() & operand2.uint_val(); break; case ComValue::LongType: result.long_ref() = operand1.long_val() & operand2.long_val(); break; case ComValue::ULongType: result.ulong_ref() = operand1.ulong_val() & operand2.ulong_val(); break; case ComValue::FloatType: result.type(ComValue::UnknownType); break; case ComValue::DoubleType: result.type(ComValue::UnknownType); break; case ComValue::BooleanType: result.boolean_ref() = operand1.boolean_val() & operand2.boolean_val(); break; } reset_stack(); push_stack(result); } /*****************************************************************************/ BitXorFunc::BitXorFunc(ComTerp* comterp) : NumFunc(comterp) { } void BitXorFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); switch (result.type()) { case ComValue::CharType: result.char_ref() = operand1.char_val() ^ operand2.char_val(); break; case ComValue::UCharType: result.uchar_ref() = operand1.uchar_val() ^ operand2.uchar_val(); break; case ComValue::ShortType: result.short_ref() = operand1.short_val() ^ operand2.short_val(); break; case ComValue::UShortType: result.ushort_ref() = operand1.ushort_val() ^ operand2.ushort_val(); break; case ComValue::IntType: result.int_ref() = operand1.int_val() ^ operand2.int_val(); break; case ComValue::UIntType: result.uint_ref() = operand1.uint_val() ^ operand2.uint_val(); break; case ComValue::LongType: result.long_ref() = operand1.long_val() ^ operand2.long_val(); break; case ComValue::ULongType: result.ulong_ref() = operand1.ulong_val() ^ operand2.ulong_val(); break; case ComValue::FloatType: result.type(ComValue::UnknownType); break; case ComValue::DoubleType: result.type(ComValue::UnknownType); break; case ComValue::BooleanType: result.boolean_ref() = operand1.boolean_val() ^ operand2.boolean_val(); break; } reset_stack(); push_stack(result); } /*****************************************************************************/ BitOrFunc::BitOrFunc(ComTerp* comterp) : NumFunc(comterp) { } void BitOrFunc::execute() { if (nargs()==2) { ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); switch (result.type()) { case ComValue::CharType: result.char_ref() = operand1.char_val() | operand2.char_val(); break; case ComValue::UCharType: result.uchar_ref() = operand1.uchar_val() | operand2.uchar_val(); break; case ComValue::ShortType: result.short_ref() = operand1.short_val() | operand2.short_val(); break; case ComValue::UShortType: result.ushort_ref() = operand1.ushort_val() | operand2.ushort_val(); break; case ComValue::IntType: result.int_ref() = operand1.int_val() | operand2.int_val(); break; case ComValue::UIntType: result.uint_ref() = operand1.uint_val() | operand2.uint_val(); break; case ComValue::LongType: result.long_ref() = operand1.long_val() | operand2.long_val(); break; case ComValue::ULongType: result.ulong_ref() = operand1.ulong_val() | operand2.ulong_val(); break; case ComValue::FloatType: result.type(ComValue::UnknownType); break; case ComValue::DoubleType: result.type(ComValue::UnknownType); break; case ComValue::BooleanType: result.boolean_ref() = operand1.boolean_val() | operand2.boolean_val(); break; } reset_stack(); push_stack(result); } else { int curarg = 0; ComValue result(stack_arg(curarg++)); while(curarg> operand2.char_val(); break; case ComValue::UCharType: result.uchar_ref() = operand1.uchar_val() >> operand2.uchar_val(); break; case ComValue::ShortType: result.short_ref() = operand1.short_val() >> operand2.short_val(); break; case ComValue::UShortType: result.ushort_ref() = operand1.ushort_val() >> operand2.ushort_val(); break; case ComValue::IntType: result.int_ref() = operand1.int_val() >> operand2.int_val(); break; case ComValue::UIntType: result.uint_ref() = operand1.uint_val() >> operand2.uint_val(); break; case ComValue::LongType: result.long_ref() = operand1.long_val() >> operand2.long_val(); break; case ComValue::ULongType: result.ulong_ref() = operand1.ulong_val() >> operand2.ulong_val(); break; case ComValue::FloatType: result.type(ComValue::UnknownType); break; case ComValue::DoubleType: result.type(ComValue::UnknownType); break; case ComValue::BooleanType: result.boolean_ref() = operand1.boolean_val() >> operand2.boolean_val(); break; } reset_stack(); push_stack(result); } ivtools-1.2.11a1/src/ComTerp/bitfunc.h000066400000000000000000000065221214471147700174750ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * This is a collection of bitwise operators. They inherit the * C-like promotion mechanism of NumFunc. */ #if !defined(_bitfunc_h) #define _bitfunc_h #include //: & (bit_and) operator. class BitAndFunc : public NumFunc { public: BitAndFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "& is the bit_and operator"; } }; //: ^ (bit_xor) operator. class BitXorFunc : public NumFunc { public: BitXorFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "^ is the bit_xor operator"; } }; //: | (bit_or) operator. class BitOrFunc : public NumFunc { public: BitOrFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "| is the bit_or operator"; } }; //: bitwise nand command. class BitNandFunc : public NumFunc { public: BitNandFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "val=nand(a b) -- bitwise nand (~(a&b))"; } }; //: bitwise xnor command. class BitXnorFunc : public NumFunc { public: BitXnorFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "val=xnor(a b) -- bitwise xnor (~(a^b))"; } }; //: bitwise nor command. class BitNorFunc : public NumFunc { public: BitNorFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "val=nor(a b) -- bitwise nor (~(a|b))"; } }; //: ~ (bit_not) operator. class BitNotFunc : public NumFunc { public: BitNotFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "~ is the bit_not operator"; } }; //: << (left-shift) operator. class LeftShiftFunc : public NumFunc { public: LeftShiftFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "<< is the left-shift operator"; } }; //: >> (right-shift) operator. class RightShiftFunc : public NumFunc { public: RightShiftFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return ">> is the right-shift operator"; } }; #endif /* !defined(_bitfunc_h) */ ivtools-1.2.11a1/src/ComTerp/boolfunc.cc000066400000000000000000000471571214471147700200210ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #define TITLE "BoolFunc" static int sym_symid = symbol_add("sym"); static int n_symid = symbol_add("n"); /*****************************************************************************/ AndFunc::AndFunc(ComTerp* comterp, boolean pre) : NumFunc(comterp) { _pre = pre; } void AndFunc::execute() { ComValue operand1(_pre ? stack_arg(0) : stack_arg_post_eval(0)); if (operand1.is_false()) { reset_stack(); push_stack(operand1); return; } ComValue operand2(_pre ? stack_arg(1) : stack_arg_post_eval(1)); reset_stack(); promote(operand1, operand2); ComValue result(operand1); result.type(ComValue::BooleanType); switch (result.type()) { case ComValue::CharType: result.char_ref() = operand1.char_val() && operand2.char_val(); break; case ComValue::UCharType: result.uchar_ref() = operand1.uchar_val() && operand2.uchar_val(); break; case ComValue::ShortType: result.short_ref() = operand1.short_val() && operand2.short_val(); break; case ComValue::UShortType: result.ushort_ref() = operand1.ushort_val() && operand2.ushort_val(); break; case ComValue::IntType: result.int_ref() = operand1.int_val() && operand2.int_val(); break; case ComValue::UIntType: result.uint_ref() = operand1.uint_val() && operand2.uint_val(); break; case ComValue::LongType: result.long_ref() = operand1.long_val() && operand2.long_val(); break; case ComValue::ULongType: result.ulong_ref() = operand1.ulong_val() && operand2.ulong_val(); break; case ComValue::FloatType: result.float_ref() = operand1.float_val() && operand2.float_val(); break; case ComValue::DoubleType: result.double_ref() = operand1.double_val() && operand2.double_val(); break; case ComValue::BooleanType: result.boolean_ref() = operand1.boolean_val() && operand2.boolean_val(); break; } push_stack(result); } OrFunc::OrFunc(ComTerp* comterp, boolean pre) : NumFunc(comterp) { _pre = pre; } void OrFunc::execute() { ComValue operand1(_pre ? stack_arg(0) : stack_arg_post_eval(0)); if (operand1.is_true()) { reset_stack(); push_stack(operand1); return; } ComValue operand2(_pre ? stack_arg(1) : stack_arg_post_eval(1)); reset_stack(); promote(operand1, operand2); ComValue result(operand1); result.type(ComValue::BooleanType); switch (result.type()) { case ComValue::CharType: result.char_ref() = operand1.char_val() || operand2.char_val(); break; case ComValue::UCharType: result.uchar_ref() = operand1.uchar_val() || operand2.uchar_val(); break; case ComValue::ShortType: result.short_ref() = operand1.short_val() || operand2.short_val(); break; case ComValue::UShortType: result.ushort_ref() = operand1.ushort_val() || operand2.ushort_val(); break; case ComValue::IntType: result.int_ref() = operand1.int_val() || operand2.int_val(); break; case ComValue::UIntType: result.uint_ref() = operand1.uint_val() || operand2.uint_val(); break; case ComValue::LongType: result.long_ref() = operand1.long_val() || operand2.long_val(); break; case ComValue::ULongType: result.ulong_ref() = operand1.ulong_val() || operand2.ulong_val(); break; case ComValue::FloatType: result.float_ref() = operand1.float_val() || operand2.float_val(); break; case ComValue::DoubleType: result.double_ref() = operand1.double_val() || operand2.double_val(); break; case ComValue::BooleanType: result.boolean_ref() = operand1.boolean_val() || operand2.boolean_val(); break; } push_stack(result); } NegFunc::NegFunc(ComTerp* comterp) : NumFunc(comterp) { } void NegFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue result(operand1); result.type(ComValue::BooleanType); switch (operand1.type()) { case ComValue::CharType: result.char_ref() = ! operand1.char_val(); break; case ComValue::UCharType: result.uchar_ref() = ! operand1.uchar_val(); break; case ComValue::ShortType: result.short_ref() = ! operand1.short_val(); break; case ComValue::UShortType: result.ushort_ref() = ! operand1.ushort_val(); break; case ComValue::IntType: result.int_ref() = ! operand1.int_val(); break; case ComValue::UIntType: result.uint_ref() = ! operand1.uint_val(); break; case ComValue::LongType: result.long_ref() = ! operand1.long_val(); break; case ComValue::ULongType: result.ulong_ref() = ! operand1.ulong_val(); break; case ComValue::FloatType: result.float_ref() = ! operand1.float_val(); break; case ComValue::DoubleType: result.double_ref() = ! operand1.double_val(); break; case ComValue::BooleanType: result.boolean_ref() = ! operand1.boolean_val(); break; case ComValue::UnknownType: result.boolean_ref() = true; break; case ComValue::ArrayType: case ComValue::ObjectType: result.boolean_ref() = false; break; case ComValue::SymbolType: case ComValue::StringType: result.boolean_ref() = operand1.symbol_val()<0; break; case ComValue::StreamType: result.boolean_ref() = !operand1.stream_mode(); break; } reset_stack(); push_stack(result); } EqualFunc::EqualFunc(ComTerp* comterp) : NumFunc(comterp) { } void EqualFunc::execute() { boolean symflag = stack_key(sym_symid).is_true(); ComValue& nval = stack_key(n_symid); ComValue& operand1 = stack_arg(0, symflag); ComValue& operand2 = stack_arg(1, symflag); promote(operand1, operand2); ComValue result(operand1); result.type(ComValue::BooleanType); if (operand2.type()==ComValue::UnknownType && operand1.type()!=ComValue::UnknownType) result.boolean_ref() = 0; else if (operand2.type()==ComValue::BlankType && operand1.type()!=ComValue::BlankType) result.boolean_ref() = 0; else if (operand1.is_numeric() && !operand2.is_numeric()) result.boolean_ref() = 0; else { switch (operand1.type()) { case ComValue::CharType: result.boolean_ref() = operand1.char_val() == operand2.char_val(); break; case ComValue::UCharType: result.boolean_ref() = operand1.uchar_val() == operand2.uchar_val(); break; case ComValue::ShortType: result.boolean_ref() = operand1.short_val() == operand2.short_val(); break; case ComValue::UShortType: result.boolean_ref() = operand1.ushort_val() == operand2.ushort_val(); break; case ComValue::IntType: result.boolean_ref() = operand1.int_val() == operand2.int_val(); break; case ComValue::UIntType: result.boolean_ref() = operand1.uint_val() == operand2.uint_val(); break; case ComValue::LongType: result.boolean_ref() = operand1.long_val() == operand2.long_val(); break; case ComValue::ULongType: result.boolean_ref() = operand1.ulong_val() == operand2.ulong_val(); break; case ComValue::FloatType: result.boolean_ref() = operand1.float_val() == operand2.float_val(); break; case ComValue::DoubleType: result.boolean_ref() = operand1.double_val() == operand2.double_val(); break; case ComValue::StringType: case ComValue::SymbolType: if (nval.is_unknown()) result.boolean_ref() = operand1.symbol_val() == operand2.symbol_val(); else { const char* str1 = operand1.symbol_ptr(); const char* str2 = operand2.symbol_ptr(); result.boolean_ref() = strncmp(str1, str2, nval.int_val())==0; } break; case ComValue::ArrayType: result.boolean_ref() = operand2.type() == ComValue::ArrayType && (operand1.array_val() == operand2.array_val() || operand1.array_val()->Equal(operand2.array_val())); break; case ComValue::ObjectType: if (!operand1.object_compview()) result.boolean_ref() = operand2.type() == ComValue::ObjectType && operand1.obj_val() == operand2.obj_val() && operand1.class_symid() == operand2.class_symid(); else result.boolean_ref() = operand2.type() == ComValue::ObjectType && operand1.class_symid() == operand2.class_symid() && operand2.object_compview() && ((ComponentView*)operand1.obj_val())->GetSubject() == ((ComponentView*)operand2.obj_val())->GetSubject(); break; default: result.boolean_ref() = operand1.is_type(ComValue::UnknownType) && operand2.is_type(ComValue::UnknownType) || operand1.is_type(ComValue::BlankType) && operand2.is_type(ComValue::BlankType); break; } } reset_stack(); push_stack(result); } NotEqualFunc::NotEqualFunc(ComTerp* comterp) : NumFunc(comterp) { } void NotEqualFunc::execute() { boolean symflag = stack_key(sym_symid).is_true(); ComValue& nval = stack_key(n_symid); ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); result.type(ComValue::BooleanType); if (operand1.type() != operand2.type()) { result.boolean_ref() = true; reset_stack(); push_stack(result); return; } switch (operand1.type()) { case ComValue::CharType: result.boolean_ref() = operand1.char_val() != operand2.char_val(); break; case ComValue::UCharType: result.boolean_ref() = operand1.uchar_val() != operand2.uchar_val(); break; case ComValue::ShortType: result.boolean_ref() = operand1.short_val() != operand2.short_val(); break; case ComValue::UShortType: result.boolean_ref() = operand1.ushort_val() != operand2.ushort_val(); break; case ComValue::IntType: result.boolean_ref() = operand1.int_val() != operand2.int_val(); break; case ComValue::UIntType: result.boolean_ref() = operand1.uint_val() != operand2.uint_val(); break; case ComValue::LongType: result.boolean_ref() = operand1.long_val() != operand2.long_val(); break; case ComValue::ULongType: result.boolean_ref() = operand1.ulong_val() != operand2.ulong_val(); break; case ComValue::FloatType: result.boolean_ref() = operand1.float_val() != operand2.float_val(); break; case ComValue::DoubleType: result.boolean_ref() = operand1.double_val() != operand2.double_val(); break; case ComValue::StringType: case ComValue::SymbolType: if (nval.is_unknown()) result.boolean_ref() = operand1.symbol_val() != operand2.symbol_val(); else { const char* str1 = operand1.symbol_ptr(); const char* str2 = operand2.symbol_ptr(); result.boolean_ref() = strncmp(str1, str2, nval.int_val())!=0; } break; case ComValue::ArrayType: result.boolean_ref() = operand2.type() != ComValue::ArrayType || operand1.array_val() != operand2.array_val() && !operand1.array_val()->Equal(operand2.array_val()); break; case ComValue::ObjectType: if (!operand1.object_compview()) result.boolean_ref() = operand2.type() != ComValue::ObjectType || operand1.obj_val() != operand2.obj_val() || operand1.class_symid() != operand2.class_symid(); else result.boolean_ref() = operand2.type() != ComValue::ObjectType || operand1.class_symid() != operand2.class_symid() || !operand2.object_compview() || ((ComponentView*)operand1.obj_val())->GetSubject() != ((ComponentView*)operand2.obj_val())->GetSubject(); break; case ComValue::UnknownType: result.boolean_ref() = operand2.is_known(); break; } reset_stack(); push_stack(result); } GreaterThanFunc::GreaterThanFunc(ComTerp* comterp) : NumFunc(comterp) { } void GreaterThanFunc::execute() { boolean symflag = stack_key(sym_symid).is_true(); ComValue& nval = stack_key(n_symid); ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); result.type(ComValue::BooleanType); switch (operand1.type()) { case ComValue::CharType: result.boolean_ref() = operand1.char_val() > operand2.char_val(); break; case ComValue::UCharType: result.boolean_ref() = operand1.uchar_val() > operand2.uchar_val(); break; case ComValue::ShortType: result.boolean_ref() = operand1.short_val() > operand2.short_val(); break; case ComValue::UShortType: result.boolean_ref() = operand1.ushort_val() > operand2.ushort_val(); break; case ComValue::IntType: result.boolean_ref() = operand1.int_val() > operand2.int_val(); break; case ComValue::UIntType: result.boolean_ref() = operand1.uint_val() > operand2.uint_val(); break; case ComValue::LongType: result.boolean_ref() = operand1.long_val() > operand2.long_val(); break; case ComValue::ULongType: result.boolean_ref() = operand1.ulong_val() > operand2.ulong_val(); break; case ComValue::FloatType: result.boolean_ref() = operand1.float_val() > operand2.float_val(); break; case ComValue::DoubleType: result.boolean_ref() = operand1.double_val() > operand2.double_val(); break; case ComValue::SymbolType: const char* str1 = operand1.symbol_ptr(); const char* str2 = operand2.symbol_ptr(); if (nval.is_unknown()) result.boolean_ref() = strcmp(str1, str2)>0; else result.boolean_ref() = strncmp(str1, str2, nval.int_val())>0; break; } reset_stack(); push_stack(result); } GreaterThanOrEqualFunc::GreaterThanOrEqualFunc(ComTerp* comterp) : NumFunc(comterp) { } void GreaterThanOrEqualFunc::execute() { boolean symflag = stack_key(sym_symid).is_true(); ComValue& nval = stack_key(n_symid); ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); result.type(ComValue::BooleanType); switch (operand1.type()) { case ComValue::CharType: result.boolean_ref() = operand1.char_val() >= operand2.char_val(); break; case ComValue::UCharType: result.boolean_ref() = operand1.uchar_val() >= operand2.uchar_val(); break; case ComValue::ShortType: result.boolean_ref() = operand1.short_val() >= operand2.short_val(); break; case ComValue::UShortType: result.boolean_ref() = operand1.ushort_val() >= operand2.ushort_val(); break; case ComValue::IntType: result.boolean_ref() = operand1.int_val() >= operand2.int_val(); break; case ComValue::UIntType: result.boolean_ref() = operand1.uint_val() >= operand2.uint_val(); break; case ComValue::LongType: result.boolean_ref() = operand1.long_val() >= operand2.long_val(); break; case ComValue::ULongType: result.boolean_ref() = operand1.ulong_val() >= operand2.ulong_val(); break; case ComValue::FloatType: result.boolean_ref() = operand1.float_val() >= operand2.float_val(); break; case ComValue::DoubleType: result.boolean_ref() = operand1.double_val() >= operand2.double_val(); break; case ComValue::SymbolType: const char* str1 = operand1.symbol_ptr(); const char* str2 = operand2.symbol_ptr(); if (nval.is_unknown()) result.boolean_ref() = strcmp(str1, str2)>=0; else result.boolean_ref() = strncmp(str1, str2, nval.int_val())>=0; break; } reset_stack(); push_stack(result); } LessThanFunc::LessThanFunc(ComTerp* comterp) : NumFunc(comterp) { } void LessThanFunc::execute() { boolean symflag = stack_key(sym_symid).is_true(); ComValue& nval = stack_key(n_symid); ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); result.type(ComValue::BooleanType); switch (operand1.type()) { case ComValue::CharType: result.boolean_ref() = operand1.char_val() < operand2.char_val(); break; case ComValue::UCharType: result.boolean_ref() = operand1.uchar_val() < operand2.uchar_val(); break; case ComValue::ShortType: result.boolean_ref() = operand1.short_val() < operand2.short_val(); break; case ComValue::UShortType: result.boolean_ref() = operand1.ushort_val() < operand2.ushort_val(); break; case ComValue::IntType: result.boolean_ref() = operand1.int_val() < operand2.int_val(); break; case ComValue::UIntType: result.boolean_ref() = operand1.uint_val() < operand2.uint_val(); break; case ComValue::LongType: result.boolean_ref() = operand1.long_val() < operand2.long_val(); break; case ComValue::ULongType: result.boolean_ref() = operand1.ulong_val() < operand2.ulong_val(); break; case ComValue::FloatType: result.boolean_ref() = operand1.float_val() < operand2.float_val(); break; case ComValue::DoubleType: result.boolean_ref() = operand1.double_val() < operand2.double_val(); break; case ComValue::SymbolType: const char* str1 = operand1.symbol_ptr(); const char* str2 = operand2.symbol_ptr(); if (nval.is_unknown()) result.boolean_ref() = strcmp(str1, str2)<0; else result.boolean_ref() = strncmp(str1, str2, nval.int_val())<0; break; } reset_stack(); push_stack(result); } LessThanOrEqualFunc::LessThanOrEqualFunc(ComTerp* comterp) : NumFunc(comterp) { } void LessThanOrEqualFunc::execute() { boolean symflag = stack_key(sym_symid).is_true(); ComValue& nval = stack_key(n_symid); ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); result.type(ComValue::BooleanType); switch (operand1.type()) { case ComValue::CharType: result.boolean_ref() = operand1.char_val() <= operand2.char_val(); break; case ComValue::UCharType: result.boolean_ref() = operand1.uchar_val() <= operand2.uchar_val(); break; case ComValue::ShortType: result.boolean_ref() = operand1.short_val() <= operand2.short_val(); break; case ComValue::UShortType: result.boolean_ref() = operand1.ushort_val() <= operand2.ushort_val(); break; case ComValue::IntType: result.boolean_ref() = operand1.int_val() <= operand2.int_val(); break; case ComValue::UIntType: result.boolean_ref() = operand1.uint_val() <= operand2.uint_val(); break; case ComValue::LongType: result.boolean_ref() = operand1.long_val() <= operand2.long_val(); break; case ComValue::ULongType: result.boolean_ref() = operand1.ulong_val() <= operand2.ulong_val(); break; case ComValue::FloatType: result.boolean_ref() = operand1.float_val() <= operand2.float_val(); break; case ComValue::DoubleType: result.boolean_ref() = operand1.double_val() <= operand2.double_val(); break; case ComValue::SymbolType: const char* str1 = operand1.symbol_ptr(); const char* str2 = operand2.symbol_ptr(); if (nval.is_unknown()) result.boolean_ref() = strcmp(str1, str2)<=0; else result.boolean_ref() = strncmp(str1, str2, nval.int_val())<=0; break; } reset_stack(); push_stack(result); } ivtools-1.2.11a1/src/ComTerp/boolfunc.h000066400000000000000000000122351214471147700176500ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1997,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * This is a collection of boolean operators. They inherit the * C-like promotion mechanism of NumFunc. */ #if !defined(_boolfunc_h) #define _boolfunc_h #include //: && (and) operator. class AndFunc : public NumFunc { public: AndFunc(ComTerp*, boolean pre=false); virtual void execute(); virtual boolean post_eval() { return !_pre; } virtual const char* docstring() { return "&& is the and operator"; } protected: boolean _pre; }; //: || (or) operator. class OrFunc : public NumFunc { public: OrFunc(ComTerp*, boolean pre=false); virtual void execute(); virtual boolean post_eval() { return !_pre; } virtual const char* docstring() { return "|| is the or operator"; } protected: boolean _pre; }; //: ! (negate) operator. class NegFunc : public NumFunc { public: NegFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "! is the negate operator"; } }; //: == (equality) operator. // also useful for partial string comparison with :n keyword, i.e. // eq("string1" "string2" :n 6) returns true. // also useful for symbol comparison with :sym keyword. class EqualFunc : public NumFunc { public: EqualFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "== is the equal operator\nbool=eq(str1 str2 :n len) -- partial string comparison\nbool=eq(sym1 sym2 :sym) -- symbol comparison"; } }; //: != (non-equality) operator. // also useful for partial string comparison with :n keyword. // neq("string1" "string2" :n 6) returns false. // also useful for symbol comparison with :sym keyword. class NotEqualFunc : public NumFunc { public: NotEqualFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "!= is the not-equal operator\nbool=neq(str1 str2 :n len) -- partial string comparison\nbool=neq(sym1 sym2 :sym) -- symbol comparison"; } }; //: > (greater than) operator. // also useful for partial string comparison with :n keyword, i.e. // gt("string1" "string2" :n 6) returns false. // also useful for symbol comparison with :sym keyword. class GreaterThanFunc : public NumFunc { public: GreaterThanFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "> is the greater-than operator\nbool=gt(str1 str2 :n len) -- partial string comparison\nbool=gt(sym1 sym2 :sym) -- symbol comparison"; } }; //: >= (greater than or equal) operator. // also useful for partial string comparison with :n keyword. // also useful for symbol comparison with :sym keyword. class GreaterThanOrEqualFunc : public NumFunc { public: GreaterThanOrEqualFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return ">= is the greater-than-or-equal operator\nbool=gt_or_eq(str1 str2 :n len) -- partial string comparison\nbool=gt_or_eq(sym1 sym2 :sym) -- symbol comparison"; } }; //: < (less than) operator. // also useful for partial string comparison with :n keyword, i.e. // lt("string2" "string1" :n 6) returns false. // also useful for symbol comparison with :sym keyword. class LessThanFunc : public NumFunc { public: LessThanFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "< is the less-than operator\nbool=lt(str1 str2 :n len) -- partial string comparison\nbool=lt(sym1 sym2 :sym) -- symbol comparison"; } }; //: <= (less than or equal) operator. class LessThanOrEqualFunc : public NumFunc { // also useful for partial string comparison with :n keyword. // also useful for symbol comparison with :sym keyword. public: LessThanOrEqualFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "<= is the less-than-or-equal operator\nbool=lt_or_eq(str1 str2 :n len) -- partial string comparison\nbool=lt_or_eq(sym1 sym2 :sym) -- symbol comparison"; } }; #endif /* !defined(_boolfunc_h) */ ivtools-1.2.11a1/src/ComTerp/bquotefunc.cc000066400000000000000000000035411214471147700203520ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1998,1999,2000 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #define TITLE "BackQuoteFunc" /*****************************************************************************/ BackQuoteFunc::BackQuoteFunc(ComTerp* comterp) : ComFunc(comterp) { } void BackQuoteFunc::execute() { #if 0 // maybe, maybe not ComValue topval(stack_arg(0, true)); if (topval.is_command()) topval.assignval(stack_arg_post_eval(0, true /* no symbol lookup */)); reset_stack(); topval.bquote(1); push_stack(topval); #else ComValue retval(stack_arg(0, true)); reset_stack(); retval.bquote(1); push_stack(retval); #endif } ivtools-1.2.11a1/src/ComTerp/bquotefunc.h000066400000000000000000000031751214471147700202170ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * LISP-like backquote command */ #if !defined(_bquotefunc_h) #define _bquotefunc_h #include class ComTerp; //: backquote operator, similar to LISP class BackQuoteFunc : public ComFunc { public: BackQuoteFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "` is the LISP-like backquote operator"; } }; #endif /* !defined(_bquotefunc_h) */ ivtools-1.2.11a1/src/ComTerp/charfunc.cc000066400000000000000000000050721214471147700177710ustar00rootroot00000000000000/* * Copyright (c) 2009 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #define TITLE "CharFunc" /*****************************************************************************/ CtoiFunc::CtoiFunc(ComTerp* comterp) : ComFunc(comterp) {} void CtoiFunc::execute() { ComValue charv(stack_arg(0)); reset_stack(); int intval = charv.int_val() - '0'; ComValue result(intval, ComValue::IntType); push_stack(result); } /*****************************************************************************/ IsSpaceFunc::IsSpaceFunc(ComTerp* comterp) : ComFunc(comterp) {} void IsSpaceFunc::execute() { ComValue charv(stack_arg(0)); reset_stack(); int boolval = isspace(charv.char_val()); ComValue result(boolval, ComValue::BooleanType); push_stack(result); } /*****************************************************************************/ IsDigitFunc::IsDigitFunc(ComTerp* comterp) : ComFunc(comterp) {} void IsDigitFunc::execute() { ComValue charv(stack_arg(0)); reset_stack(); int boolval = isdigit(charv.char_val()); ComValue result(boolval, ComValue::BooleanType); push_stack(result); } /*****************************************************************************/ IsAlphaFunc::IsAlphaFunc(ComTerp* comterp) : ComFunc(comterp) {} void IsAlphaFunc::execute() { ComValue charv(stack_arg(0)); reset_stack(); int boolval = isalpha(charv.char_val()); ComValue result(boolval, ComValue::BooleanType); push_stack(result); } ivtools-1.2.11a1/src/ComTerp/charfunc.h000066400000000000000000000043631214471147700176350ustar00rootroot00000000000000/* * Copyright (c) 2009 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * This is a collection of character functions. */ #if !defined(_charfunc_h) #define _charfunc_h #include class CtoiFunc : public ComFunc { public: CtoiFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "int=ctoi(char) -- convert character to integer"; } protected: }; class IsSpaceFunc : public ComFunc { public: IsSpaceFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "flag=isspace(char) -- return true if character is whitespace"; } protected: }; class IsDigitFunc : public ComFunc { public: IsDigitFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "flag=isdigit(char) -- return true if character is a numeric digit"; } protected: }; class IsAlphaFunc : public ComFunc { public: IsAlphaFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "flag=isalpha(char) -- return true if character is alphabetical"; } protected: }; #endif /* !defined(_numfunc_h) */ ivtools-1.2.11a1/src/ComTerp/comfunc.cc000066400000000000000000000347401214471147700176360ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #define TITLE "ComFunc" #ifdef LEAKCHECK extern LeakChecker AttributeValuechecker; #endif /*****************************************************************************/ int ComFunc::_symid = -1; ComFunc::ComFunc(ComTerp* comterp) { _comterp = comterp; _context = nil; _docstring2 = nil; } void ComFunc::reset_stack() { if (!post_eval()) { int count = nargs() + nkeys() - npops(); #if 0 // now done immediately with stack_pop for (int i=1; i<=npops(); i++) { ((AttributeValue)_comterp->stack_top(i)).AttributeValue::~AttributeValue(); #ifdef LEAKCHECK AttributeValuechecker.create(); #endif } #endif _comterp->decr_stack(count); } else _comterp->decr_stack(1); _comterp->_just_reset = true; npops() = 0; } ComValue& ComFunc::stack_arg(int n, boolean symbol, ComValue& dflt) { if (post_eval()) return stack_arg_post(n, symbol, dflt); int count = nargs() + nkeys() - npops(); for (int i=0; istack_top(i-count+1); if( argref.type() == ComValue::KeywordType) return dflt; if (i == n) { if (i+1 < count) { ComValue& keyref = _comterp->stack_top(i-count+2); if (keyref.is_type(ComValue::KeywordType) && keyref.keynarg_val()) return dflt; } if (!symbol) argref = _comterp->lookup_symval(argref); return argref; } } return dflt; } ComValue& ComFunc::stack_key(int id, boolean symbol, ComValue& dflt, boolean use_dflt_for_no_key) { if (post_eval()) return stack_key_post(id, symbol, dflt, use_dflt_for_no_key); int count = nargs() + nkeys() - npops(); for (int i=0; istack_top(-i); if( keyref.type() == ComValue::KeywordType) { if (keyref.symbol_val() == id) { if (i+1==count || keyref.keynarg_val() == 0) { if (use_dflt_for_no_key) return ComValue::trueval(); else return dflt; } else { ComValue& valref = _comterp->stack_top(-i-1); if (valref.type() == ComValue::KeywordType) { if (use_dflt_for_no_key) return ComValue::trueval(); else return dflt; } else { if (!symbol) valref = _comterp->lookup_symval(valref); return valref; } } } } } return use_dflt_for_no_key ? dflt : ComValue::nullval(); } ComValue& ComFunc::stack_dotname(int n) { return _comterp->stack_top(n+1+npops()); } ComValue ComFunc::stack_arg_post_eval(int n, boolean symbol, ComValue& dflt) { ComValue argoff(comterp()->stack_top()); int offtop = argoff.int_val()-comterp()->_pfnum; int argcnt; for (int i=0; i=nargsfixed()) return dflt; for (int j=nargsfixed(); j>n; j--) { argcnt = 0; skip_arg_in_expr(offtop, argcnt); } comterp()->post_eval_expr(argcnt, offtop, pedepth()+1 #ifdef POSTEVAL_EXPERIMENT , symbol #endif ); return comterp()->pop_stack(!symbol); } void ComFunc::print_stack_arg_post_eval(int n) { ComValue argoff(comterp()->stack_top()); int offtop = argoff.int_val()-comterp()->_pfnum; int argcnt; for (int i=0; i=nargsfixed()) return; for (int j=nargsfixed(); j>n; j--) { argcnt = 0; skip_arg_in_expr(offtop, argcnt); } comterp()->print_post_eval_expr(argcnt, offtop, pedepth()+1); return; } postfix_token* ComFunc::copy_stack_arg_post_eval(int n, int& ntoks) { ComValue argoff(comterp()->stack_top()); int offtop = argoff.int_val()-comterp()->_pfnum; int argcnt; for (int i=0; i=nargsfixed()) return NULL; for (int j=nargsfixed(); j>n; j--) { argcnt = 0; skip_arg_in_expr(offtop, argcnt); } postfix_token* tokbuf = comterp()->copy_post_eval_expr(argcnt, offtop); ntoks = argcnt; return tokbuf; } ComValue** ComFunc::stack_arg_post_eval_nargsfixed(boolean symbol, ComValue& dflt) { ComValue argoff(comterp()->stack_top()); int offtop = argoff.int_val()-comterp()->_pfnum; int argcnt; for (int i=0; i0; j--) { argcnt = 0; skip_arg_in_expr(offtop, argcnt); offtopbuf[j-1] = offtop; argcntbuf[j-1] = argcnt; } ComValue** vals = new ComValue*[nargsfixed()]; for(int i=0; ipost_eval_expr(argcntbuf[i], offtopbuf[i], pedepth()+1 #ifdef POSTEVAL_EXPERIMENT , symbol #endif ); vals[i] = new ComValue(comterp()->pop_stack(!symbol)); } delete offtopbuf; delete argcntbuf; return vals; } ComValue ComFunc::stack_key_post_eval (int id, boolean symbol, ComValue& dflt, boolean use_dflt_for_no_key) { ComValue argoff(comterp()->stack_top()); int offtop = argoff.int_val()-comterp()->_pfnum; int count = 0; while (count < nkeys()) { ComValue& curr = comterp()->expr_top(offtop); if (!curr.is_type(ComValue::KeywordType)) return use_dflt_for_no_key ? dflt : ComValue::nullval(); count++; int argcnt = 0; skip_key_in_expr(offtop, argcnt); if (curr.symbol_val() == id) { if (argcnt) { comterp()->post_eval_expr(argcnt, offtop, pedepth()+1); return comterp()->pop_stack(!symbol); } else return use_dflt_for_no_key ? dflt : ComValue::trueval(); } } return use_dflt_for_no_key ? dflt : ComValue::nullval(); } ComValue& ComFunc::stack_arg_post(int n, boolean symbol, ComValue& dflt) { ComValue argoff(comterp()->stack_top()); int offtop = argoff.int_val()-comterp()->_pfnum; int argcnt; for (int i=0; i=nargsfixed()) return dflt; for (int j=nargsfixed(); j>n; j--) { argcnt = 0; skip_arg_in_expr(offtop, argcnt); } int loc = comterp()->_pfnum + offtop + argcnt-1; if (loc<0) fprintf(stderr, "unexpected negative index for _pfcomvals\n"); else return comterp()->_pfcomvals[loc]; } ComValue& ComFunc::stack_key_post (int id, boolean symbol, ComValue& dflt, boolean use_dflt_for_no_key) { ComValue argoff(comterp()->stack_top()); int offtop = argoff.int_val()-comterp()->_pfnum; int count = 0; while (count < nkeys()) { ComValue& curr = comterp()->expr_top(offtop); if (!curr.is_type(ComValue::KeywordType)) return use_dflt_for_no_key ? dflt : ComValue::nullval(); count++; int argcnt = 0; skip_key_in_expr(offtop, argcnt); if (curr.symbol_val() == id) { if (argcnt) { int loc = comterp()->_pfnum + offtop + argcnt-1; return comterp()->_pfcomvals[loc]; } else return use_dflt_for_no_key ? dflt : ComValue::trueval(); } } return use_dflt_for_no_key ? dflt : ComValue::nullval(); } boolean ComFunc::skip_key_on_stack(int& stackptr, int& argcnt) { return comterp()->skip_key(&comterp()->stack_top(), stackptr, -comterp()->stack_height(), argcnt); } boolean ComFunc::skip_arg_on_stack(int& stackptr, int& argcnt) { return comterp()->skip_arg(&comterp()->stack_top(), stackptr, -comterp()->stack_height(), argcnt); } boolean ComFunc::skip_key_in_expr(int& offtop, int& argcnt) { return comterp()->skip_key(&comterp()->_pfcomvals[comterp()->_pfnum-1], offtop, -comterp()->_pfnum, argcnt); } boolean ComFunc::skip_arg_in_expr(int& offtop, int& argcnt) { return comterp()->skip_arg(&comterp()->_pfcomvals[comterp()->_pfnum-1], offtop, -comterp()->_pfnum, argcnt); } ComValue ComFunc::pop_stack() { /* get rid of keywords -- use stack_key and stack_arg to get those */ if (!npops() && nkeys()) { int count = nargs() + nkeys(); int nkey = nkeys(); for (int i=0; ipop_stack()); npops()++; if (val.type() == ComValue::KeywordType) nkey--; if (nkey==0) break; } } if (npops()pop_stack(); } else return ComValue::nullval(); } ComValue ComFunc::pop_symbol() { /* get rid of keywords -- use stack_key and stack_arg to get those */ if (!npops() && nkeys()) { int count = nargs() + nkeys(); int nkey = nkeys(); for (int i=0; ipop_stack(); npops()++; if (val.type() == ComValue::KeywordType) nkey--; if (nkey==0) break; } } if (npops()pop_symbol(); } else return ComValue::nullval(); } void ComFunc::push_stack(ComValue& val) { _comterp->push_stack(val); } void ComFunc::push_stack(AttributeValue& val) { _comterp->push_stack(val); } ComValue& ComFunc::lookup_symval(ComValue& sym) { ComValue& retval = _comterp->lookup_symval(sym); return retval; } void ComFunc::assign_symval(int id, ComValue* sym) { _comterp->localtable()->insert(id, sym); return; } int ComFunc::bintest(const char* command) { char combuf[BUFSIZ]; #if 0 sprintf( combuf, "echo-n $PATH; which %s", command ); #else sprintf( combuf, "which %s 2> /dev/null", command ); #endif FILE* fptr = popen(combuf, "r"); char testbuf[BUFSIZ]; fgets(testbuf, BUFSIZ, fptr); pclose(fptr); if (strncmp(testbuf+strlen(testbuf)-strlen(command)-1, command, strlen(command)) != 0) { return -1; } return 0; } boolean ComFunc::bincheck(const char* command) { int status = bintest(command); return !status; } ComFuncState* ComFunc::funcstate() { return _comterp->top_funcstate(); } void ComFunc::push_funcstate(int nargs, int nkeys, int pedepth, int command_symid) { ComFuncState cfs(nargs, nkeys, pedepth, command_symid==0 ? classid() : command_symid ); _comterp->push_funcstate(cfs); } void ComFunc::pop_funcstate() { _comterp->pop_funcstate(); } void ComFunc::exec(int nargs, int nkeys, int pedepth, int command_symid) { push_funcstate(nargs, nkeys, pedepth, command_symid); execute(); pop_funcstate(); } int& ComFunc::nargs() { return _comterp->top_funcstate()->nargs(); } int& ComFunc::nkeys() { return _comterp->top_funcstate()->nkeys(); } int& ComFunc::npops() { return _comterp->top_funcstate()->npops(); } int ComFunc::nargspost() { ComFuncState* funcstate = _comterp->top_funcstate(); if (funcstate->nargspost()>=0) return funcstate->nargspost(); int nargs = funcstate->nargs(); int nkeys = funcstate->nkeys(); int topptr = 0; if (post_eval()) { ComValue argoff(comterp()->stack_top()); topptr = argoff.int_val()-comterp()->_pfnum; } int argcnt=0; while (nargs>0 || nkeys>0) { ComValue& val = comterp()->expr_top(topptr); int cnt = 0; if (val.is_type(ComValue::KeywordType)) { argcnt++; skip_key_in_expr(topptr, cnt); argcnt += cnt; nargs -= cnt ? 1 : 0; nkeys--; } else { skip_arg_in_expr(topptr, cnt); argcnt += cnt; nargs--; } } return argcnt; } int ComFunc::nargskey() { ComFuncState* funcstate = _comterp->top_funcstate(); if (funcstate->nargskey()>=0) return funcstate->nargskey(); int nkeys = funcstate->nkeys(); int topptr = 0; if (post_eval()) { ComValue argoff(comterp()->stack_top()); topptr = argoff.int_val()-comterp()->_pfnum; } int nkeyargs = 0; while (nkeys>0) { int argcnt = 0; if (!post_eval()) { skip_key_on_stack(topptr, argcnt); } else { skip_key_in_expr(topptr, argcnt); } nkeyargs += argcnt ? 1 : 0; nkeys--; } funcstate->nargskey() = nkeyargs; return nkeyargs; } int& ComFunc::pedepth() { return _comterp->top_funcstate()->pedepth(); } AttributeList* ComFunc::stack_keys(boolean symbol, AttributeValue& dflt) { AttributeList* al = new AttributeList(); int count = nargs() + nkeys() - npops(); for (int i=0; istack_top(-i); if( keyref.type() == ComValue::KeywordType) { int key_symid = keyref.symbol_val(); if (i+1==count || keyref.keynarg_val() == 0) al->add_attr(key_symid, dflt); else { ComValue& valref = _comterp->stack_top(-i-1); if (valref.type() == ComValue::KeywordType) al->add_attr(key_symid, dflt); else { if (!symbol) valref = _comterp->lookup_symval(valref); al->add_attr(key_symid, valref); } } } } return al; } ComTerpServ* ComFunc::comterpserv() { return _comterp && _comterp->is_serv() ? (ComTerpServ*)_comterp : nil; } ostream& operator<< (ostream& out, const ComFunc& cf) { out << symbol_pntr(cf.funcid()); return out; } /*****************************************************************************/ ComFuncState::ComFuncState(int narg, int nkey, int pedepth, int command_symid) { _nargs = narg; _nkeys = nkey; _npops = 0; _nargskey = -1; _nargspost = -1; _pedepth = pedepth; _command_symid = command_symid; } ComFuncState::ComFuncState(const ComFuncState& cfs) { *this = cfs; } ostream& operator<< (ostream& out, const ComFuncState& cf) { out << "nargs = " << cf._nargs; out << ";nkeys = " << cf._nkeys; return out; } ivtools-1.2.11a1/src/ComTerp/comfunc.h000066400000000000000000000272431214471147700175000ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * ComFunc is a simple action callback pointed to by a ComCom * (or possibly any other external function binding mechanism) */ #if !defined(_comfunc_h) #define _comfunc_h #include #include #include #include #include #include class AttributeList; class ComFuncState; class Component; //: command base class for extending ComTerp. // class whose derived classes get constructed and added to a // ComTerp command interpreter, one per command to be supported. class ComFunc { public: ComFunc(ComTerp*); virtual ~ComFunc() { delete _docstring2;} virtual void execute() = 0; // method that needs to be filled in, that will take ComValue arguments // off the stack, then compute and push a ComValue result on the stack. void exec(int nargs, int nkeys, int pedepth=0, int command_symid=0); // invokes push_funcstate, then plain execute, then pop_funcstate. // for use from the body of regular execute methods. int& nargs(); // number of white space separated arguments inside parentheses // that are not keywords (keywords indicated by a ':' prefix // on a symbol). int& nkeys(); // number of arguments inside parentheses that are keywords (keywords // indicated by a ':' prefix on a symbol). Arguments that follow // keywords are counted by nargs(). That's why there is a need for // nargsfixed() and nargstotal() methods, to distinguish between // arguments associated with fixed arguments (the ones that // precede the keyword arguments), and the ones enmeshed with the // keywords. int nargsfixed() {return nargs() - nargskey();} // number of arguments prior to any keyword. The ones that require a // fixed order to determine their meaning (unlike the arguments that // follow keywords, which can be in any order). int nargstotal() {return nargs() + nkeys();} // nargs()+nkeys() int nargskey(); // number of arguments follow keywords, assumed to be less than // or equal to nkeys() (this requirement could be relaxed). int nargspost(); // number of arguments to a post-evaluating command // that represent commands and arguments ready to be evaluated // by the post-eval methods: stack_arg_post_eval() and // stack_key_post_eval(). ComFuncState* funcstate(); // current ComFuncState for use of current ComFunc. void push_funcstate(int nargs, int nkeys, int pedepth=0, int command_symid=0); // push new ComFuncState on a stack of them. void pop_funcstate(); // pop the top one off the ComFuncState stack. ComTerp* comterp() { return _comterp; } // return ComTerp this ComFunc is associated with. ComTerpServ* comterpserv(); // return ComTerpServ this ComFunc is associated with. void comterp( ComTerp* comterp) { _comterp = comterp; } void comterpserv( ComTerpServ* serv) { _comterp = (ComTerp*)serv; } ComValue pop_stack(); // pop top off the stack. ComValue pop_symbol(); // pop top off the stack preserving symbol ids if ComValue is a symbol type. void push_stack(ComValue&); // push ComValue onto the stack. void push_stack(AttributeValue&); // push AttributeValue onto the stack, converting to a ComValue // in the process. void reset_stack(); // reset the stack to its state before this ComFunc execute() method // was called. Needs to be called once and only once in each // derived execute() method. Save it to last if you're using references // to ComValue objects directly on the stack. Otherwise, call it as // soon as all the arguments have been loaded into local copies. ComValue& stack_arg(int n, boolean symbol=false, ComValue& dflt=ComValue::nullval()); // return the nth argument on the stack for this ComFunc execute() call. ComValue& stack_key(int id, boolean symbol=false, ComValue& dflt=ComValue::trueval(), boolean use_dflt_for_no_key=false /* the antonym would be use_dflt_for_no_arg */); // return the value of an argument that follows a keyword, // optionally return the value of 'dflt' if no argument follows // the keyword. If 'use_dflt_for_no_key' is true, 'dflt' gets returned // as the value when a keyword is not found. ComValue& stack_dotname(int n); // unused method to get at a dotted list of names, i.e. a.b.c ComValue stack_arg_post_eval(int n, boolean symbol=false, ComValue& dflt=ComValue::nullval()); // evaluate the nth argument for this post-evaluating ComFunc. void print_stack_arg_post_eval(int n); // print the expression for the nth argument for this post-evaluating ComFunc. postfix_token* copy_stack_arg_post_eval(int n, int& ntoks); // copy the expression for the nth argument for this post-evaluating ComFunc. ComValue stack_key_post_eval(int id, boolean symbol=false, ComValue& dflt=ComValue::trueval(), boolean use_dflt_for_no_key=false); // evaluate the argument following a keyword for this post-evaluating ComFunc. // Optionally return the value of 'dflt' if no argument follows // the keyword. If 'use_dflt_for_no_key' is true, 'dflt' gets returned // as the value when a keyword is not found. AttributeList* stack_keys(boolean symbol = false, AttributeValue& dflt=ComValue::trueval()); // return newly-constructed AttributeList (which needs referencing) // that contains a copy of each keyword/value pair in the arguments // to the invocation of this ComFunc. 'dflt' is used whenever a // keyword has no matching argument. ComValue** stack_arg_post_eval_nargsfixed(boolean symbol=false, ComValue& dflt=ComValue::nullval()); // evaluate all nargsfixed arguments for this post-evaluating ComFunc, // and return in newly allocated array of newly allocated pointers. void funcid(int id) { _funcid = id; } // set symbol id of name for func int funcid() const { return _funcid; } // get symbol id of name for func ComValue& lookup_symval(ComValue&); // lookup variable value given a symbol ComValue ComValue& lookup_symval(int symid); // lookup variable value given a symbol id. void assign_symval(int id, ComValue*); virtual boolean post_eval() { return false; } virtual const char* docstring() { return "%s: no docstring method defined"; } const char* docstring2() { return _docstring2 ? _docstring2 : docstring(); } void docstring2(const char* str) { delete _docstring2; _docstring2 = strnew(str); } static int bintest(const char* name); static boolean bincheck(const char* name); friend ostream& operator << (ostream& s, const ComFunc&); // print contents to ostream, brief or not depending on // associated ComTerp brief flag. Component* context() { return _context; } void context(Component* comp) { _context = comp; } protected: int& npops(); // number of calls to pop_stack() since execute method called. int& pedepth(); // depth of being embedded in blocks of post-evaluated ccommands // (commands whose arguments are not pre-evaluated for them). ComValue& stack_arg_post(int n, boolean symbol=false, ComValue& dflt=ComValue::nullval()); // find the ComValue object in the unevaluated input arguments // of a post-eval ComFunc that represents the start of the // code for the nth argument (prior to any keywords). ComValue& stack_key_post(int id, boolean symbol=false, ComValue& dflt=ComValue::trueval(), boolean use_dflt_for_no_key=false); // find the ComValue object in the unevaluated input arguments // of a post-eval ComFunc that represents the start of the // code for the argument that follows a keyword. If no argument // follows keyword, 'dflt' is returned, unless 'use_dflt_for_no_key' // is true, when 'dflt' gets returned when no matching keyword is found. boolean skip_key_on_stack(int& stackptr, int& arglen); // skip a keyword going down the stack. boolean skip_arg_on_stack(int& stackptr, int& arglen); // skip an argument going down the stack. boolean skip_key_in_expr(int& topptr, int& arglen); // skip a keyword in a buffer of unevaluated ComValue objects, // decrementing an index into a buffer set up to hold the // currently interpreting expression. boolean skip_arg_in_expr(int& topptr, int& arglen); // skip an argument in unevaluated ComValue objects, // decrementing an index into a buffer set up to hold the // currently interpreting expression. ComTerp* _comterp; int _funcid; Component* _context; const char* _docstring2; CLASS_SYMID("ComFunc"); }; //: state object for holding invocation specific data about a ComFunc. // object that holds the state of a ComFunc used in a particular context, // which allows for nested and recursive use of a singular ComFunc. class ComFuncState { public: ComFuncState(int nargs, int nkeys, int pedepth=0, int command_symid=0); // initialize with number of arguments (including arguments following // keywords), number of keywords, an option post-eval depth (nesting // within blocks of post-evaluation commands), and an optional // symbol id associated with the ComFunc. ComFuncState(const ComFuncState&); // copy constructor. int& nargs() {return _nargs;} // number of arguments (including arguments following keywords). int& nkeys() {return _nkeys;} // number of keywords, ':' prefixed symbols in a list of arguments. int& npops() { return _npops;} // number of pops since the execute method called. int& nargskey() { return _nargskey; } // number of arguments following keywords. Assumption of nargskey()<=nkey(). int& nargspost() { return _nargspost; } // number of unevaluated ComValue objects input to a post-evaluation ComFunc. int& pedepth() { return _pedepth; } // post-evaluation depth: the nesting within blocks of post-evaluation commands, // within blocks of conditionally executing control commands. int& command_symid() { return _command_symid; } // symbol id associated with the ComFunc. friend ostream& operator << (ostream& s, const ComFuncState&); // print contents to ostream, brief or not depending on // associated ComTerp brief flag. protected: int _nargs; int _nkeys; int _npops; int _nargskey; int _nargspost; int _pedepth; int _command_symid; }; #endif /* !defined(_comfunc_h) */ ivtools-1.2.11a1/src/ComTerp/comhandler.cc000066400000000000000000000165061214471147700203200ustar00rootroot00000000000000/* * Copyright (c) 2005 Scott E. Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1996 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifdef HAVE_ACE #include #include #if __GNUC__==2 && __GNUC_MINOR__<=7 #else using namespace std; #include #endif #include #include #include #include #if BUFSIZ>1024 #undef BUFSIZ #define BUFSIZ 1024 #endif int ComterpHandler::_logger_mode = 0; /*****************************************************************************/ // Default constructor. ComterpHandler::ComterpHandler (ComTerpServ* serv) #if 0 : ACE_Svc_Handler(0,0,ComterpHandler::reactor_singleton()) #endif { //comterp_ = serv ? serv : new ComTerpServ(BUFSIZ*BUFSIZ); comterp_ = serv ? serv : new ComTerpServ(BUFSIZ*16); comterp_->handler(this); comterp_->add_defaults(); _timeoutscriptid = -1; _wrfptr = _rdfptr = nil; _log_only = 0; } ComterpHandler::~ComterpHandler() { } const char* ComterpHandler::timeoutscript() { return symbol_pntr(_timeoutscriptid); } void ComterpHandler::timeoutscript(const char* timeoutscript) { if (timeoutscript) timeoutscriptid(symbol_add((char *)timeoutscript)); } int ComterpHandler::timeoutscriptid() { return _timeoutscriptid; } void ComterpHandler::timeoutscriptid(int timeoutscriptid) { if (_timeoutscriptid != -1) ComterpHandler::reactor_singleton()->cancel_timer (this); _timeoutscriptid = timeoutscriptid; if (_timeoutscriptid != -1) { if (ComterpHandler::reactor_singleton()->schedule_timer (this, (const void *) this, ACE_Time_Value (timeoutseconds()), ACE_Time_Value (timeoutseconds())) == -1) /* ACE_ERROR_RETURN ((LM_ERROR, "can'(%P|%t) t register with reactor\n"), -1) */; } } void ComterpHandler::destroy (void) { if (ComterpHandler::logger_mode()==0) ACE_DEBUG ((LM_DEBUG, "(%P|%t) disconnected from %s\n", this->peer_name_)); #if 0 ComterpHandler::reactor_singleton()->cancel_timer (this); #endif this->peer ().close (); if (_timeoutscriptid<0) { if (comterp_->running()) comterp_->delete_later(1); else { delete comterp_; comterp_ = nil; } } else /* timer could be still running */; if (_wrfptr) { fclose(_wrfptr); _wrfptr = nil; } if (_rdfptr) { fclose(_rdfptr); _rdfptr = nil; } } int ComterpHandler::handle_timeout (const ACE_Time_Value &, const void *arg) { if (_timeoutscriptid<0) return 0; comterp_->push_servstate(); comterp_->load_string(symbol_pntr(_timeoutscriptid)); if (comterp_->read_expr()) { if (comterp_->eval_expr()) { err_print( stderr, "comterp" ); timeoutscriptid(-1); } else if (comterp_->quitflag()) { #if 0 /* bug */ delete comterp_; #endif timeoutscriptid(-1); comterp_->pop_servstate(); comterp_ = nil; return -1; } else { if (!comterp_->stack_empty()) { #if __GNUC__<3 filebuf obuf(1); #else fileptr_filebuf obuf(stdout, ios_base::out); #endif ostream ostr(&obuf); ostr << "timeexpr result: "; comterp_->print_stack_top(ostr); ostr << "\n"; ostr.flush(); } } } comterp_->pop_servstate(); return 0; } int ComterpHandler::handle_input (ACE_HANDLE fd) { if (!_wrfptr) _wrfptr = fdopen(fd, "w"); // if (!_rdfptr) _rdfptr = fdopen(fd, "r"); vector inv; char ch; ch = '\0'; int status=1; int bytesavail=1; while (ch != '\n' && status>0 && bytesavail) { status = read(fd, &ch, 1); if (status == 1 && ch != '\n') inv.push_back(ch); bytesavail=0; ioctl(fd, FIONREAD, &bytesavail); } inv.push_back('\0'); boolean input_good = status != -1; char* inbuf = &inv[0]; if (!comterp_ || !input_good) return -1; else if (!inbuf ) { return -1; } else if ( !*inbuf) { return 0; } if (!ComterpHandler::logger_mode() && !log_only()) { comterp_->load_string(inbuf); if (fd>0 && !comterp_->muted() && strncmp(inbuf, "ready", 5)!=0) cerr << "(" << fd << "): " << inbuf << "\n"; comterp_->_fd = fd; comterp_->_outfunc = (outfuncptr)&ComTerpServ::fd_fputs; int status = comterp_->ComTerp::run(false /* !once */, comterp_->force_nested() /* !nested */); if(comterp_->force_nested()) ComValue retval(comterp_->pop_stack(false)); if (comterp_->delete_later()) { delete comterp_; comterp_ = nil; } return input_good&&(status==0||status==3||status==2) ? 0 : -1; } else { if (inbuf[0]!='\004') cout << "from pipe(" << fd << "): " << inbuf << "\n"; fileptr_filebuf obuf(fd ? wrfptr() : stdout, ios_base::out); ostream ostr(&obuf); ostr << "\n"; ostr.flush(); return (input_good && inbuf[0]!='\004') ? 0 : -1; } } int ComterpHandler::open (void *) { ACE_INET_Addr addr; if (this->peer ().get_remote_addr (addr) == -1) return -1; else { const char* hostname = addr.get_host_name(); char buffer[MAXHOSTNAMELEN]; addr.addr_to_string(buffer, MAXHOSTNAMELEN); ACE_OS::strncpy (this->peer_name_, buffer, MAXHOSTNAMELEN + 1); if (ComterpHandler::reactor_singleton()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) can't register with reactor\n"), -1); #if defined(__NetBSD__) /* this seems to be required for NetBSD */ else if (ComterpHandler::reactor_singleton()->schedule_timer (this, (const void *) this, ACE_Time_Value (10), ACE_Time_Value (10)) == -1) ACE_ERROR_RETURN ((LM_ERROR, "can'(%P|%t) t register with reactor\n"), -1); #endif else if (ComterpHandler::logger_mode()==0) ACE_DEBUG ((LM_DEBUG, "(%P|%t) connected with %s\n", this->peer_name_)); return 0; } } // Perform termination activities when deregistered from the // ACE_Reactor. int ComterpHandler::close (u_long) { this->destroy (); return 0; } // Our Reactor Singleton. typedef ACE_Singleton REACTOR; ACE_Reactor* ComterpHandler::reactor_singleton() { return REACTOR::instance(); } #endif /* HAVE_ACE */ ivtools-1.2.11a1/src/ComTerp/comhandler.h000066400000000000000000000122271214471147700201560ustar00rootroot00000000000000/* * Copyright (c) 1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef _comterp_handler_ #define _comterp_handler_ /* * ComterpHandler is an ACE handler that can be invoked by an ACE acceptor */ #ifdef HAVE_ACE #include #ifdef __alpha__ #define __USE_GNU #endif #include #include #include #include #include #include #include class ComTerpServ; //: An ACE_Test_and_Set Singleton. typedef ACE_Singleton, ACE_Null_Mutex> COMTERP_QUIT_HANDLER; //: handler to invoke ComTerp on socket (version with ACE) class ComterpHandler : public ACE_Svc_Handler { public: // = Initialization and termination methods. ComterpHandler (ComTerpServ* serv=NULL); virtual ~ComterpHandler(); virtual void destroy (void); // Ensure dynamic allocation. // = Hooks for opening and closing handlers. virtual int open (void *); // open handler hook. virtual int close (u_long); // close handler hook. const char* timeoutscript(); // return text of commands to execute every timeout. void timeoutscript(const char*); // install new text of commands to execute every timeout. int timeoutscriptid(); // return symbol id of text of commands to execute every timeout. void timeoutscriptid(int); // set symbol id of text of commands to execute every timeout. void timeoutseconds(int seconds) { _seconds = seconds; } // set timeout period in seconds. int timeoutseconds() { return _seconds; } // return timeout period in seconds. ComTerpServ* comterp() { return comterp_; } // return associated ComTerpServ pointer. static void logger_mode(int flag) { _logger_mode = flag; } // set flag to put comterp in logging mode, where commands are echoed // to stdout without executing static int logger_mode() { return _logger_mode; } // return flag that indicates comterp is in logging-only mode FILE* wrfptr() { return _wrfptr; } // file pointer for writing to handle FILE* rdfptr() { return _rdfptr; } // file pointer for reading from handle static ACE_Reactor* reactor_singleton(); // alternate way of getting at reactor singleton int log_only() { return _log_only; } // return flag that indicates whether just this handler is in logging mode void log_only(int flag ) { _log_only = flag; } // set flag that indicates whether just this handler is in logging mode protected: // = Demultiplexing hooks. virtual int handle_input (ACE_HANDLE); // called when input ready on ACE_HANDLE. virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); // called when timer goes off. char peer_name_[MAXHOSTNAMELEN + 1]; // Host we are connected to. ComTerpServ* comterp_; // private local comterp server int _timeoutscriptid; // command for timeoutscript execution int _seconds; // timeout in seconds FILE* _wrfptr; // file pointer for writing to handle FILE* _rdfptr; // file pointer for reading from handle static int _logger_mode; // mode for logging commands: 0 = no log, 1 = log only int _log_only; // put just this handler into log mode }; //: Specialize a ComterpAcceptor. typedef ACE_Acceptor ComterpAcceptor; #else #include class ComTerpServ; //: version without ACE class ComterpHandler { public: ComterpHandler(ComTerpServ* serv=nil) {comterp_ = serv ? serv : new ComTerpServ(); _handle = 0; comterp_->add_defaults();} ComterpHandler(int id, ComTerpServ* serv = nil) { comterp_ = serv ? serv : new ComTerpServ(); _handle = id; comterp_->add_defaults();} int get_handle() { return _handle;} FILE* wrfptr() { return nil; } // file pointer for writing to handle FILE* rdfptr() { return nil; } // file pointer for reading from handle ComTerp* comterp() { return comterp_; } protected: int _handle; ComTerpServ* comterp_; }; #endif #endif /* _comterp_handler_ */ ivtools-1.2.11a1/src/ComTerp/commodule.h000066400000000000000000000002421214471147700200200ustar00rootroot00000000000000/* * ComModule has been moved to the Attribute library so that * its derived classes (i.e. LexScan) can be utilized there */ #include ivtools-1.2.11a1/src/ComTerp/comterp.cc000066400000000000000000001415001214471147700176460ustar00rootroot00000000000000/* * Copyright (c) 2001-2009 Scott E. Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #if __GNUC__>=3 #include #endif #include #include #include #include #include #include #include #include #include #include // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __GNUC__>=3 #include #endif #ifdef LEAKCHECK #include #endif #define TITLE "ComTerp" #define STREAM_MECH extern int _detail_matched_delims; extern int _no_bracesplus; using std::cerr; using std::cout; implementTable(ComValueTable,int,void*) ComTerp* ComTerp::_instance = nil; ComValueTable* ComTerp::_globaltable = nil; /*****************************************************************************/ ComTerp::ComTerp() : Parser() { init(); } ComTerp::ComTerp(const char* path) : Parser(path) { init(); } ComTerp::ComTerp(void* inptr, char*(*infunc)(char*,int,void*), int(*eoffunc)(void*), int(*errfunc)(void*)) : Parser(inptr, infunc, eoffunc, errfunc) { init(); } void ComTerp::init() { /* Save pointer to this instance */ if (!_instance) _instance = this; /* Allocate stack to initial size */ _stack_top = -1; _stack_siz = 1024; if(dmm_calloc((void**)&_stack, _stack_siz, sizeof(ComValue)) != 0) KANRET("error in call to dmm_calloc"); /* Allocate funcstate stack to initial size */ _fsstack_top = -1; _fsstack_siz = 256; if(dmm_calloc((void**)&_fsstack, _fsstack_siz, sizeof(ComFuncState)) != 0) KANRET("error in call to dmm_calloc"); /* Allocate servstate stack to initial size */ _ctsstack_top = -1; _ctsstack_siz = 256; if(dmm_calloc((void**)&_ctsstack, _ctsstack_siz, sizeof(ComTerpState)) != 0) KANRET("error in call to dmm_calloc"); _pfoff = 0; _pfnum = 0; _quitflag = false; _pfcomvals = nil; /* Create ComValue symbol table */ _localtable = new ComValueTable(100); #if 0 /* deferred until first use */ if (!_globaltable) { _globaltable = new ComValueTable(100); } #endif _errbuf = new char[BUFSIZ]; _alist = nil; _brief = true; _just_reset = false; _defaults_added = false; _handler = nil; _val_for_next_func = nil; _func_for_next_expr = nil; _trace_mode = 0; _npause = 0; _stepflag = 0; _echo_postfix = 0; _delim_func = 0; _ignore_commands = 0; _autostream = 0; _running = 0; _muted = 0; _fd = -1; _arg_strs = nil; _narg_strs = 0; _top_commands = NULL; } ComTerp::~ComTerp() { /* Free stacks */ if(dmm_free((void**)&_stack) != 0) KANRET ("error in call to dmm_free"); if(dmm_free((void**)&_fsstack) != 0) KANRET ("error in call to dmm_free"); if(dmm_free((void**)&_ctsstack) != 0) KANRET ("error in call to dmm_free"); delete _errbuf; delete _arg_strs; delete _top_commands; } const ComValue* ComTerp::stack(unsigned int &top) const { top = _stack_top; return _stack; } boolean ComTerp::read_expr() { check_parser_client(); int status = parser (_inptr, _infunc, _eoffunc, _errfunc, (FILE*)_outptr, _outfunc, _buffer, _bufsiz, &_bufptr, _token, _toksiz, &_linenum, &_pfbuf, &_pfsiz, &_pfnum); _pfoff = 0; save_parser_client(); postfix_echo(); return status==0 && (_pfnum==0 || _pfbuf[_pfnum-1].type != TOK_EOF) && _buffer[0] != '\0'; } void ComTerp::increment_linenum() { check_parser_client(); _linenum++; save_parser_client(); } boolean ComTerp::eof() { return _pfnum ? _pfbuf[_pfnum-1].type == TOK_EOF : false; } boolean ComTerp::brief() const { return _brief; } int ComTerp::eval_expr(boolean nested) { if(_pfnum==0) return FUNCBAD; _pfoff = 0; delete [] _pfcomvals; _pfcomvals = nil; if (!nested) _stack_top = -1; while (_pfoff < _pfnum) { load_sub_expr(); eval_expr_internals(); } return FUNCOK; } boolean ComTerp::top_expr() { return _pfoff >= _pfnum && NextFunc::next_depth()<=1; } int ComTerp::eval_expr(ComValue* pfvals, int npfvals) { push_servstate(); _pfoff = 0; _pfnum = npfvals; _pfcomvals = pfvals; while (_pfoff < _pfnum) { load_sub_expr(); eval_expr_internals(); } pop_servstate(); return FUNCOK; } void ComTerp::eval_expr_internals(int pedepth) { static int step_symid = symbol_add("step"); ComValue sv = pop_stack(false); if (sv.type() == ComValue::CommandType) { #ifdef STREAM_MECH /* if func has StreamType ComValue's for arguments */ /* create another StreamType ComValue to hold all its */ /* arguments, along with a pointer to the func. */ boolean has_streams = false; int streamid = -1; if (!((ComFunc*)sv.obj_val())->post_eval()) for(int i=0; iis_stream() : false; } if (has_streams) { streamid = i; break; } } if (has_streams) { AttributeValueList* avl = new AttributeValueList(); /* if delims associated with symbol, put that first in stream list */ if (_delim_func && sv.nids()!=1) { ComValue nameval(sv.command_symid(), ComValue::SymbolType); avl->Prepend(new AttributeValue(nameval)); } for(int i=0; iPrepend(new AttributeValue(topval)); } ComValue val(sv.obj_val(), avl); val.stream_mode(1); // for external use push_stack(val); return; } #endif ComFunc* func = nil; int nargs = sv.narg(); int nkeys = sv.nkey(); int func_for_next_expr_post_eval = 0; if (_func_for_next_expr) { func = _func_for_next_expr; _func_for_next_expr = nil; push_stack(sv); func->push_funcstate(1, 0, pedepth, func->funcid()); } else { func = (ComFunc*)sv.obj_val(); if (_delim_func && sv.nids()!=1) { ComValue nameval(sv.command_symid(), ComValue::SymbolType); push_stack(nameval); // this assumes it will be immediately popped off the stack if (!func->post_eval()) nargs++; else func_for_next_expr_post_eval = 1; } func->push_funcstate(nargs, nkeys, pedepth, func->funcid()); } /* output execution trace */ if (this->trace_mode()) { for(int i=0; ipost_eval()) cerr << ": nargs=" << nargs << " nkeys=" << nkeys << "\n"; else { int ntotal = func->nargs() + func->nkeys(); for(int i=0; iwrfptr() ? handler()->wrfptr() : stdout, ios_base::out); ostream out(&fbufout); out << ">>> " << *func << "(" << *func->funcstate() << ")\n"; static int pause_symid = symbol_add("pause"); ComValue pausekey(pause_symid, 0, ComValue::KeywordType); push_stack(pausekey); ComterpStepFunc stepfunc(this); stepfunc.push_funcstate(0,1, pedepth, step_symid); stepfunc.execute(); stepfunc.pop_funcstate(); pop_stack(); } int stack_base = _stack_top; if (!func->post_eval()) stack_base -= nargs+nkeys; else { stack_base -= 1; stack_base -= func_for_next_expr_post_eval; } func->execute(); func->pop_funcstate(); if (_just_reset && !_func_for_next_expr) { push_stack(ComValue::blankval()); _just_reset = false; } if (stack_base+1 < _stack_top) { fprintf(stderr, "func \"%s\" pushed more than a single value on stack\n", symbol_pntr(func->funcid())); fprintf(stderr, "stack_base %d, stack_top %d\n", stack_base, _stack_top); for(int i=stack_base+1; i<=_stack_top; i++) std::cerr << i << ": " << _stack[i] << "\n"; } else if (stack_base+1 > _stack_top) fprintf(stderr, "func \"%s\" failed to push a single value on stack\n", symbol_pntr(func->funcid())); } else if (sv.type() == ComValue::SymbolType) { if (_func_for_next_expr) { ComFunc* func = _func_for_next_expr; _func_for_next_expr = nil; push_stack(sv); func->push_funcstate(1, 0, pedepth, func->funcid()); func->execute(); func->pop_funcstate(); if (_just_reset && val_for_next_func().is_null()) { push_stack(ComValue::blankval()); _just_reset = false; } } else { if (_alist) { int id = sv.symbol_val(); AttributeValue* val = _alist->find(id); if (val) { ComValue newval(*val); push_stack(newval); } else push_stack(ComValue::nullval()); } else push_stack(lookup_symval(sv)); } } else if (sv.is_object(Attribute::class_symid())) { push_stack(*((Attribute*)sv.obj_val())->Value()); } else if (sv.type() == ComValue::BlankType) { if (!stack_empty()) eval_expr_internals(pedepth); } else { /* everything else*/ push_stack(sv); } } void ComTerp::load_sub_expr() { /* initialize arrays of ComValue's wrapped around ComFunc's */ /* and counters that indicate depth of post-eval operators */ if (!_pfcomvals) { _pfcomvals = new ComValue[_pfnum]; for (int i=_pfnum-1; i>=0; i--) { ComValue* sv = _pfcomvals + i; token_to_comvalue(_pfbuf+i, sv); } int offset = 0; for (int j=_pfnum-1; j>=0; j--) { ComValue* sv = _pfcomvals + j; if (sv->is_type(ComValue::CommandType)) { ComFunc* func = (ComFunc*)sv->obj_val(); if (func && func->post_eval()) { int newoffset = offset; skip_func(_pfcomvals+_pfnum-1, newoffset, -_pfnum); int start = j-1; int stop = _pfnum+newoffset; for (int k=start; k>=stop; k--) _pfcomvals[k].pedepth()++; } } offset--; } } /* skip pushing values on stack until _postevaldepth is 0 */ /* push all the zero-depth things until you get a CommandType */ while (_pfoff < _pfnum ) { if (_pfcomvals[_pfoff].pedepth()) { _pfoff++; continue; } if (_pfcomvals[_pfoff].is_type(ComValue::CommandType)) { ComFunc* func = (ComFunc*)_pfcomvals[_pfoff].obj_val(); if (func && func->post_eval()) { ComValue argoffval(_pfoff); push_stack(argoffval); } } if (!_pfcomvals[_pfoff].is_blank()) { push_stack(_pfcomvals[_pfoff]); } else { /* to handle a list as the 1st operand of the tuple operator */ if (stack_top(0).is_array()) { stack_top(0).array_val()->nested_insert(true); } else if (stack_top(0).is_symbol()) { AttributeValue* av = lookup_symval(&stack_top(0)); if (av && av->is_array()) av->array_val()->nested_insert(true); } } _pfoff++; if (stack_top().type() == ComValue::CommandType && !_pfcomvals[_pfoff-1].pedepth()) break; } #if 0 /* find the index of the last (or outermost) */ /* post_eval command in the postfix buffer */ int top_post_eval = -1; int pfptr = _pfnum-1; while (pfptr > _pfoff ) { void *vptr = nil; /* look up ComFunc and check post_eval flag */ if (_pfbuf[pfptr].type==TOK_COMMAND) localtable()->find(vptr, _pfbuf[pfptr].v.dfintval); ComValue* comptr = (ComValue*)vptr; if (comptr && comptr->is_type(AttributeValue::CommandType)) { ComFunc* comfunc = (ComFunc*)comptr->obj_val(); if (comfunc && comfunc->post_eval()) { top_post_eval = pfptr; break; } } pfptr--; } /* push tokens onto the stack until the last post_eval command is pushed */ /* or if none, the first !post_eval command is pushed */ while (_pfoff < _pfnum ) { push_stack(_pfbuf + _pfoff); _pfoff++; if (stack_top().type() == ComValue::CommandType && (top_post_eval<0 || top_post_eval == _pfoff-1) ) break; } /* count down on stack to determine the number of */ /* args associated with keywords for this command */ if (stack_top().type() == ComValue::CommandType && top_post_eval<0) { int nargs_after_key = 0; for (int i=0; i<_pfbuf[_pfoff-1].narg+_pfbuf[_pfoff-1].nkey; i++) { ComValue& val = stack_top(-i-1); if (val.is_type(ComValue::KeywordType)) nargs_after_key += val.keynarg_val(); } return nargs_after_key; } else return 0; #endif } int ComTerp::post_eval_expr(int tokcnt, int offtop, int pedepth #ifdef POSTEVAL_EXPERIMENT , int nolookup #endif ) { #ifdef POSTEVAL_EXPERIMENT int numtok = tokcnt; #endif if (tokcnt) { int offset = _pfnum+offtop; while (tokcnt>0) { while (tokcnt>0) { if (_pfcomvals[offset].pedepth()==pedepth) { if (_pfcomvals[offset].is_type(ComValue::CommandType)) { ComFunc* func = (ComFunc*)_pfcomvals[offset].obj_val(); if (func && func->post_eval()) { ComValue argoffval(offset); push_stack(argoffval); } } if (!_pfcomvals[offset].is_blank()) { push_stack(_pfcomvals[offset]); } else { /* to handle a list as the 1st operand of the tuple operator */ if (stack_top(0).is_array()) { stack_top(0).array_val()->nested_insert(true); } else if (stack_top(0).is_symbol()) { AttributeValue* av = lookup_symval(&stack_top(0)); if (av->is_array()) av->array_val()->nested_insert(true); } } } tokcnt--; offset++; if (_pfcomvals[offset-1].pedepth()!=pedepth) continue; if (stack_top().is_type(ComValue::CommandType) && stack_top().pedepth() == pedepth) break; } #ifdef POSTEVAL_EXPERIMENT if (!(stack_top().is_symbol()&&numtok==1&&nolookup)) #endif eval_expr_internals(pedepth); } } return FUNCOK; } void ComTerp::print_post_eval_expr(int tokcnt, int offtop, int pedepth ) { ComValue topval; if (tokcnt) { int offset = _pfnum+offtop; while (tokcnt>0) { while (tokcnt>0) { if (_pfcomvals[offset].pedepth()==pedepth) { if (_pfcomvals[offset].is_type(ComValue::CommandType)) { ComFunc* func = (ComFunc*)_pfcomvals[offset].obj_val(); if (func && func->post_eval()) { ComValue argoffval(offset); cout << argoffval << " "; topval = argoffval; } } if (!_pfcomvals[offset].is_blank()) { cout << _pfcomvals[offset] << " "; topval = _pfcomvals[offset]; } } tokcnt--; offset++; if (_pfcomvals[offset-1].pedepth()!=pedepth) continue; if (topval.is_type(ComValue::CommandType) && topval.pedepth() == pedepth) break; } cout << "| "; } } cout << "\n"; } postfix_token* ComTerp::copy_post_eval_expr(int tokcnt, int offtop) { postfix_token* tokbuf = new postfix_token[tokcnt]; int offset = _pfnum+offtop; for(int i=0; inarg(); int nkeys = sv->nkey(); if (offlimit == offset) { cerr << "offlimit hit by ComTerp::skip_func\n"; return false; } offset--; while(nargs>0 || nkeys>0) { ComValue* nv = topval + offset; int tokcnt; if (nv->is_type(ComValue::KeywordType)) { skip_key(topval, offset, offlimit, tokcnt); nkeys--; nargs -= tokcnt ? 1 : 0; } else { skip_arg(topval, offset, offlimit, tokcnt); nargs--; } } return true; } boolean ComTerp::skip_key(ComValue* topval, int& offset, int offlimit, int& tokcnt) { ComValue& curr = *(topval+offset); tokcnt = 0; if (curr.is_type(ComValue::KeywordType)) { if (offlimit == offset) { cerr << "offlimit hit by ComTerp::skip_key\n"; return false; } offset--; if (curr.keynarg_val()) { int subtokcnt; skip_arg(topval, offset, offlimit, subtokcnt); tokcnt += subtokcnt; } return true; } return false; } boolean ComTerp::skip_arg(ComValue* topval, int& offset, int offlimit, int& tokcnt) { tokcnt = 0; ComValue& curr = *(topval+offset); if (curr.is_type(ComValue::KeywordType)) { cerr << "unexpected keyword found by ComTerp::skip_arg\n"; return false; } else if (curr.is_type(ComValue::UnknownType)) { cerr << "unexpected unknown found by ComTerp::skip_arg\n"; return false; } else if (curr.is_type(ComValue::BlankType)) { if (offlimit == offset) { cerr << "offlimit hit by ComTerp::skip_arg\n"; return false; } offset--; boolean val = skip_arg(topval, offset, offlimit, tokcnt); tokcnt++; return val; } else { if (offlimit == offset) { cerr << "offlimit hit by ComTerp::skip_arg\n"; return false; } offset--; tokcnt++; if (curr.narg() || curr.nkey()) { int count = 0; while (count<(curr.narg() + curr.nkey())) { ComValue& next = *(topval+offset); int subtokcnt = 0; if (next.is_type(ComValue::KeywordType)) { skip_key(topval, offset, offlimit, subtokcnt); tokcnt += subtokcnt + 1; if (subtokcnt) count++; } else if (next.is_type(ComValue::CommandType) || next.is_type(ComValue::SymbolType)) { skip_arg(topval, offset, offlimit, subtokcnt); tokcnt += subtokcnt; } else if (next.is_type(ComValue::BlankType)) { if (offlimit == offset) { cerr << "offlimit hit by ComTerp::skip_arg\n"; return false; } offset--; skip_arg(topval, offset, offlimit, subtokcnt); tokcnt += subtokcnt+1; } else { if (offlimit == offset) { cerr << "offlimit hit by ComTerp::skip_arg\n"; return false; } offset--; tokcnt++; } count++; } } return true; } } ComValue& ComTerp::expr_top(int n) { if (_pfnum+n < 0 || n>0) { return ComValue::unkval(); } else return _pfcomvals[_pfnum-1+n]; } int ComTerp::print_stack() const { for (int i = _stack_top; i >= 0; i--) { cout << _stack[i] << "\n"; } return true; } int ComTerp::print_stack_top() const { if (_stack_top < 0) return true; ComValue::comterp(this); cout << _stack[_stack_top] << "\n"; return true; } int ComTerp::print_stack_top(ostream& out) const { if (_stack_top < 0) return true; ComValue::comterp(this); out << _stack[_stack_top]; return true; } void ComTerp::push_stack(postfix_token* token) { if (_stack_top+1 == _stack_siz) { _stack_siz *= 2; dmm_realloc_size(sizeof(ComValue)); if(dmm_realloc((void**)&_stack, (unsigned long)_stack_siz) != 0) { KANRET("error in call to dmm_realloc"); return; } } _stack_top++; token_to_comvalue(token, _stack + _stack_top); _just_reset = false; } void ComTerp::token_to_comvalue(postfix_token* token, ComValue* sv) { *sv = ComValue(token); /* See if this really is a command with a ComFunc */ if (sv->type() == ComValue::SymbolType) { void* vptr = nil; unsigned int command_symid = sv->int_val(); if(!ignore_commands()) localtable()->find(vptr, command_symid); else if (strncmp(sv->symbol_ptr(), "__", 2)==0) { int bufsiz = strlen(sv->symbol_ptr()); char buf[bufsiz]; strcpy(buf, sv->symbol_ptr()+2); command_symid = symbol_add(buf); localtable()->find(vptr, command_symid); } /* handle case where symbol has matched parens, and things are set up to invoke a delim-specific func. */ if (/*!vptr && */ _delim_func && sv->nids() != 1) { if (sv->nids() == TOK_RPAREN) { static int parens_symid = symbol_add("()"); localtable()->find(vptr, parens_symid); } if (sv->nids() == TOK_RBRACKET) { static int brackets_symid = symbol_add("[]"); localtable()->find(vptr, brackets_symid); } else if (sv->nids() == TOK_RBRACE) { static int braces_symid = symbol_add("{}"); localtable()->find(vptr, braces_symid); } else if (sv->nids() == TOK_RANGBRACK) { static int anglebrackets_symid = symbol_add("<>"); localtable()->find(vptr, anglebrackets_symid); } else if (sv->nids() == TOK_RANGBRACK2) { static int dblanglebrackets_symid = symbol_add("<<>>"); localtable()->find(vptr, dblanglebrackets_symid); } command_symid = sv->symbol_val(); } /* handle case where symbol has arguments/keywords, but is not defined */ else if (!vptr && (sv->narg() || sv->nkey())) { static int nil_symid = symbol_add("nil"); localtable()->find(vptr, nil_symid); } if (vptr && ((ComValue*)vptr)->type() == ComValue::CommandType) { sv->obj_ref() = ((ComValue*)vptr)->obj_ref(); sv->type(ComValue::CommandType); sv->command_symid(command_symid); } } else if (sv->type() == ComValue::KeywordType) { sv->keynarg_ref() = token->narg; } } void ComTerp::push_stack(ComValue& value) { if (_stack_top+1 == _stack_siz) { _stack_siz *= 2; dmm_realloc_size(sizeof(ComValue)); if(dmm_realloc((void**)&_stack, (unsigned long)_stack_siz) != 0) { KANRET("error in call to dmm_realloc"); return; } } _stack_top++; if (_stack_top<0) { fprintf(stderr, "warning: comterp stack still empty after push\n"); return; } ComValue* sv = _stack + _stack_top; *sv = ComValue(value); if (sv->type() == ComValue::KeywordType) sv->keynarg_ref() = value.keynarg_val(); _just_reset = false; } void ComTerp::push_stack(AttributeValue& value) { ComValue comval(value); push_stack(comval); } void ComTerp::incr_stack() { _stack_top++; ComValue& sv = stack_top(); /* See if this really is a command with a ComFunc */ if (sv.type() == ComValue::SymbolType) { void* vptr = nil; localtable()->find(vptr, sv.int_val()); if (vptr && ((ComValue*)vptr)->type() == ComValue::CommandType) { sv.obj_ref() = ((ComValue*)vptr)->obj_ref(); sv.type(ComValue::CommandType); } } } void ComTerp::incr_stack(int n) { for (int i=0; i=0; i++) { ComValue& stacktop = _stack[_stack_top--]; stacktop.AttributeValue::~AttributeValue(); #ifdef LEAKCHECK // destructor called where constructor never called AttributeValue::_leakchecker->create(); #endif } } ComValue ComTerp::pop_stack(boolean lookupsym) { if (!stack_empty()) { ComValue& stacktop = _stack[_stack_top--]; ComValue topval(stacktop); stacktop.AttributeValue::~AttributeValue(); #ifdef LEAKCHECK // destructor called where constructor never called AttributeValue::_leakchecker->create(); #endif if (lookupsym && topval.is_symbol()) { return lookup_symval(topval); } else if (lookupsym && topval.is_attribute()) { topval.assignval(*((Attribute*)topval.obj_val())->Value()); return topval; }else return topval; } else { cerr << "stack empty, blank returned\n"; return ComValue::blankval(); } } ComValue& ComTerp::lookup_symval(ComValue& comval) { if (comval.bquote()) return comval; if (comval.type() == ComValue::SymbolType) { void* vptr = nil; if (!comval.global_flag() && localtable()->find(vptr, comval.symbol_val()) ) { comval.assignval(*(ComValue*)vptr); return comval; } else if (_alist) { int id = comval.symbol_val(); AttributeValue* aval = _alist->find(id); if (aval) { ComValue newval(*aval); *&comval = newval; } return comval; } else if (globaltable()->find(vptr, comval.symbol_val())) { comval.assignval(*(ComValue*)vptr); return comval; } else return ComValue::nullval(); } else if (comval.is_object(Attribute::class_symid())) { comval.assignval(*((Attribute*)comval.obj_val())->Value()); } return comval; } AttributeValue* ComTerp::lookup_symval(ComValue* comval) { if (comval->bquote()) return nil; if (comval->type() == ComValue::SymbolType) { void* vptr = nil; if (!comval->global_flag() && localtable()->find(vptr, comval->symbol_val()) ) { return (AttributeValue*)vptr; } else if (_alist) { int id = comval->symbol_val(); AttributeValue* aval = _alist->find(id); if (aval) { return aval; } return nil; } else if (globaltable()->find(vptr, comval->symbol_val())) { return (AttributeValue*)vptr; } else return nil; } else if (comval->is_object(Attribute::class_symid())) { return ((Attribute*)comval->obj_val())->Value(); } return nil; } ComValue& ComTerp::lookup_symval(int symid) { void* vptr = nil; if (localtable()->find(vptr, symid)) { ComValue* valptr = (ComValue*)vptr; return *valptr; } else return ComValue::nullval(); } ComValue& ComTerp::stack_top(int n) { if (_stack_top+n < 0 || _stack_top+n >= _stack_siz) { return ComValue::blankval(); } else return _stack[_stack_top+n]; } ComValue& ComTerp::pop_symbol() { ComValue& stacktop = _stack[_stack_top--]; if (stacktop.type() == ComValue::SymbolType) return stacktop; else return ComValue::nullval(); } void ComTerp::clear_top_commands() { delete _top_commands; _top_commands = nil; } int ComTerp::add_command(const char* name, ComFunc* func, const char* alias, const char* docstring2) { int symid = symbol_add((char *)name); if(docstring2) func->docstring2(docstring2); if (!_top_commands) _top_commands = new AttributeValueList(); _top_commands->Append(new AttributeValue(symid, AttributeValue::SymbolType)); func->funcid(symid); ComValue* comval = new ComValue(); comval->type(ComValue::CommandType); comval->obj_ref() = (void*)func; comval->command_symid(symid); localtable()->insert(symid, comval); if (alias) { int alias_symid = symbol_add((char *)alias); ComValue* aliasval = new ComValue(); aliasval->type(ComValue::CommandType); aliasval->obj_ref() = (void*)func; aliasval->command_symid(alias_symid, true /* alias */); localtable()->insert(symid, aliasval); } return symid; } ComTerp& ComTerp::instance() { if (!_instance) ComTerp* comterp = new ComTerp(); return *_instance; } void ComTerp::quit(boolean quitflag) { _quitflag = quitflag; } void ComTerp::exit(int status) { _exit( status ); } boolean ComTerp::quitflag() { return _quitflag; } void ComTerp::quitflag(boolean flag) { _quitflag = flag; } int ComTerp::run(boolean one_expr, boolean nested) { int old_runflag = running(); running(true); int status = 1; _errbuf[0] = '\0'; char errbuf_save[BUFSIZ]; errbuf_save[0] = '\0'; #if __GNUC__<3 filebuf fbuf; if (handler()) { int fd = Math::max(1, handler()->get_handle()); fbuf.attach(fd); } else fbuf.attach(fileno(stdout)); #elif (__GNUC__==3 && __GNUC_MINOR__<1) || __GNUC__>3 || defined(__CYGWIN__) fileptr_filebuf fbuf(handler() && handler()->wrfptr() ? handler()->wrfptr() : (_fd>0 ? fdopen(_fd, "w") : stdout), ios_base::out); #else fileptr_filebuf fbuf(handler()&&handler()->get_handle()>0 ? handler()->get_handle() : 1, ios_base::out, false, static_cast(BUFSIZ)); #endif ostream out(&fbuf); boolean eolflag = false; boolean errorflag = false; while (!eof() && !quitflag() && !eolflag) { if (read_expr()) { status = 0; int top_before = _stack_top; eval_expr(nested); if (top_before == _stack_top) status = 2; err_str( _errbuf, BUFSIZ, "comterp" ); errno = 0; if (strlen(_errbuf)==0) { if (quitflag()) { status = -1; break; } else if (!func_for_next_expr() && val_for_next_func().is_null() && muted()!=1) { if (stack_top().is_stream() && autostream()) { ComValue streamv(stack_top()); do { pop_stack(); NextFunc::execute_impl(this, streamv); if (stack_top().is_known()) { print_stack_top(out); out << "\n"; out.flush(); } } while (stack_top().is_known()); } else { print_stack_top(out); out << "\n"; out.flush(); } } } else { out << _errbuf << "\n"; out.flush(); strcpy(errbuf_save, _errbuf); _errbuf[0] = '\0'; } } else { err_str( _errbuf, BUFSIZ, "comterp" ); if (strlen(_errbuf)>0) { errorflag = true; out << _errbuf << "\n"; out.flush(); strcpy(errbuf_save, _errbuf); _errbuf[0] = '\0'; } else { eolflag = true; if (errbuf_save[0]) strcpy(_errbuf, errbuf_save); } } if (!nested) decr_stack(_stack_top+1); if (one_expr) break; } if (status==1 && _pfnum==0) status=2; if (status==1 && !errorflag) status=3; #if 0 // has to be dealt with a different way if (nested && status!=2) pop_stack(); #endif if (errno == EPIPE) { status = -1; fprintf(stderr, "broken pipe detected: comterp quit\n"); } running(old_runflag); return status; } void ComTerp::add_defaults() { if (!_defaults_added) { _defaults_added = true; add_command("nil", new NilFunc(this)); add_command("char", new CharFunc(this)); add_command("short", new ShortFunc(this)); add_command("int", new IntFunc(this)); add_command("long", new LongFunc(this)); add_command("float", new FloatFunc(this)); add_command("double", new DoubleFunc(this)); add_command("add", new AddFunc(this)); add_command("sub", new SubFunc(this)); add_command("minus", new MinusFunc(this)); add_command("mpy", new MpyFunc(this)); add_command("div", new DivFunc(this)); add_command("mod", new ModFunc(this)); add_command("min", new MinFunc(this)); add_command("max", new MaxFunc(this)); add_command("abs", new AbsFunc(this)); add_command("assign", new AssignFunc(this)); add_command("mod_assign", new ModAssignFunc(this)); add_command("mpy_assign", new MpyAssignFunc(this)); add_command("add_assign", new AddAssignFunc(this)); add_command("sub_assign", new SubAssignFunc(this)); add_command("div_assign", new DivAssignFunc(this)); add_command("incr", new IncrFunc(this)); add_command("incr_after", new IncrAfterFunc(this)); add_command("decr", new DecrFunc(this)); add_command("decr_after", new DecrAfterFunc(this)); add_command("bit_and", new BitAndFunc(this)); add_command("bit_xor", new BitXorFunc(this)); add_command("bit_or", new BitOrFunc(this)); add_command("bit_not", new BitNotFunc(this)); add_command("nand", new BitNandFunc(this)); add_command("xnor", new BitXnorFunc(this)); add_command("nor", new BitNorFunc(this)); add_command("lshift", new LeftShiftFunc(this)); add_command("rshift", new RightShiftFunc(this)); add_command("and", new AndFunc(this)); add_command("or", new OrFunc(this)); add_command("negate", new NegFunc(this)); add_command("eq", new EqualFunc(this)); add_command("not_eq", new NotEqualFunc(this)); add_command("gt", new GreaterThanFunc(this)); add_command("gt_or_eq", new GreaterThanOrEqualFunc(this)); add_command("lt", new LessThanFunc(this)); add_command("lt_or_eq", new LessThanOrEqualFunc(this)); add_command("stream", new StreamFunc(this)); add_command("concat", new ConcatFunc(this)); add_command("repeat", new RepeatFunc(this)); add_command("iterate", new IterateFunc(this)); add_command("next", new NextFunc(this)); add_command("each", new EachFunc(this)); add_command("filter", new FilterFunc(this)); add_command("dot", new DotFunc(this)); add_command("attrname", new DotNameFunc(this)); add_command("attrval", new DotValFunc(this)); add_command("list", new ListFunc(this)); add_command("at", new ListAtFunc(this)); add_command("size", new ListSizeFunc(this)); add_command("tuple", new TupleFunc(this)); add_command("index", new ListIndexFunc(this)); add_command("sum", new SumFunc(this)); add_command("mean", new MeanFunc(this)); add_command("var", new VarFunc(this)); add_command("stddev", new StdDevFunc(this)); add_command("rand", new RandFunc(this)); add_command("srand", new SRandFunc(this)); add_command("exp", new ExpFunc(this)); add_command("log", new LogFunc(this)); add_command("log10", new Log10Func(this)); add_command("pow", new PowFunc(this)); add_command("acos", new ACosFunc(this)); add_command("asin", new ASinFunc(this)); add_command("atan", new ATanFunc(this)); add_command("atan2", new ATan2Func(this)); add_command("cos", new CosFunc(this)); add_command("sin", new SinFunc(this)); add_command("tan", new TanFunc(this)); add_command("sqrt", new SqrtFunc(this)); add_command("pi", new PiFunc(this)); add_command("radtodeg", new RadToDegFunc(this)); add_command("degtorad", new DegToRadFunc(this)); add_command("floor", new FloorFunc(this)); add_command("ceil", new CeilFunc(this)); add_command("round", new RoundFunc(this)); add_command("xform", new XformFunc(this)); add_command("invert", new InvertXformFunc(this)); add_command("xpose", new XposeFunc(this)); add_command("cond", new CondFunc(this)); add_command("seq", new SeqFunc(this)); add_command("run", new RunFunc(this)); add_command("help", new HelpFunc(this)); add_command("optable", new OptableFunc(this)); add_command("trace", new ComterpTraceFunc(this)); add_command("pause", new ComterpPauseFunc(this)); add_command("step", new ComterpStepFunc(this)); add_command("stackheight", new ComterpStackHeightFunc(this)); add_command("symid", new SymIdFunc(this)); add_command("symval", new SymValFunc(this)); add_command("symbol", new SymbolFunc(this)); add_command("symadd", new SymAddFunc(this)); add_command("symvar", new SymVarFunc(this)); add_command("symstr", new SymStrFunc(this)); add_command("strref", new StrRefFunc(this)); add_command("global", new GlobalSymbolFunc(this)); add_command("split", new SplitStrFunc(this)); add_command("join", new JoinStrFunc(this)); add_command("substr", new SubStrFunc(this)); add_command("type", new TypeSymbolFunc(this)); add_command("class", new ClassSymbolFunc(this)); add_command("bquote", new BackQuoteFunc(this)); add_command("postfix", new PostFixFunc(this)); add_command("posteval", new PostEvalFunc(this)); add_command("if", new IfThenElseFunc(this)); add_command("for", new ForFunc(this)); add_command("while", new WhileFunc(this)); add_command("switch", new SwitchFunc(this)); add_command("open", new OpenFileFunc(this)); add_command("close", new CloseFileFunc(this)); add_command("print", new PrintFunc(this)); add_command("gets", new GetStringFunc(this)); add_command("usleep", new USleepFunc(this)); #ifdef HAVE_ACE add_command("timeexpr", new TimeExprFunc(this)); #endif add_command("eval", new EvalFunc(this)); add_command("shell", new ShellFunc(this)); add_command("quit", new QuitFunc(this)); add_command("exit", new ExitFunc(this)); add_command("mute", new MuteFunc(this)); add_command("empty", new EmptyFunc(this)); add_command("ctoi", new CtoiFunc(this)); add_command("isspace", new IsSpaceFunc(this)); add_command("isdigit", new IsDigitFunc(this)); add_command("isalpha", new IsAlphaFunc(this)); add_command("arg", new GetArgFunc(this)); add_command("narg", new NumArgFunc(this)); add_command("continue", new ContinueFunc(this)); add_command("break", new BreakFunc(this)); add_command("func", new FuncObjFunc(this)); } } void ComTerp::set_attributes(AttributeList* alist) { Unref(_alist); _alist = alist; Resource::ref(_alist); } AttributeList* ComTerp::get_attributes() { return _alist;} int ComTerp::runfile(const char* filename, boolean popen_flag) { int old_runflag = running(); running(true); /* save tokens to restore after the file has run */ int toklen; postfix_token* tokbuf = copy_postfix_tokens(toklen); int tokoff = _pfoff; /* swap in input pointer and function */ push_servstate(); FILE* fptr = popen_flag ? popen(filename, "r") : fopen(filename, "r"); _inptr = fptr; _outfunc = nil; if (!fptr) cerr << "unable to run from file " << filename << "\n"; ComValue* retval = nil; int status = 0; while( fptr && !feof(fptr)) { if (read_expr()) { if (eval_expr(true)) { err_print( stderr, "comterp" ); fileptr_filebuf obuf(stdout, ios_base::out); ostream ostr(&obuf); ostr << "err\n"; ostr.flush(); status = -1; } else if (quitflag()) { status = 1; break; } else { /* save last thing on stack */ retval = new ComValue(pop_stack()); } } } if (popen_flag) pclose(fptr); else fclose(fptr); pop_servstate(); load_postfix(tokbuf, toklen, tokoff); delete tokbuf; if (retval) { push_stack(*retval); delete retval; } else push_stack(ComValue::nullval()); running(old_runflag); return status; } ComterpHandler* ComTerp::handler() { return _handler; } void ComTerp::handler(ComterpHandler* handler) { _handler = handler; } void ComTerp::load_postfix(postfix_token* tokens, int toklen, int tokoff) { if (toklen>_pfsiz) { _pfsiz *= 2; dmm_realloc_size(sizeof(postfix_token)); if( dmm_realloc( (void **)&_pfbuf, (long)_pfsiz )) { cerr << "error in reallocing pfbuf in Parser::load_postfix_tokens"; return; } } for (int i=0; i=64) { rowcnt = 0; out << "\n"; } else #if 0 out << "\t"; #else for(int t=0; t<=tlen; t++) out << ' '; #endif } delete funcids; } } int* ComTerp::get_commands(int& ncomm, boolean sort) { TableIterator(ComValueTable) i(*localtable()); int bufsiz = 256; int* buffer = new int[bufsiz]; ncomm = 0; int opercnt = 0; while (i.more()) { int key = i.cur_key(); ComValue* value = (ComValue*)i.cur_value(); if (value->is_type(AttributeValue::CommandType)) { const char* command_name = symbol_pntr(key); int opid = opr_tbl_opstr(key); const char* operator_name = symbol_pntr(opr_tbl_operid(opid)); if (operator_name) { key = opr_tbl_operid(opid); opercnt++; } if (ncomm==bufsiz) { int* newbuf = new int[bufsiz*2]; for (int j=0; j")!=0 && strcmp(str,"<<>>")!=0 && *str!='\'') // for ipl ISA support sortedbuffer[i++] = buffer[j]; } if (i != opercnt) cerr << "bad number of operators\n"; for (j=0; j 0); } sortedbuffer[count] = buffer[j]; } delete buffer; /* one more pass over the sorted buffer to remove duplicates */ int copydist = 0; for (j=0; jfind(vptr, symid); return (ComValue*)vptr; } else return &ComValue::unkval(); } ComValue* ComTerp::globalvalue(int symid) { ComValueTable* table = globaltable(); if (table) { void* vptr = nil; table->find(vptr, symid); return (ComValue*)vptr; } else return &ComValue::unkval(); } extern int _continuation_prompt_disabled; // from ComUtil/parser.c void ComTerp::disable_prompt() { _continuation_prompt_disabled = 1; } void ComTerp::enable_prompt() { _continuation_prompt_disabled = 0; } ComFuncState* ComTerp::top_funcstate() { return _fsstack_top < 0 ? nil : _fsstack+_fsstack_top; } void ComTerp::pop_funcstate() { if (_fsstack_top >=0) _fsstack_top--; } void ComTerp::push_funcstate(ComFuncState& funcstate) { if (_fsstack_top+1 == _fsstack_siz) { _fsstack_siz *= 2; dmm_realloc_size(sizeof(ComFuncState)); if(dmm_realloc((void**)&_fsstack, (unsigned long)_fsstack_siz) != 0) { KANRET("error in call to dmm_realloc"); return; } } _fsstack_top++; ComFuncState* sfs = _fsstack + _fsstack_top; *sfs = ComFuncState(funcstate); } void ComTerp::func_for_next_expr(ComFunc* func) { if (!_func_for_next_expr) _func_for_next_expr = func; } ComFunc* ComTerp::func_for_next_expr() { return _func_for_next_expr; } void ComTerp::val_for_next_func(ComValue& val) { if (_val_for_next_func) { delete _val_for_next_func; } _val_for_next_func = new ComValue(val); } ComValue& ComTerp::val_for_next_func() { if (_val_for_next_func) { return *_val_for_next_func; } else return ComValue::nullval(); } void ComTerp::clr_val_for_next_func() { delete _val_for_next_func; _val_for_next_func = nil; } ComTerpState* ComTerp::top_servstate() { return _ctsstack_top < 0 ? nil : _ctsstack+_ctsstack_top; } void ComTerp::pop_servstate() { if (_ctsstack_top >=0) { ComTerpState* cts_state = top_servstate(); /* clean up */ delete _buffer; delete _pfbuf; delete [] _pfcomvals; /* restore copies of everything */ _pfbuf = cts_state->pfbuf(); _pfsiz = cts_state->pfsiz(); _pfnum = cts_state->pfnum(); _pfoff = cts_state->pfoff(); _bufptr = cts_state->bufptr(); _linenum = cts_state->linenum(); // _just_reset = cts_state->just_reset(); _buffer = cts_state->buffer(); _pfcomvals = cts_state->pfcomvals(); _infunc = cts_state->infunc(); _eoffunc = cts_state->eoffunc(); _errfunc = cts_state->errfunc(); _inptr = cts_state->inptr(); _alist = cts_state->alist(); _ctsstack_top--; } } void ComTerp::push_servstate() { ComTerpState cts_state; /* save copies of everything */ cts_state.pfbuf() = _pfbuf; cts_state.pfsiz() = _pfsiz; cts_state.pfnum() = _pfnum; cts_state.pfoff() = _pfoff; cts_state.bufptr() = _bufptr; cts_state.linenum() = _linenum; // cts_state.just_reset() = _just_reset; cts_state.buffer() = _buffer; cts_state.pfcomvals() = _pfcomvals; cts_state.infunc() = _infunc; cts_state.eoffunc() = _eoffunc; cts_state.errfunc() = _errfunc; cts_state.inptr() = _inptr; cts_state.alist() = _alist; /* re-initialize */ if(dmm_calloc((void**)&_pfbuf, _pfsiz, sizeof(postfix_token)) != 0) KANRET("error in call to dmm_calloc"); _pfnum = _pfoff = 0; _buffer = new char[_bufsiz]; _bufptr = 0; _linenum = 0; // _just_reset = false; _pfcomvals = nil; if (_ctsstack_top+1 == _ctsstack_siz) { _ctsstack_siz *= 2; dmm_realloc_size(sizeof(ComTerpState)); if(dmm_realloc((void**)&_ctsstack, (unsigned long)_ctsstack_siz) != 0) { KANRET("error in call to dmm_realloc"); return; } } _ctsstack_top++; ComTerpState* ctss = _ctsstack + _ctsstack_top; *ctss = cts_state; } boolean ComTerp::stack_empty() { return _stack_top<0; } void ComTerp::postfix_echo() { if (!_echo_postfix) return; postfix_echo(_pfbuf, _pfnum); } void ComTerp::postfix_echo(postfix_token* pfbuf, int pfnum) { // print everything in the pfbuf for this function fileptr_filebuf fbuf(handler() && handler()->wrfptr() ? handler()->wrfptr() : stdout, ios_base::out); ostream out(&fbuf); boolean oldbrief = brief(); brief(true); ComValue val; for (int i=0; i= TOK_RPAREN )) { if (!_detail_matched_delims) { out << "[" << val.narg() << "|" << val.nkey() << "]"; ComFunc* func = (ComFunc*)val.obj_val(); if (func->post_eval()) out << "*"; } else { char ldelim, rdelim; boolean dbldelim = 0; if (val.nids()==TOK_RPAREN) {ldelim = '('; rdelim = ')'; } else if (val.nids()==TOK_RBRACKET) {ldelim = '['; rdelim = ']'; } else if (val.nids()==TOK_RBRACE) {ldelim = '{'; rdelim = '}'; } else if (val.nids()==TOK_RANGBRACK) {ldelim = '<'; rdelim = '>'; } else if (val.nids()==TOK_RANGBRACK2) {ldelim = '<'; rdelim = '>'; dbldelim=1;} else {ldelim = ':'; rdelim = 0x0;}; out << ldelim; if (dbldelim) out << ldelim; out << val.narg(); if (rdelim) { out << rdelim; if (dbldelim) out << rdelim; } } } else if (val.is_type(AttributeValue::SymbolType) && (val.narg() || val.nkey())) out << "{" << val.narg() << "|" << val.nkey() << "}"; else if (val.is_type(AttributeValue::KeywordType)) out << "(" << val.keynarg_val() << ")"; out << ((i==pfnum-1) ? "\n" : " "); } brief(oldbrief); } int ComTerp::arg_str(int n) { if (n<0 || n>_narg_strs) return -1; return _arg_strs ? _arg_strs[n] : nil; } int ComTerp::narg_str() { return _narg_strs; } void ComTerp::set_args(int argc, char** argv) { if (_arg_strs) delete _arg_strs; _narg_strs = argc; _arg_strs = new int[_narg_strs]; for (int i=0; i<_narg_strs; i++) _arg_strs[i] = symbol_add(argv[i]); return; } void ComTerp::set_args(const char* argstr) { int argc = 0; const char* argptr = argstr; char buffer[BUFSIZ]; int bufoff = 0; while (*argptr) { while(*argptr && isspace(*argptr)) argptr++; if (!*argptr) break; while (*argptr && !isspace(*argptr) && bufoff #include declareTable(ComValueTable,int,void*) class AttributeList; class AttributeValue; class AttributeValueList; class ComFunc; class ComFuncState; class ComTerpState; class ComValue; #include class ComterpHandler; //: extendable command interpreter. // ComTerp is an extendable command interpreter with a simple C-like expression // syntax and support for commands with fixed-location and keyword-prefixed // arguments. The underlying architecture of this interpreter is patterned // after Fischer and LeBlanc's "Crafting a Compiler with C", with their pipeline // of scanner --> parser --> code_conversion --> code_generation retrofitted into // one of scanner --> parser --> code_conversion --> interpreter. //

// You use a ComTerp by first constructing one with a default set of commands // and operators, then add any commands (derived ComFunc objects) needed for a // particular application, then start it running on either stdin or // some alternate input file described by arguments to the constructor. // To embed a ComTerp in another application you'll probably want to use // a ComTerpServ, which has extensions to ComTerp for passing input and output // strings from/to the interpreter by buffers. class ComTerp : public Parser { public: ComTerp(); // construct with default set of ComFunc objects. ComTerp(const char* path); // construct and run on commands read from 'path'. ComTerp(void*, char*(*)(char*,int,void*), int(*)(void*), int(*)(void*)); // construct with IO system based on a void* pointer and three function // pointers to receive that void* as their first argument, with // signatures that match fgets, feof, and ferror. ~ComTerp(); void init(); // initialize memory for the regular stack, the ComFuncState stack, // and the symbol tables. boolean read_expr(); // read expression from the input, return true if all ok. boolean eof(); // return true when end-of-file found on the input. void increment_linenum(); // increment line number when empty line is read virtual int eval_expr(boolean nested=false); // evaluate topmost expression on the stack, with a flag to // indicate if this call to eval_expr() is nested inside // another, so that initialization doesn't get repeated. virtual int eval_expr(ComValue* pfvals, int npfvals); // evaluate postfix expression stored in ComValue objects. virtual int post_eval_expr(int tokcnt, int offtop, int pedepth #ifdef POSTEVAL_EXPERIMENT , int nolookup=false #endif ); // copy unevaluated expression to the stack and evaluate. void print_post_eval_expr(int tokcnt, int offtop, int pedepth); // print unevaluated expression postfix_token* copy_post_eval_expr(int tokcnt, int offtop); // copy unevaluated expression boolean top_expr(); // return true if the topmost expression is currently being evaluated int print_stack_top() const; // print the top of the stack to stdout. int print_stack_top(ostream& out) const; // print the top of the stack to an ostream. int print_stack() const; // print the entire stack to stdout. int stack_height() { return _stack_top+1; } // return current height of the stack. boolean brief() const; // return brief mode flag. void brief(boolean flag) { _brief = flag; } // set brief mode flag. int add_command(const char* name, ComFunc*, const char* alias = nil, const char* docstring2 = nil); // add a derived ComFunc to be known by 'name'. void list_commands(ostream& out, boolean sorted = false); // print an optionally sorted list of commands to an ostream. int* get_commands(int &ncommands, boolean sorted = false); // return an optionally sorted list of command names. ComValue pop_stack(boolean lookupsym=true); // return a reference (on the stack) to what was the top of the stack, // if 'lookupsym' is false, don't look up ComValue objects in // the local or global symbol table to replace a symbol, just // return the symbol itself. ComValue& lookup_symval(ComValue&); // look up a ComValue associated with a symbol (specified in the // input ComValue) in the local or global symbol tables. AttributeValue* lookup_symval(ComValue*); // look up a pointer to an AttributeValue associated with a symbol // (specified in the input ComValue) in the local or global symbol // tables. Do not alter the input ComValue. ComValue& lookup_symval(int symid); // look up a ComValue associated with a symbol (specified with a // symbol id) in the local or global symbol tables. ComValue& stack_top(int n=0); // return reference to top of the stack, offset by 'n' (usually negative). ComValue& pop_symbol(); // return a reference (on the stack) to what was the top of the stack, void push_stack(ComValue&); // copy the state of a ComValue onto the stack, incrementing the // reference count of any AttributeValueList, otherwise replicating data. void push_stack(AttributeValue&); // copy the state of an AttributeValue into a ComValue on the stack, // incrementing the reference count of any AttributeValueList, // otherwise replicating data. boolean stack_empty(); ComValue& expr_top(int n=0); // top of currently evaluating expression buffer. static ComTerp& instance(); // instance of ComTerp for global use. void quit(boolean quitflag=true); // set flag that will cause a quit to happen as soon as possible. void quitflag(boolean flag); // set flag that will cause a quit to happen as soon as possible. boolean quitflag(); // return value of flag that will cause a quit to happen as soon as possible. virtual void exit(int status=0); // call _exit(). virtual int run(boolean one_expr=false, boolean nested=false); // run interpreter until end-of-file or quit command, unless // 'one_expr' is true. Leave 'one_expr' false when using a ComTerpServ. // Return Value: -1 if eof, 0 if normal operation, 1 if // partial expression parsed, 2 if no result computed, 3 if error in parsing. // 'nested' indicates contents of stack should be preserved. virtual int runfile(const char* filename, boolean popen_flag=0); // run interpreter on contents of 'filename'. void add_defaults(); // add default commands (ComFunc objects). ComValueTable* localtable() const { return _localtable; } // local symbol table associated with an individual ComTerp. ComValueTable* globaltable() const { if (!_globaltable) _globaltable = new ComValueTable(100); return _globaltable; } // global symbol table associated with every ComTerp. ComValue* localvalue(int symid); // value associated with a symbol id in the local symbol table. ComValue* globalvalue(int symid); // value associated with a symbol id in the global symbol table. ComValue* eithervalue(int symid, boolean globalfirst=false); // value associated with a symbol id in either symbol table. const char* errmsg() { return _errbuf; } // current error message buffer. void set_attributes(AttributeList*); // set AttributeList to be used as an additional local symbol table. AttributeList* get_attributes(); // return pointer to AttributeList being used as an additional // local symbol table. void handler(ComterpHandler* h ); // set handler for invoking ComFunc execute methods. ComterpHandler* handler(); // return pointer to handler that can read_expressions from // a connection and interpret them. void disable_prompt(); // disable '>' prompting sent in response to an unfinished input expression. void enable_prompt(); // enable '>' prompting sent in response to an unfinished input expression. unsigned int& pfnum() { return _pfnum; } // number of arguments in the input postfix buffer of a tokenized // tree like expression ready to be evaluated, but not yet // converted to ComValue objects. virtual boolean is_serv() { return false; } // flag to test if ComTerp or ComTerpServ void func_for_next_expr(ComFunc* func); // set ComFunc to use on subsequent expression ComFunc* func_for_next_expr(); // get ComFunc to use on subsequent expression void val_for_next_func(ComValue& val); // set ComValue to pass to subequent command ComValue& val_for_next_func(); // get ComValue to pass to subequent command void clr_val_for_next_func(); // clear out ComValue to pass to subequent command unsigned int& linenum() { return _linenum; } // count of lines processed ComTerpState* top_servstate(); // return pointer to top state on ComTerpServ state stack void push_servstate(); // push ComTerpServ state for later retrieval void pop_servstate(); // pop ComTerpServ state that was saved earlier void trace_mode(int mode) { _trace_mode = mode; } // set trace mode int trace_mode() { return _trace_mode; } // return trace mode int& npause() { return _npause; } // return (reference to) number of pauses int& stepflag() { return _stepflag; } // return flag that controls stepwise execution void echo_postfix(boolean flag) { _echo_postfix = flag; } // set flag that indicates whether to echo postfix or not boolean echo_postfix() const { return _echo_postfix; } // return flag that indicates whether to echo contents of postfix buffer void postfix_echo(); // echo the postfix tokens void postfix_echo(postfix_token* pfbuf, int pfnum); // echo the postfix tokens void delim_func(boolean flag) { _delim_func = flag; } // set flag that indicates whether to run a delimeter selected func. boolean delim_func() const { return _delim_func; } // return flag that indicates whether to run a delimeter selected func. void ignore_commands(boolean flag) { _ignore_commands = flag; } // set flag that indicates whether to ignore all built-in commands boolean ignore_commands() const { return _ignore_commands; } // return flag that indicates whether to ignore all built-in commands void autostream(boolean flag) { _autostream = flag; } // set flag that indicates whether to run a delimeter selected func. boolean autostream() const { return _autostream; } // return flag that indicates whether to run a delimeter selected func. void running(boolean flag) { _running = flag; } // set flag that indicates whether to run a delimeter selected func. boolean running() const { return _running; } // return flag that indicates whether to run a delimeter selected func. void muted(boolean flag) { _muted = flag; } // set flag that indicates whether to mute output boolean muted() const { return _muted; } // return flag that indicates whether to mute output void force_nested(boolean flag) { _force_nested = flag; } // set flag to ensure subsequent calls are nested boolean force_nested() { return _force_nested; } // get flag to ensure subsequent calls are nested int arg_str(int n); // return nth command line argument int narg_str(); // return number of command line argument void set_args(int argc, char** argv); // set command line arguments void set_args(const char* argstr); // set command line arguments void clear_top_commands(); // clear list used to collect list of top-level commands AttributeValueList* top_commands() { return _top_commands; } // list of top-most commands for this derived interpreter protected: void incr_stack(); void incr_stack(int n); void decr_stack(int n=1); boolean skip_func(ComValue* topval, int& offset, int offlimit); boolean skip_key(ComValue* topval, int& offset, int offlimit, int& argcnt); boolean skip_arg(ComValue* topval, int& offset, int offlimit, int& argcnt); void push_stack(postfix_token*); void token_to_comvalue(postfix_token*, ComValue*); const ComValue* stack(unsigned int &top) const; void load_sub_expr(); void load_postfix(postfix_token*, int toklen, int tokoff); void eval_expr_internals(int pedepth=0); ComFuncState* top_funcstate(); // return top ComFuncState on stack virtual void push_funcstate(ComFuncState& funcstate); // push ComFuncState onto stack virtual void pop_funcstate(); // pop ComFuncState off stack ComValue* _stack; // stack of multi-value objects, central to the interpreter int _stack_top; // current top of stack, -1 indicates empty unsigned int _stack_siz; // current maximum stack size boolean _quitflag; // flag that can be set to terminate interpreter char* _errbuf; // buffer used for rendering error messages char* _errbuf2; // ancillary buffer for rendering error messages int _pfoff; // current offset in _pfbuf boolean _brief; // when used to produce ComValue output boolean _just_reset; // flag that gets set after call to ::reset_stack() boolean _defaults_added; // flag for base set of commands added ComValueTable* _localtable; // per interpreter symbol table static ComValueTable* _globaltable; // interpreter shared symbol table AttributeList* _alist; // extends symbol tables with names in an AttributeList ComFuncState* _fsstack; // stack of func-status (nargs/nkeys/...) int _fsstack_top; unsigned int _fsstack_siz; ComTerpState* _ctsstack; // stack of ComTerpServ state int _ctsstack_top; unsigned int _ctsstack_siz; ComValue* _pfcomvals; // postfix buffer of ComValue's converted from postfix_token static ComTerp* _instance; // default instance of a ComTerp ComterpHandler* _handler; // I/O handler for this ComTerp. ComFunc* _func_for_next_expr; // ComFunc to run on next expression ComValue* _val_for_next_func; // ComValue to pass to next command int _trace_mode; // trace mode int _npause; // depth of pause int _stepflag; // true if single-stepping interpreter boolean _echo_postfix; // echos postfix tokens if true boolean _delim_func; // use delimeter selected func, passing symbol in ::command_symid() boolean _ignore_commands; // ignore any built-in commands. boolean _autostream; // automatically iterates over stream if left on stack boolean _running; // flag to inform others this ComTerp in use boolean _muted; // flag to mute any response from a ComTerp boolean _force_nested; // flag to ensure subsequent calls are nested int _fd; // handle for I/O int* _arg_strs; // array of string ids for command line arguments int _narg_strs; // size of array of string ids for command line arguments AttributeValueList* _top_commands; // list of top-most commands for this derived comterp friend class ComFunc; friend class ComterpHandler; friend class ComTerpIOHandler; }; //: object for holding ComTerp state // object that holds the state of a ComTerp // which allows for nested and recursive use of a singular ComTerp class ComTerpState { public: ComTerpState() {} ComTerpState(ComTerpState& ctss) { *this = ctss; } // copy constructor. postfix_token*& pfbuf() { return _pfbuf; } int& pfsiz() { return _pfsiz;; } int& pfnum() { return _pfnum; } int& pfoff() { return _pfoff; } int& bufptr() { return _bufptr; } int& bufsiz() { return _bufsiz; } int& linenum() { return _linenum; } // int& just_reset() { return _just_reset; } char*& buffer() { return _buffer; } ComValue*& pfcomvals() { return _pfcomvals; } infuncptr& infunc() { return _infunc; } eoffuncptr& eoffunc() { return _eoffunc; } errfuncptr& errfunc() { return _errfunc; } void*& inptr() { return _inptr; } AttributeList*& alist() { return _alist; } protected: postfix_token* _pfbuf; int _pfsiz; int _pfnum; int _pfoff; int _bufptr; int _linenum; // int _just_reset; char* _buffer; int _bufsiz; ComValue* _pfcomvals; infuncptr _infunc; eoffuncptr _eoffunc; errfuncptr _errfunc; void* _inptr; AttributeList* _alist; }; #endif /* !defined(_comterp_h) */ ivtools-1.2.11a1/src/ComTerp/comterpserv.cc000066400000000000000000000320341214471147700205470ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #if __GNUC__>=3 #include #endif #if BUFSIZ>1024 #undef BUFSIZ #define BUFSIZ 1024 #endif // #define TIMING_TEST #if defined(TIMING_TEST) #include #include #include #include /* Return 1 if the difference is negative, otherwise 0. */ int timeval_subtract(struct timeval *result, struct timeval *t2, struct timeval *t1) { long int diff = (t2->tv_usec + 1000000 * t2->tv_sec) - (t1->tv_usec + 1000000 * t1->tv_sec); result->tv_sec = diff / 1000000; result->tv_usec = diff % 1000000; return (diff<0); } /* Return 1 if the sum is negative, otherwise 0. */ int timeval_add(struct timeval *result, struct timeval *t2, struct timeval *t1) { long int sum = (t2->tv_usec + 1000000 * t2->tv_sec) + (t1->tv_usec + 1000000 * t1->tv_sec); result->tv_sec = sum / 1000000; result->tv_usec = sum % 1000000; return (sum<0); } void timeval_print(struct timeval *tv) { char buffer[30]; time_t curtime; printf("%ld.%06ld\n", tv->tv_sec, tv->tv_usec); curtime = tv->tv_sec; #if 0 strftime(buffer, 30, "%m-%d-%Y %T", localtime(&curtime)); printf(" = %s.%06ld\n", buffer, tv->tv_usec); #endif } #endif /* defined(TIMING_TEST) */ ComTerpServ::ComTerpServ(int linesize, int fd) : ComTerp() { _linesize = linesize; _instr = new char[_linesize]; _outstr = new char[_linesize]; _inptr = this; _infunc = (infuncptr)&ComTerpServ::s_fgets; _eoffunc = (eoffuncptr)&ComTerpServ::s_feof; _errfunc = (errfuncptr)&ComTerpServ::s_ferror; _outptr = this; _outfunc = (outfuncptr)&ComTerpServ::s_fputs; _fd = fd; _outpos = 0; if (_fd>=0) _fptr = fdopen(_fd, "rw"); else _fptr = stdin; #ifdef HAVE_ACE _handler = nil; #endif /* inform the parser which infunc is the oneshot infunc */ _oneshot_infunc = (infuncptr)&s_fgets; /* initialize shadow copy too */ __oneshot_infunc = (infuncptr)&s_fgets; _logger_mode = 0; _delete_later = 0; } ComTerpServ::~ComTerpServ() { delete [] _instr; delete [] _outstr; if (_fptr != stdin) fclose(_fptr); } void ComTerpServ::load_string(const char* expr) { _inpos = 0; /* copy string into buffer, ensuring it ends with a newline */ int count=0; char* inptr = _instr; char* exptr = (char*) expr; char ch; do { ch = *exptr++; *inptr++ = ch; } while (ch && count++<_linesize-2); if (!ch && count>0 && *(inptr-2) != '\n') { *(inptr-1) = '\n'; *(inptr) = '\0'; } else if (count==_linesize-2) { *(inptr) = '\n'; *(inptr+1) = '\0'; } } char* ComTerpServ::s_fgets(char* s, int n, void* serv) { ComTerpServ* server = (ComTerpServ*)serv; char* instr = server->_instr; char* outstr = s; int& inpos = server->_inpos; int& linesize = server->_linesize; int outpos; /* copy characters until n-1 characters are transferred, */ /* the input buffer is exhausted, or a newline is found. */ for (outpos = 0; outpos < n-1 && inpos < linesize-1 && instr[inpos] != '\n' && instr[inpos] != '\0';) outstr[outpos++] = instr[inpos++]; /* copy the newline character if there is room */ if (outpos < n-1 && inpos < linesize-1 && instr[inpos] == '\n') outstr[outpos++] = instr[inpos++]; /* append a null byte */ outstr[outpos] = '\0'; return s; } int ComTerpServ::s_feof(void* serv) { ComTerpServ* server = (ComTerpServ*)serv; int& inpos = server->_inpos; return inpos == -1; } int ComTerpServ::s_ferror(void* serv) { return 0; } int ComTerpServ::s_fputs(const char* s, void* serv) { ComTerpServ* server = (ComTerpServ*)serv; char* outstr = server->_outstr; int& outpos = server->_outpos; int& linesize = server->_linesize; for (; outpos < linesize-1 && s[outpos]; outpos++) outstr[outpos] = s[outpos]; outstr[outpos] = '\0'; return 1; } char* ComTerpServ::fd_fgets(char* s, int n, void* serv) { ComTerpServ* server = (ComTerpServ*)serv; int fd = Math::max(server->_fd, 1); char instr[BUFSIZ]; FILE* ifptr = fd==0 ? stdin : server->handler()->rdfptr(); fileptr_filebuf fbuf(ifptr, ios_base::in); istream in (&fbuf); in.get(instr, BUFSIZ, '\n'); // needs to be generalized with server->_instat = in.good(); char* outstr = s; int inpos = 0; int& bufsize = server->_bufsiz; int outpos; /* copy characters until n-1 characters are transferred, */ /* or the input buffer is exhausted */ for (outpos = 0; outpos < n-1 && inpos < bufsize-1 && instr[inpos] != '\n' && instr[inpos] != '\0';) outstr[outpos++] = instr[inpos++]; /* add a newline character if there is room */ if (outpos < n-1 && inpos < bufsize-1) outstr[outpos++] = '\n'; /* append a null byte */ outstr[outpos] = '\0'; return s; } int ComTerpServ::fd_fputs(const char* s, void* serv) { ComTerpServ* server = (ComTerpServ*)serv; char* outstr = server->_outstr; int& outpos = server->_outpos; int& bufsize = server->_bufsiz; int fd = (int)server->_fd; FILE* ofptr = fd==1 ? stdout : server->handler()->wrfptr(); fileptr_filebuf fbuf(ofptr, ios_base::out); ostream out(&fbuf); for (; outpos < bufsize-1 && s[outpos]; outpos++) out.put(s[outpos]); out.flush(); outpos = 0; return 1; } int ComTerpServ::run(boolean one_expr, boolean nested) { char buffer[_linesize]; char errbuf[_linesize]; errbuf[0] = '\0'; int status = 0; _inptr = _fptr; _infunc = (infuncptr)&fgets; _eoffunc = (eoffuncptr)&ffeof; _errfunc = (errfuncptr)&fferror; _fd = handler() ? handler()->get_handle() : (_fd > 0 ? _fd : fileno(stdout)); _outfunc = (outfuncptr)&fd_fputs; _linenum = 0; ComTerp::run(one_expr, nested); _inptr = this; _infunc = (infuncptr)&ComTerpServ::s_fgets; _eoffunc = (eoffuncptr)&ComTerpServ::s_feof; _errfunc = (errfuncptr)&ComTerpServ::s_ferror; _outptr = this; _outfunc = (outfuncptr)&ComTerpServ::s_fputs; return status; } int ComTerpServ::runfile(const char* filename, boolean popen_flag) { /* save enough state as needed by this interpreter */ push_servstate(); _inptr = this; _infunc = (infuncptr)&ComTerpServ::s_fgets; _eoffunc = (eoffuncptr)&ComTerpServ::s_feof; _errfunc = (errfuncptr)&ComTerpServ::s_ferror; _outfunc = nil; _linenum = 0; _linesize = BUFSIZ*BUFSIZ; char inbuf[_linesize]; char outbuf[_linesize]; inbuf[0] = '\0'; FILE* ifptr = NULL; ifptr = popen_flag ? popen(filename, "r") : fopen(filename, "r"); if (!ifptr) { fprintf(stderr, "Unable to open file %s to run\n", filename); pop_servstate(); return -1; } fileptr_filebuf ibuf(ifptr, ios_base::in); istream istr(&ibuf); ComValue* retval = nil; int status = 0; /* save tokens to restore after the file has run */ int toklen; postfix_token* tokbuf = copy_postfix_tokens(toklen); int tokoff = _pfoff; int last_status = 0; while( istr.good()) { #if defined(TIMING_TEST) static struct timeval tvBefore, tvAfter, tvParse, tvConvert, tvDiff; #endif *inbuf='\0'; istr.getline(inbuf, _linesize-1); if (istr.eof() && !*inbuf) // deal with last line without new-line break; if (_linenum==0 && !*inbuf) { // run a dummy space in to initialize parser inbuf[0]=' '; inbuf[1]='\0'; } if (*inbuf) load_string(inbuf); else increment_linenum(); if (*inbuf && (last_status=read_expr())) { #if defined(TIMING_TEST) static int initialized=0; if (!initialized) { initialized = 1; gettimeofday(&tvBefore, NULL); gettimeofday(&tvAfter, NULL); timeval_subtract(&tvParse, &tvBefore, &tvBefore); timeval_subtract(&tvConvert, &tvBefore, &tvBefore); } gettimeofday(&tvAfter, NULL); timeval_subtract(&tvDiff, &tvAfter, &tvBefore); timeval_add(&tvParse, &tvDiff, &tvParse); tvBefore = tvAfter; fprintf(stderr, "Parse Time: "); timeval_print(&tvParse); #endif if (eval_expr(true)) { char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "comterp(%s)", filename); err_print( stderr, buf ); FILE* ofptr = handler() ? handler()->wrfptr() : stdout; fileptr_filebuf obuf(ofptr, ios_base::out); ostream ostr(&obuf); ostr.flush(); status = -1; } else if (quitflag()) { delete retval; retval = nil; // remove prior retval status = 1; break; } else if (!func_for_next_expr() && val_for_next_func().is_null() /* && muted()!=1 */) { #if defined(TIMING_TEST) gettimeofday(&tvAfter, NULL); timeval_subtract(&tvDiff, &tvAfter, &tvBefore); timeval_add(&tvConvert, &tvDiff, &tvConvert); tvBefore = tvAfter; fprintf(stderr, "Convert Time: "); timeval_print(&tvConvert); #endif if (stack_top().is_stream() && autostream()) { ComValue streamv(stack_top()); do { pop_stack(); NextFunc::execute_impl(this, streamv); } while (stack_top().is_known()); pop_stack(); } else { /* save last thing on stack */ if(retval) delete retval; retval = new ComValue(pop_stack()); } } } else if (*inbuf) { char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "comterp(%s)", filename); err_print( stderr, buf ); FILE* ofptr = handler() ? handler()->wrfptr() : stdout; fileptr_filebuf obuf(ofptr, ios_base::out); ostream ostr(&obuf); ostr.flush(); status = -1; } } if(last_status==0 && *inbuf) { COMERR_SET1( ERR_UNEXPECTED_EOF, _linenum ); *inbuf = '\0'; parser_reset(); } load_postfix(tokbuf, toklen, tokoff); delete tokbuf; ibuf.close(); if (ifptr) if(popen_flag) pclose(ifptr); else fclose(ifptr); if (retval) { push_stack(*retval); delete retval; } else if (!quitflag()) push_stack(ComValue::nullval()); pop_servstate(); return status; } ComValue ComTerpServ::run(const char* expression, boolean nested) { _errbuf[0] = '\0'; push_servstate(); _pfcomvals = nil; if (expression) { load_string(expression); _infunc = (infuncptr)&ComTerpServ::s_fgets; _eoffunc = (eoffuncptr)&ComTerpServ::s_feof; _errfunc = (errfuncptr)&ComTerpServ::s_ferror; _inptr = this; read_expr(); err_str(_errbuf, BUFSIZ, "comterp"); } int status; if (!*_errbuf) { status = eval_expr(nested); err_str(_errbuf, BUFSIZ, "comterp"); } pop_servstate(); return (*_errbuf || status!=FUNCOK) ? ComValue::nullval() : pop_stack(); } ComValue ComTerpServ::run(postfix_token* tokens, int ntokens) { _errbuf[0] = '\0'; push_servstate(); _pfbuf = copy_postfix_tokens(tokens, ntokens); _pfnum = ntokens; _pfoff = 0; eval_expr(/*nested=*/1); err_str(_errbuf, BUFSIZ, "comterp"); ComValue retval(*_errbuf ? ComValue::nullval() : pop_stack()); _pfbuf = nil; _pfnum = 0; _pfoff = 0; pop_servstate(); return retval; } postfix_token* ComTerpServ::gen_code(const char* script, int& ntoken) { push_servstate(); load_string(script); read_expr(); postfix_token* copied_tokens = copy_postfix_tokens(ntoken); pop_servstate(); return copied_tokens; } void ComTerpServ::read_string(const char* script) { load_string(script); read_expr(); } void ComTerpServ::add_defaults() { if (!_defaults_added) { ComTerp::add_defaults(); add_command("remote", new RemoteFunc(this)); add_command("socket", new SocketFunc(this)); add_command("eval", new EvalFunc(this)); } } ivtools-1.2.11a1/src/ComTerp/comterpserv.h000066400000000000000000000075651214471147700204240ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * ComTerpServ is a ComTerp with added ability to load its input from a buffer. */ #ifndef comterpserv_h #define comterpserv_h /* * Server-oriented interpreter deals with strings */ #ifdef HAVE_ACE #include #endif #include //: extended ComTerp that works with buffered IO. class ComTerpServ : public ComTerp { public: ComTerpServ(int bufsize = 1024/* *1024 */, int fd = -1); // construct with optional 'bufsize', and on an optional 'fd'. ~ComTerpServ(); void load_string(const char*); // load string to be interpreted into buffer. void read_string(const char*); // load string to be interpreted into buffer, and read postfix // tokens from it. postfix_token* gen_code(const char*, int& codelen); // generate buffer of length 'codelen' of postfix tokens ready // to be converted into ComValue objects and executed. virtual int run(boolean one_expr=false, boolean nested=false); // run this interpreter until quit or exit command. virtual ComValue run(const char*, boolean nested=false); // interpret and return value of expression. 'nested' flag used // to indicated nested call to the run() method, to avoid // re-initialization. virtual ComValue run(postfix_token*, int); // execute a buffer of postfix tokens and return the value. virtual int runfile(const char*, boolean popen_flag=0); // run interpreter on commands read from a file. void add_defaults(); // add a default list of ComFunc objects to this interpreter. virtual boolean is_serv() { return true; } // flag to test if ComTerp or ComTerpServ void delete_later(boolean flag) { _delete_later = flag; } boolean delete_later() { return _delete_later; } protected: static char* s_fgets(char* s, int n, void* serv); // signature like fgets used to copy input from a buffer. static int s_feof(void* serv); // signature like feof used to relay end-of-file. static int s_ferror(void* serv); // signature like ferror used to relay error info. static int s_fputs(const char* s, void* serv); // signature like fputs used to copy output back to buffer. static char* fd_fgets(char* s, int n, void* serv); // signature like fgets used to explicitly read from an filedescriptor. static int fd_fputs(const char* s, void* serv); // signature like fputs used to explicitly read from an filedescriptor. protected: int _linesize; char* _instr; int _inpos; char* _outstr; int _outpos; FILE* _fptr; int _instat; int _logger_mode; int _delete_later; friend class ComterpHandler; friend class ComTerpIOHandler; }; #endif ivtools-1.2.11a1/src/ComTerp/comvalue.cc000066400000000000000000000304711214471147700200140ustar00rootroot00000000000000/* * Copyright (c) 2001-2007 Scott E. Johnston * Copyright (c) 1994-1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include ComValue ComValue::_nullval; ComValue ComValue::_trueval(1, ComValue::BooleanType); ComValue ComValue::_falseval(0, ComValue::BooleanType); ComValue ComValue::_blankval(ComValue::BlankType); ComValue ComValue::_unkval(ComValue::UnknownType); ComValue ComValue::_oneval(1, ComValue::IntType); ComValue ComValue::_zeroval(0, ComValue::IntType); ComValue ComValue::_minusoneval(-1, ComValue::IntType); ComValue ComValue::_twoval(2, ComValue::IntType); /*****************************************************************************/ const ComTerp* ComValue::_comterp = nil; ComValue::ComValue(const ComValue& sv) { *this = sv; } ComValue::ComValue(ComValue* sv) { *this = *sv; dup_as_needed(); } ComValue::ComValue(AttributeValue& sv) { *(AttributeValue*)this = sv; zero_vals(); } ComValue::ComValue() { type(UnknownType); _command_symid = -1; zero_vals(); } ComValue::ComValue(ValueType valtype) { type(valtype); _command_symid = -1; zero_vals(); } ComValue::ComValue(unsigned char v) : AttributeValue(v) {zero_vals();} ComValue::ComValue(char v) : AttributeValue(v) {zero_vals();} ComValue::ComValue(unsigned short v) : AttributeValue(v) {zero_vals();} ComValue::ComValue(short v) : AttributeValue(v) {zero_vals();} ComValue::ComValue(unsigned int v, ValueType type) : AttributeValue(v, type) {zero_vals();} ComValue::ComValue(unsigned int kv, unsigned int kn, ValueType type) : AttributeValue(kv, kn, type) {zero_vals();} ComValue::ComValue(int v, ValueType type) : AttributeValue(v, type) {zero_vals();} ComValue::ComValue(unsigned long v) : AttributeValue(v) {zero_vals();} ComValue::ComValue(long v) : AttributeValue(v) {zero_vals();} ComValue::ComValue(float v) : AttributeValue(v) {zero_vals();} ComValue::ComValue(double v) : AttributeValue(v) {zero_vals();} ComValue::ComValue(int classid, void* ptr) : AttributeValue(classid, ptr) {zero_vals();} ComValue::ComValue(AttributeValueList* avl) : AttributeValue(avl) {zero_vals();} ComValue::ComValue(void* funcptr, AttributeValueList* listptr) : AttributeValue(funcptr, listptr) {zero_vals();} ComValue::ComValue(const char* string) : AttributeValue(string) {zero_vals();} ComValue::ComValue(ComFunc* func) : AttributeValue(ComFunc::class_symid(), func) {zero_vals(); type(ComValue::CommandType); command_symid(func->funcid()); } ComValue::ComValue(ComponentView* view, int compid) : AttributeValue(view, compid) {zero_vals();} ComValue::~ComValue() { } ComValue::ComValue(postfix_token* token) { clear(); void* v1 = &_v; void* v2 = &token->v; memcpy(v1, v2, sizeof(_v)); switch (token->type) { case TOK_STRING: type(StringType); break; case TOK_CHAR: type(CharType); break; case TOK_DFINT: type(IntType); break; case TOK_DFUNS: type(UIntType); break; case TOK_LNINT: type(LongType); break; case TOK_LNUNS: type(ULongType); break; case TOK_FLOAT: type(FloatType); break; case TOK_DOUBLE: type(DoubleType); break; case TOK_EOF: type(EofType); break; case TOK_COMMAND: type(SymbolType); _v.symval.globalflag=0; break; case TOK_KEYWORD: type(KeywordType); break; case TOK_BLANK: type(BlankType); break; default: type(UnknownType); break; } _narg = token->narg; _nkey = token->nkey; _nids = token->nids; // nids not always used for number-of-ids _command_symid = -1; _pedepth = 0; _bquote = 0; } ComValue& ComValue::operator= (const ComValue& sv) { assignval(sv); _narg = sv._narg; _nkey = sv._nkey; _nids = sv._nids; _pedepth = sv._pedepth; _bquote = sv._bquote; #if 0 // duplicated ref_as_needed call in assignval() ref_as_needed(); #endif return *this; } int ComValue::narg() const { return _narg; } int ComValue::nkey() const { return _nkey; } int ComValue::nids() const { return _nids; } int ComValue::bquote() const { return _bquote; } ostream& operator<< (ostream& out, const ComValue& sv) { ComValue* svp = (ComValue*)&sv; const char* title; const char* symbol; int counter; boolean brief = sv.comterp() ? sv.comterp()->brief() : false; switch( svp->type() ) { case ComValue::KeywordType: if (brief) out << ":" << symbol_pntr( svp->symbol_ref() ); else out << "Keyword( " << symbol_pntr( svp->keyid_val() ) << ") narg: " << svp->keynarg_val(); break; case ComValue::SymbolType: if (brief) { if (svp->global_flag()) out << "global("; symbol = symbol_pntr(svp->symbol_ref()); out << (symbol ? symbol : "(null)"); if (svp->global_flag()) out << ")"; } else { title = "symbol( "; symbol = symbol_pntr( svp->symbol_ref() ); out << title << (symbol ? symbol : "(null)"); counter = strlen(title) + strlen(symbol); while( ++counter < 32 ) out << ' '; out << ") narg " << svp->narg() << " nkey " << svp->nkey() << " nids: " << svp->nids(); } break; case ComValue::StringType: if (brief) ParamList::output_text(out, svp->string_ptr()); else { out << "string("; ParamList::output_text(out, svp->string_ptr()); out << ")"; } break; case ComValue::BooleanType: if (brief) out << svp->boolean_ref(); else out << "boolean( " << svp->boolean_ref() << " )"; break; case ComValue::CharType: if (brief) out << "`\\" << std::setw(3) << std::setfill('0') << std::oct << (int)svp->char_ref() << std::dec << "`" << std::resetiosflags(std::ios_base::basefield); else out << "char( " << svp->char_ref() << ":" << (int)svp->char_ref() << " )"; break; case ComValue::UCharType: if (brief) out << "`\\" << std::setw(3) << std::setfill('0') << std::oct << (unsigned int) svp->uchar_ref() << std::dec << "`" << std::resetiosflags(std::ios_base::basefield); else out << "uchar( " << svp->uchar_ref() << ":" << (int)svp->uchar_ref() << " )"; break; case ComValue::ShortType: if (brief) out << svp->short_ref(); else out << "short( " << svp->short_ref() << ":" << (int)svp->short_ref() << " )"; break; case ComValue::UShortType: if (brief) { if (svp->state()==AttributeValue::OctState) out << "0" << std::oct << svp->ushort_ref() << std::dec; else if (svp->state()==AttributeValue::HexState) out << "0x" << std::hex << svp->ushort_ref() << std::dec; else out << svp->ushort_ref(); } else out << "ushort( " << svp->ushort_ref() << ":" << (int)svp->ushort_ref() << " )"; break; case ComValue::IntType: if (brief) out << svp->int_ref(); else out << "int( " << svp->int_ref() << " )"; break; case ComValue::UIntType: if (brief) { if (svp->state()==AttributeValue::OctState) out << "0" << std::oct << svp->uint_ref() << std::dec; else if (svp->state()==AttributeValue::HexState) out << "0x" << std::hex << svp->uint_ref() << std::dec; else out << svp->uint_ref(); } else out << "uint( " << svp->uint_ref() << " )"; break; case ComValue::LongType: if (brief) out << svp->long_ref() << "L"; else out << "long( " << svp->long_ref() << " )"; break; case ComValue::ULongType: if (brief) { if (svp->state()==AttributeValue::OctState) out << "0" << std::oct << svp->ulong_ref() << std::dec; else if (svp->state()==AttributeValue::HexState) out << "0x" << std::hex << svp->ulong_ref() << std::dec; else out << svp->ulong_ref() << "L"; } else out << "ulong( " << svp->ulong_ref() << " )"; break; case ComValue::FloatType: if (brief) out << svp->float_ref(); else out << "float( " << svp->float_ref() << " )"; break; case ComValue::DoubleType: if (brief) out << svp->double_ref(); else out << "double( " << svp->double_ref() << " )"; break; case ComValue::EofType: out << "eof"; break; case ComValue::ArrayType: if (brief) { ALIterator i; AttributeValueList* avl = svp->array_val(); avl->First(i); out << "{"; while (!avl->Done(i)) { ComValue val(*avl->GetAttrVal(i)); out << val; avl->Next(i); if (!avl->Done(i)) out << ","; }; out << "}"; } else { out << "list of length " << svp->array_len(); ALIterator i; AttributeValueList* avl = svp->array_val(); avl->First(i); while (!avl->Done(i)) { out << "\n\t" << *avl->GetAttrVal(i); avl->Next(i); } } break; case ComValue::StreamType: out << "stream_mode() << "(" << symbol_pntr(((ComFunc*)svp->stream_func())->funcid()) << ")" << ">"; break; case ComValue::CommandType: if (brief) out << symbol_pntr( svp->command_symid()); else { title = "command( "; symbol = symbol_pntr( svp->command_symid()); out << title << symbol << ")"; } break; case ComValue::BlankType: // cerr << ""; break; case ComValue::ObjectType: if (svp->class_symid() == Attribute::class_symid()) out << *((Attribute*)svp->obj_val())->Value(); else if (svp->class_symid() == AttributeList::class_symid()) out << *((AttributeList*)svp->obj_val()); else out << /* "<" << */ symbol_pntr(svp->class_symid()) /* << ">" */ ; break; case ComValue::UnknownType: out << "nil"; break; default: break; } return out; } ComValue& ComValue::nullval() { *&_nullval = ComValue(); return _nullval; } ComValue& ComValue::trueval() { *&_trueval = ComValue(1, ComValue::BooleanType); return _trueval; } ComValue& ComValue::falseval() { *&_falseval = ComValue(0, ComValue::BooleanType); return _falseval; } ComValue& ComValue::blankval() { *&_blankval = ComValue(ComValue::BlankType); return _blankval; } ComValue& ComValue::unkval() { *&_unkval = ComValue(ComValue::UnknownType); return _unkval; } ComValue& ComValue::oneval() { *&_oneval = ComValue(1, ComValue::IntType); return _oneval; } ComValue& ComValue::zeroval() { *&_zeroval = ComValue(0, ComValue::IntType); return _zeroval; } ComValue& ComValue::minusoneval() { *&_minusoneval = ComValue(-1, ComValue::IntType); return _minusoneval; } ComValue& ComValue::twoval() { *&_twoval = ComValue(2, ComValue::IntType); return _twoval; } boolean ComValue::is_comfunc(int func_classid) { return is_type(CommandType) && func_classid==((ComFunc*)obj_val())->classid(); } void* ComValue::geta(int id, int compid) { if (is_object(id)) { if (object_compview()) return ((ComponentView*)obj_val())->GetSubject(); else return obj_val(); } else { if (compid>=0 && object_compview()) { if (((ComponentView*)obj_val())->GetSubject()->IsA(compid)) return ((ComponentView*)obj_val())->GetSubject(); } return nil; } } ivtools-1.2.11a1/src/ComTerp/comvalue.h000066400000000000000000000155561214471147700176650ustar00rootroot00000000000000/* * Copyright (c) 2001-2007 Scott E. Johnston * Copyright (c) 1994-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * ComValue is the general object for interpreter values stored on the * stack and associated with global symbols. */ #if !defined(_comvalue_h) #define _comvalue_h #include #include #include class ComFunc; class ComTerp; //: AttributeValue with extensions for use with ComTerp. // ComValue adds to AttributeValue a set of convenient static methods // for returning constants useful in any application of ComTerp, as well // as four integers (narg(), nkey(), nids(), pedepth()) used for storing // necessary command and keyword state after code conversion and during // interpretation. class ComValue : public AttributeValue { public: ComValue(const ComValue&); // deep copy constructor. ComValue(ComValue*); // deep copy constructor. ComValue(AttributeValue&); // copy constructor from an AttributeValue. ComValue(postfix_token* token); // copy constructor from a postfix token generated by a Parser. ComValue(ValueType type); // construct of a given 'type' with no initial value. ComValue(); // construct of UnknownType. ComValue(char val); // CharType constructor. ComValue(unsigned char val); // UCharType constructor. ComValue(short val); // ShortType constructor. ComValue(unsigned short val); // UShortType constructor. ComValue(int val, ValueType type=IntType); // IntType constructor or any other int-like value. ComValue(unsigned int val, ValueType type=IntType); // UIntType constructor or any other unsigned-int-like value including SymbolType. ComValue(unsigned int val, unsigned int, ValueType type=KeywordType); // KeywordType constructor (or can be used for ObjectType). ComValue(long val); // LongType constructor. ComValue(unsigned long val); // ULongType constructor. ComValue(float val); // FloatType constructor. ComValue(double val); // DoubleType constructor. ComValue(int class_symid, void* ptr); // ObjectType constructor. ComValue(AttributeValueList* listptr); // ArrayType/ListType constructor. ComValue(void* funcptr, AttributeValueList* listptr); // StreamType constructor. ComValue(const char* val); // StringType constructor. ComValue(ComFunc* func); // CommandType constructor. ComValue(ComponentView* view, int compid); // ComponentView constructor. void init(); // initialize member variables. virtual ~ComValue(); ComValue& operator= (const ComValue&); // assignment operator. virtual void* geta(int type, int compid=-1); // return a pointer if ObjectType matches int narg() const; // number of arguments associated with this command or keyword. int nkey() const; // number of keywords associated with this command. int nids() const; // number of subordinate identifiers associated with this identifier (not used). int bquote() const; // return backquote flag void narg(int n) {_narg = n; } // set number of arguments associated with this command or keyword. void nkey(int n) {_nkey = n; } // set number of keywords associated with this command. void nids(int n) {_nids = n; } // set number of subordinate identifiers associated with this identifier (not used). void bquote(int flag) {_bquote = flag; } // set backquote flag int& pedepth() { return _pedepth; } // set/get depth of nesting in post-evaluated blocks of control commands. // Used by ComTerp to efficiently extract and execute post-evaluation commands. boolean unknown() { return ComValue::UnknownType == type(); } // return true if UnknownType. boolean null() { return unknown(); } // return true if UnknownType. boolean is_comfunc(int func_classid); // returns true if CommandType with ComFunc friend ostream& operator << (ostream& s, const ComValue&); // print contents to ostream, brief or not depending on // associated ComTerp brief flag. static void comterp(const ComTerp* comterp) { _comterp = comterp; } // set static pointer to ComTerp used to provide brief flag. static const ComTerp* comterp() { return _comterp; } // return static pointer to ComTerp used to provide brief flag. static ComValue& nullval(); // returns reference to UnknownType ComValue. static ComValue& trueval(); // returns reference to BooleanType ComValue with value of 1. static ComValue& falseval(); // returns reference to BooleanType ComValue with value of 0. static ComValue& blankval(); // returns reference to BlankType ComValue. ComTerp places one of these // on the stack whenever the execution of a ComFunc places nothing on the stack. static ComValue& unkval(); // returns reference to UnknownType ComValue. static ComValue& oneval(); // returns reference to IntType ComValue with value of 1. static ComValue& zeroval(); // returns reference to IntType ComValue with value of 0. static ComValue& minusoneval(); // returns reference to IntType ComValue with value of -1. static ComValue& twoval(); // returns reference to IntType ComValue with value of 2. protected: void zero_vals() { _narg = _nkey = _nids = _pedepth = _bquote = 0; } int _narg; int _nkey; int _nids; int _pedepth; int _bquote; static const ComTerp* _comterp; static ComValue _nullval; static ComValue _trueval; static ComValue _falseval; static ComValue _blankval; static ComValue _unkval; static ComValue _oneval; static ComValue _zeroval; static ComValue _minusoneval; static ComValue _twoval; }; #endif /* !defined(_comvalue_h) */ ivtools-1.2.11a1/src/ComTerp/condfunc.cc000066400000000000000000000031551214471147700177770ustar00rootroot00000000000000/* * Copyright (c) 1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #define TITLE "CondFunc" /*****************************************************************************/ CondFunc::CondFunc(ComTerp* comterp) : ComFunc(comterp) { } void CondFunc::execute() { ComValue booltest(stack_arg_post_eval(0)); ComValue retval(booltest.is_true() ? stack_arg_post_eval(1) : (nargs()>=3 ? stack_arg_post_eval(2) : ComValue::nullval())); reset_stack(); push_stack(retval); } ivtools-1.2.11a1/src/ComTerp/condfunc.h000066400000000000000000000035751214471147700176470ustar00rootroot00000000000000/* * Copyright (c) 1998,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * the conditional operator */ #if !defined(_condfunc_h) #define _condfunc_h #include //: conditional control command for ComTerp // val=cond(testexpr trueexpr falseexpr) -- evaluate testexpr, and if true, // evaluate and return trueexpr, otherwise evaluate and return falseexpr. class CondFunc : public ComFunc { public: CondFunc(ComTerp*); virtual void execute(); boolean post_eval() { return true; } // post-evaluated command. virtual const char* docstring() { return "val=%s(testexpr trueexpr falseexpr) -- evaluate testexpr, and if true,\nevaluate and return trueexpr, otherwise evaluate and return falseexpr"; } }; #endif /* !defined(_condfunc_h) */ ivtools-1.2.11a1/src/ComTerp/ctrlfunc.cc000066400000000000000000000350021214471147700200140ustar00rootroot00000000000000/* * Copyright (c) 1994,1995,1998,1999 Vectaport Inc. * Copyright (c) 2011 Wave Semiconductor Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #ifdef HAVE_ACE #include #endif #define TITLE "CtrlFunc" #if __GNUC__>=3 static char newline; #if __GNUC__>3||__GNUC_MINOR_>1 #include #endif #endif using std::cerr; /*****************************************************************************/ QuitFunc::QuitFunc(ComTerp* comterp) : ComFunc(comterp) { } void QuitFunc::execute() { reset_stack(); _comterp->quit(); } /*****************************************************************************/ ExitFunc::ExitFunc(ComTerp* comterp) : ComFunc(comterp) { } void ExitFunc::execute() { ComValue statusv(stack_arg(0)); reset_stack(); if(statusv.is_int()) _comterp->exit(statusv.int_val()); else _comterp->exit(); } /*****************************************************************************/ TimeExprFunc::TimeExprFunc(ComTerp* comterp) : ComFunc(comterp) { } void TimeExprFunc::execute() { #ifdef HAVE_ACE ComValue timeoutstr(stack_arg(0)); static int sec_symval = symbol_add("sec"); ComValue sec_val(stack_key(sec_symval, false, ComValue::oneval(), true)); reset_stack(); ComterpHandler* handler = ((ComTerpServ*)_comterp)->handler(); if (handler) { if (nargs()) { if (timeoutstr.type() == ComValue::StringType) { handler->timeoutseconds(sec_val.int_val()); handler->timeoutscriptid(timeoutstr.string_val()); push_stack(timeoutstr); } else push_stack(ComValue::nullval()); } else { ComValue retval(handler->timeoutscriptid(), ComValue::StringType); push_stack(retval); } } #endif } /*****************************************************************************/ RunFunc::RunFunc(ComTerp* comterp) : ComFunc(comterp) { } void RunFunc::execute() { ComValue runfilename(stack_arg(0)); static int str_sym = symbol_add("str"); ComValue strv(stack_key(str_sym)); static int popen_sym = symbol_add("popen"); ComValue popenv(stack_key(popen_sym)); reset_stack(); if (runfilename.type() == ComValue::StringType) { const char* path = expand_tilde(runfilename.string_ptr()); if (strv.is_true()) { ComValue retval (((ComTerpServ*)_comterp)->run(path, true /* nested */)); push_stack(retval); } else { static int depth = 0; static char* curr_basepath = NULL; char* prev_basepath = NULL; char runpath[BUFSIZ]; int bufleft = BUFSIZ-1; *runpath = '\0'; if(curr_basepath && *path=='.') strncpy(runpath, curr_basepath, BUFSIZ-1); _comterp->set_args(path); const char* oldptr = path; char* newptr = runpath+strlen(runpath); bufleft -+ strlen(runpath); while(!isspace(*oldptr) && *oldptr && --bufleft) *newptr++ = *oldptr++; *newptr = '\0'; prev_basepath = curr_basepath; curr_basepath = new char[BUFSIZ]; realpath(runpath, curr_basepath); char* ptr = curr_basepath+strlen(curr_basepath)-1; while(ptr > curr_basepath && *ptr != '/') *ptr--='\0'; #if 0 fprintf(stderr, "READY(%d) prev_basepath %s\n", depth, prev_basepath); fprintf(stderr, "READY(%d) curr_basepath %s\n", depth, curr_basepath); fprintf(stderr, "READY(%d) runpath %s\n", depth, runpath); #endif depth++; _comterp->runfile(runpath, popenv.is_true()); if(_comterp->quitflag()) _comterp->quitflag(0); depth--; delete curr_basepath; curr_basepath = prev_basepath; #if 0 fprintf(stderr, "DONE(%d) curr_basepath %s\n", depth, curr_basepath); #endif } } return; } const char* RunFunc::expand_tilde(const char* path) { static wordexp_t p; wordfree(&p); if(wordexp(path, &p, 0)!=0) return path; return p.we_wordv[0]; } /*****************************************************************************/ RemoteFunc::RemoteFunc(ComTerp* comterp) : ComFunc(comterp) { } void RemoteFunc::execute() { ComValue arg1v(stack_arg(0)); ComValue arg2v(stack_arg(1)); ComValue arg3v(stack_arg(2)); static int nowait_sym = symbol_add("nowait"); ComValue nowaitv(stack_key(nowait_sym)); reset_stack(); #ifdef HAVE_ACE #if __GNUC__==3&&__GNUC_MINOR__<1 fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n"); push_stack(ComValue::nullval()); return; #endif ACE_SOCK_STREAM *socket = nil; ACE_SOCK_Connector *conn = nil; SocketObj* socketobj = nil; char* cmdstr = nil; if (arg1v.is_string() && arg2v.is_num() && arg3v.is_string()) { cmdstr = (char*)arg3v.string_ptr(); const char* hoststr = arg1v.string_ptr(); const char* portstr = arg2v.is_string() ? arg2v.string_ptr() : nil; u_short portnum = portstr ? atoi(portstr) : arg2v.ushort_val(); ACE_INET_Addr addr (portnum, hoststr); socket = new ACE_SOCK_STREAM; conn = new ACE_SOCK_Connector; if (conn->connect (*socket, addr) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "open")); push_stack(ComValue::nullval()); return; } } else if (arg1v.is_object() && arg2v.is_string()) { cmdstr = (char*)arg2v.string_ptr(); socketobj = (SocketObj*)arg1v.geta(SocketObj::class_symid()); if (socketobj) socket = socketobj->socket(); } else return; #if 0 #if __GNUC__<3 filebuf ofbuf; ofbuf.attach(socket->get_handle()); #elif __GNUC__<4 && !defined(__CYGWIN__) fileptr_filebuf ofbuf((int)socket->get_handle(), ios_base::out, false, static_cast(BUFSIZ)); #else fileptr_filebuf ofbuf((int)socket->get_handle(), ios_base::out, static_cast(BUFSIZ)); #endif ostream out(&ofbuf); out << cmdstr; if (cmdstr[strlen(cmdstr)-1] != '\n') out << "\n"; out.flush(); #else #if 0 int i=0; do { if(write(socket->get_handle(), cmdstr+i++, 1)!=1) fprintf(stderr, "Unexpected error writing byte to socket\n"); } while ( cmdstr[i]!='\0'); if (cmdstr[i-1] != '\n') write(socket->get_handle(), "\n", 1); #else int cmdlen = strlen(cmdstr); int newline_flag = cmdstr[cmdlen-1]=='\n'; if (!newline_flag) cmdstr[cmdlen]='\n'; int nbytes = write(socket->get_handle(), cmdstr, cmdlen+(newline_flag?0:1)); if (nbytes != cmdlen+(newline_flag?0:1)) fprintf(stderr, "write to socket failed\n"); if (!newline_flag) cmdstr[cmdlen]='\0'; #endif #endif if (nowaitv.is_false()) { #if __GNUC__<3 filebuf ifbuf; ifbuf.attach(socket->get_handle()); istream in(&ifbuf); char* buf; in.gets(&buf); #else char buf[BUFSIZ]; int i=0; do { read(socket->get_handle(), buf+i++, 1); } while (irun(buf, true)); push_stack(retval); } if(!socketobj) { if (socket->close () == -1) ACE_ERROR ((LM_ERROR, "%p\n", "close")); delete socket; delete conn; } return; #else cerr << "for the remote command to work rebuild comterp with ACE\n"; return; #endif } /*****************************************************************************/ #ifdef HAVE_ACE int SocketObj::_symid = -1; SocketObj::SocketObj(const char* host, unsigned short port) { _socket = nil; _conn = nil; _host = strnew(host); _port = port; } SocketObj::~SocketObj() { if( _socket ) { _socket->close(); delete _socket; delete _conn; delete _host; } } int SocketObj::connect() { ACE_INET_Addr addr(_port, _host); _socket = new ACE_SOCK_STREAM; _conn = new ACE_SOCK_Connector; return _conn->connect(*_socket, addr); } int SocketObj::close() { return _socket->close(); } int SocketObj::get_handle() { return _socket->get_handle(); } #endif /*****************************************************************************/ SocketFunc::SocketFunc(ComTerp* comterp) : ComFunc(comterp) { } void SocketFunc::execute() { ComValue hostv(stack_arg(0)); ComValue portv(stack_arg(1)); reset_stack(); #ifdef HAVE_ACE #if __GNUC__==3&&__GNUC_MINOR__<1 fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n"); push_stack(ComValue::nullval()); return; #endif if (hostv.is_string() && portv.is_known()) { const char* hoststr = hostv.string_ptr(); const char* portstr = portv.is_string() ? portv.string_ptr() : nil; u_short portnum = portstr ? atoi(portstr) : portv.ushort_val(); SocketObj* socket = new SocketObj(hoststr, portnum); if (socket->connect() == -1 ) { ACE_ERROR ((LM_ERROR, "%p\n", "open")); push_stack(ComValue::nullval()); return; } ComValue retval(SocketObj::class_symid(), (void*)socket); push_stack(retval); } return; #else cerr << "for the socket command to work rebuild comterp with ACE\n"; return; #endif } /*****************************************************************************/ EvalFunc::EvalFunc(ComTerp* comterp) : ComFunc(comterp) { } void EvalFunc::execute() { static int symret_sym = symbol_add("symret"); ComValue symretv(stack_key(symret_sym)); static int alist_sym = symbol_add("alist"); ComValue alistv(stack_key(alist_sym)); if (!comterp()->is_serv()) { cerr << "need server mode comterp (or remote mode) for eval command\n"; reset_stack(); push_stack(ComValue::nullval()); return; } AttributeList* alist = (AttributeList*) alistv.geta(AttributeList::class_symid()); AttributeList* old_alist = NULL; if (alist) { old_alist = comterp()->get_attributes(); comterp()->set_attributes(alist); } // evaluate every string fixed argument on the stack and return in array int numargs = nargsfixed(); if (numargs>1) { AttributeValueList* avl = nil; for (int i=0; irun(argv.symbol_ptr(), true /* nested */)); } else if (argv.is_object(FuncObj::class_symid())) { FuncObj* tokbuf = (FuncObj*)argv.obj_val(); val = new ComValue(comterpserv()->run(tokbuf->toks(), tokbuf->ntoks())); } if (val->is_nil() && symretv.is_true()) { delete val; val = new ComValue(argv.symbol_val(), AttributeValue::SymbolType); } if (!avl) avl = new AttributeValueList(); avl->Append(val); } reset_stack(); if (avl) { ComValue retval(avl); push_stack(retval); } } /* unless only single argument */ else if (numargs==1) { ComValue argv (stack_arg(0)); reset_stack(); if (argv.is_nil()) { push_stack(ComValue::nullval()); } else if (argv.is_string()) { ComValue val(comterpserv()->run(argv.symbol_ptr(), true /* nested */)); if (val.is_nil() && symretv.is_true()) { val.assignval(ComValue(argv.symbol_val(), AttributeValue::SymbolType)); } comterp()->push_stack(val); } else if (argv.is_object(FuncObj::class_symid())) { FuncObj* tokbuf = (FuncObj*)argv.obj_val(); ComValue val(comterpserv()->run(tokbuf->toks(), tokbuf->ntoks())); if (val.is_nil() && symretv.is_true()) { val.assignval(ComValue(argv.symbol_val(), AttributeValue::SymbolType)); } comterp()->push_stack(val); } } else reset_stack(); if (old_alist) comterp()->set_attributes(old_alist); return; } /*****************************************************************************/ ShellFunc::ShellFunc(ComTerp* comterp) : ComFunc(comterp) { } void ShellFunc::execute() { ComValue shellcmdstr(stack_arg(0)); reset_stack(); ComValue retval; if (shellcmdstr.type() == ComValue::StringType) { retval.int_ref() = system(shellcmdstr.string_ptr()); retval.type(ComValue::IntType); } push_stack(retval); return; } /*****************************************************************************/ USleepFunc::USleepFunc(ComTerp* comterp) : ComFunc(comterp) { } void USleepFunc::execute() { ComValue msecv(stack_arg(0)); reset_stack(); if (msecv.int_val()>0) usleep(msecv.int_val()); push_stack(msecv); return; } /*****************************************************************************/ NilFunc::NilFunc(ComTerp* comterp) : ComFunc(comterp) { } void NilFunc::execute() { reset_stack(); static int nil_symid = symbol_add("nil"); int comm_symid = funcstate()->command_symid(); if (comm_symid && comm_symid!= nil_symid) cerr << "unknown command \"" << symbol_pntr(comm_symid) << "\" returned nil\n"; push_stack(ComValue::nullval()); } /*****************************************************************************/ MuteFunc::MuteFunc(ComTerp* comterp) : ComFunc(comterp) { } void MuteFunc::execute() { ComValue mutev(stack_arg(0)); reset_stack(); if (mutev.is_unknown()) comterp()->muted(!comterp()->muted()); else comterp()->muted(mutev.int_val()); ComValue retval(comterp()->muted()); push_stack(retval); return; } /*****************************************************************************/ EmptyFunc::EmptyFunc(ComTerp* comterp) : ComFunc(comterp) { } void EmptyFunc::execute() { reset_stack(); // fprintf(stderr, "*** empty statement ***\n"); } ivtools-1.2.11a1/src/ComTerp/ctrlfunc.h000066400000000000000000000132461214471147700176640ustar00rootroot00000000000000/* * Copyright (c) 1994,1995,1998,1999 Vectaport Inc. * Copyright (c) 2011 Wave Semiconductor Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(_ctrlfunc_h) #define _ctrlfunc_h #include class ComTerp; //: quit command for ComTerp. // quit() -- quit this interpreter. class QuitFunc : public ComFunc { public: QuitFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "quit() -- quit this interpreter"; } }; //: exit command for ComTerp. // exit() -- exit entire application. class ExitFunc : public ComFunc { public: ExitFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "exit(status) -- exit entire application"; } }; //: timer expression command for ComTerp. // timeexpr(comstr :sec n) -- command string to execute at intervals. class TimeExprFunc : public ComFunc { public: TimeExprFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s(comstr :sec n) -- command string to execute at intervals"; } }; //: run command for ComTerp. // run(filename :str) -- run commands from a file (or string). class RunFunc : public ComFunc { public: RunFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s(filename :str :popen) -- run commands from a file (or string)"; } static const char* expand_tilde(const char* path); }; //: remote execution command for ComTerp. // remote(hoststr portnum cmdstr :nowait) -- remotely evaluate command string then locally // evaluate result string. class RemoteFunc : public ComFunc { public: RemoteFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s(hoststr|sockobj [portnum] cmdstr :nowait) -- remotely evaluate command string then locally evaluate result string"; } }; #ifdef HAVE_ACE class ACE_SOCK_STREAM; class ACE_SOCK_Connector; class SocketObj { public: SocketObj(const char* host, unsigned short port); virtual ~SocketObj(); ACE_SOCK_STREAM* socket() { return _socket; } int connect(); int close(); const char* host() { return _host; } unsigned short port() { return _port; } int get_handle(); ACE_SOCK_STREAM* _socket; ACE_SOCK_Connector* _conn; char* _host; unsigned short _port; CLASS_SYMID("SocketObj"); }; #endif //: create socket object // sockobj=socket(hoststr portnum) -- create and open socket object // create and open socket object class SocketFunc : public ComFunc { public: SocketFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s(hoststr portnum ) -- create and open socket object"; } }; //: eval string command for ComTerp. // str|lst=eval(cmdstr|tokbuf [cmdstr|tokbuf ...] :symret) -- evaluate string (or tokbuf) as commands, optionally returning symbol instead of nil. class EvalFunc : public ComFunc { public: EvalFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "str|lst=%s(cmdstr|funcobj [cmdstr|funcobj ...] :symret :alist attrlist) -- evaluate string (or funcobj) as commands, optionally return symbol instead of nil"; } }; //: shell escape command for ComTerp. // shell(cmdstr) -- evaluate command in shell. class ShellFunc : public ComFunc { public: ShellFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s(cmdstr) -- evaluate command in shell"; } }; //: usleep sleep microseconds // usleep(usec) -- sleep microseconds class USleepFunc : public ComFunc { public: USleepFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s(usec) -- sleep microseconds"; } }; //: nil command for ComTerp. // nil([...]) -- accept any arguments and return nil. class NilFunc : public ComFunc { public: NilFunc(ComTerp*); virtual boolean post_eval() { return true; } virtual void execute(); virtual const char* docstring() { return "%s([...]) -- accept any arguments and return nil"; } }; //: mute command for ComTerp // mute([flag]) -- set or toggle mute flag class MuteFunc : public ComFunc { public: MuteFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s([flag]) -- set or toggle mute flag (2 disables command echo)"; } }; //: empty command for ComTerp. // empty() -- empty statement class EmptyFunc : public ComFunc { public: EmptyFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "empty() -- empty statement"; } }; #endif /* !defined(_ctrlfunc_h) */ ivtools-1.2.11a1/src/ComTerp/debugfunc.cc000066400000000000000000000122441214471147700201410ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if __GNUC__==2 && __GNUC_MINOR__<=7 #else #include #endif #if __GNUC__>=3 #include #endif #include #include #include #include #include #include using std::cerr; using std::vector; #define TITLE "DebugFunc" /*****************************************************************************/ ComterpTraceFunc::ComterpTraceFunc(ComTerp* comterp) : ComFunc(comterp) { } void ComterpTraceFunc::execute() { static int get_symid = symbol_add("get"); boolean get_flag = stack_key(get_symid).is_true(); if (get_flag) { reset_stack(); int mode = comterp()->trace_mode(); ComValue retval(mode, ComValue::IntType); push_stack(retval); } else { if (nargs()==0) { reset_stack(); int mode = !comterp()->trace_mode(); comterp()->trace_mode(mode); ComValue retval(mode, ComValue::IntType); push_stack(retval); } else { ComValue retval(stack_arg(0)); reset_stack(); comterp()->trace_mode(retval.int_val()); push_stack(retval); } } } /*****************************************************************************/ ComterpPauseFunc::ComterpPauseFunc(ComTerp* comterp) : ComFunc(comterp) { } void ComterpPauseFunc::execute_body(ComValue& msgstrv) { comterp()->npause()++; comterp()->push_servstate(); fileptr_filebuf fbufin(comterp() && comterp()->handler() && comterp()->handler()->rdfptr() ? comterp()->handler()->rdfptr() : stdin, ios_base::in); istream in(&fbufin); fileptr_filebuf fbufout(comterp()->handler() && comterp()->handler()->wrfptr() ? comterp()->handler()->wrfptr() : stdout, ios_base::out); ostream out(&fbufout); if (msgstrv.is_string()) { std::ostrstream sbuf1_s; sbuf1_s << (stepfunc() ? "step(" : "pause(") << comterp()->npause() << "): " << msgstrv.string_ptr() << "\n"; sbuf1_s.put('\0'); out << sbuf1_s.str(); out.flush(); } std::ostrstream sbuf2_s; sbuf2_s << (stepfunc() ? "step(" : "pause(") << comterp()->npause() << "): enter command or press C/R to continue\n"; sbuf2_s.put('\0'); out << sbuf2_s.str(); out.flush(); vector cvect; ComValue retval; do { char ch; cvect.erase(cvect.begin(), cvect.end()); /* need to handle embedded newlines differently */ do { ch = in.get(); cvect.push_back(ch); } while (in.good() && ch != '\n'); if (cvect[0] != '\n' && (cvect[0] != '\r' || cvect[1] != '\n')) { if (comterpserv()) { retval.assignval(comterpserv()->run(&cvect[0])); ComValue::comterp(comterpserv()); out << retval << "\n"; out.flush(); } else { cerr << "execution of commands during step requires comterp in server or remote mode\n"; } } } while (cvect[0] != '\n' && (cvect[0] != '\r' || cvect[1] != '\n')); comterp()->pop_servstate(); std::ostrstream sbuf_e; sbuf_e << (stepfunc() ? "end of step(" : "end of pause(") << comterp()->npause()-- << ")\n"; sbuf_e.put('\0'); out << sbuf_e.str(); push_stack(retval); } void ComterpPauseFunc::execute() { ComValue msgstrv(stack_arg(0)); reset_stack(); execute_body(msgstrv); } /*****************************************************************************/ ComterpStepFunc::ComterpStepFunc(ComTerp* comterp) : ComterpPauseFunc(comterp) { } void ComterpStepFunc::execute() { ComValue msgstrv(stack_arg(0)); static int pause_symid = symbol_add("pause"); ComValue pausekey(stack_key(pause_symid)); reset_stack(); if (pausekey.is_true()) { execute_body(msgstrv); } else { comterp()->stepflag() = !comterp()->stepflag(); ComValue retval(comterp()->stepflag()); push_stack(retval); } } /*****************************************************************************/ ComterpStackHeightFunc::ComterpStackHeightFunc(ComTerp* comterp) : ComFunc(comterp) { } void ComterpStackHeightFunc::execute() { reset_stack(); ComValue retval(comterp()->stack_height()); push_stack(retval); } ivtools-1.2.11a1/src/ComTerp/debugfunc.h000066400000000000000000000053401214471147700200020ustar00rootroot00000000000000/* * Copyright (c) 2000 Vectaport Inc, IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * collection of debug functions */ #if !defined(_debugfunc_h) #define _debugfunc_h #include class ComTerp; class ComValue; //: command for toggling or setting trace mode // val=trace([flag] :get) -- toggle or set trace mode class ComterpTraceFunc : public ComFunc { public: ComterpTraceFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "val=%s([flag] :get) -- toggle or set trace mode"; } }; //: command to pause script execution until C/R // pause -- pause script execution until C/R class ComterpPauseFunc : public ComFunc { public: ComterpPauseFunc(ComTerp*); virtual void execute(); virtual void execute_body(ComValue&); virtual const char* docstring() { return "%s -- pause script execution until C/R"; } virtual boolean stepfunc() { return false; } }; //: command to toggle step script execution // pause -- toggle stepwise script execution class ComterpStepFunc : public ComterpPauseFunc { public: ComterpStepFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s -- toggle stepwise script execution"; } virtual boolean stepfunc() { return true; } }; //: command to return stack height for debugging // stackheight -- return stack height for debug purposes class ComterpStackHeightFunc : public ComFunc { public: ComterpStackHeightFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s -- return stack height for debug purposes"; } }; #endif /* !defined(_debugfunc_h) */ ivtools-1.2.11a1/src/ComTerp/dotfunc.cc000066400000000000000000000122571214471147700176450ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #define TITLE "DotFunc" using std::cerr; /*****************************************************************************/ int DotFunc::_symid = -1; DotFunc::DotFunc(ComTerp* comterp) : ComFunc(comterp) { } void DotFunc::execute() { ComValue before_part(stack_arg(0, true)); ComValue after_part(stack_arg(1, true)); reset_stack(); if (!before_part.is_symbol() && !(before_part.is_attribute() && (((Attribute*)before_part.obj_val())->Value()->is_unknown() || ((Attribute*)before_part.obj_val())->Value()->is_attributelist())) && !before_part.is_attributelist()) { cerr << "expression before \".\" needs to evaluate to a symbol or (instead of " << symbol_pntr(before_part.type_symid()); if (before_part.is_object()) cerr << " of class " << symbol_pntr(before_part.class_symid()); cerr << ")\n"; return; } if (nargs()>1 && !after_part.is_string()) { cerr << "expression after \".\" needs to be a symbol or evaluate to a symbol (instead of " << symbol_pntr(after_part.type_symid()); if (before_part.is_object()) cerr << " for class " << symbol_pntr(before_part.class_symid()); cerr << ")\n"; return; } /* lookup value of before variable */ void* vptr = nil; AttributeList* al = nil; if (!before_part.is_attribute() && !before_part.is_attributelist()) { int before_symid = before_part.symbol_val(); boolean global = before_part.global_flag(); if (!global) { comterp()->localtable()->find(vptr, before_symid); if (!vptr) comterp()->globaltable()->find(vptr, before_symid); } else { comterp()->globaltable()->find(vptr, before_symid); } if (vptr &&((ComValue*) vptr)->class_symid() == AttributeList::class_symid()) { al = (AttributeList*) ((ComValue*) vptr)->obj_val(); } else { al = new AttributeList(); Resource::ref(al); ComValue* comval = new ComValue(AttributeList::class_symid(), (void*)al); if (!global) comterp()->localtable()->insert(before_symid, comval); else comterp()->globaltable()->insert(before_symid, comval); } } else if (!before_part.is_attributelist()) { if (((Attribute*)before_part.obj_val())->Value()->is_attributelist()) al = (AttributeList*) ((Attribute*) before_part.obj_val())->Value()->obj_val(); else { al = new AttributeList(); AttributeValue newval(AttributeList::class_symid(), (void*) al); *((Attribute*)before_part.obj_val())->Value() = newval; } } else al = (AttributeList*) before_part.obj_val(); if (nargs()>1) { int after_symid = after_part.symbol_val(); Attribute* attr = al ? al->GetAttr(after_symid) : nil; if (!attr) { attr = new Attribute(after_symid, new AttributeValue()); al->add_attribute(attr); } ComValue retval(Attribute::class_symid(), attr); push_stack(retval); } else { ComValue retval(AttributeList::class_symid(), al); push_stack(retval); } } /*****************************************************************************/ DotNameFunc::DotNameFunc(ComTerp* comterp) : ComFunc(comterp) { } void DotNameFunc::execute() { ComValue dotted_pair(stack_arg(0, true)); reset_stack(); if (dotted_pair.class_symid() != Attribute::class_symid()) return; Attribute *attr = (Attribute*)dotted_pair.obj_val(); ComValue retval(attr->SymbolId(), ComValue::StringType); push_stack(retval); } /*****************************************************************************/ DotValFunc::DotValFunc(ComTerp* comterp) : ComFunc(comterp) { } void DotValFunc::execute() { ComValue dotted_pair(stack_arg(0, true)); reset_stack(); if (dotted_pair.class_symid() != Attribute::class_symid()) return; Attribute *attr = (Attribute*)dotted_pair.obj_val(); push_stack(*attr->Value()); } ivtools-1.2.11a1/src/ComTerp/dotfunc.h000066400000000000000000000045341214471147700175060ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * dot func supports a compound variable */ #if !defined(_dotfunc_h) #define _dotfunc_h #include //: . (dot) operator, for compound variables | dotlst=dot(name) -- construct empty dottted pair list. class DotFunc : public ComFunc { public: DotFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s (.) makes compound variables | dotlst=dot(name) -- construct empty dotted pair list"; } CLASS_SYMID("DotFunc"); }; //: name returns name field of a dotted pair // attrname(attribute) returns name field of a dotted pair class DotNameFunc : public ComFunc { public: DotNameFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s(attribute) returns name field of a dotted pair"; } }; //: value returns value field of a dotted pair // attrval(attribute) returns value field of a dotted pair class DotValFunc : public ComFunc { public: DotValFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s(attribute) returns value field of a dotted pair"; } }; #endif /* !defined(_dotfunc_h) */ ivtools-1.2.11a1/src/ComTerp/helpfunc.cc000066400000000000000000000207121214471147700200020ustar00rootroot00000000000000/* * Copyright (c) 2001,2005 Scott E. Johnston * Copyright (c) 1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING vv * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #if __GNUC__>=3 #include #endif #include using std::streambuf; #define TITLE "HelpFunc" #define HELPOUT 0 // set to 1 if desire to print instead of return help info /*****************************************************************************/ HelpFunc::HelpFunc(ComTerp* comterp) : ComFunc(comterp) { } void HelpFunc::execute() { // print list of commands if no arguments provided, otherwise // take everything off the stack and check commands, strings, and symbols // for valid command names and print their document string // (check if an ordinary symbol is less than the largest symbol id of an operator // because that is what it would be (an operator) static int all_symid = symbol_add("all"); ComValue allflag(stack_key(all_symid)); static int posteval_symid = symbol_add("posteval"); ComValue postevalflag(stack_key(posteval_symid)); static int aliases_symid = symbol_add("aliases"); ComValue aliasesflag(stack_key(aliases_symid)); static int top_symid = symbol_add("top"); ComValue topflag(stack_key(top_symid)); boolean noargs = !nargs() && !nkeys(); ComFunc** comfuncs= nil; int* command_ids = nil; boolean* str_flags; int nfuncs = 0; /* build up table of command ids and flags to indicate if its an operator encased in quotes */ if (allflag.is_false() && postevalflag.is_false() && topflag.is_false()) { nfuncs = nargs(); comfuncs = new ComFunc*[nfuncs]; command_ids = new int[nfuncs]; str_flags = new boolean[nfuncs]; for (int i=0; ilocaltable()->find(vptr, val.string_val()); if (vptr && ((ComValue*)vptr)->is_command()) { comfuncs[i] = (ComFunc*)((ComValue*)vptr)->obj_val(); } else comfuncs[i] = nil; command_ids[i] = val.string_val(); str_flags[i] = true; } else { comfuncs[i] = nil; if (val.is_type(AttributeValue::SymbolType)) command_ids[i] = val.symbol_val(); else command_ids[i] = -1; str_flags[i] = false; } } } else if (topflag.is_true()) { AttributeValueList* avl = comterp()->top_commands(); nfuncs = avl->Number(); command_ids = new int[nfuncs]; comfuncs = new ComFunc*[nfuncs]; str_flags = new boolean[nfuncs]; Iterator it; avl->First(it); for (int j=0; jGetAttrVal(it)->symbol_val(); avl->Next(it); command_ids[j] = command_id; void* vptr; comterp()->localtable()->find(vptr, command_id); if (vptr && ((ComValue*)vptr)->is_command()) { comfuncs[j] = (ComFunc*)((ComValue*)vptr)->obj_val(); if (postevalflag.is_true() && !comfuncs[j]->post_eval()) comfuncs[j] = nil; } else comfuncs[j] = nil; str_flags[j] = false; } } else { command_ids = comterp()->get_commands(nfuncs, true); comfuncs = new ComFunc*[nfuncs]; str_flags = new boolean[nfuncs]; for (int j=0; jlocaltable()->find(vptr, command_id); if (vptr && ((ComValue*)vptr)->is_command()) { comfuncs[j] = (ComFunc*)((ComValue*)vptr)->obj_val(); if (postevalflag.is_true() && !comfuncs[j]->post_eval()) comfuncs[j] = nil; } else comfuncs[j] = nil; str_flags[j] = false; } } reset_stack(); std::strstreambuf sbuf; #if __GNUC__<3 filebuf fbuf; if (comterp()->handler() && HELPOUT) { int fd = Math::max(1, comterp()->handler()->get_handle()); fbuf.attach(fd); } ostream outs( (comterp()->handler() && HELPOUT) ? ((streambuf*)&fbuf) : (streambuf*)&sbuf ); ostream *out = &outs; #else fileptr_filebuf fbuf((comterp()->handler() && HELPOUT) && comterp()->handler()->wrfptr() ? comterp()->handler()->wrfptr() : stdout, ios_base::out); #if 1 ostream outs((comterp()->handler() && HELPOUT) ? (streambuf*)&fbuf : (streambuf*)&sbuf); #else ostream outs((streambuf*)&fbuf); #endif ostream *out = &outs; #endif if (noargs) { *out << "help available on these commands:\n"; comterp()->list_commands(*out, true); *out << "\n(provide any of the above, operators in quotes, as arguments to help,\ni.e. help(help) or help(\"++\"))\n"; } else { boolean first=true; for (int i=0; ilocaltable()->find(vptr, command_ids[i]); if (vptr && ((ComValue*)vptr)->type() == ComValue::CommandType) { if (first) first = false; else #if 0 out->put('\n'); #else *out << '\n'; #endif #if __GNUC__<3 out->form(comfuncs[i]->docstring2(), symbol_pntr(command_ids[i])); #else { char buffer[BUFSIZ]; snprintf(buffer, BUFSIZ, comfuncs[i]->docstring2(), symbol_pntr(command_ids[i])); *out << buffer; } #endif printed = true; } } if (!printed && command_ids[i]>=0) { /* if symid is smaller than the highest operator it must be one */ if (command_ids[i]>=0 && command_ids[i]<=opr_tbl_topstr()) { int op_ids[OPTYPE_NUM]; const char* opstr = symbol_pntr(command_ids[i]); unsigned int charcnt; opr_tbl_entries((char*)opstr, op_ids, OPTYPE_NUM, &charcnt); for (int j=0; j=0) { ComValue* value = comterp()->localvalue(opr_tbl_commid(op_ids[j])); if (value) { ComFunc* comfunc = (ComFunc*)value->obj_val(); if (postevalflag.is_true() && !comfunc->post_eval()) continue; if (first) first = false; else out->put('\n'); #if __GNUC__<3 out->form(comfunc->docstring2(), symbol_pntr(value->command_symid())); #else { char buffer[BUFSIZ]; snprintf(buffer, BUFSIZ, comfunc->docstring2(), symbol_pntr(value->command_symid())); *out << buffer; } #endif } else out_form((*out), "unknown operator: %s\n", symbol_pntr(command_ids[i])); } } } else if (comfuncs[i]) { if (first) first = false; else out->put('\n'); if (str_flags[i]) out->put('"'); *out << symbol_pntr(command_ids[i]); if (str_flags[i]) out->put('"'); *out << " unknown"; } } } } if (!comterp()->handler() || !HELPOUT) { *out << '\0'; int help_str_symid = symbol_add(sbuf.str()); ComValue retval(sbuf.str()); push_stack(retval); } else out->flush(); delete command_ids; delete comfuncs; delete str_flags; } /*****************************************************************************/ OptableFunc::OptableFunc(ComTerp* comterp) : ComFunc(comterp) { } void OptableFunc::execute() { reset_stack(); opr_tbl_print(stdout, OPBY_PRIORITY); return; } ivtools-1.2.11a1/src/ComTerp/helpfunc.h000066400000000000000000000040431214471147700176430ustar00rootroot00000000000000/* * Copyright (c) 2005 Scott E. Johnston * Copyright (c) 1998,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * collection of help functions */ #if !defined(_helpfunc_h) #define _helpfunc_h #include class ComTerp; //: help command for ComTerp. // help([command] [command...] :all :posteval) -- help for commands. class HelpFunc : public ComFunc { public: HelpFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "%s([command] [command...] :all :posteval :top) -- help for commands"; } }; //: print contents of operator table // optable() -- print contents of operator table to stdout class OptableFunc : public ComFunc { public: OptableFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s() -- print contents of operator table"; } }; #endif /* !defined(_helpfunc_h) */ ivtools-1.2.11a1/src/ComTerp/iofunc.cc000066400000000000000000000322521214471147700174630ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #if __GNUC__>=3 #include #endif #include #define TITLE "IoFunc" using std::streambuf; /*****************************************************************************/ int FileObj::_symid = -1; FileObj::FileObj(const char* filename, const char* mode, int pipeflag) { _filename = strnew(filename); _mode = strnew(mode); _pipe = pipeflag; _fptr = _pipe ? popen(filename, mode) : fopen(filename, mode); } FileObj::FileObj(FILE* fptr) { _filename = NULL; _mode = NULL; _pipe = false; _fptr = fptr; } FileObj::~FileObj() { if( _fptr && _filename) _pipe ? pclose(_fptr) : fclose(_fptr); delete _filename; delete _mode; } /*****************************************************************************/ int PipeObj::_symid = -1; PipeObj::PipeObj(const char* command) { _command = strnew(command); _pid = popen2(command, &_wrfd, &_rdfd); _wrfptr = _rdfptr = NULL; } void PipeObj::close() { if(_wrfptr) fclose(_wrfptr); if(_rdfptr) fclose(_rdfptr); ::close(_wrfd); ::close(_rdfd); _wrfptr = NULL; _rdfptr = NULL; _wrfd = -1; _rdfd = -1; } PipeObj::~PipeObj() { delete _command; close(); } /*****************************************************************************/ PrintFunc::PrintFunc(ComTerp* comterp) : ComFunc(comterp) { } void PrintFunc::execute() { ComValue formatstr(stack_arg(0)); static int str_symid = symbol_add("str"); ComValue strflag(stack_key(str_symid)); static int string_symid = symbol_add("string"); ComValue stringflag(stack_key(string_symid)); static int sym_symid = symbol_add("sym"); ComValue symflag(stack_key(sym_symid)); static int symbol_symid = symbol_add("symbol"); ComValue symbolflag(stack_key(symbol_symid)); static int err_symid = symbol_add("err"); ComValue errflag(stack_key(err_symid)); static int out_symid = symbol_add("out"); ComValue outflag(stack_key(out_symid)); static int file_symid = symbol_add("file"); ComValue fileobjv(stack_key(file_symid)); static int prefix_symid = symbol_add("prefix"); ComValue prefixv(stack_key(prefix_symid)); const char* fstr = formatstr.is_string() ? formatstr.string_ptr() : "nil"; ComValue::comterp(comterp()); #if __GNUC__<3 streambuf* strmbuf = nil; if (stringflag.is_false() && strflag.is_false() && symbolflag.is_false() && symflag.is_false()) { filebuf * fbuf = new filebuf(); strmbuf = fbuf; if (comterp()->handler()) { int fd = Math::max(1, comterp()->handler()->get_handle()); fbuf->attach(fd); } else fbuf->attach(fileno(errflag.is_false() ? stdout : stderr)); } else { strmbuf = new std::strstreambuf(); } #else streambuf* strmbuf = nil; if (stringflag.is_false() && strflag.is_false() && symbolflag.is_false() && symflag.is_false()) { fileptr_filebuf * fbuf = nil; if (comterp()->handler() && fileobjv.is_unknown() && errflag.is_false() && outflag.is_false()) { fbuf = new fileptr_filebuf(comterp()->handler() && comterp()->handler()->wrfptr() ? comterp()->handler()->wrfptr() : stdout, ios_base::out); } else if (fileobjv.is_known()) { FileObj *fileobj = (FileObj*)fileobjv.geta(FileObj::class_symid()); if (fileobj) fbuf = new fileptr_filebuf(fileobj->fptr(), ios_base::out); else { PipeObj *pipeobj = (PipeObj*)fileobjv.geta(PipeObj::class_symid()); fbuf = new fileptr_filebuf(pipeobj ? pipeobj->wrfptr() : stdout, ios_base::out); } } else fbuf = new fileptr_filebuf(errflag.is_false() ? stdout : stderr, ios_base::out); strmbuf = fbuf; } else strmbuf = new std::strstreambuf(); #endif ostream out(strmbuf); int narg = nargsfixed(); if (narg==1) { if (formatstr.is_string() && !prefixv.is_string()) out << formatstr.symbol_ptr(); else { if (prefixv.is_string()) out << prefixv.symbol_ptr(); out << formatstr; // which could be arbitrary ComValue if (prefixv.is_string()) out << "\n"; } } else { const char* fstrptr = fstr; int curr=1; while (currFirst(i); boolean first = true; while (!avl->Done(i)) { ComValue val(*avl->GetAttrVal(i)); push_stack(formatstr); push_stack(val); exec(2,0); avl->Next(i); if (!avl->Done(i)) out << "\n"; } } break; case ComValue::BlankType: out << ""; break; case ComValue::UnknownType: out_form(out, fbuf, nil); break; default: break; } } } reset_stack(); if (stringflag.is_true() || strflag.is_true()) { out << '\0'; ComValue retval(((std::strstreambuf*)strmbuf)->str()); push_stack(retval); } else if (symbolflag.is_true() || symflag.is_true()) { out << '\0'; int symbol_id = symbol_add(((std::strstreambuf*)strmbuf)->str()); ComValue retval(symbol_id, ComValue::SymbolType); push_stack(retval); } else push_stack(ComValue::blankval()); delete strmbuf; } int PrintFunc::format_extent(const char* fstr) { /* %[flags][width][.precision][length]specifier */ int len=0; if (*fstr!='%') return 0; else len++; /* flags: minus, plus, space, pound, zero */ while(fstr[len] == '-' || fstr[len] == '+' || fstr[len] == ' ' || fstr[len] == '#' || fstr[len] == '0') len++; /* width: 0-9 or star */ if(fstr[len]=='*') len++; else while(fstr[len] >= '0' && fstr[len] <= '9') len++; /* .precision */ if(fstr[len]=='.') { if(fstr[len]=='*') len+=2; else { len++; if(fstr[len] < '0' || fstr[len] > '9') return 0; while(fstr[len] >= '0' && fstr[len] <= '9') len++; } } /* length: h, l, or L */ while(fstr[len] == 'h' || fstr[len] == 'l' || fstr[len] == 'L') len++; /* specifier */ if(fstr[len] == 'c' || fstr[len] == 'd' || fstr[len] == 'i' || fstr[len] == 'e' || fstr[len] == 'E' || fstr[len] == 'f' || fstr[len] == 'g' || fstr[len] == 'G' || fstr[len] == 'o' || fstr[len] == 's' || fstr[len] == 'u' || fstr[len] == 'x' || fstr[len] == 'X' || fstr[len] == 'p' || fstr[len] == 'n' ) return len+1; else return 0; } /*****************************************************************************/ OpenFileFunc::OpenFileFunc(ComTerp* comterp) : ComFunc(comterp) { } void OpenFileFunc::execute() { ComValue filenamev(stack_arg(0)); ComValue modev(stack_arg(1)); static int pipe_symid = symbol_add("pipe"); ComValue pipeflagv(stack_key(pipe_symid)); static int in_symid = symbol_add("in"); ComValue inflagv(stack_key(in_symid)); static int out_symid = symbol_add("out"); ComValue outflagv(stack_key(out_symid)); static int err_symid = symbol_add("err"); ComValue errflagv(stack_key(err_symid)); reset_stack(); if (inflagv.is_true()) { FileObj* fileobj = new FileObj(stdin); ComValue retval(FileObj::class_symid(), (void*)fileobj); push_stack(retval); return; } if (outflagv.is_true()) { FileObj* fileobj = new FileObj(stdout); ComValue retval(FileObj::class_symid(), (void*)fileobj); push_stack(retval); return; } if (errflagv.is_true()) { FileObj* fileobj = new FileObj(stderr); ComValue retval(FileObj::class_symid(), (void*)fileobj); push_stack(retval); return; } if (pipeflagv.is_true() && modev.is_string() && (strcmp(modev.string_ptr(),"rw")==0 || strcmp(modev.string_ptr(),"wr")==0)) { PipeObj* pipeobj = new PipeObj(filenamev.string_ptr()); ComValue retval(PipeObj::class_symid(), (void*)pipeobj); push_stack(retval); if (Component::use_unidraw()) { ComterpHandler* pipe_handler = new ComterpHandler(comterpserv()); if (ComterpHandler::reactor_singleton()->register_handler(pipeobj->rdfd(), pipe_handler, ACE_Event_Handler::READ_MASK)==-1) { fprintf(stderr, "Trouble opening handler for pipeobj\n"); exit(1); } pipe_handler->log_only(1); } } else { FileObj* fileobj = new FileObj(filenamev.string_ptr(), modev.is_string() ? modev.string_ptr() : "r", pipeflagv.is_true()); if (fileobj->fptr()) { ComValue retval(FileObj::class_symid(), (void*)fileobj); push_stack(retval); } else { delete fileobj; push_stack(ComValue::nullval()); } } } /*****************************************************************************/ CloseFileFunc::CloseFileFunc(ComTerp* comterp) : ComFunc(comterp) { } void CloseFileFunc::execute() { ComValue fileobjv(stack_arg(0)); reset_stack(); FileObj *fileobj = (FileObj*)fileobjv.geta(FileObj::class_symid()); if (fileobj && fileobj->fptr()) fclose(fileobj->fptr()); else { PipeObj *pipeobj = (PipeObj*)fileobjv.geta(PipeObj::class_symid()); pipeobj->close(); } } /*****************************************************************************/ GetStringFunc::GetStringFunc(ComTerp* comterp) : ComFunc(comterp) { } void GetStringFunc::execute() { ComValue fileobjv(stack_arg(0)); reset_stack(); FileObj *fileobj = (FileObj*)fileobjv.geta(FileObj::class_symid()); FILE* fptr = NULL; if (fileobj && fileobj->fptr()) { fptr = fileobj->fptr(); } else { PipeObj *pipeobj = (PipeObj*)fileobjv.geta(PipeObj::class_symid()); if (pipeobj && pipeobj->rdfptr()) fptr = pipeobj->rdfptr(); } char buffer[BUFSIZ]; char* ptr = fgets(buffer, BUFSIZ, fptr); if (ptr) { ComValue retval(buffer); push_stack(retval); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ GetArgFunc::GetArgFunc(ComTerp* comterp) : ComFunc(comterp) { } void GetArgFunc::execute() { ComValue numv(stack_arg(0)); reset_stack(); int arg_sym = comterp()->arg_str(numv.int_val()); if (arg_sym>0) { ComValue retval(comterp()->arg_str(numv.int_val()), ComValue::StringType); push_stack(retval); } else push_stack(ComValue::nullval()); return; } /*****************************************************************************/ NumArgFunc::NumArgFunc(ComTerp* comterp) : ComFunc(comterp) { } void NumArgFunc::execute() { reset_stack(); ComValue retval(comterp()->narg_str(), ComValue::IntType); push_stack(retval); return; } ivtools-1.2.11a1/src/ComTerp/iofunc.h000066400000000000000000000105401214471147700173210ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1998,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * collection of io functions */ #if !defined(_iofunc_h) #define _iofunc_h #include class ComTerp; class ComValue; //: value printing command for ComTerp. // [str]=print([fmtstr] [val [val1 [... valn]]] :string|:str :symbol|:sym :out :err :file fileobj|pipeobj :prefix str) -- print value(s) with optional format string class PrintFunc : public ComFunc { public: PrintFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "[str]=%s([fmtstr] [val [val1 [... valn]]] :string|:str :symbol|:sym :out :err :file fileobj|pipeobj :prefix str) -- print value with optional format string"; } static int format_extent(const char* fstr); }; //: open file command // fileobj|pipeobj=open([filename modestr] :pipe :out :err) -- open file command class OpenFileFunc : public ComFunc { public: OpenFileFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "fileobj|pipeobj=open([filename [modestr]] :pipe :in :out :err) -- open file command"; } }; //: close file command // close(fileobj|pipeobj) -- close file command class CloseFileFunc : public ComFunc { public: CloseFileFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "close(fileobj|pipeobj) -- close file command"; } }; class FileObj { public: FileObj(const char* filename, const char* mode, int pipeflag); FileObj(FILE* fptr); virtual ~FileObj(); const char* filename() { return _filename; } const char* mode() { return _mode; } FILE* fptr() { return _fptr; } protected: char* _filename; char* _mode; FILE* _fptr; FILE* _fptr2; int _pipe; pid_t _pid; CLASS_SYMID("FileObj"); }; class PipeObj { public: PipeObj(const char* command); virtual ~PipeObj(); const char* command() { return _command; } int pid() { return _pid; } int wrfd() { return _wrfd; } int rdfd() { return _rdfd; } FILE* wrfptr() { return _wrfptr ? _wrfptr : _wrfptr=fdopen(_wrfd, "w"); } FILE* rdfptr() { return _rdfptr ? _rdfptr : _rdfptr=fdopen(_rdfd, "r"); } void close(); protected: char* _command; pid_t _pid; int _wrfd; int _rdfd; FILE* _wrfptr; FILE* _rdfptr; CLASS_SYMID("PipeObj"); }; //: get string from FileObj // str=gets(fileobj) -- gets a new-line terminated string from a file class GetStringFunc : public ComFunc { public: GetStringFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "str=%s(fileobj|pipeobj) -- gets a new-line terminated string from a file"; } }; //: return command line argument // str=arg(n) -- return command line argument class GetArgFunc : public ComFunc { public: GetArgFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "str=%s(n) -- return command line argument"; } }; //: return number of command line arguments // n=narg() -- return number of command line arguments class NumArgFunc : public ComFunc { public: NumArgFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "n=%s() -- return number of command line arguments"; } }; #endif /* !defined(_iofunc_h) */ ivtools-1.2.11a1/src/ComTerp/lexscan.h000066400000000000000000000002151214471147700174710ustar00rootroot00000000000000/* * LexScan was moved to the Attribute library so it could be utilized * without the ComTerp system. */ #include ivtools-1.2.11a1/src/ComTerp/listfunc.cc000066400000000000000000000244401214471147700200270ustar00rootroot00000000000000/* * Copyright (c) 2011 Wave Semiconductor Inc. * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #define TITLE "ListFunc" /*****************************************************************************/ ListFunc::ListFunc(ComTerp* comterp) : ComFunc(comterp) { } void ListFunc::execute() { ComValue listv(stack_arg_post_eval(0)); static int strmlst_symid = symbol_add("strmlst"); // hidden debug keyword ComValue strmlstv(stack_key_post_eval(strmlst_symid)); static int attr_symid = symbol_add("attr"); ComValue attrv(stack_key_post_eval(attr_symid)); boolean attrflag = attrv.is_true(); static int size_symid = symbol_add("size"); ComValue sizev(stack_key_post_eval(size_symid)); reset_stack(); if (attrflag) { AttributeList* al = new AttributeList(); Resource::ref(al); ComValue retval(AttributeList::class_symid(), al); push_stack(retval); return; } AttributeValueList* avl; if (listv.is_array()) avl = new AttributeValueList(listv.array_val()); else { avl = new AttributeValueList(); if (listv.is_stream()) { if (strmlstv.is_false()) { /* stream to list conversion */ boolean done = false; while (!done) { NextFunc::execute_impl(comterp(), listv); ComValue topval(comterp()->pop_stack()); AttributeValue* newval = new AttributeValue(topval); if (newval->is_unknown()) { done = true; delete newval; } else avl->Append(newval); } } else { /* simply return stream's internal list for debug purposes */ if (listv.stream_list()) { ComValue retval(listv.stream_list()); push_stack(retval); } else push_stack(ComValue::nullval()); return; } } else if (sizev.is_int()) { for (int i=0; iAppend(new AttributeValue()); } else if (nargs()) avl->Append(new AttributeValue(listv)); } Resource::ref(avl); ComValue retval(avl); push_stack(retval); } /*****************************************************************************/ ListAtFunc::ListAtFunc(ComTerp* comterp) : ComFunc(comterp) { } void ListAtFunc::execute() { ComValue listv(stack_arg(0)); ComValue nv(stack_arg(1, false, ComValue::zeroval())); static int set_symid = symbol_add("set"); ComValue setv(stack_key(set_symid, false, ComValue::blankval(), true /* return blank if no :set */)); boolean setflag = !setv.is_blank(); static int ins_symid = symbol_add("ins"); ComValue insv(stack_key(ins_symid, false, ComValue::blankval(), true /* return blank if no :ins */)); boolean insflag = !insv.is_blank(); reset_stack(); if (listv.is_type(ComValue::ArrayType) && !nv.is_nil() && (nv.int_val()>=0 || insflag)) { AttributeValueList* avl = listv.array_val(); if (avl) { if (insflag) { avl->Insert(nv.int_val(), new AttributeValue(insv)); push_stack(insv); return; } else if (setflag) { AttributeValue* oldv = avl->Set(nv.int_val(), new AttributeValue(setv)); delete oldv; push_stack(setv); return; } else { AttributeValue* retv = avl->Get(nv.int_val()); if (retv) push_stack(*retv); else push_stack(ComValue::blankval()); return; } } } else if (listv.is_object(AttributeList::class_symid())) { AttributeList* al = (AttributeList*)listv.obj_val(); if (al && nv.int_val()Number()) { int count = 0; Iterator it; for (al->First(it); !al->Done(it); al->Next(it)) { if (count==nv.int_val()) { ComValue retval(Attribute::class_symid(), (void*) al->GetAttr(it)); if (insflag) { fprintf(stderr, "Insert not yet supported for AttributeList\n"); } else if (setflag) *al->GetAttr(it)->Value() = setv; push_stack(retval); return; } count++; } } } else if (listv.is_string()) { const char* str = listv.string_ptr(); if(!setflag) { if(strlen(str) > nv.int_val()) { ComValue retval(*(str+nv.int_val()), ComValue::CharType); push_stack(retval); return; } } else { if(nv.int_val()=0) { *((char *)str+nv.int_val()) = setv.char_val(); ComValue retval(setv); push_stack(retval); return; } } } push_stack(ComValue::nullval()); } /*****************************************************************************/ ListSizeFunc::ListSizeFunc(ComTerp* comterp) : ComFunc(comterp) { } void ListSizeFunc::execute() { ComValue listv(stack_arg(0)); reset_stack(); if (listv.is_type(ComValue::ArrayType)) { AttributeValueList* avl = listv.array_val(); if (avl) { ComValue retval(avl->Number()); push_stack(retval); return; } } else if (listv.is_object(AttributeList::class_symid())) { AttributeList* al = (AttributeList*)listv.obj_val(); if (al) { ComValue retval(al->Number()); push_stack(retval); return; } } else if (listv.is_string()) { ComValue retval((int)strlen(listv.symbol_ptr()), ComValue::IntType); push_stack(retval); return; } else if (listv.is_object(FuncObj::class_symid())) { FuncObj* tokbuf = (FuncObj*)listv.obj_val(); if (tokbuf) { ComValue retval(tokbuf->ntoks()); push_stack(retval); return; } } push_stack(ComValue::nullval()); } /*****************************************************************************/ int TupleFunc::_symid; TupleFunc::TupleFunc(ComTerp* comterp) : ComFunc(comterp) { } void TupleFunc::execute() { ComValue* operand1 = new ComValue(stack_arg(0)); ComValue* operand2 = new ComValue(stack_arg(1)); reset_stack(); if (!operand1->is_array() || operand1->array_val()->nested_insert()) { AttributeValueList* avl = new AttributeValueList(); avl->Append(operand1); avl->Append(operand2); ComValue retval(avl); push_stack(retval); if( operand1->is_array()) operand1->array_val()->nested_insert(false); } else { AttributeValueList* avl = operand1->array_val(); avl->Append(operand2); push_stack(*operand1); delete operand1; } if (operand2->is_array()) operand2->array_val()->nested_insert(false); } /*****************************************************************************/ ListIndexFunc::ListIndexFunc(ComTerp* comterp) : ComFunc(comterp) { } void ListIndexFunc::execute() { ComValue listorstrv(stack_arg(0)); ComValue valv(stack_arg(1)); static int last_symid = symbol_add("last"); ComValue lastv(stack_key(last_symid)); boolean lastflag = lastv.is_true(); static int all_symid = symbol_add("all"); ComValue allv(stack_key(all_symid)); boolean allflag = allv.is_true(); reset_stack(); AttributeValueList *nvl = allflag ? new AttributeValueList : nil; if (listorstrv.is_array()) { AttributeValueList* avl = listorstrv.array_val(); Iterator it; if (lastflag) avl->Last(it); else avl->First(it); int index= lastflag ? avl->Number()-1 : 0; while(!avl->Done(it)) { AttributeValue* testv = avl->GetAttrVal(it); comterp()->push_stack(*testv); comterp()->push_stack(valv); EqualFunc eqfunc(comterp()); eqfunc.exec(2,0); if(comterp()->pop_stack().is_true()) { if (allflag) nvl->Append(new AttributeValue(index, AttributeValue::IntType)); else { ComValue retval(index, ComValue::IntType); push_stack(retval); return; } } if (lastflag) avl->Prev(it); else avl->Next(it); index += lastflag ? -1 : 1; }; } else if (listorstrv.is_string()) { if (valv.is_char()) { const char* string = listorstrv.string_ptr(); int sz=strlen(string); int i= lastflag ? sz : 0; while(lastflag ? i>=0 : iAppend(new AttributeValue(i, AttributeValue::IntType)); else { ComValue retval(i, ComValue::IntType); push_stack(retval); return; } } i = i + (lastflag?-1:1); } } else if (valv.is_string()) { const char* string = listorstrv.string_ptr(); const char* foundstr = strstr(string, valv.symbol_ptr()); const char* newfoundstr = foundstr; if((lastflag||allflag) && foundstr!=NULL) { do { foundstr = newfoundstr; newfoundstr = strstr(foundstr+strlen(valv.symbol_ptr()), valv.symbol_ptr()); if(allflag) { if(lastflag) nvl->Prepend(new AttributeValue((int)(foundstr-string), AttributeValue::IntType)); else nvl->Append(new AttributeValue((int)(foundstr-string), AttributeValue::IntType)); } } while (newfoundstr!=NULL); } if(foundstr!=NULL && !allflag) { ComValue retval((int)(foundstr-string), ComValue::IntType); push_stack(retval); return; } } } if(allflag) { ComValue retval(nvl); push_stack(retval); return; } push_stack(ComValue::nullval()); return; } ivtools-1.2.11a1/src/ComTerp/listfunc.h000066400000000000000000000065111214471147700176700ustar00rootroot00000000000000/* * Copyright (c) 2011 Wave Semiconductor Inc. * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * collection of list manipulation functions */ #if !defined(_listfunc_h) #define _listfunc_h #include class ComTerp; class ComValue; //: create list command for ComTerp. // lst=list([olst|strm|val] :strmlst :attr :size n) -- create list, copy list, or convert stream class ListFunc : public ComFunc { public: ListFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "lst=%s([olst|strm|val] :strmlst :attr :size n) -- create list, copy list, or convert stream"; } }; //: list member command for ComTerp. // val=at(list|attrlist|str n :set val :ins val) -- return (or set or insert after) the nth item in a list or string. class ListAtFunc : public ComFunc { public: ListAtFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "val=at(list|attrlist n :set val :ins val) -- return (or set or insert after) the nth item in a list"; } }; //: list size command for ComTerp. // num=size(list|attrlist|string) -- return size of a list (or string). class ListSizeFunc : public ComFunc { public: ListSizeFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "val=size(list|attrlist|string) -- return the size of the list (or string)"; } }; //: , (tuple) operator. class TupleFunc : public ComFunc { public: TupleFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return ", is the tuple operator"; } CLASS_SYMID("TupleFunc"); }; //: list index command for ComTerp. // val=index(list|str val|char|str :last :all) -- return index of value (or char or string) in list (or string), nil if not found. class ListIndexFunc : public ComFunc { public: ListIndexFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "num=index(list|str val|char|str :last :all) -- return index of value (or char or string) in list (or string), nil if not found"; } }; #endif /* !defined(_listfunc_h) */ ivtools-1.2.11a1/src/ComTerp/mathfunc.cc000066400000000000000000000140671214471147700200110ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #define TITLE "MathFunc" /*****************************************************************************/ ExpFunc::ExpFunc(ComTerp* comterp) : ComFunc(comterp) { } void ExpFunc::execute() { ComValue operandx = stack_arg(0); reset_stack(); if (operandx.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(exp(operandx.double_val())); push_stack(result); } LogFunc::LogFunc(ComTerp* comterp) : ComFunc(comterp) { } void LogFunc::execute() { ComValue operandx = stack_arg(0); reset_stack(); if (operandx.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(log(operandx.double_val())); push_stack(result); } Log10Func::Log10Func(ComTerp* comterp) : ComFunc(comterp) { } void Log10Func::execute() { ComValue operandx = stack_arg(0); reset_stack(); if (operandx.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(log10(operandx.double_val())); push_stack(result); } PowFunc::PowFunc(ComTerp* comterp) : ComFunc(comterp) { } void PowFunc::execute() { ComValue operandx = stack_arg(0); ComValue operandy = stack_arg(1); reset_stack(); if (operandx.is_nil() || operandy.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(pow(operandx.double_val(), operandy.double_val())); push_stack(result); } ACosFunc::ACosFunc(ComTerp* comterp) : ComFunc(comterp) { } void ACosFunc::execute() { ComValue operandx = stack_arg(0); reset_stack(); if (operandx.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(acos(operandx.double_val())); push_stack(result); } ASinFunc::ASinFunc(ComTerp* comterp) : ComFunc(comterp) { } void ASinFunc::execute() { ComValue operandx = stack_arg(0); reset_stack(); if (operandx.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(asin(operandx.double_val())); push_stack(result); } ATanFunc::ATanFunc(ComTerp* comterp) : ComFunc(comterp) { } void ATanFunc::execute() { ComValue operandx = stack_arg(0); reset_stack(); if (operandx.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(atan(operandx.double_val())); push_stack(result); } ATan2Func::ATan2Func(ComTerp* comterp) : ComFunc(comterp) { } void ATan2Func::execute() { ComValue operandx = stack_arg(0); ComValue operandy = stack_arg(0); reset_stack(); if (operandx.is_nil() || operandy.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(atan2(operandx.double_val(),operandy.double_val())); push_stack(result); } CosFunc::CosFunc(ComTerp* comterp) : ComFunc(comterp) { } void CosFunc::execute() { ComValue operandx = stack_arg(0); reset_stack(); if (operandx.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(cos(operandx.double_val())); push_stack(result); } SinFunc::SinFunc(ComTerp* comterp) : ComFunc(comterp) { } void SinFunc::execute() { ComValue operandx = stack_arg(0); reset_stack(); if (operandx.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(sin(operandx.double_val())); push_stack(result); } TanFunc::TanFunc(ComTerp* comterp) : ComFunc(comterp) { } void TanFunc::execute() { ComValue operandx = stack_arg(0); reset_stack(); if (operandx.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(tan(operandx.double_val())); push_stack(result); } SqrtFunc::SqrtFunc(ComTerp* comterp) : ComFunc(comterp) { } void SqrtFunc::execute() { ComValue operandx = stack_arg(0); reset_stack(); if (operandx.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(sqrt(operandx.double_val())); push_stack(result); } PiFunc::PiFunc(ComTerp* comterp) : ComFunc(comterp) { } void PiFunc::execute() { reset_stack(); ComValue result((double)3.1415926535897932270E0); push_stack(result); } RadToDegFunc::RadToDegFunc(ComTerp* comterp) : ComFunc(comterp) { } void RadToDegFunc::execute() { ComValue operandx = stack_arg(0); reset_stack(); if (operandx.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(operandx.double_val()*360.0/(2*3.1415926535897932270E0)); push_stack(result); } DegToRadFunc::DegToRadFunc(ComTerp* comterp) : ComFunc(comterp) { } void DegToRadFunc::execute() { ComValue operandx = stack_arg(0); reset_stack(); if (operandx.is_nil()) { push_stack(ComValue::nullval()); return; } ComValue result(operandx.double_val()*2*3.1415926535897932270E0/360.); push_stack(result); } ivtools-1.2.11a1/src/ComTerp/mathfunc.h000066400000000000000000000133301214471147700176430ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1998,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * This is a collection of mathematical operators. */ #if !defined(_mathfunc_h) #define _mathfunc_h #include //: exponential command for ComTerp. // dbl=exp(x) -- returns the value e raised to the power of x. class ExpFunc : public ComFunc { public: ExpFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x) -- returns the value e raised to the power of x"; } }; //: logarithmic (natural) command for ComTerp. // dbl=log(x) -- returns the natural logarithm of x. class LogFunc : public ComFunc { public: LogFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x) -- returns the natural logarithm of x"; } }; //: logarithmic (base 10) command for ComTerp. // dbl=log10(x) -- returns the base-10 logarithm of x. class Log10Func : public ComFunc { public: Log10Func(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x) -- returns the base-10 logarithm of x"; } }; //: power command for ComTerp. // dbl=pow(x y) -- returns the value of x raised to the power of y. class PowFunc : public ComFunc { public: PowFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x y) -- returns the value of x raised to the power of y"; } }; //: arc-cosine command for ComTerp. // dbl=acos(x) -- returns the arc cosine of x in radians. class ACosFunc : public ComFunc { public: ACosFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x) -- returns the arc cosine of x in radians"; } }; //: arc-sine command for ComTerp. // dbl=asin(x) -- returns the arc sine of x in radians. class ASinFunc : public ComFunc { public: ASinFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x) -- returns the arc sine of x in radians"; } }; //: arc-tangent command for ComTerp. // dbl=atan(x) -- returns the arc tangent of x in radians. class ATanFunc : public ComFunc { public: ATanFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x) -- returns the arc tangent of x in radians"; } }; //: arc-tangent (of y over x) command for ComTerp. // dbl=atan2(y x) -- returns the arc tangent of y over x. class ATan2Func : public ComFunc { public: ATan2Func(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(y x) -- returns the arc tangent of y over x"; } }; //: cosine command for ComTerp. // dbl=cos(x) -- returns the cosine of x radians. class CosFunc : public ComFunc { public: CosFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x) -- returns the cosine of x radians"; } }; //: sine command for ComTerp. // dbl=sin(x) -- returns the sine of x radians. class SinFunc : public ComFunc { public: SinFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x) -- returns the sine of x radians"; } }; //: tangent command for ComTerp. // dbl=tan(x) -- returns the tangent of x radians. class TanFunc : public ComFunc { public: TanFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x) -- returns the tangent of x radians"; } }; //: square-root command for ComTerp. // dbl=sqrt(x) -- returns square root of x. class SqrtFunc : public ComFunc { public: SqrtFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x) -- returns square root of x"; } }; //: Pi command for ComTerp. // dbl=pi() -- returns the value of pi. class PiFunc : public ComFunc { public: PiFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s() -- returns the value of pi"; } }; //: radians to degrees command for ComTerp. // dbl=radtodeg(dbl) -- convert radians to degrees class RadToDegFunc : public ComFunc { public: RadToDegFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x) -- convert radians to degrees"; } }; //: degrees to radianscommand for ComTerp. // dbl=degtorad(dbl) -- convert degrees to radians class DegToRadFunc : public ComFunc { public: DegToRadFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "dbl=%s(x) -- convert radians to degrees"; } }; #endif /* !defined(_mathfunc_h) */ ivtools-1.2.11a1/src/ComTerp/numfunc.cc000066400000000000000000001012511214471147700176470ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 1994,1995,1999,2000 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #define TITLE "NumFunc" /*****************************************************************************/ NumFunc::NumFunc(ComTerp* comterp) : ComFunc(comterp) { } void NumFunc::promote(ComValue& op1, ComValue& op2) { if (op1.type() == op2.type()) return; #if 0 if (op1.is_unknown() || op2.is_unknown()) { op1.type(ComValue::UnknownType); op2.type(ComValue::UnknownType); return; } #endif boolean op1bigger = op1.type()!=ComValue::BooleanType ? op1.type() > op2.type() : false; ComValue* greater = op1bigger ? &op1 : &op2; ComValue* lesser = op1bigger ? &op2 : &op1; /* skip promotion if first is string */ if (op1.type()==ComValue::StringType) return; /* first do the integral promotions if necessary */ switch (greater->type()) { case ComValue::CharType: greater->int_ref() = greater->char_val(); greater->type(ComValue::IntType); break; case ComValue::UCharType: greater->int_ref() = greater->uchar_val(); greater->type(ComValue::IntType); break; case ComValue::ShortType: greater->int_ref() = greater->short_val(); greater->type(ComValue::IntType); break; case ComValue::UShortType: greater->int_ref() = greater->ushort_val(); greater->type(ComValue::IntType); break; default: break; } switch (lesser->type()) { case ComValue::BooleanType: lesser->int_ref() = lesser->boolean_val(); lesser->type(ComValue::IntType); break; case ComValue::CharType: lesser->int_ref() = lesser->char_val(); lesser->type(ComValue::IntType); break; case ComValue::UCharType: lesser->int_ref() = lesser->uchar_val(); lesser->type(ComValue::IntType); break; case ComValue::ShortType: lesser->int_ref() = lesser->short_val(); lesser->type(ComValue::IntType); break; case ComValue::UShortType: lesser->int_ref() = lesser->ushort_val(); lesser->type(ComValue::IntType); break; default: break; } /* now promote as necessary */ switch (greater->type()) { case ComValue::UIntType: switch (lesser->type()) { case ComValue::IntType: lesser->uint_ref() = lesser->uint_val(); break; } lesser->type(ComValue::UIntType); break; case ComValue::LongType: switch (lesser->type()) { case ComValue::IntType: lesser->long_ref() = lesser->int_val(); break; case ComValue::UIntType: lesser->long_ref() = lesser->uint_val(); break; } lesser->type(ComValue::LongType); break; case ComValue::ULongType: switch (lesser->type()) { case ComValue::IntType: lesser->ulong_ref() = lesser->int_val(); break; case ComValue::UIntType: lesser->ulong_ref() = lesser->uint_val(); break; case ComValue::LongType: lesser->ulong_ref() = lesser->long_val(); break; } lesser->type(ComValue::ULongType); break; case ComValue::FloatType: switch (lesser->type()) { case ComValue::IntType: lesser->float_ref() = lesser->int_val(); break; case ComValue::UIntType: lesser->float_ref() = lesser->uint_val(); break; case ComValue::LongType: lesser->float_ref() = lesser->long_val(); break; case ComValue::ULongType: lesser->float_ref() = lesser->ulong_val(); break; } lesser->type(ComValue::FloatType); break; case ComValue::DoubleType: switch (lesser->type()) { case ComValue::IntType: lesser->double_ref() = lesser->int_val(); break; case ComValue::UIntType: lesser->double_ref() = lesser->uint_val(); break; case ComValue::LongType: lesser->double_ref() = lesser->long_val(); break; case ComValue::ULongType: lesser->double_ref() = lesser->ulong_val(); break; case ComValue::FloatType: lesser->double_ref() = lesser->float_val(); break; } lesser->type(ComValue::DoubleType); break; default: break; } return; } /*****************************************************************************/ AddFunc::AddFunc(ComTerp* comterp) : NumFunc(comterp) { } void AddFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); if (operand1.is_unknown() || operand2.is_unknown()) { reset_stack(); push_stack(ComValue::nullval()); return; } switch (result.type()) { case ComValue::BooleanType: result.int_ref() = operand1.int_val() + operand2.int_val(); result.type(ComValue::IntType); break; case ComValue::CharType: result.char_ref() = operand1.char_val() + operand2.char_val(); break; case ComValue::UCharType: result.uchar_ref() = operand1.uchar_val() + operand2.uchar_val(); break; case ComValue::ShortType: result.short_ref() = operand1.short_val() + operand2.short_val(); break; case ComValue::UShortType: result.ushort_ref() = operand1.ushort_val() + operand2.ushort_val(); break; case ComValue::IntType: result.int_ref() = operand1.int_val() + operand2.int_val(); break; case ComValue::UIntType: result.uint_ref() = operand1.uint_val() + operand2.uint_val(); break; case ComValue::LongType: result.long_ref() = operand1.long_val() + operand2.long_val(); break; case ComValue::ULongType: result.ulong_ref() = operand1.ulong_val() + operand2.ulong_val(); break; case ComValue::FloatType: result.float_ref() = operand1.float_val() + operand2.float_val(); break; case ComValue::DoubleType: result.double_ref() = operand1.double_val() + operand2.double_val(); break; case ComValue::StringType: { // braces are work-around for gcc-2.8.1 bug in stack mgmt. if (operand2.is_string()) { int len1 = strlen(operand1.string_ptr()); int len2 = strlen(operand2.string_ptr()); char buffer[len1+len2+1]; strcpy(buffer, operand1.string_ptr()); strcpy(buffer+len1, operand2.string_ptr()); result.string_ref() = symbol_add(buffer); // symbol_reference(result.string_val()); } else { int len1 = strlen(operand1.string_ptr()); char buffer[len1+2]; strcpy(buffer, operand1.string_ptr()); buffer[len1] = operand2.char_val(); buffer[len1+1] = '\0'; result.string_ref() = symbol_add(buffer); // symbol_reference(result.string_val()); } } break; case ComValue::ArrayType: { if (operand2.is_array()) { Resource::unref(result.array_val()); result.array_ref() = AddFunc::matrix_add(operand1.array_val(), operand2.array_val()); Resource::ref(result.array_val()); } else result.type(ComValue::UnknownType); // nil } break; } reset_stack(); push_stack(result); } AttributeValueList* AddFunc::matrix_add(AttributeValueList* list1, AttributeValueList* list2) { AttributeValueList* sum = new AttributeValueList(); Iterator it1, it2; list1->First(it1); list2->First(it2); while (!list1->Done(it1) && !list2->Done(it2)) { push_stack(*list1->GetAttrVal(it1)); push_stack(*list2->GetAttrVal(it2)); exec(2, 0); ComValue topval(comterp()->pop_stack()); sum->Append(new AttributeValue(topval)); list1->Next(it1); list2->Next(it2); } return sum; } SubFunc::SubFunc(ComTerp* comterp) : NumFunc(comterp) { } void SubFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); if (operand1.is_unknown() || operand2.is_unknown()) { reset_stack(); push_stack(ComValue::nullval()); return; } switch (result.type()) { case ComValue::CharType: result.char_ref() = operand1.char_val() - operand2.char_val(); break; case ComValue::UCharType: result.uchar_ref() = operand1.uchar_val() - operand2.uchar_val(); break; case ComValue::ShortType: result.short_ref() = operand1.short_val() - operand2.short_val(); break; case ComValue::UShortType: result.ushort_ref() = operand1.ushort_val() - operand2.ushort_val(); break; case ComValue::IntType: result.int_ref() = operand1.int_val() - operand2.int_val(); break; case ComValue::UIntType: result.uint_ref() = operand1.uint_val() - operand2.uint_val(); break; case ComValue::LongType: result.long_ref() = operand1.long_val() - operand2.long_val(); break; case ComValue::ULongType: result.ulong_ref() = operand1.ulong_val() - operand2.ulong_val(); break; case ComValue::FloatType: result.float_ref() = operand1.float_val() - operand2.float_val(); break; case ComValue::DoubleType: result.double_ref() = operand1.double_val() - operand2.double_val(); break; } reset_stack(); push_stack(result); } MinusFunc::MinusFunc(ComTerp* comterp) : NumFunc(comterp) { } void MinusFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue result(operand1); if (operand1.is_unknown()) { reset_stack(); push_stack(ComValue::nullval()); return; } switch (result.type()) { case ComValue::CharType: result.char_ref() = - operand1.char_val(); break; case ComValue::UCharType: result.uchar_ref() = - operand1.uchar_val(); break; case ComValue::ShortType: result.short_ref() = - operand1.short_val(); break; case ComValue::UShortType: result.ushort_ref() = - operand1.ushort_val(); break; case ComValue::IntType: result.int_ref() = - operand1.int_val(); break; case ComValue::UIntType: result.uint_ref() = - operand1.uint_val(); break; case ComValue::LongType: result.long_ref() = - operand1.long_val(); break; case ComValue::ULongType: result.ulong_ref() = - operand1.ulong_val(); break; case ComValue::FloatType: result.float_ref() = - operand1.float_val(); break; case ComValue::DoubleType: result.double_ref() = - operand1.double_val(); break; } reset_stack(); push_stack(result); } MpyFunc::MpyFunc(ComTerp* comterp) : NumFunc(comterp) { } void MpyFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); if (operand1.is_unknown() || operand2.is_unknown()) { reset_stack(); push_stack(ComValue::nullval()); return; } switch (result.type()) { case ComValue::CharType: result.char_ref() = operand1.char_val() * operand2.char_val(); break; case ComValue::UCharType: result.uchar_ref() = operand1.uchar_val() * operand2.uchar_val(); break; case ComValue::ShortType: result.short_ref() = operand1.short_val() * operand2.short_val(); break; case ComValue::UShortType: result.ushort_ref() = operand1.ushort_val() * operand2.ushort_val(); break; case ComValue::IntType: result.int_ref() = operand1.int_val() * operand2.int_val(); break; case ComValue::UIntType: result.uint_ref() = operand1.uint_val() * operand2.uint_val(); break; case ComValue::LongType: result.long_ref() = operand1.long_val() * operand2.long_val(); break; case ComValue::ULongType: result.ulong_ref() = operand1.ulong_val() * operand2.ulong_val(); break; case ComValue::FloatType: result.float_ref() = operand1.float_val() * operand2.float_val(); break; case ComValue::DoubleType: result.double_ref() = operand1.double_val() * operand2.double_val(); break; case ComValue::ArrayType: { if (operand2.is_array()) { Resource::unref(result.array_val()); AttributeValueList* avl = MpyFunc::matrix_mpy(operand1.array_val(), operand2.array_val()); if (avl) { result.array_ref() = avl; Resource::ref(result.array_val()); } else result.type(ComValue::UnknownType); // nil } else result.type(ComValue::UnknownType); // nil } break; } reset_stack(); push_stack(result); } AttributeValueList* MpyFunc::matrix_mpy(AttributeValueList* list1, AttributeValueList* list2) { static AddFunc addfunc(comterp()); Iterator it1, it2; list1->First(it1); list2->First(it2); // extract dimensions int i1max, j1max; int i2max, j2max; i1max = list1->Number(); i2max = list2->Number(); j1max = list1->GetAttrVal(it1)->is_array() && list1->GetAttrVal(it1)->array_val() ? list1->GetAttrVal(it1)->array_val()->Number() : 0; j2max = list2->GetAttrVal(it2)->is_array() && list1->GetAttrVal(it2)->array_val() ? list1->GetAttrVal(it2)->array_val()->Number() : 0; /* ensure inner dimension is the same */ /* allow for vector argument on rhs */ if (j1max != i2max && (j1max || i2max!=1)) return nil; /* ensure each row is of equal length */ list1->First(it1); list1->Next(it1); while (!list1->Done(it1)) { int jlen = list1->GetAttrVal(it1)->is_array() && list1->GetAttrVal(it1)->array_val() ? list1->GetAttrVal(it1)->array_val()->Number() : 0; if (jlen != j1max) return nil; list1->Next(it1); } list2->First(it2); list2->Next(it2); while (!list2->Done(it2)) { int jlen = list2->GetAttrVal(it2)->is_array() && list2->GetAttrVal(it2)->array_val() ? list2->GetAttrVal(it2)->array_val()->Number() : 0; if (jlen != j2max) return nil; list2->Next(it2); } AttributeValueList* product = new AttributeValueList(); int i3max = i1max; int j3max = j2max; /* loop over output rows */ Iterator iti1, itj1; list1->First(iti1); for (int i3=0; i3Append(new AttributeValue(prodrow)); AttributeValue* row1v = list1->GetAttrVal(iti1); AttributeValueList* row1 = row1v && row1v->is_array() ? row1v->array_val() : nil; if (j3max) { /* loop over output columns */ for (int j3=0; j3First(itj1); /* generate inner product */ for (int n=0; nFirst(iti2); for (int i=0; iNext(iti2); AttributeValue* row2v = list1->GetAttrVal(iti2); AttributeValueList* row2 = row2v && row2v->is_array() ? row2v->array_val() : nil; if (row2) { row2->First(itj2); for (int j=0; jNext(itj2); } if ((row1 || !j1max) && row2) { if (row1) comterp()->push_stack(*row1->GetAttrVal(itj1)); else comterp()->push_stack(*row1v); comterp()->push_stack(*row2->GetAttrVal(itj2)); exec(2,0); if (n) addfunc.exec(2,0); } if (row1) row1->Next(itj1); } ComValue topval(comterp()->pop_stack()); prodrow->Append(new AttributeValue(topval)); } /* done looping over output columsn */ } else { /* handle single output column */ if (row1) row1->First(itj1); /* generate inner product */ for (int n=0; nFirst(iti2); for (int i=0; iNext(iti2); AttributeValue* val2v = list1->GetAttrVal(iti2); if ((row1 || !j1max) && val2v) { if (row1) comterp()->push_stack(*row1->GetAttrVal(itj1)); else comterp()->push_stack(*row1v); comterp()->push_stack(*val2v); exec(2,0); if (n) addfunc.exec(2,0); } if (row1) row1->Next(itj1); } ComValue topval(comterp()->pop_stack()); prodrow->Append(new AttributeValue(topval)); } list1->Next(iti1); } /* done looping over output rows */ return product; } DivFunc::DivFunc(ComTerp* comterp) : NumFunc(comterp) { } void DivFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); if (operand1.is_unknown() || operand2.is_unknown()) { reset_stack(); push_stack(ComValue::nullval()); return; } ComValue result(operand1); switch (result.type()) { case ComValue::CharType: if (operand2.char_val()!=0) result.char_ref() = operand1.char_val() / operand2.char_val(); else COMERR_SET(ERR_DIV_BY_ZERO); break; case ComValue::UCharType: if (operand2.uchar_val()!=0) result.uchar_ref() = operand1.uchar_val() / operand2.uchar_val(); else COMERR_SET(ERR_DIV_BY_ZERO); break; case ComValue::ShortType: if (operand2.short_val()!=0) result.short_ref() = operand1.short_val() / operand2.short_val(); else COMERR_SET(ERR_DIV_BY_ZERO); break; case ComValue::UShortType: if (operand2.ushort_val()!=0) result.ushort_ref() = operand1.ushort_val() / operand2.ushort_val(); else COMERR_SET(ERR_DIV_BY_ZERO); break; case ComValue::IntType: if (operand2.int_val()!=0) result.int_ref() = operand1.int_val() / operand2.int_val(); else COMERR_SET(ERR_DIV_BY_ZERO); break; case ComValue::UIntType: if (operand2.uint_val()!=0) result.uint_ref() = operand1.uint_val() / operand2.uint_val(); else COMERR_SET(ERR_DIV_BY_ZERO); break; case ComValue::LongType: if (operand2.long_val()!=0) result.long_ref() = operand1.long_val() / operand2.long_val(); else COMERR_SET(ERR_DIV_BY_ZERO); break; case ComValue::ULongType: if (operand2.ulong_val()!=0) result.ulong_ref() = operand1.ulong_val() / operand2.ulong_val(); else COMERR_SET(ERR_DIV_BY_ZERO); break; case ComValue::FloatType: if (operand2.float_val()!=0) result.float_ref() = operand1.float_val() / operand2.float_val(); else COMERR_SET(ERR_DIV_BY_ZERO); break; case ComValue::DoubleType: if (operand2.double_val()!=0) result.double_ref() = operand1.double_val() / operand2.double_val(); else COMERR_SET(ERR_DIV_BY_ZERO); break; } reset_stack(); push_stack(result); } ModFunc::ModFunc(ComTerp* comterp) : NumFunc(comterp) { } void ModFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); if (operand1.is_unknown() || operand2.is_unknown()) { reset_stack(); push_stack(ComValue::nullval()); return; } switch (result.type()) { case ComValue::CharType: if (operand2.char_val()!=0) result.char_ref() = operand1.char_val() % operand2.char_val(); else COMERR_SET(ERR_MOD_BY_ZERO); break; case ComValue::UCharType: if (operand2.uchar_val()!=0) result.uchar_ref() = operand1.uchar_val() % operand2.uchar_val(); else COMERR_SET(ERR_MOD_BY_ZERO); break; case ComValue::ShortType: if (operand2.short_val()!=0) result.short_ref() = operand1.short_val() % operand2.short_val(); else COMERR_SET(ERR_MOD_BY_ZERO); break; case ComValue::UShortType: if (operand2.ushort_val()!=0) result.ushort_ref() = operand1.ushort_val() % operand2.ushort_val(); else COMERR_SET(ERR_MOD_BY_ZERO); break; case ComValue::IntType: if (operand2.int_val()!=0) result.int_ref() = operand1.int_val() % operand2.int_val(); else COMERR_SET(ERR_MOD_BY_ZERO); break; case ComValue::UIntType: if (operand2.uint_val()!=0) result.uint_ref() = operand1.uint_val() % operand2.uint_val(); else COMERR_SET(ERR_MOD_BY_ZERO); break; case ComValue::LongType: if (operand2.long_val()!=0) result.long_ref() = operand1.long_val() % operand2.long_val(); else COMERR_SET(ERR_MOD_BY_ZERO); break; case ComValue::ULongType: if (operand2.ulong_val()!=0) result.ulong_ref() = operand1.ulong_val() % operand2.ulong_val(); else COMERR_SET(ERR_MOD_BY_ZERO); break; case ComValue::FloatType: if (operand2.float_val()!=0) result.float_ref() = (long) operand1.float_val() % (long) operand2.float_val(); else COMERR_SET(ERR_MOD_BY_ZERO); break; case ComValue::DoubleType: if (operand2.double_val()!=0) result.double_ref() = (long) operand1.double_val() % (long) operand2.double_val(); else COMERR_SET(ERR_MOD_BY_ZERO); break; } reset_stack(); push_stack(result); } MinFunc::MinFunc(ComTerp* comterp) : NumFunc(comterp) { } void MinFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); if (operand1.is_unknown() || operand2.is_unknown()) { reset_stack(); push_stack(ComValue::nullval()); return; } switch (result.type()) { case ComValue::CharType: result.char_ref() = operand1.char_val() < operand2.char_val() ? operand1.char_val() : operand2.char_val(); break; case ComValue::UCharType: result.uchar_ref() = operand1.uchar_val() < operand2.uchar_val() ? operand1.uchar_val() : operand2.uchar_val(); break; case ComValue::ShortType: result.short_ref() = operand1.short_val() < operand2.short_val() ? operand1.short_val() : operand2.short_val(); break; case ComValue::UShortType: result.ushort_ref() = operand1.ushort_val() < operand2.ushort_val() ? operand1.ushort_val() : operand2.ushort_val(); break; case ComValue::IntType: result.int_ref() = operand1.int_val() < operand2.int_val() ? operand1.int_val() : operand2.int_val(); break; case ComValue::UIntType: result.uint_ref() = operand1.uint_val() < operand2.uint_val() ? operand1.uint_val() : operand2.uint_val(); break; case ComValue::LongType: result.long_ref() = operand1.long_val() < operand2.long_val() ? operand1.long_val() : operand2.long_val(); break; case ComValue::ULongType: result.ulong_ref() = operand1.ulong_val() < operand2.ulong_val() ? operand1.ulong_val() : operand2.ulong_val(); break; case ComValue::FloatType: result.float_ref() = operand1.float_val() < operand2.float_val() ? operand1.float_val() : operand2.float_val(); break; case ComValue::DoubleType: result.double_ref() = operand1.double_val() < operand2.double_val() ? operand1.double_val() : operand2.double_val(); break; case ComValue::UnknownType: result.assignval(operand2); break; } reset_stack(); push_stack(result); } MaxFunc::MaxFunc(ComTerp* comterp) : NumFunc(comterp) { } void MaxFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue& operand2 = stack_arg(1); promote(operand1, operand2); ComValue result(operand1); if (operand1.is_unknown() || operand2.is_unknown()) { reset_stack(); push_stack(ComValue::nullval()); return; } switch (result.type()) { case ComValue::CharType: result.char_ref() = operand1.char_val() > operand2.char_val() ? operand1.char_val() : operand2.char_val(); break; case ComValue::UCharType: result.uchar_ref() = operand1.uchar_val() > operand2.uchar_val() ? operand1.uchar_val() : operand2.uchar_val(); break; case ComValue::ShortType: result.short_ref() = operand1.short_val() > operand2.short_val() ? operand1.short_val() : operand2.short_val(); break; case ComValue::UShortType: result.ushort_ref() = operand1.ushort_val() > operand2.ushort_val() ? operand1.ushort_val() : operand2.ushort_val(); break; case ComValue::IntType: result.int_ref() = operand1.int_val() > operand2.int_val() ? operand1.int_val() : operand2.int_val(); break; case ComValue::UIntType: result.uint_ref() = operand1.uint_val() > operand2.uint_val() ? operand1.uint_val() : operand2.uint_val(); break; case ComValue::LongType: result.long_ref() = operand1.long_val() > operand2.long_val() ? operand1.long_val() : operand2.long_val(); break; case ComValue::ULongType: result.ulong_ref() = operand1.ulong_val() > operand2.ulong_val() ? operand1.ulong_val() : operand2.ulong_val(); break; case ComValue::FloatType: result.float_ref() = operand1.float_val() > operand2.float_val() ? operand1.float_val() : operand2.float_val(); break; case ComValue::DoubleType: result.double_ref() = operand1.double_val() > operand2.double_val() ? operand1.double_val() : operand2.double_val(); break; case ComValue::UnknownType: result.assignval(operand2); break; } reset_stack(); push_stack(result); } AbsFunc::AbsFunc(ComTerp* comterp) : NumFunc(comterp) { } void AbsFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue result(operand1); if (operand1.is_unknown()) { reset_stack(); push_stack(ComValue::nullval()); return; } switch (result.type()) { case ComValue::CharType: result.char_ref() = operand1.char_val() < 0 ? -operand1.char_val() : operand1.char_val(); break; case ComValue::ShortType: result.short_ref() = operand1.short_val() < 0 ? -operand1.short_val() : operand1.short_val(); break; case ComValue::IntType: result.int_ref() = operand1.int_val() < 0 ? -operand1.int_val() : operand1.int_val(); break; case ComValue::LongType: result.long_ref() = operand1.long_val() < 0 ? -operand1.long_val() : operand1.long_val(); break; case ComValue::FloatType: result.float_ref() = operand1.float_val() < 0.0 ? -operand1.float_val() : operand1.float_val(); break; case ComValue::DoubleType: result.double_ref() = operand1.double_val() < 0.0 ? -operand1.double_val() : operand1.double_val(); break; } reset_stack(); push_stack(result); } CharFunc::CharFunc(ComTerp* comterp) : ComFunc(comterp) {} void CharFunc::execute() { ComValue operand(stack_arg(0)); static int u_symid = symbol_add("u"); int uval_flag = stack_key(u_symid).is_true(); reset_stack(); if (operand.is_string()) { const char* numstr = operand.symbol_ptr(); int negflag = *numstr=='-'; AttributeValue* av = ParamList::lexscan()->get_attrval((char*)numstr+negflag, strlen(numstr+negflag)); operand = ComValue(av->char_val()); if (negflag) operand.char_ref() = - operand.char_val(); delete av; } ComValue result(operand.char_val(), operand.is_nil() ? ComValue::UnknownType : (uval_flag ? ComValue::UCharType : ComValue::CharType)); push_stack(result); } ShortFunc::ShortFunc(ComTerp* comterp) : ComFunc(comterp) {} void ShortFunc::execute() { ComValue operand(stack_arg(0)); static int u_symid = symbol_add("u"); int uval_flag = stack_key(u_symid).is_true(); reset_stack(); if (operand.is_string()) { const char* numstr = operand.symbol_ptr(); int negflag = *numstr=='-'; AttributeValue* av = ParamList::lexscan()->get_attrval((char*)numstr+negflag, strlen(numstr+negflag)); operand = ComValue(av->short_val()); if (negflag) operand.short_ref() = - operand.short_val(); delete av; } ComValue result(operand.short_val(), operand.is_nil() ? ComValue::UnknownType : (uval_flag ? ComValue::UShortType : ComValue::ShortType)); push_stack(result); } IntFunc::IntFunc(ComTerp* comterp) : ComFunc(comterp) {} void IntFunc::execute() { ComValue operand(stack_arg(0)); static int u_symid = symbol_add("u"); int uval_flag = stack_key(u_symid).is_true(); reset_stack(); if (operand.is_string()) { const char* numstr = operand.symbol_ptr(); int negflag = *numstr=='-'; AttributeValue* av = ParamList::lexscan()->get_attrval((char*)numstr+negflag, strlen(numstr+negflag)); operand = ComValue(av->int_val(), ComValue::IntType); if (negflag) operand.int_ref() = - operand.int_val(); delete av; } ComValue result(operand.int_val(), operand.is_nil() ? ComValue::UnknownType : (uval_flag ? ComValue::UIntType : ComValue::IntType)); push_stack(result); } LongFunc::LongFunc(ComTerp* comterp) : ComFunc(comterp) {} void LongFunc::execute() { ComValue operand(stack_arg(0)); static int u_symid = symbol_add("u"); int uval_flag = stack_key(u_symid).is_true(); reset_stack(); if (operand.is_string()) { const char* numstr = operand.symbol_ptr(); int negflag = *numstr=='-'; AttributeValue* av = ParamList::lexscan()->get_attrval((char*)numstr+negflag, strlen(numstr+negflag)); operand = ComValue(av->long_val()); if (negflag) operand.long_ref() = - operand.long_val(); delete av; } ComValue result(operand.long_val()); if(uval_flag) result.type(ComValue::ULongType); push_stack(result); } FloatFunc::FloatFunc(ComTerp* comterp) : ComFunc(comterp) {} void FloatFunc::execute() { ComValue operand(stack_arg(0)); reset_stack(); if (operand.is_string()) { const char* numstr = operand.symbol_ptr(); int negflag = *numstr=='-'; AttributeValue* av = ParamList::lexscan()->get_attrval((char*)numstr+negflag, strlen(numstr+negflag)); operand = ComValue(av->float_val()); if (negflag) operand.float_ref() = - operand.float_val(); delete av; } ComValue result(operand.float_val()); push_stack(result); } DoubleFunc::DoubleFunc(ComTerp* comterp) : ComFunc(comterp) {} void DoubleFunc::execute() { ComValue operand(stack_arg(0)); reset_stack(); if (operand.is_string()) { const char* numstr = operand.symbol_ptr(); int negflag = *numstr=='-'; AttributeValue* av = ParamList::lexscan()->get_attrval((char*)numstr+negflag, strlen(numstr+negflag)); operand = ComValue(av->double_val()); if (negflag) operand.double_ref() = - operand.double_val(); delete av; } ComValue result(operand.double_val()); push_stack(result); } FloorFunc::FloorFunc(ComTerp* comterp) : NumFunc(comterp) { } void FloorFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue result(operand1); switch (result.type()) { case ComValue::CharType: case ComValue::UCharType: case ComValue::ShortType: case ComValue::UShortType: case ComValue::IntType: case ComValue::UIntType: case ComValue::LongType: case ComValue::ULongType: break; case ComValue::FloatType: { ComValue val((long)floor((double) operand1.float_val())); result.assignval(val); } break; case ComValue::DoubleType: { ComValue val((long)floor(operand1.double_val())); result.assignval(val); } break; } reset_stack(); push_stack(result); } CeilFunc::CeilFunc(ComTerp* comterp) : NumFunc(comterp) { } void CeilFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue result(operand1); switch (result.type()) { case ComValue::CharType: case ComValue::UCharType: case ComValue::ShortType: case ComValue::UShortType: case ComValue::IntType: case ComValue::UIntType: case ComValue::LongType: case ComValue::ULongType: break; case ComValue::FloatType: { ComValue val((long)ceil((double) operand1.float_val())); result.assignval(val); } break; case ComValue::DoubleType: { ComValue val((long)ceil(operand1.double_val())); result.assignval(val); } break; } reset_stack(); push_stack(result); } RoundFunc::RoundFunc(ComTerp* comterp) : NumFunc(comterp) { } void RoundFunc::execute() { ComValue& operand1 = stack_arg(0); ComValue result(operand1); switch (result.type()) { case ComValue::CharType: case ComValue::UCharType: case ComValue::ShortType: case ComValue::UShortType: case ComValue::IntType: case ComValue::UIntType: case ComValue::LongType: case ComValue::ULongType: break; case ComValue::FloatType: { ComValue val((long)floor((double) operand1.float_val()+0.5)); result.assignval(val); } break; case ComValue::DoubleType: { ComValue val((long)floor(operand1.double_val()+0.5)); result.assignval(val); } break; } reset_stack(); push_stack(result); } ivtools-1.2.11a1/src/ComTerp/numfunc.h000066400000000000000000000154771214471147700175270ustar00rootroot00000000000000/* * Copyright (c) 1994,1995,1999,2000 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * This is a collection of a numeric operators. They * automatically promote numeric types as needed, just like C. */ #if !defined(_numfunc_h) #define _numfunc_h #include class ComTerp; class ComValue; //: base class for all numeric ComTerp commands. class NumFunc : public ComFunc { public: NumFunc(ComTerp*); void promote(ComValue&, ComValue&); // method to do C-style promotion of operand types. }; //: + (plus) operator. // adds numerics and matrices, and concatenating strings class AddFunc : public NumFunc { public: AddFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "+ is the add operator for numerics and matrices, and the concatenation operator for strings"; } AttributeValueList* matrix_add(AttributeValueList*, AttributeValueList*); }; //: - (subtraction) operator. class SubFunc : public NumFunc { public: SubFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "- is the minus operator"; } }; //: - (unary prefix minus) operator. class MinusFunc : public NumFunc { public: MinusFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return " and the unary prefix minus"; } }; //: * (multiply) operator. // multiplies numerics and matrices class MpyFunc : public NumFunc { public: MpyFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "* is the multiply operator for numerics and matrices"; } AttributeValueList* matrix_mpy(AttributeValueList*, AttributeValueList*); }; //: / (divide) operator. class DivFunc : public NumFunc { public: DivFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "/ is the divide operator"; } }; //: modulo command for ComTerp. class ModFunc : public NumFunc { public: ModFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s is the mod operator"; } }; //: minimum command for ComTerp. // n=min(a b) -- return minimum of a and b. class MinFunc : public NumFunc { public: MinFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "n=%s(a b) -- return minimum of a and b"; } }; //: maximum command for ComTerp. // n=max(a b) -- return maximum of a and b. class MaxFunc : public NumFunc { public: MaxFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "n=%s(a b) -- return maximum of a and b"; } }; //: absolute-value command for ComTerp. // n=abs(a) -- return absolute value of a. class AbsFunc : public NumFunc { public: AbsFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "n=%s(a) -- return absolute value of a"; } }; //: floor command for ComTerp. // num=floor(num) -- return closest integer value less than or equal to argument class FloorFunc : public NumFunc { public: FloorFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "num=%s(num) -- return closest integer value less than or equal to argument"; } }; //: ceiling command for ComTerp. // num=ceil(num) -- return closest integer value greater than or equal to argument class CeilFunc : public NumFunc { public: CeilFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "num=%s(num) -- return closest integer value greater than or equal to argument"; } }; //: ceiling command for ComTerp. // num=round(num) -- return closest integer value class RoundFunc : public NumFunc { public: RoundFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "num=%s(num) -- return closest integer value"; } }; //: character conversion command for ComTerp. // c=char(num|str) -- convert any numeric to a char. class CharFunc : public ComFunc { public: CharFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "c=%s(num|str :u) -- convert any numeric to a char"; } }; //: short integer conversion command for ComTerp. // s=short(num|str) -- convert any numeric to a short. class ShortFunc : public ComFunc { public: ShortFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "s=%s(num|str :u) -- convert any numeric to a short"; } }; //: integer conversion command for ComTerp. // i=int(num|str) -- convert any numeric to an int. class IntFunc : public ComFunc { public: IntFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "i=%s(num|str :u) -- convert any numeric to an int"; } }; //: long integer conversion command for ComTerp. // l=long(num|str) -- convert any numeric to a long. class LongFunc : public ComFunc { public: LongFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "l=%s(num|str :u) -- convert any numeric to a long"; } }; //: floating-point conversion command for ComTerp. // f=float(num|str) -- convert any numeric to a float. class FloatFunc : public ComFunc { public: FloatFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "f=%s(num|str) -- convert any numeric to a float"; } }; //: double-length floating-point conversion command for ComTerp. // d=double(num|str) -- convert any numeric to a double. class DoubleFunc : public ComFunc { public: DoubleFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "d=%s(num|str) -- convert any numeric to a double"; } }; #endif /* !defined(_numfunc_h) */ ivtools-1.2.11a1/src/ComTerp/parser.cc000066400000000000000000000170571214471147700175020ustar00rootroot00000000000000/* * Copyright (c) 2005 Scott E. Johnston * Copyright (c) 1994, 1995, 1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #define TITLE "Parser" #if __GNUC__>=3 static char newline; #endif /*****************************************************************************/ Parser::Parser() : ComTerpModule() { init(); } Parser::Parser(const char* path) : ComTerpModule(path) { init(); } Parser::Parser(void* inptr, char*(*infunc)(char*,int,void*), int(*eoffunc)(void*), int(*errfunc)(void*)) : ComTerpModule(inptr, infunc, eoffunc, errfunc) { init(); } Parser::Parser(istream& in) : ComTerpModule(&in, istream_fgets, istream_feof, istream_ferror) { init(); } void Parser::init() { /* Allocate block for initial postfix tokens to start with */ _pfsiz = 256; if(dmm_calloc((void**)&_pfbuf, _pfsiz, sizeof(postfix_token)) != 0) KANRET("error in call to dmm_calloc"); /* Create and load operator table */ if(opr_tbl_default() != 0) KANRET("error in creating and loading default operator table"); /* initialize the backup copies of all the globals */ __continuation_prompt = 0; __continuation_prompt_disabled = 0; __skip_shell_comments = 0; __detail_matched_delims = 0; __angle_brackets = 0; __token_state_save = TOK_WHITESPACE; __ignore_numerics = 0; } Parser::~Parser() { /* Free postfix token buffer */ if(dmm_free((void**)&_pfbuf) != 0) KANRET ("error in call to dmm_free"); } int Parser::print_next_expr() { int status = parser (_inptr, _infunc, _eoffunc, _errfunc, NULL, NULL, _buffer, _bufsiz, &_bufptr, _token, _toksiz, &_linenum, &_pfbuf, &_pfsiz, &_pfnum); if (status) err_print( stdout, "parser" ); else for (int i = 0; i < _pfnum; i++) print_pfbuf(_pfbuf,i); return _pfbuf[_pfnum-1].type != TOK_EOF; } postfix_token* Parser::copy_postfix_tokens(int& ntokens) { ntokens = _pfnum; return copy_postfix_tokens(_pfbuf, ntokens); } postfix_token* Parser::copy_postfix_tokens(postfix_token* toks, int ntokens) { postfix_token *pfcopy = new postfix_token[ntokens]; for (int i=0; i in.get(newline); #endif if (in.good()) { int i = 0; for (; i #include #include //: C++ wrapper for ComUtil parser capability. class Parser : public ComTerpModule { public: Parser(); Parser(const char* path); Parser(void*, char*(*)(char*,int,void*), int(*)(void*), int(*)(void*)); // see descriptions in ComTerp or ComTerpModule. Parser(istream&); ~Parser(); int print_next_expr(); postfix_token* copy_postfix_tokens(int& ntokens); // make a copy of current buffer of postfix tokens. postfix_token* copy_postfix_tokens(postfix_token* toks, int ntokens); // make a copy of any buffer of postfix tokens. boolean skip_matched_parens(); // support for '()', '{}', and '[]'. void check_parser_client(boolean restore=false); /* set this object as client of underlying C-based scanner/parser */ void save_parser_client(); /* save current parser info for this client */ void parser_reset(); /* reset parser when needed */ protected: void init(); static char* istream_fgets(char* s, int n, void* istreamptr); // signature like fgets for reading from an istream. static int istream_feof(void* istreamptr); // signature like feof for passing on istream end-of-file. static int istream_ferror(void* istreamptr); // signature like feof for passing on istream error info. protected: postfix_token* _pfbuf; unsigned int _pfsiz; unsigned int _pfnum; /* copies of scanner/parser internals */ int __continuation_prompt; int __continuation_prompt_disabled; int __skip_shell_comments; infuncptr __oneshot_infunc; int __detail_matched_delims; int __ignore_numerics; int __angle_brackets; unsigned __token_state_save; unsigned _expecting; /* Type of operator expected next */ /* copy of operator table */ void* _opr_tbl_ptr; unsigned _opr_tbl_numop; unsigned _opr_tbl_maxop; unsigned _opr_tbl_maxpri; int _opr_tbl_lastop; paren_stack* _ParenStack; /* Stack to count args and keywords */ int _TopOfParenStack; /* Top of ParenStack */ int _SizeOfParenStack; /* Allocated size of ParenStack */ oper_stack* _OperStack; /* Operator stack */ int _TopOfOperStack; /* Top of OperStack */ int _SizeOfOperStack; /* Allocated size of OperStack */ unsigned _NextBufptr; /* Variables for look-ahead token */ char* _NextToken; unsigned _NextToklen; unsigned _NextToktype; unsigned _NextTokstart; unsigned _NextLinenum; int _NextOp_ids[OPTYPE_NUM]; }; extern int _continuation_prompt; extern int _continuation_prompt_disabled; extern int _skip_shell_comments; extern infuncptr _oneshot_infunc; extern int _detail_matched_delims; extern int _ignore_numerics; extern int _angle_brackets; extern unsigned _token_state_save; extern void* parser_client; /* pointer to current client */ extern unsigned expecting; /* Type of operator expected next */ extern paren_stack *ParenStack; /* Stack to count args and keywords */ extern int TopOfParenStack; /* Top of ParenStack */ extern int SizeOfParenStack; /* Allocated size of ParenStack */ extern oper_stack *OperStack; /* Operator stack */ extern int TopOfOperStack; /* Top of OperStack */ extern int SizeOfOperStack; /* Allocated size of OperStack */ extern unsigned NextBufptr; /* Variables for look-ahead token */ extern char *NextToken; extern unsigned NextToklen; extern unsigned NextToktype; extern unsigned NextTokstart; extern unsigned NextLinenum; extern int NextOp_ids[OPTYPE_NUM]; #endif /* !defined(_parser_h) */ ivtools-1.2.11a1/src/ComTerp/postfunc.cc000066400000000000000000000236451214471147700200470ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #if __GNUC__>=3 #include #endif #define TITLE "PostFunc" extern int _detail_matched_delims; boolean SeqFunc::_continueflag = 0; boolean SeqFunc::_breakflag = 0; /*****************************************************************************/ PostFixFunc::PostFixFunc(ComTerp* comterp) : ComFunc(comterp) { } void PostFixFunc::execute() { // print everything on the stack for this function fileptr_filebuf fbuf(comterp()->handler() && comterp()->handler()->wrfptr() ? comterp()->handler()->wrfptr() : stdout, ios_base::out); ostream out(&fbuf); boolean oldbrief = comterp()->brief(); comterp()->brief(true); int numargs = nargspost(); ComValue argoff(comterp()->stack_top()); int topptr = argoff.int_val()-(comterp()->pfnum()-1); for (int i=topptr-numargs; i<=topptr-1; i++) { ComValue& val = comterp()->expr_top(i); val.comterp(comterp()); out << val; if (val.is_type(AttributeValue::CommandType) || (_detail_matched_delims && val.is_type(AttributeValue::SymbolType) && val.nids() >= TOK_RPAREN )) { if (!_detail_matched_delims) { out << "[" << val.narg() << "|" << val.nkey() << "]"; ComFunc* func = (ComFunc*)val.obj_val(); if (func->post_eval()) out << "*"; } else { char ldelim, rdelim; boolean dbldelim = 0; if (val.nids()==TOK_RPAREN) {ldelim = '('; rdelim = ')'; } else if (val.nids()==TOK_RBRACKET) {ldelim = '['; rdelim = ']'; } else if (val.nids()==TOK_RBRACE) {ldelim = '{'; rdelim = '}'; } else if (val.nids()==TOK_RANGBRACK) {ldelim = '<'; rdelim = '>'; } else if (val.nids()==TOK_RANGBRACK2) {ldelim = '<'; rdelim = '>'; dbldelim=1;} else {ldelim = ':'; rdelim = 0x0;}; out << ldelim; if(dbldelim) out << ldelim; out << val.narg(); if (rdelim) { out << rdelim; if(dbldelim) out << rdelim; } } } else if (val.is_type(AttributeValue::SymbolType) && (val.narg() || val.nkey())) out << "{" << val.narg() << "|" << val.nkey() << "}"; else if (val.is_type(AttributeValue::KeywordType)) out << "(" << val.keynarg_val() << ")"; out << ((i+1>topptr) ? "\n" : " "); } comterp()->brief(oldbrief); reset_stack(); } /*****************************************************************************/ PostEvalFunc::PostEvalFunc(ComTerp* comterp) : ComFunc(comterp) { } void PostEvalFunc::execute() { // evaluate every fixed argument on the stack and return in array int numargs = nargstotal(); if (numargs) { AttributeValueList* avl = nil; for (int i=0; iis_nil()) { delete val; break; } if (!avl) avl = new AttributeValueList(); avl->Append(val); } reset_stack(); if (avl) { ComValue retval(avl); push_stack(retval); } } else reset_stack(); } /*****************************************************************************/ IfThenElseFunc::IfThenElseFunc(ComTerp* comterp) : ComFunc(comterp) { } void IfThenElseFunc::execute() { ComValue booltest(stack_arg_post_eval(0)); static int then_symid = symbol_add("then"); static int else_symid = symbol_add("else"); ComValue retval(booltest.is_true() ? stack_key_post_eval(then_symid) : stack_key_post_eval(else_symid)); reset_stack(); push_stack(retval); } /*****************************************************************************/ ForFunc::ForFunc(ComTerp* comterp) : ComFunc(comterp) { } void ForFunc::execute() { static int body_symid = symbol_add("body"); ComValue initexpr(stack_arg_post_eval(0)); ComValue* bodyexpr = nil; if (nargsfixed()>4) fprintf(stderr, "Unexpected for loop with more than one body\n"); while (!SeqFunc::breakflag() && !comterp()->quitflag()) { SeqFunc::continueflag(0); ComValue whileexpr(stack_arg_post_eval(1)); if (whileexpr.is_false()) break; delete bodyexpr; ComValue keybody(stack_key_post_eval(body_symid, false, ComValue::unkval(), true)); if (keybody.is_unknown() && nargsfixed()>= 4) bodyexpr = new ComValue(stack_arg_post_eval(3)); else bodyexpr = new ComValue(keybody); ComValue nextexpr(stack_arg_post_eval(2)); } SeqFunc::breakflag(0); reset_stack(); if (bodyexpr) { push_stack(*bodyexpr); delete bodyexpr; } else push_stack(ComValue::nullval()); } /*****************************************************************************/ WhileFunc::WhileFunc(ComTerp* comterp) : ComFunc(comterp) { } void WhileFunc::execute() { static int body_symid = symbol_add("body"); static int until_symid = symbol_add("until"); static int nilchk_symid = symbol_add("nilchk"); ComValue untilflag(stack_key_post_eval(until_symid)); ComValue nilchkflag(stack_key_post_eval(nilchk_symid)); ComValue* bodyexpr = nil; if (nargsfixed()>2) fprintf(stderr, "Unexpected while loop with more than one body\n"); while (!SeqFunc::breakflag() && !comterp()->quitflag()) { SeqFunc::continueflag(0); if (untilflag.is_false()) { ComValue doneexpr(stack_arg_post_eval(0)); if (nilchkflag.is_false() ? doneexpr.is_false() : doneexpr.is_unknown()) break; } delete bodyexpr; ComValue keybody(stack_key_post_eval(body_symid, false, ComValue::unkval(), true)); if (keybody.is_unknown() && nargsfixed()>= 2) bodyexpr = new ComValue(stack_arg_post_eval(1)); else bodyexpr = new ComValue(keybody); if (untilflag.is_true()) { ComValue doneexpr(stack_arg_post_eval(0)); if (nilchkflag.is_false() ? doneexpr.is_true() : doneexpr.is_unknown()) break; } } SeqFunc::breakflag(0); reset_stack(); if (bodyexpr) { push_stack(*bodyexpr); delete bodyexpr; } else push_stack(ComValue::nullval()); } /*****************************************************************************/ SeqFunc::SeqFunc(ComTerp* comterp) : ComFunc(comterp) { } void SeqFunc::execute() { ComValue arg1(stack_arg_post_eval(0, true)); if (SeqFunc::continueflag() || SeqFunc::breakflag() || comterp()->quitflag()) { reset_stack(); push_stack(arg1); } else { ComValue arg2(stack_arg_post_eval(1, true)); reset_stack(); push_stack(arg2.is_blank() ? arg1 : arg2); } } /*****************************************************************************/ ContinueFunc::ContinueFunc(ComTerp* comterp) : ComFunc(comterp) { } void ContinueFunc::execute() { reset_stack(); SeqFunc::continueflag(1); ComValue retval(ComValue::trueval()); push_stack(retval); return; } /*****************************************************************************/ BreakFunc::BreakFunc(ComTerp* comterp) : ComFunc(comterp) { } void BreakFunc::execute() { reset_stack(); SeqFunc::breakflag(1); ComValue retval(ComValue::trueval()); push_stack(retval); return; } /*****************************************************************************/ SwitchFunc::SwitchFunc(ComTerp* comterp) : ComFunc(comterp) { } void SwitchFunc::execute() { ComValue valv(stack_arg_post_eval(0)); int case_symid; if(valv.is_int()) { char buffer[BUFSIZ]; snprintf(buffer, BUFSIZ, "case%s%d", valv.int_val()>=0 ? "" : "_", valv.int_val()>=0 ? valv.int_val() : -valv.int_val()); case_symid = symbol_add(buffer); } else if (valv.is_symbol() || valv.is_string()) { case_symid = valv.symbol_val(); } else if (valv.is_char()) { char cbuf[2]; cbuf[0] = valv.char_val(); cbuf[1] = '\0'; case_symid = symbol_add(cbuf); } ComValue retval(stack_key_post_eval(case_symid)); if (retval.is_unknown()) { static int default_symid = symbol_add("default"); retval = stack_key_post_eval(default_symid); } reset_stack(); push_stack(retval); } /*****************************************************************************/ int FuncObj::_symid = -1; FuncObj::FuncObj(postfix_token* toks, int ntoks) { _toks = toks; _ntoks = ntoks; } FuncObj::~FuncObj() { delete [] _toks; } /*****************************************************************************/ FuncObjFunc::FuncObjFunc(ComTerp* comterp) : ComFunc(comterp) { } void FuncObjFunc::execute() { int toklen; postfix_token* tokbuf = copy_stack_arg_post_eval(0, toklen); static int echo_symid = symbol_add("echo"); ComValue echov(stack_key_post_eval(echo_symid)); reset_stack(); if (!tokbuf) push_stack(ComValue::nullval()); else { if (echov.is_true()) comterp()->postfix_echo(tokbuf, toklen); FuncObj* tokbufobj = new FuncObj(tokbuf, toklen); ComValue retval(FuncObj::class_symid(), (void*)tokbufobj); push_stack(retval); } } ivtools-1.2.11a1/src/ComTerp/postfunc.h000066400000000000000000000134121214471147700177000ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 1998,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(_postfunc_h) #define _postfunc_h #include class ComTerp; //: echo postfix output of parser. // postfix(arg1 [arg2 [arg3 ... [argn]]]) -- echo unevaluated postfix arguments // (with [narg|nkey] after defined commands, {narg|nkey} after undefined commands // (narg) after keys). class PostFixFunc : public ComFunc { public: PostFixFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "%s(arg1 [arg2 [arg3 ... [argn]]]) -- echo unevaluated postfix arguments\n(with [narg|nkey] after defined commands, {narg|nkey} after undefined commands\n(narg) after keys)"; } }; //: post-evaluate command for ComTerp. // arr=posteval(arg1 [arg2 [arg3 ... [argn]]]) -- post-evaluate every fixed argument // (until nil) then return array. class PostEvalFunc : public ComFunc { public: PostEvalFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "arr=%s(arg1 [arg2 [arg3 ... [argn]]]) -- post-evaluate every fixed argument (until nil) then return array"; } }; //: if-then-else command for ComTerp. // val=if(testexpr :then expr :else expr) -- evaluate testexpr and execute the // :then expression if true, the :else expression if false. class IfThenElseFunc : public ComFunc { public: IfThenElseFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "val=%s(testexpr :then expr :else expr) -- evaluate testexpr and\nexecute the :then expression if true, the :else expression if false."; } }; //: for-loop command for ComTerp. // val=for(initexpr whileexpr [nextexpr [bodyexpr]] :body expr) -- for loop. class ForFunc : public ComFunc { public: ForFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "val=%s(initexpr whileexpr [nextexpr [bodyexpr]] :body expr) -- for loop"; } }; //: while-loop command for ComTerp. // val=while([testexpr [bodyexpr]] :nilchk :until :body expr ) -- while loop. class WhileFunc : public ComFunc { public: WhileFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "val=%s([testexpr [bodyexpr]] :nilchk :until :body expr ) -- while loop"; } }; //: ; (sequence) operator. class SeqFunc : public ComFunc { public: SeqFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "; is the sequencing operator"; } static boolean continueflag() { return _continueflag; } static void continueflag(boolean flag) { _continueflag = flag; } static boolean breakflag() { return _breakflag; } static void breakflag(boolean flag) { _breakflag = flag; } protected: static boolean _continueflag; static boolean _breakflag; }; //: continue command class ContinueFunc : public ComFunc { public: ContinueFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s -- skip to next iteration of for or while loop"; } }; //: break command class BreakFunc : public ComFunc { public: BreakFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s -- break out of for or while loop"; } }; //: switch command for ComTerp. // switch(val key-body-pairs) -- switch statement (:casen for pos., :case_n for neg., otherwise :symbol) class SwitchFunc : public ComFunc { public: SwitchFunc(ComTerp*); virtual boolean post_eval() { return true; } virtual void execute(); virtual const char* docstring() { return "switch(val key-body-pairs) -- switch statement (:casen for pos., :case_n for neg., otherwise :symbol)"; } }; class FuncObj { public: FuncObj(postfix_token* toks, int ntoks); virtual ~FuncObj(); postfix_token* toks() { return _toks; } int ntoks() { return _ntoks; } CLASS_SYMID("FuncObj"); protected: postfix_token* _toks; int _ntoks; }; //: create token buffer object // funcobj=func(body) -- encapsulate a body of commands into an executable object class FuncObjFunc : public ComFunc { public: FuncObjFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "funcobj=%s(body :echo) -- encapsulate a body of commands into an executable object"; } }; #endif /* !defined(_postfunc_h) */ ivtools-1.2.11a1/src/ComTerp/randfunc.cc000066400000000000000000000050211214471147700177720ustar00rootroot00000000000000/* * Copyright (c) 1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #define TITLE "RandFunc" /*****************************************************************************/ RandFunc::RandFunc(ComTerp* comterp) : ComFunc(comterp) { } void RandFunc::execute() { ComValue minmaxlist(stack_arg(0)); reset_stack(); /* set min and max bounds for random number */ double minval = 0.0; double maxval = 1.0; if (minmaxlist.is_type(ComValue::ArrayType)) { AttributeValueList* avl = minmaxlist.array_val(); if (avl->Number()==2) { Iterator it; avl->First(it); minval = avl->GetAttrVal(it)->double_val(); avl->Next(it); maxval = avl->GetAttrVal(it)->double_val(); } } ComValue retval(RandFunc::drand(minval, maxval)); push_stack(retval); } double RandFunc::drand(double minval, double maxval) { #ifndef RAND_MAX #include #define RAND_MAX INT_MAX #endif double gain = (maxval-minval)/RAND_MAX; double bias = minval; int rnum = rand(); double rval = rnum*gain+bias; return rval; } /*****************************************************************************/ SRandFunc::SRandFunc(ComTerp* comterp) : ComFunc(comterp) { } void SRandFunc::execute() { ComValue seedval(stack_arg(0)); reset_stack(); srand(seedval.uint_val()); } ivtools-1.2.11a1/src/ComTerp/randfunc.h000066400000000000000000000041051214471147700176360ustar00rootroot00000000000000/* * Copyright (c) 1998,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * collection of random number generating functions */ #if !defined(_randfunc_h) #define _randfunc_h #include class ComTerp; //: random-number command for ComTerp. // val=rand([minval,maxval]) -- return random number between 0 and 1 or minval,maxval. class RandFunc : public ComFunc { public: RandFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "val=%s([minval,maxval]) -- return random number between 0 and 1 or minval,maxval"; } static double drand(double minval, double maxval); }; //: command to seed ComTerp random number generator. // srand(seedval) -- seed random number generator. class SRandFunc : public ComFunc { public: SRandFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s(seedval) -- seed random number generator"; } }; #endif /* !defined(_randfunc_h) */ ivtools-1.2.11a1/src/ComTerp/scanner.cc000066400000000000000000000055421214471147700176330ustar00rootroot00000000000000/* * Copyright (c) 1994, 1995 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #if 0 // moved to lexscan.c #include #include #endif #include Scanner::Scanner() : LexScan() { } Scanner::Scanner(const char* path) : LexScan(path) { } Scanner::Scanner(void* inptr, char*(*infunc)(char*,int,void*), int(*eoffunc)(void*), int(*errfunc)(void*)) : LexScan(inptr, infunc, eoffunc, errfunc) { } Scanner::~Scanner() { } const void* Scanner::get_next_token(unsigned int& toktype) { unsigned int toklen, tokstart; int status = scanner (_inptr, _infunc, _eoffunc, _errfunc, NULL, NULL, _buffer, _bufsiz, &_bufptr, _token, _toksiz, &toklen, &toktype, &tokstart, &_linenum); return _token; } const char* Scanner::get_next_token_string(unsigned int& toktype) { unsigned int toklen, tokstart; int status = scanner (_inptr, _infunc, _eoffunc, _errfunc, NULL, NULL, _buffer, _bufsiz, &_bufptr, _token, _toksiz, &toklen, &toktype, &tokstart, &_linenum); unsigned tok_buflen = _bufptr-tokstart; strncpy(_tokbuf, _buffer+tokstart, tok_buflen); _tokbuf[tok_buflen] = '\0'; return _tokbuf; } #if 0 // moved to lexscan.c const int Scanner::get_next_value(AttributeValue* attrval, char delim) { const void* token; postfix_token pftok; unsigned int toktype; do { token = get_next_token(toktype); pftok.type = toktype; memcpy(&pftok.v, token, sizeof(pftok.v)); } while(toktype == TOK_OPERATOR && *(char*)token==delim); if (toktype==TOK_EOF) return 0; else { AttributeValue tokval(&pftok); *attrval = tokval; return 1; } } #endif ivtools-1.2.11a1/src/ComTerp/scanner.h000066400000000000000000000036001214471147700174660ustar00rootroot00000000000000/* * Copyright (c) 1994, 1995, 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Scanner returns a stream of tokens for the ComTerp language */ #if !defined(scanner_h) #define _scanner_h #include //: C++ wrapper for ComUtil scanner capability. class Scanner : public LexScan { public: Scanner(); Scanner(const char* path); Scanner(void*, char*(*)(char*,int,void*), int(*)(void*), int(*)(void*)); // see descriptions in ComTerp or ComTerpModule. ~Scanner(); const void* get_next_token(unsigned int& toktype); // return pointer to token of 'toktype'. const char* get_next_token_string(unsigned int& toktype); // return pointer to string from which token was scanned. protected: }; #endif /* !defined(_scanner_h) */ ivtools-1.2.11a1/src/ComTerp/statfunc.cc000066400000000000000000000106541214471147700200310ustar00rootroot00000000000000/* * Copyright (c) 1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #define TITLE "StatFunc" /*****************************************************************************/ SumFunc::SumFunc(ComTerp* comterp) : ComFunc(comterp) { _meanfunc = false; } void SumFunc::execute() { ComValue vallist(stack_arg(0)); reset_stack(); if (vallist.is_type(ComValue::ArrayType)) { AttributeValueList* avl = vallist.array_val(); AddFunc addfunc(comterp()); push_stack(ComValue::zeroval()); Iterator it; int count = 0; for (avl->First(it); !avl->Done(it); avl->Next(it)) { count++; push_stack(*avl->GetAttrVal(it)); addfunc.exec(2,0); } if (_meanfunc) { DivFunc divfunc(comterp()); ComValue divisor(count, ComValue::IntType); push_stack(divisor); divfunc.exec(2,0); } } else { push_stack(vallist); } } /*****************************************************************************/ MeanFunc::MeanFunc(ComTerp* comterp) : SumFunc(comterp) { _meanfunc = true; } /*****************************************************************************/ VarFunc::VarFunc(ComTerp* comterp) : ComFunc(comterp) { _stddevfunc = false; } void VarFunc::execute() { ComValue vallist(stack_arg(0)); reset_stack(); if (vallist.is_type(ComValue::ArrayType)) { AttributeValueList* avl = vallist.array_val(); AddFunc addfunc(comterp()); MpyFunc mpyfunc(comterp()); ComValue sqrsumval(ComValue::zeroval()); ComValue sumval(ComValue::zeroval()); ComValue mnsquaresval; Iterator it; int count = 0; for (avl->First(it); !avl->Done(it); avl->Next(it)) { count++; /* square value and add to sum of squares */ push_stack(*avl->GetAttrVal(it)); push_stack(*avl->GetAttrVal(it)); mpyfunc.exec(2,0); push_stack(sqrsumval); addfunc.exec(2,0); sqrsumval = comterp()->pop_stack(); /* add value to running sum */ push_stack(sumval); push_stack(*avl->GetAttrVal(it)); addfunc.exec(2,0); sumval = comterp()->pop_stack(); } /* compute mean of squares */ DivFunc divfunc(comterp()); push_stack(sqrsumval); ComValue countval((float)count); push_stack(countval); divfunc.exec(2,0); mnsquaresval = comterp()->pop_stack(); /* compute mean squared */ push_stack(sumval); push_stack(countval); divfunc.exec(2,0); ComValue meanval(comterp()->pop_stack()); push_stack(meanval); push_stack(meanval); mpyfunc.exec(2,0); ComValue mnsquaredval(comterp()->pop_stack()); /* subract mean squared from sum of squares to get variance */ SubFunc subfunc(comterp()); push_stack(mnsquaresval); push_stack(mnsquaredval); subfunc.exec(2,0); /* compute standard deviation if StdDevFunc */ if (_stddevfunc) { SqrtFunc sqrtfunc(comterp()); sqrtfunc.exec(1,0); } } else { push_stack(ComValue::zeroval()); } } /*****************************************************************************/ StdDevFunc::StdDevFunc(ComTerp* comterp) : VarFunc(comterp) { _stddevfunc = true; } ivtools-1.2.11a1/src/ComTerp/statfunc.h000066400000000000000000000052201214471147700176640ustar00rootroot00000000000000/* * Copyright (c) 1998,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * collection of statistical functions */ #if !defined(_statfunc_h) #define _statfunc_h #include class ComTerp; //: sum-of-values command for ComTerp. // val=sum(val1[,val2[,...,valn]]) -- return sum of values. class SumFunc : public ComFunc { public: SumFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "val=%s(val1[,val2[,...,valn]]) -- return sum of values"; } protected: boolean _meanfunc; }; //: mean-of-values command for ComTerp. // val=mean(val1[,val2[,...,valn]]) -- return mean of values. class MeanFunc : public SumFunc { public: MeanFunc(ComTerp*); virtual const char* docstring() { return "val=%s(val1[,val2[,...,valn]]) -- return mean of values"; } }; //: variance-of-values command for ComTerp. // val=var(val1[,val2[,...,valn]]) -- return variance of values. class VarFunc : public ComFunc { public: VarFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "val=%s(val1[,val2[,...,valn]]) -- return variance of values"; } protected: boolean _stddevfunc; }; //: standard-deviation-of-values command for ComTerp. // val=stddev(val1[,val2[,...,valn]]) -- return standard deviation of values. class StdDevFunc : public VarFunc { public: StdDevFunc(ComTerp*); virtual const char* docstring() { return "val=%s(val1[,val2[,...,valn]]) -- return standard deviation of values"; } }; #endif /* !defined(_statfunc_h) */ ivtools-1.2.11a1/src/ComTerp/strmfunc.cc000066400000000000000000000355131214471147700200440ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 1994-1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #define TITLE "StrmFunc" #define STREAM_MECH /*****************************************************************************/ StrmFunc::StrmFunc(ComTerp* comterp) : ComFunc(comterp) { } /*****************************************************************************/ int StreamFunc::_symid; StreamFunc::StreamFunc(ComTerp* comterp) : StrmFunc(comterp) { } void StreamFunc::execute() { ComValue operand1(stack_arg_post_eval(0)); reset_stack(); if (operand1.is_stream()) { /* stream copy */ AttributeValueList* old_avl = operand1.stream_list(); AttributeValueList* new_avl = new AttributeValueList(old_avl); ComValue retval(operand1.stream_func(), new_avl); retval.stream_mode(operand1.stream_mode()); push_stack(retval); } else { /* conversion operator */ static StreamNextFunc* snfunc = nil; if (!snfunc) { snfunc = new StreamNextFunc(comterp()); snfunc->funcid(symbol_add("stream")); } if (operand1.is_array()) { AttributeValueList* avl = new AttributeValueList(operand1.array_val()); ComValue stream(snfunc, avl); stream.stream_mode(-1); // for internal use (use by this func) push_stack(stream); } else if (operand1.is_attributelist()) { AttributeValueList* avl = new AttributeValueList(); AttributeList* al = (AttributeList*)operand1.obj_val(); Iterator i; for(al->First(i); !al->Done(i); al->Next(i)) { Attribute* attr = al->GetAttr(i); AttributeValue* av = new AttributeValue(Attribute::class_symid(), (void*)attr); avl->Append(av); } ComValue stream(snfunc, avl); stream.stream_mode(-1); // for internal use (use by this func) push_stack(stream); } } } /*****************************************************************************/ int StreamNextFunc::_symid; StreamNextFunc::StreamNextFunc(ComTerp* comterp) : StrmFunc(comterp) { } void StreamNextFunc::execute() { ComValue operand1(stack_arg(0)); reset_stack(); /* invoked by the next command */ AttributeValueList* avl = operand1.stream_list(); if (avl) { Iterator i; avl->First(i); AttributeValue* retval = avl->Done(i) ? nil : avl->GetAttrVal(i); if (retval) { push_stack(*retval); avl->Remove(retval); delete retval; } else { operand1.stream_list(nil); push_stack(ComValue::nullval()); } } else push_stack(ComValue::nullval()); } /*****************************************************************************/ int ConcatFunc::_symid; ConcatFunc::ConcatFunc(ComTerp* comterp) : StrmFunc(comterp) { } void ConcatFunc::execute() { ComValue operand1(stack_arg_post_eval(0)); ComValue operand2(stack_arg_post_eval(1)); reset_stack(); /* setup for concatenation */ static ConcatNextFunc* cnfunc = nil; if (!cnfunc) { cnfunc = new ConcatNextFunc(comterp()); cnfunc->funcid(symbol_add("concat")); } AttributeValueList* avl = new AttributeValueList(); avl->Append(new AttributeValue(operand1)); avl->Append(new AttributeValue(operand2)); ComValue stream(cnfunc, avl); stream.stream_mode(-1); // for internal use (use by ConcatNextFunc) push_stack(stream); } /*****************************************************************************/ int ConcatNextFunc::_symid; ConcatNextFunc::ConcatNextFunc(ComTerp* comterp) : StrmFunc(comterp) { } void ConcatNextFunc::execute() { ComValue operand1(stack_arg(0)); /* invoked by next func */ reset_stack(); AttributeValueList* avl = operand1.stream_list(); if (avl) { Iterator i; avl->First(i); AttributeValue* oneval = avl->GetAttrVal(i); avl->Next(i); AttributeValue* twoval = avl->GetAttrVal(i); boolean done = false; /* stream first argument until nil */ if (oneval->is_known()) { if (oneval->is_stream()) { ComValue valone(*oneval); NextFunc::execute_impl(comterp(), valone); if (comterp()->stack_top().is_unknown()) { *oneval = ComValue::nullval(); comterp()->pop_stack(); } else done = true; } else { push_stack(*oneval); *oneval = ComValue::nullval(); done = true; } } /* stream 2nd argument until nil */ if (twoval->is_known() && !done) { if (twoval->is_stream()) { ComValue valtwo(*twoval); NextFunc::execute_impl(comterp(), valtwo); if (comterp()->stack_top().is_unknown()) *twoval = ComValue::nullval(); } else { push_stack(*twoval); *twoval = ComValue::nullval(); } } else if (!done) push_stack(ComValue::nullval()); } else push_stack(ComValue::nullval()); return; } /*****************************************************************************/ RepeatFunc::RepeatFunc(ComTerp* comterp) : StrmFunc(comterp) { } void RepeatFunc::execute() { ComValue operand1(stack_arg(0)); #ifdef STREAM_MECH if (operand1.is_stream() && nargs()==1) { reset_stack(); AttributeValueList* avl = operand1.stream_list(); if (avl) { Iterator i; avl->First(i); AttributeValue* repval = avl->GetAttrVal(i); avl->Next(i); AttributeValue* cntval = avl->GetAttrVal(i); if (cntval->int_val()>0) push_stack(*repval); else push_stack(ComValue::nullval()); cntval->int_ref()--; } else push_stack(ComValue::nullval()); return; } else if (operand1.is_stream()) { fprintf(stderr, "no more than doubly nested streams supported as of yet\n"); push_stack(ComValue::nullval()); return; } #endif ComValue operand2(stack_arg(1)); reset_stack(); if (operand1.is_nil() || operand2.is_nil()) { push_stack(ComValue::nullval()); return; } int n = operand2.int_val(); if (n<=0) return; #ifdef STREAM_MECH AttributeValueList* avl = new AttributeValueList(); avl->Append(new AttributeValue(operand1)); avl->Append(new AttributeValue(operand2)); ComValue stream(this, avl); stream.stream_mode(-1); // for internal use (use by this func) push_stack(stream); #else AttributeValueList* avl = new AttributeValueList(); for (int i=0; iAppend(new ComValue(operand1)); ComValue array(avl); push_stack(array); #endif } /*****************************************************************************/ IterateFunc::IterateFunc(ComTerp* comterp) : StrmFunc(comterp) { } void IterateFunc::execute() { ComValue operand1(stack_arg(0)); #ifdef STREAM_MECH if (operand1.is_stream() && nargs()==1) { reset_stack(); AttributeValueList* avl = operand1.stream_list(); if (avl) { Iterator i; avl->First(i); AttributeValue* startval = avl->GetAttrVal(i); avl->Next(i); AttributeValue* stopval = avl->GetAttrVal(i); avl->Next(i); AttributeValue* nextval = avl->GetAttrVal(i); push_stack(*nextval); if (nextval->int_val()==stopval->int_val()) *nextval = ComValue::nullval(); else { if (startval->int_val()<=stopval->int_val()) nextval->int_ref()++; else nextval->int_ref()--; } } else push_stack(ComValue::nullval()); return; } else if (operand1.is_stream()) { fprintf(stderr, "no more than doubly nested streams supported as of yet\n"); push_stack(ComValue::nullval()); return; } #endif ComValue operand2(stack_arg(1)); reset_stack(); if (operand1.is_nil() || operand2.is_nil()) { push_stack(ComValue::nullval()); return; } int start = operand1.int_val(); int stop = operand2.int_val(); #ifdef STREAM_MECH AttributeValueList* avl = new AttributeValueList(); avl->Append(new AttributeValue(operand1)); avl->Append(new AttributeValue(operand2)); avl->Append(new AttributeValue(operand1)); ComValue stream(this, avl); stream.stream_mode(-1); // for internal use (use by this func) push_stack(stream); #else int dir = start>stop ? -1 : 1; AttributeValueList* avl = new AttributeValueList(); for (int i=start; i!=stop; i+=dir) avl->Append(new ComValue(i, ComValue::IntType)); avl->Append(new ComValue(stop, ComValue::IntType)); ComValue array(avl); push_stack(array); #endif } /*****************************************************************************/ int NextFunc::_next_depth = 0; NextFunc::NextFunc(ComTerp* comterp) : StrmFunc(comterp) { } void NextFunc::execute() { ComValue streamv(stack_arg_post_eval(0)); reset_stack(); execute_impl(comterp(), streamv); } void NextFunc::execute_impl(ComTerp* comterp, ComValue& streamv) { _next_depth++; if (!streamv.is_stream()) { _next_depth--; return; } int outside_stackh = comterp->stack_height(); if (streamv.stream_mode()<0) { /* internal execution -- handled by stream func */ comterp->push_stack(streamv); if(((ComFunc*)streamv.stream_func())->comterp()!=comterp) { ((ComFunc*)streamv.stream_func())->comterp(comterp); // just in case fprintf(stderr, "unexpected need to fix comterp in stream_func\n"); } ((ComFunc*)streamv.stream_func())->exec(1, 0); if (comterp->stack_top().is_null() && comterp->stack_height()>outside_stackh) streamv.stream_list()->clear(); else if (comterp->stack_height()==outside_stackh) comterp->push_stack(ComValue::blankval()); } else if (streamv.stream_mode()>0) { /* external execution -- handled by this func */ ComFunc* funcptr = (ComFunc*)streamv.stream_func(); AttributeValueList* avl = streamv.stream_list(); int narg=0; int nkey=0; if (funcptr && avl) { Iterator i; avl->First(i); while (!avl->Done(i)) { AttributeValue* val = avl->GetAttrVal(i); if (val->is_stream()) { int inside_stackh = comterp->stack_height(); /* stream argument, use stream func to get next one */ if (val->stream_mode()<0 && val->stream_func()) { /* internal use */ comterp->push_stack(*val); ((ComFunc*)val->stream_func())->exec(1,0); }else { /* external use */ ComValue cval(*val); NextFunc::execute_impl(comterp, cval); } if (comterp->stack_top().is_null() && comterp->stack_height()>inside_stackh) { /* sub-stream returnnull, zero it, and return null for this one */ val->stream_list()->clear(); streamv.stream_list()->clear(); while (comterp->stack_height()>outside_stackh) comterp->pop_stack(); comterp->push_stack(ComValue::nullval()); _next_depth--; return; } else if (comterp->stack_height()==inside_stackh) comterp->push_stack(ComValue::blankval()); narg++; } else { /* non-stream argument, push as is */ comterp->push_stack(*val); if (val->is_key()) nkey++; else narg++; } avl->Next(i); } funcptr->exec(narg, nkey); } if (comterp->stack_top().is_null() && comterp->stack_height() > outside_stackh) streamv.stream_list()->clear(); else if (comterp->stack_height()==outside_stackh) comterp->push_stack(ComValue::blankval()); } else comterp->push_stack(ComValue::nullval()); _next_depth--; } /*****************************************************************************/ EachFunc::EachFunc(ComTerp* comterp) : ComFunc(comterp) { } void EachFunc::execute() { ComValue strmv(stack_arg_post_eval(0)); reset_stack(); if (strmv.is_stream()) { int cnt = 0; /* traverse stream */ boolean done = false; while (!done) { NextFunc::execute_impl(comterp(), strmv); if (comterp()->pop_stack().is_unknown()) done = true; else cnt++; } ComValue retval(cnt, ComValue::IntType); push_stack(retval); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ int FilterFunc::_symid; FilterFunc::FilterFunc(ComTerp* comterp) : StrmFunc(comterp) { } void FilterFunc::execute() { ComValue streamv(stack_arg_post_eval(0)); ComValue filterv(stack_arg(1)); reset_stack(); /* setup for filterenation */ static FilterNextFunc* flfunc = nil; if (!flfunc) { flfunc = new FilterNextFunc(comterp()); flfunc->funcid(symbol_add("filter")); } AttributeValueList* avl = new AttributeValueList(); avl->Append(new AttributeValue(streamv)); avl->Append(new AttributeValue(filterv)); ComValue stream(flfunc, avl); stream.stream_mode(-1); // for internal use (use by FilterNextFunc) push_stack(stream); } /*****************************************************************************/ int FilterNextFunc::_symid; FilterNextFunc::FilterNextFunc(ComTerp* comterp) : StrmFunc(comterp) { } void FilterNextFunc::execute() { ComValue operand1(stack_arg(0)); /* invoked by next func */ reset_stack(); AttributeValueList* avl = operand1.stream_list(); if (avl) { Iterator i; avl->First(i); AttributeValue* strmval = avl->GetAttrVal(i); avl->Next(i); AttributeValue* filterval = avl->GetAttrVal(i); /* filter stream */ if (strmval->is_known()) { if (strmval->is_stream()) { boolean done = false; while(!done) { ComValue strm2filt(*strmval); NextFunc::execute_impl(comterp(), strm2filt); if (comterp()->stack_top().is_unknown()) { *strmval = ComValue::nullval(); push_stack(*strmval); comterp()->pop_stack(); done = true; } else { if (comterp()->stack_top().is_object() && comterp()->stack_top().class_symid()==filterval->symbol_val()) done = true; else comterp()->pop_stack(); } } } else { push_stack(*strmval); *strmval = ComValue::nullval(); } } } else push_stack(ComValue::nullval()); return; } ivtools-1.2.11a1/src/ComTerp/strmfunc.h000066400000000000000000000110621214471147700176770ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 1994,1995,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * collection of stream functions */ #if !defined(_strmfunc_h) #define _strmfunc_h #include class ComTerp; class ComValue; //: base class for ComTerp stream commands. class StrmFunc : public ComFunc { public: StrmFunc(ComTerp*); }; //: stream command class StreamFunc : public StrmFunc { public: StreamFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "strm=%s(ostrm|list|attrlist) -- copy stream or convert list"; } CLASS_SYMID("StreamFunc"); }; //: hidden func used by next command for stream command class StreamNextFunc : public StrmFunc { public: StreamNextFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "hidden func used by next command for stream command."; } CLASS_SYMID("StreamNextFunc"); }; //: ,, (concat) operator. class ConcatFunc : public StrmFunc { public: ConcatFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return ",, is the concat operator"; } CLASS_SYMID("ConcatFunc"); }; //: hidden func used by next command for ,, (concat) operator. class ConcatNextFunc : public StrmFunc { public: ConcatNextFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "hidden func used by next command for ,, (concat) operator."; } CLASS_SYMID("ConcatNextFunc"); }; //: ** (repeat) operator. class RepeatFunc : public StrmFunc { public: RepeatFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "** is the repeat operator"; } }; //: .. (iterate) operator. class IterateFunc : public StrmFunc { public: IterateFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return ".. is the iterate operator"; } }; //: next command from stream for ComTerp class NextFunc : public StrmFunc { public: NextFunc(ComTerp*); virtual void execute(); static void execute_impl(ComTerp*, ComValue& strmv); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "val=%s(stream) -- return next value from stream"; } static int next_depth() { return _next_depth; } protected: static int _next_depth; }; //: traverse stream command for ComTerp. // cnt=each(strm) -- traverse stream returning its length class EachFunc : public ComFunc { public: EachFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "cnt=%s(strm) -- traverse stream returning its length"; } }; //: stream filter command class FilterFunc : public StrmFunc { public: FilterFunc(ComTerp*); virtual void execute(); virtual boolean post_eval() { return true; } virtual const char* docstring() { return "val=filter(strm classid)"; } CLASS_SYMID("FilterFunc"); }; //: hidden func used by next command for stream filter command class FilterNextFunc : public StrmFunc { public: FilterNextFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "hidden func used by next command for filter command"; } CLASS_SYMID("FilterNextFunc"); }; #endif /* !defined(_strmfunc_h) */ ivtools-1.2.11a1/src/ComTerp/symbolfunc.cc000066400000000000000000000332211214471147700203560ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1998,1999,2000 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #define TITLE "SymbolFunc" /*****************************************************************************/ SymIdFunc::SymIdFunc(ComTerp* comterp) : ComFunc(comterp) { } void SymIdFunc::execute() { static int max_symid = symbol_add("max"); boolean max_flag = stack_key(max_symid).is_true(); if(max_flag) { reset_stack(); ComValue retval(symbol_max(), ComValue::IntType); push_stack(retval); return; } // return id of each symbol in the arguments boolean noargs = !nargs() && !nkeys(); int numargs = nargs(); if (!numargs) return; int symbol_ids[numargs]; for (int i=0; i1) { AttributeValueList* avl = new AttributeValueList(); ComValue retval(avl); for (int i=0; iAppend(new AttributeValue(symbol_ids[i], AttributeValue::IntType)); push_stack(retval); } else { ComValue retval (symbol_ids[0], AttributeValue::IntType); push_stack(retval); } } /*****************************************************************************/ SymAddFunc::SymAddFunc(ComTerp* comterp) : ComFunc(comterp) { } void SymAddFunc::execute() { // return each symbol in the arguments as is boolean noargs = !nargs() && !nkeys(); int numargs = nargs(); if (!numargs) return; int symbol_ids[numargs]; for (int i=0; i1) { AttributeValueList* avl = new AttributeValueList(); ComValue retval(avl); for (int i=0; ibquote(1); if (symbol_ids[i]<0) av->type(ComValue::UnknownType); avl->Append(av); } push_stack(retval); } else { ComValue retval (symbol_ids[0], AttributeValue::SymbolType); if (symbol_ids[0]<0) retval.type(ComValue::UnknownType); // retval.bquote(1); push_stack(retval); } for (int i=0; i1) { AttributeValueList* avl = new AttributeValueList(); ComValue retval(avl); for (int i=0; ibquote(1); avl->Append(av); } push_stack(retval); } else { ComValue retval (symbol_ids[0], AttributeValue::SymbolType); retval.bquote(1); push_stack(retval); } } /*****************************************************************************/ SymValFunc::SymValFunc(ComTerp* comterp) : ComFunc(comterp) { } void SymValFunc::execute() { // return value for each symbol variable boolean noargs = !nargs() && !nkeys(); int numargs = nargs(); if (!numargs) return; ComValue* varvalues[numargs]; for (int i=0; i symbol --> value varvalues[i] = &stack_arg(i, false); lookup_symval(*varvalues[i]); } if (numargs>1) { AttributeValueList* avl = new AttributeValueList(); ComValue retval(avl); for (int i=0; iAppend(new ComValue(*varvalues[i])); reset_stack(); push_stack(retval); } else { ComValue retval (*varvalues[0]); reset_stack(); push_stack(retval); } } /*****************************************************************************/ SymVarFunc::SymVarFunc(ComTerp* comterp) : ComFunc(comterp) { } void SymVarFunc::execute() { ComValue symv(stack_arg(0)); reset_stack(); push_stack(symv); } /*****************************************************************************/ SymStrFunc::SymStrFunc(ComTerp* comterp) : ComFunc(comterp) { } void SymStrFunc::execute() { ComValue symv(stack_arg(0)); reset_stack(); symv.type(ComValue::StringType); push_stack(symv); } /*****************************************************************************/ StrRefFunc::StrRefFunc(ComTerp* comterp) : ComFunc(comterp) { } void StrRefFunc::execute() { ComValue strv(stack_arg(0)); reset_stack(); if (strv.type()==ComValue::StringType) { ComValue retval(symbol_refcount(strv.symbol_val()), ComValue::IntType); push_stack(retval); } else if (strv.type()==ComValue::IntType) { ComValue retval(symbol_refcount(strv.int_val()), ComValue::IntType); push_stack(retval); } else push_stack(ComValue::nullval()); return; } /*****************************************************************************/ SplitStrFunc::SplitStrFunc(ComTerp* comterp) : ComFunc(comterp) { } void SplitStrFunc::execute() { ComValue commav(','); ComValue symvalv(stack_arg(0)); static int tokstr_symid = symbol_add("tokstr"); ComValue tokstrv(stack_key(tokstr_symid, false, commav)); boolean tokstrflag = tokstrv.is_known(); static int tokval_symid = symbol_add("tokval"); ComValue tokvalv(stack_key(tokval_symid, false, commav)); boolean tokvalflag = tokvalv.is_known(); reset_stack(); if (symvalv.is_string()) { AttributeValueList* avl = new AttributeValueList(); ComValue retval(avl); const char* str = symvalv.symbol_ptr(); int len = strlen(str); if (!tokstrflag && !tokvalflag) { for (int i=0; iAppend(new AttributeValue(str[i])); } else if (tokstrflag) { char buffer[BUFSIZ]; int bufoff = 0; char delim = tokstrv.char_val(); while (*str) { int delim1=0; while(*str && (isspace(*str) || *str==delim)) { if (*str==delim) { if ((delim1 || avl->Number()==0) && !isspace(delim) ) { ComValue* comval = new ComValue(ComValue::nullval()); avl->Append(comval); } else delim1=1; } str++; } if (!*str) { if (delim1 && !isspace(delim)) { ComValue* comval = new ComValue(ComValue::nullval()); avl->Append(comval); } break; } while (*str && !isspace(*str) && *str!=delim && bufoffAppend(new AttributeValue(buffer)); bufoff=0; } } else { char buffer[BUFSIZ]; int bufoff = 0; char delim = tokvalv.char_val(); while (*str) { int delim1=0; while(*str && (isspace(*str) || *str==delim)) { if (*str==delim) { if((delim1 || avl->Number()==0) && !isspace(delim)) { ComValue* comval = new ComValue(ComValue::nullval()); avl->Append(comval); } else delim1=1; } str++; } if (!*str) { if (delim1 && !isspace(delim)) { ComValue* comval = new ComValue(ComValue::nullval()); avl->Append(comval); } break; } while (*str && !isspace(*str) && *str!=delim && bufoffrun(buffer, true /*nested*/)); avl->Append(comval); bufoff=0; } } push_stack(retval); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ JoinStrFunc::JoinStrFunc(ComTerp* comterp) : ComFunc(comterp) { } void JoinStrFunc::execute() { ComValue listv(stack_arg(0)); static int sym_symid = symbol_add("sym"); ComValue symflagv(stack_key(sym_symid)); boolean symflag = symflagv.is_true(); reset_stack(); if (listv.is_array()) { AttributeValueList* avl = listv.array_val(); if (avl) { char cbuf[avl->Number()+1]; Iterator i; int cnt=0; for (avl->First(i); !avl->Done(i); avl->Next(i)) { cbuf[cnt] = avl->GetAttrVal(i)->char_val(); cnt++; } cbuf[cnt] = '\0'; ComValue retval(symbol_add(cbuf), symflag ? ComValue::SymbolType : ComValue::StringType); push_stack(retval); return; } } push_stack(ComValue::nullval()); } /*****************************************************************************/ GlobalSymbolFunc::GlobalSymbolFunc(ComTerp* comterp) : ComFunc(comterp) { } void GlobalSymbolFunc::execute() { static int clear_symid = symbol_add("clear"); ComValue clearflagv(stack_key(clear_symid)); boolean clearflag = clearflagv.is_true(); static int cnt_symid = symbol_add("cnt"); ComValue cntflagv(stack_key(cnt_symid)); boolean cntflag = cntflagv.is_true(); if (cntflag) { reset_stack(); TableIterator(ComValueTable) it(*comterp()->globaltable()); int cnt=0; while(it.more()) { cnt++; it.next(); } ComValue retval(cnt); push_stack(retval); return; } // return symbol(s) with global flag set boolean noargs = !nargs() && !nkeys(); int numargs = nargs(); if (!numargs) { reset_stack(); return; } int symbol_ids[numargs]; for (int i=0; i1) { AttributeValueList* avl = new AttributeValueList(); ComValue retval(avl); for (int i=0; iglobal_flag(true); av->bquote(1); avl->Append(av); } else { void* oldval = nil; comterp()->globaltable()->find_and_remove(oldval, symbol_ids[i]); if (oldval) delete (ComValue*)oldval; } } push_stack(retval); } else { if (!clearflag) { ComValue retval (symbol_ids[0], AttributeValue::SymbolType); retval.global_flag(true); retval.bquote(1); push_stack(retval); } else { void* oldval = nil; comterp()->globaltable()->find_and_remove(oldval, symbol_ids[0]); if (oldval) delete (ComValue*)oldval; } } } /*****************************************************************************/ SubStrFunc::SubStrFunc(ComTerp* comterp) : ComFunc(comterp) { } void SubStrFunc::execute() { ComValue strv(stack_arg(0)); ComValue nv(stack_arg(1)); static int after_symid = symbol_add("after"); ComValue afterflagv(stack_key(after_symid)); boolean afterflag = afterflagv.is_true(); reset_stack(); if (strv.is_unknown()) { push_stack(ComValue::nullval()); return; } const char* string = strv.symbol_ptr(); int n; int offset; if(!nv.is_string()) { n = !afterflag ? nv.int_val() : strlen(string)-nv.int_val(); offset = afterflag ? nv.int_val() : 0; } else { const char* foundstr = strstr(string, nv.symbol_ptr()); n = afterflag ? strlen(string)-(foundstr-string) : foundstr-string; offset = afterflag ? foundstr-string : 0; }; if(n>0) { char buffer[n+1]; strncpy(buffer, string+offset, n); buffer[n] = '\0'; ComValue retval(buffer); push_stack(retval); } else push_stack(ComValue::nullval()); } ivtools-1.2.11a1/src/ComTerp/symbolfunc.h000066400000000000000000000124631214471147700202250ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1998,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * collection of symbol functions */ #if !defined(_symbolfunc_h) #define _symbolfunc_h #include class ComTerp; //: symbol id command for ComTerp. // int|lst=symid(symbol [symbol ...] | :max) -- return id(s) associated with symbol(s) class SymIdFunc : public ComFunc { public: SymIdFunc(ComTerp*); virtual void execute(); // virtual boolean post_eval() { return true; } virtual const char* docstring() { return "int|lst=%s(symbol [symbol ...] | :max) -- return id(s) associated with symbol(s)"; } }; //: symbol command for ComTerp. // sym|lst=symbol(symid [symid ...]) -- return symbol(s) associated with integer id(s) class SymbolFunc : public ComFunc { public: SymbolFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "sym|lst=%s(symid [symid ...]) -- return symbol(s) associated with integer id(s)"; } }; //: lookup symbol value command for ComTerp. // val|lst=symval(symbol_var [symbol_var ...]) -- return value(s) associated with symbol variable(s) class SymValFunc : public ComFunc { public: SymValFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "val|lst=%s(symbol_var [symbol_var ...]) -- return value(s) associated with symbol variables(s)"; } }; //: return symbol variable as-is // sym=symvar(sym) -- return symbol variable as-is class SymVarFunc : public ComFunc { public: SymVarFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "str=%s(sym) -- return symbol variable as-is"; } }; //: return string version of symbol // str=symstr(sym) -- return string version of symbol class SymStrFunc : public ComFunc { public: SymStrFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "str=%s(sym) -- return string version of symbol"; } }; //: return string reference count // n=strref(str|symid) -- return string reference count class StrRefFunc : public ComFunc { public: StrRefFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "n=%s(str|symid) -- return string reference count"; } }; //: create symbol command for ComTerp. // sym|lst=symadd(syml|str [sym|str ...]) -- create symbol(s) and return without lookup class SymAddFunc : public ComFunc { public: SymAddFunc(ComTerp*); virtual void execute(); // virtual boolean post_eval() { return true; } virtual const char* docstring() { return "sym|lst=%s(sym|str [sym|str ...]) -- create symbol(s) and return without lookup"; } }; //: command to split a symbol or string into a list of character objects // lst=split(symbol|string :tokstr [delim] :tokval [delim]) -- split symbol or string into list of characters (or tokens). class SplitStrFunc : public ComFunc { public: SplitStrFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "lst=%s(symbol|string :tokstr [delim] :tokval [delim]) -- split symbol or string into list of characters (or tokens)"; } }; //: command to join list of characters into a string object // str=join(clist) -- join list of characters into string class JoinStrFunc : public ComFunc { public: JoinStrFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "str=%s(clist) -- join list of characters into string"; } }; //: command to make assign a global variable // val=global(symbol)|global(symbol)=val|global(symbol :clear)|global(:dump) -- make symbol global class GlobalSymbolFunc : public ComFunc { public: GlobalSymbolFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "sym=%s(symbol)|global(symbol)=val|global(symbol :clear)|global(:dump) -- make symbol global"; } }; //: command to extract a sub string // str=substr(str n :after) -- extract characters from a string class SubStrFunc : public ComFunc { public: SubStrFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "str=%s(str n|str :after) -- extract characters from a string"; } }; #endif /* !defined(_symbolfunc_h) */ ivtools-1.2.11a1/src/ComTerp/typefunc.cc000066400000000000000000000070351214471147700200360ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1998,1999,2000 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #define TITLE "TypeFunc" /*****************************************************************************/ TypeSymbolFunc::TypeSymbolFunc(ComTerp* comterp) : ComFunc(comterp) { } void TypeSymbolFunc::execute() { // return type symbol for each argumen boolean noargs = !nargs() && !nkeys(); int numargs = nargs(); if (!numargs) return; int type_syms[numargs]; for (int i=0; i1) { AttributeValueList* avl = new AttributeValueList(); ComValue retval(avl); for (int i=0; iAppend(new AttributeValue()); else { ComValue* av = new ComValue(type_syms[i], AttributeValue::SymbolType); av->bquote(1); avl->Append(av); } push_stack(retval); } else { if (type_syms[0]<0) push_stack(ComValue::nullval()); else { ComValue retval (type_syms[0], AttributeValue::SymbolType); retval.bquote(1); push_stack(retval); } } } /*****************************************************************************/ ClassSymbolFunc::ClassSymbolFunc(ComTerp* comterp) : ComFunc(comterp) { } void ClassSymbolFunc::execute() { // return type symbol for each argumen boolean noargs = !nargs() && !nkeys(); int numargs = nargs(); if (!numargs) return; int class_syms[numargs]; for (int i=0; i1) { AttributeValueList* avl = new AttributeValueList(); ComValue retval(avl); for (int i=0; iAppend(new AttributeValue()); else { ComValue* av = new ComValue(class_syms[i], AttributeValue::SymbolType); av->bquote(1); avl->Append(av); } push_stack(retval); } else { if (class_syms[0]<0) push_stack(ComValue::nullval()); else { ComValue retval (class_syms[0], AttributeValue::SymbolType); retval.bquote(1); push_stack(retval); } } } ivtools-1.2.11a1/src/ComTerp/typefunc.h000066400000000000000000000040441214471147700176750ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * collection of type functions */ #if !defined(_typefunc_h) #define _typefunc_h #include class ComTerp; //: command to return type symbols for values // sym|lst=type(val [val ...]) -- return type symbol(s) for value(s) class TypeSymbolFunc : public ComFunc { public: TypeSymbolFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "sym|lst=%s(val [ ...]) -- return type symbol(s) for value(s)"; } }; //: command to return class symbols for values of object type // sym|lst=type(val [val ...]) -- return type symbol(s) for value(s) class ClassSymbolFunc : public ComFunc { public: ClassSymbolFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "sym|lst=%s(val [ ...]) -- return class symbol(s) for value(s) of object type"; } }; #endif /* !defined(_typefunc_h) */ ivtools-1.2.11a1/src/ComTerp/xformfunc.cc000066400000000000000000000136511214471147700202110ustar00rootroot00000000000000/* * Copyright (c) 1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #define TITLE "XformFunc" /*****************************************************************************/ XformFunc::XformFunc(ComTerp* comterp) : ComFunc(comterp) { } void XformFunc::execute() { ComValue ptslist(stack_arg(0)); ComValue afflist(stack_arg(1)); reset_stack(); if (ptslist.is_array() && afflist.is_array()) { AttributeValueList* pts_avl = ptslist.array_val(); AttributeValueList* aff_avl = afflist.array_val(); if (pts_avl->Number()==2 && aff_avl->Number()==6) { /* extract affine transform */ Iterator it; float affine[6]; aff_avl->First(it); for (int i=0; i<6; i++) { affine[i] = aff_avl->GetAttrVal(it)->float_val(); aff_avl->Next(it); } Transformer t(affine[0], affine[1], affine[2], affine[3], affine[4], affine[5]); /* check if coordinates are int or float, then apply transform */ pts_avl->First(it); boolean floatflag = pts_avl->GetAttrVal(it)->is_floatingpoint(); pts_avl->Next(it); floatflag = floatflag || pts_avl->GetAttrVal(it)->is_floatingpoint(); if (floatflag) { pts_avl->First(it); float x = pts_avl->GetAttrVal(it)->float_val(); pts_avl->Next(it); float y = pts_avl->GetAttrVal(it)->float_val(); t.transform(x, y); AttributeValueList* avl = new AttributeValueList(); avl->Append(new ComValue(x)); avl->Append(new ComValue(y)); ComValue array(avl); push_stack(array); } else { pts_avl->First(it); int x = pts_avl->GetAttrVal(it)->int_val(); pts_avl->Next(it); int y = pts_avl->GetAttrVal(it)->int_val(); t.Transform(x, y); AttributeValueList* avl = new AttributeValueList(); avl->Append(new ComValue(x)); avl->Append(new ComValue(y)); ComValue array(avl); push_stack(array); } } else push_stack(ComValue::nullval()); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ InvertXformFunc::InvertXformFunc(ComTerp* comterp) : ComFunc(comterp) { } void InvertXformFunc::execute() { ComValue afflist(stack_arg(0)); reset_stack(); if (afflist.is_array()) { AttributeValueList* aff_avl = afflist.array_val(); if (aff_avl->Number()==6) { /* extract affine transform */ Iterator it; float affine[6]; aff_avl->First(it); for (int i=0; i<6; i++) { affine[i] = aff_avl->GetAttrVal(it)->float_val(); aff_avl->Next(it); } Transformer t(affine[0], affine[1], affine[2], affine[3], affine[4], affine[5]); t.Invert(); t.matrix(affine[0], affine[1], affine[2], affine[3], affine[4], affine[5]); AttributeValueList* avl = new AttributeValueList(); for (int j=0; j<6; j++) avl->Append(new ComValue(affine[j])); ComValue array(avl); push_stack(array); } else push_stack(ComValue::nullval()); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ XposeFunc::XposeFunc(ComTerp* comterp) : ComFunc(comterp) { } void XposeFunc::execute() { ComValue listv(stack_arg(0)); reset_stack(); if (listv.is_array()) { int imax = 0; int jmax = 0; Iterator it; listv.array_val()->First(it); while (!listv.array_val()->Done(it)) { imax++; AttributeValue* av = listv.array_val()->GetAttrVal(it); if (av->is_array()) jmax = Math::max(jmax, av->array_val()->Number()); listv.array_val()->Next(it); } /* construct tranposed matrix */ jmax += jmax ? 0 : 1; AttributeValueList* new_matrix = new AttributeValueList(); for(int j=0; jAppend(new AttributeValue(new AttributeValueList())); /* save pointer to first new column */ Iterator jt; new_matrix->First(jt); AttributeValue* jv = new_matrix->GetAttrVal(jt); /* populate new matrix */ listv.array_val()->First(it); while (!listv.array_val()->Done(it)) { AttributeValue* av = listv.array_val()->GetAttrVal(it); if (av->is_array()) { Iterator at; av->array_val()->First(at); Iterator nt; new_matrix->First(nt); while (!av->array_val()->Done(at)) { new_matrix->GetAttrVal(nt)->array_val()->Append(new AttributeValue(av->array_val()->GetAttrVal(at))); av->array_val()->Next(at); new_matrix->Next(nt); } } else jv->array_val()->Append(new AttributeValue(av)); listv.array_val()->Next(it); } ComValue retval(new_matrix); push_stack(retval); } else push_stack(ComValue::nullval()); } ivtools-1.2.11a1/src/ComTerp/xformfunc.h000066400000000000000000000045761214471147700200610ustar00rootroot00000000000000/* * Copyright (c) 1998,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * collection of transform functions */ #if !defined(_xformfunc_h) #define _xformfunc_h #include class ComTerp; //: ComTerp command to apply an affine-transform to a 2d coordinate. // point=xform(x,y a00,a01,a10,a11,a20,a21) -- affine transform of x,y coordinates. class XformFunc : public ComFunc { public: XformFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "point=%s(x,y a00,a01,a10,a11,a20,a21) -- affine transform of x,y coordinates"; } }; //: ComTerp command to invert an affine transform. // affine=invert(a00,a01,a10,a11,a20,a21) -- invert affine transform. class InvertXformFunc : public ComFunc { public: InvertXformFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "affine=%s(a00,a01,a10,a11,a20,a21) -- invert affine transform"; } }; //: ComTerp command to transpose a matrix // matrix=xpose(matrix) -- transpose an arbitrary matrix class XposeFunc : public ComFunc { public: XposeFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "matrix=%s(matrix) -- transpose an arbitrary matrix"; } }; #endif /* !defined(_xformfunc_h) */ ivtools-1.2.11a1/src/ComUnidraw/000077500000000000000000000000001214471147700163645ustar00rootroot00000000000000ivtools-1.2.11a1/src/ComUnidraw/comeditor.cc000066400000000000000000000314071214471147700206650ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::cout; #include /*****************************************************************************/ ComEditor::ComEditor(OverlayComp* comp, OverlayKit* kit) : OverlayEditor(false, kit) { Init(comp, "ComEditor"); } ComEditor::ComEditor(const char* file, OverlayKit* kit) : OverlayEditor(false, kit) { if (file == nil) { Init(); } else { Catalog* catalog = unidraw->GetCatalog(); OverlayComp* comp; if (catalog->Retrieve(file, (Component*&) comp)) { Init(comp); } else { Init(); fprintf(stderr, "drawserv: couldn't open %s\n", file); } } } ComEditor::ComEditor(boolean initflag, OverlayKit* kit) : OverlayEditor(initflag, kit) { _terp = nil; _whiteboard = -1; } void ComEditor::Init (OverlayComp* comp, const char* name) { if (!comp) comp = new OverlayIdrawComp; _terp = new ComTerpServ(); ((OverlayUnidraw*)unidraw)->comterp(_terp); AddCommands(_terp); char buffer[BUFSIZ]; sprintf(buffer, "Comdraw%d", ncomterp()); add_comterp(buffer, _terp); _overlay_kit->Init(comp, name); _whiteboard = -1; } void ComEditor::InitCommands() { if (!_terp) _terp = new ComTerpServ(); const char* stdin_off_str = unidraw->GetCatalog()->GetAttribute("stdin_off"); #ifndef HAVE_ACE if ((!comterplist() || comterplist()->Number()==1) && (stdin_off_str ? strcmp(stdin_off_str, "false")==0 : true)) _terp_iohandler = new ComTerpIOHandler(_terp, stdin); else #endif _terp_iohandler = nil; #if 0 _terp->add_defaults(); AddCommands(_terp); #endif } void ComEditor::AddCommands(ComTerp* comterp) { ((ComTerpServ*)comterp)->add_defaults(); comterp->add_command("parent", new GrParentFunc(comterp)); comterp->add_command("rect", new CreateRectFunc(comterp, this)); comterp->add_command("rectangle", new CreateRectFunc(comterp, this)); comterp->add_command("line", new CreateLineFunc(comterp, this)); comterp->add_command("arrowline", new CreateLineFunc(comterp, this)); comterp->add_command("ellipse", new CreateEllipseFunc(comterp, this)); comterp->add_command("text", new CreateTextFunc(comterp, this)); comterp->add_command("multiline", new CreateMultiLineFunc(comterp, this)); comterp->add_command("arrowmultiline", new CreateMultiLineFunc(comterp, this)); comterp->add_command("openspline", new CreateOpenSplineFunc(comterp, this)); comterp->add_command("arrowspline", new CreateOpenSplineFunc(comterp, this)); comterp->add_command("polygon", new CreatePolygonFunc(comterp, this)); comterp->add_command("closedspline", new CreateClosedSplineFunc(comterp, this)); comterp->add_command("raster", new CreateRasterFunc(comterp, this)); comterp->add_command("pixmap", new CreateRasterFunc(comterp, this)); comterp->add_command("center", new CenterFunc(comterp, this)); comterp->add_command("mbr", new MbrFunc(comterp, this)); comterp->add_command("points", new PointsFunc(comterp, this)); comterp->add_command("font", new FontFunc(comterp, this)); comterp->add_command("brush", new BrushFunc(comterp, this)); comterp->add_command("pattern", new PatternFunc(comterp, this)); comterp->add_command("colors", new ColorFunc(comterp, this)); comterp->add_command("fontbyname", new FontByNameFunc(comterp, this)); comterp->add_command("colorsrgb", new ColorRgbFunc(comterp, this)); comterp->add_command("nfonts", new NFontsFunc(comterp, this)); comterp->add_command("nbrushes", new NBrushesFunc(comterp, this)); comterp->add_command("npatterns", new NPatternsFunc(comterp, this)); comterp->add_command("ncolors", new NColorsFunc(comterp, this)); comterp->add_command("setattr", new SetAttrFunc(comterp, this)); comterp->add_command("select", new SelectFunc(comterp, this)); comterp->add_command("delete", new DeleteFunc(comterp, this)); comterp->add_command("move", new MoveFunc(comterp, this)); comterp->add_command("scale", new ScaleFunc(comterp, this)); comterp->add_command("rotate", new RotateFunc(comterp, this)); comterp->add_command("fliph", new FlipHorizontalFunc(comterp, this)); comterp->add_command("flipv", new FlipVerticalFunc(comterp, this)); comterp->add_command("pan", new PanFunc(comterp, this)); comterp->add_command("smallpanup", new PanUpSmallFunc(comterp, this)); comterp->add_command("smallpandown", new PanDownSmallFunc(comterp, this)); comterp->add_command("smallpanleft", new PanLeftSmallFunc(comterp, this)); comterp->add_command("smallpanright", new PanRightSmallFunc(comterp, this)); comterp->add_command("largepanup", new PanUpLargeFunc(comterp, this)); comterp->add_command("largepandown", new PanDownLargeFunc(comterp, this)); comterp->add_command("largepanleft", new PanLeftLargeFunc(comterp, this)); comterp->add_command("largepanright", new PanRightLargeFunc(comterp, this)); comterp->add_command("zoom", new ZoomFunc(comterp, this)); comterp->add_command("zoomin", new ZoomInFunc(comterp, this)); comterp->add_command("zoomout", new ZoomOutFunc(comterp, this)); comterp->add_command("tilefile", new TileFileFunc(comterp, this)); comterp->add_command("update", new UpdateFunc(comterp, this)); comterp->add_command("ncols", new NColsFunc(comterp, this)); comterp->add_command("nrows", new NRowsFunc(comterp, this)); comterp->add_command("handles", new HandlesFunc(comterp, this)); #if 0 if (OverlayKit::bincheck("plotmtv")) comterp->add_command("barplot", new BarPlotFunc(comterp, this)); #endif comterp->add_command("save", new SaveFileFunc(comterp, this)); comterp->add_command("import", new ImportFunc(comterp, this)); comterp->add_command("export", new ExportFunc(comterp, this)); comterp->add_command("dot", new GrDotFunc(comterp)); comterp->add_command("attrlist", new GrAttrListFunc(comterp)); comterp->add_command("at", new GrListAtFunc(comterp)); comterp->add_command("size", new GrListSizeFunc(comterp)); comterp->add_command("stream", new GrStreamFunc(comterp)); comterp->add_command("acknowledgebox", new AcknowledgeBoxFunc(comterp, this)); comterp->add_command("confirmbox", new ConfirmBoxFunc(comterp, this)); comterp->add_command("highlight", new HighlightFunc(comterp, this)); comterp->add_command("frame", new FrameFunc(comterp, this)); comterp->add_command("growgroup", new GrowGroupFunc(comterp, this)); comterp->add_command("trimgroup", new TrimGroupFunc(comterp, this)); comterp->add_command("pause", new UnidrawPauseFunc(comterp, this)); comterp->add_command("paste", new PasteFunc(comterp, this)); comterp->add_command("pastemode", new PasteModeFunc(comterp, this)); comterp->add_command("addtool", new AddToolButtonFunc(comterp, this)); comterp->add_command("dtos", new DrawingToScreenFunc(comterp, this)); comterp->add_command("stod", new ScreenToDrawingFunc(comterp, this)); comterp->add_command("dtog", new DrawingToGraphicFunc(comterp, this)); comterp->add_command("gtod", new GraphicToDrawingFunc(comterp, this)); comterp->add_command("poke", new PixelPokeFunc(comterp, this)); comterp->add_command("peek", new PixelPeekFunc(comterp, this)); comterp->add_command("pokeline", new PixelPokeLineFunc(comterp, this)); comterp->add_command("pcols", new PixelColsFunc(comterp, this)); comterp->add_command("prows", new PixelRowsFunc(comterp, this)); comterp->add_command("pflush", new PixelFlushFunc(comterp, this)); comterp->add_command("pclip", new PixelClipFunc(comterp, this)); comterp->add_command("alpha", new AlphaTransFunc(comterp, this)); comterp->add_command("trans", new TransformerFunc(comterp, this)); comterp->add_command("gravity", new GravityFunc(comterp, this)); comterp->add_command("gridspacing", new GridSpacingFunc(comterp, this)); comterp->add_command("hide", new HideCompFunc(comterp, this)); comterp->add_command("show", new ShowCompFunc(comterp, this)); comterp->add_command("desensitize", new DesensitizeCompFunc(comterp, this)); comterp->add_command("sensitize", new SensitizeCompFunc(comterp, this)); #ifdef LEAKCHECK comterp->add_command("compleak", new CompLeakFunc(comterp)); comterp->add_command("viewleak", new ViewLeakFunc(comterp)); comterp->add_command("alistleak", new AlistLeakFunc(comterp)); comterp->add_command("attrvleak", new AttrvLeakFunc(comterp)); comterp->add_command("mlineleak", new MlineLeakFunc(comterp)); comterp->add_command("graphicleak", new GraphicLeakFunc(comterp)); comterp->add_command("commandleak", new CommandLeakFunc(comterp)); #endif } /* virtual */ void ComEditor::ExecuteCmd(Command* cmd) { if(!whiteboard()) /* normal Unidraw command execution */ OverlayEditor::ExecuteCmd(cmd); else { /* indirect command execution, all by script */ std::ostrstream sbuf; boolean oldflag = OverlayScript::ptlist_parens(); OverlayScript::ptlist_parens(false); switch (cmd->GetClassId()) { case PASTE_CMD: { boolean scripted = false; Clipboard* cb = cmd->GetClipboard(); if (cb) { Iterator it; for (cb->First(it); !cb->Done(it); cb->Next(it)) { OverlayComp* comp = (OverlayComp*)cb->GetComp(it); if (comp) { Creator* creator = unidraw->GetCatalog()->GetCreator(); OverlayScript* scripter = (OverlayScript*) creator->Create(Combine(comp->GetClassId(), SCRIPT_VIEW)); if (scripter) { scripter->SetSubject(comp); if (scripted) sbuf << ';'; else scripted = true; boolean status = scripter->Definition(sbuf); delete scripter; } } } } if (!scripted) sbuf << "print(\"Failed attempt to generate script for a PASTE_CMD\\n\" :err)"; sbuf.put('\0'); cout << sbuf.str() << "\n"; cout.flush(); GetComTerp()->run(sbuf.str()); delete cmd; } break; default: sbuf << "print(\"Attempt to convert unknown command (id == %d) to interpretable script\\n\" " << cmd->GetClassId() << " :err)"; cmd->Execute(); if (cmd->Reversible()) { cmd->Log(); } else { delete cmd; } break; } OverlayScript::ptlist_parens(oldflag); } } boolean ComEditor::whiteboard() { if (_whiteboard==-1) { Catalog* catalog = unidraw->GetCatalog(); const char* wbmaster_str = catalog->GetAttribute("wbmaster"); const char* wbslave_str = catalog->GetAttribute("wbslave"); if (wbmaster_str && strcmp(wbmaster_str, "true")==0 || wbslave_str && strcmp(wbslave_str, "true")==0) _whiteboard = 1; else _whiteboard = 0; } return _whiteboard; } ivtools-1.2.11a1/src/ComUnidraw/comeditor.h000066400000000000000000000057501214471147700205310ustar00rootroot00000000000000/* * Copyright (c) 1994-1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef comeditor_h #define comeditor_h #include class ComTerpIOHandler; class ComTerp; class ComTerpServ; //: editor that integrates ComTerp into the drawing editor framework. class ComEditor : public OverlayEditor { public: ComEditor(OverlayComp*, OverlayKit* = OverlayKit::Instance()); // constructor for using existing component. ComEditor(const char* file, OverlayKit* = OverlayKit::Instance()); // constructor for building top-level component from a file. ComEditor(boolean initflag, OverlayKit* = OverlayKit::Instance()); // constructor for use of derived classes. void Init(OverlayComp* = nil, const char* name = "ComEditor"); virtual void InitCommands(); // method for running Unidraw Command objects after OverlayEditor // is constructed. virtual void AddCommands(ComTerp*); // method for adding ComFunc objects to the ComTerp associated with // this ComEditor. virtual ComTerpServ* GetComTerp() { return _terp;} // return pointer to associated ComTerp (always a ComTerpServ). virtual ComTerpServ* comterp() { return _terp;} // return pointer to associated ComTerp (always a ComTerpServ). virtual void SetComTerp(ComTerpServ* terp) { _terp = terp;} // set pointer to associated ComTerp (always a ComTerpServ). virtual void comterp(ComTerpServ* terp) { _terp = terp;} // set pointer to associated ComTerp (always a ComTerpServ). virtual void ExecuteCmd(Command* cmd); // indirect command execution for distributed whiteboard mechanism. boolean whiteboard(); // test for distributed whiteboard mode, which only exists when // used with a ComEditor. protected: ComTerpServ* _terp; ComTerpIOHandler* _terp_iohandler; int _whiteboard; // -1 == unitialized, 0 = false, 1 = true }; #endif ivtools-1.2.11a1/src/ComUnidraw/comterp-acehandler.cc000066400000000000000000000032631214471147700224340ustar00rootroot00000000000000/* * Copyright (c) 1996 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifdef HAVE_ACE #include #include #include #include #include /*****************************************************************************/ // Default constructor. UnidrawComterpHandler::UnidrawComterpHandler (ComTerpServ* serv) : ComterpHandler(serv) { Iterator i; unidraw->First(i); if (!serv) ((ComEditor*)unidraw->GetEditor(i))->AddCommands(comterp_); } #endif /* HAVE_ACE */ ivtools-1.2.11a1/src/ComUnidraw/comterp-acehandler.h000066400000000000000000000034431214471147700222760ustar00rootroot00000000000000/* * Copyright (c) 1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifdef HAVE_ACE #ifndef _unidraw_comterp_handler_ #define _unidraw_comterp_handler_ #include #include #include class ComEditor; //: specialized ComterpHandler for integration into Unidraw event loop. class UnidrawComterpHandler : public ComterpHandler { public: // = Initialization and termination methods. UnidrawComterpHandler (ComTerpServ* serv=NULL); }; //: Acceptor specialized for use with Unidraw and ComTerp. typedef ACE_Acceptor UnidrawComterpAcceptor; #endif /* _unidraw_comterp_handler_ */ #endif /* HAVE_ACE */ ivtools-1.2.11a1/src/ComUnidraw/comterp-iohandler.cc000066400000000000000000000055151214471147700223150ustar00rootroot00000000000000/* * Copyright (c) 1994-1996 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include /*****************************************************************************/ ComTerpIOHandler::ComTerpIOHandler(ComTerpServ* comterp, FILE* fptr) { _fptr = fptr; _fd = fileno(fptr); _fptr_opened = false; _comterp = comterp; _buffer = new char[BUFSIZ]; link(); } ComTerpIOHandler::ComTerpIOHandler(ComTerpServ* comterp, int fd) { _fd = fd; _fptr = fdopen(fd, "r"); _fptr_opened = true; _comterp = comterp; _buffer = new char[BUFSIZ]; link(); } ComTerpIOHandler::~ComTerpIOHandler() { unlink(); delete _buffer; if (_fptr_opened) fclose(_fptr); } int ComTerpIOHandler::inputReady(int i) { /* invoke comterp to crank on one line */ #if 1 fgets( _buffer, BUFSIZ, _fptr); if (feof(_fptr)) return -1; _comterp->load_string(_buffer); #else _comterp->_infunc = (infuncptr)&ComTerpServ::fd_fgets; #endif _comterp->_fd = i; _comterp->_outfunc = (outfuncptr)&ComTerpServ::fd_fputs; boolean done = false; while (!done) { if (_comterp->read_expr()) { if (_comterp->eval_expr()) err_print( stderr, "comterp" ); else if (_comterp->quitflag()) return 0; else { if (unidraw->updated()) unidraw->Update(true); _comterp->print_stack_top(); } } else { if (err_cnt()>0) err_print( stderr, "comterp"); done = 1; } } return 0; } void ComTerpIOHandler::link() { Dispatcher::instance().link (_fd, Dispatcher::ReadMask, this); } void ComTerpIOHandler::unlink() { Dispatcher::instance().unlink(_fd); } ivtools-1.2.11a1/src/ComUnidraw/comterp-iohandler.h000066400000000000000000000033241214471147700221530ustar00rootroot00000000000000/* * Copyright (c) 1994-1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef comterp_iohandler_h #define comterp_iohandler_h #include #include class ComTerpServ; //: class for splicing comterp into Unidraw event loop class ComTerpIOHandler : public IOHandler { public: ComTerpIOHandler(ComTerpServ*, FILE* fptr); ComTerpIOHandler(ComTerpServ*, int fd); ~ComTerpIOHandler(); int inputReady(int); void link(); void unlink(); protected: FILE* _fptr; int _fd; boolean _fptr_opened; char* _buffer; ComTerpServ* _comterp; }; #endif ivtools-1.2.11a1/src/ComUnidraw/dialogfunc.cc000066400000000000000000000041031214471147700210040ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #define TITLE "DialogFunc" /*****************************************************************************/ AcknowledgeBoxFunc::AcknowledgeBoxFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void AcknowledgeBoxFunc::execute() { ComValue msgstrv(stack_arg(0)); reset_stack(); GAcknowledgeDialog::post(GetEditor()->GetWindow(), msgstrv.symbol_ptr()); } /*****************************************************************************/ ConfirmBoxFunc::ConfirmBoxFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void ConfirmBoxFunc::execute() { ComValue msgstrv(stack_arg(0)); reset_stack(); int status = GConfirmDialog::post(GetEditor()->GetWindow(), msgstrv.symbol_ptr()); ComValue retval(status); if (status==-1) retval.type(ComValue::UnknownType); push_stack(retval); } ivtools-1.2.11a1/src/ComUnidraw/dialogfunc.h000066400000000000000000000040061214471147700206500ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(_dialog_func_h) #define _dialog_func_h #include //: command to popup an acknowledge dialog box // acknowledgebox() -- popup an acknowledge dialog box class AcknowledgeBoxFunc : public UnidrawFunc { public: AcknowledgeBoxFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(message_str) -- popup an acknowledge dialog box"; } }; //: command to popup a confirmation dialog box // acknowledgebox() -- popup a confirmation dialog box, and return 1, 0, or -1 if cancelled. class ConfirmBoxFunc : public UnidrawFunc { public: ConfirmBoxFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(message_str) -- popup a confirmation dialog box, and return 1, 0, or -1 if cancelled"; } }; #endif /* !defined(_dialog_func_h) */ ivtools-1.2.11a1/src/ComUnidraw/grdotfunc.cc000066400000000000000000000111371214471147700206710ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include using std::cerr; #define TITLE "GrDotFunc" /*****************************************************************************/ int GrDotFunc::_symid = -1; GrDotFunc::GrDotFunc(ComTerp* comterp) : DotFunc(comterp) { } void GrDotFunc::execute() { ComValue& before_part(stack_arg(0, true)); ComValue& after_part(stack_arg(1, true)); if (!before_part.is_symbol() && !(before_part.is_attribute() && (((Attribute*)before_part.obj_val())->Value()->is_unknown() || ((Attribute*)before_part.obj_val())->Value()->is_attributelist() || ((Attribute*)before_part.obj_val())->Value()->object_compview())) && !(before_part.is_attributelist()) && !(before_part.object_compview())) { cerr << "expression before \".\" needs to evaluate to a symbol or (instead of " << symbol_pntr(before_part.type_symid()); if (before_part.is_object()) cerr << " of class " << symbol_pntr(before_part.class_symid()); cerr << ") -- grdotfunc.c\n"; reset_stack(); return; } if (!after_part.is_string()) { cerr << "expression after \".\" needs to be a symbol or evaluate to a symbol (instead of " << symbol_pntr(after_part.type_symid()); if (before_part.is_object()) cerr << " of class " << symbol_pntr(before_part.class_symid()); cerr << ") -- grdotfunc.c\n"; reset_stack(); return; } /* handle ComponentView case */ if (before_part.is_symbol()) lookup_symval(before_part); if (before_part.is_object() && before_part.object_compview()) { ComponentView* compview = (ComponentView*)before_part.obj_val(); OverlayComp* comp = (OverlayComp*)compview->GetSubject(); if (comp) { ComValue stuffval(AttributeList::class_symid(), (void*)comp->GetAttributeList()); before_part.assignval(stuffval); } else { cerr << "nil subject on compview value\n"; reset_stack(); push_stack(ComValue::nullval()); return; } } else if (before_part.is_object() && before_part.is_attribute() && ((Attribute*)before_part.obj_val())->Value()->object_compview()) { AttributeValue* av = ((Attribute*)before_part.obj_val())->Value(); ComponentView* compview = (ComponentView*)av->obj_val(); OverlayComp* comp = (OverlayComp*)compview->GetSubject(); if (comp) { ComValue stuffval(AttributeList::class_symid(), (void*)comp->GetAttributeList()); before_part.assignval(stuffval); } else { cerr << "nil subject on compview value\n"; reset_stack(); push_stack(ComValue::nullval()); return; } } DotFunc::execute(); } /*****************************************************************************/ GrAttrListFunc::GrAttrListFunc(ComTerp* comterp) : ComFunc(comterp) { } void GrAttrListFunc::execute() { ComValue compviewv(stack_arg(0)); reset_stack(); if (compviewv.object_compview()) { ComponentView* compview = (ComponentView*)compviewv.obj_val(); OverlayComp* comp = compview ? (OverlayComp*)compview->GetSubject() : nil; if (comp) { ComValue retval(AttributeList::class_symid(), (void*)comp->GetAttributeList()); push_stack(retval); } else push_stack(ComValue::nullval()); } } ivtools-1.2.11a1/src/ComUnidraw/grdotfunc.h000066400000000000000000000040171214471147700205320ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * dot func for componentviews */ #if !defined(_grdotfunc_h) #define _grdotfunc_h #include //: . (dot) operator, for compound variables, and access to ComponentView AttributeList's. class GrDotFunc : public DotFunc { public: GrDotFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s(.) makes compound variables, and gives access to ComponentView AttributeList's."; } CLASS_SYMID("GrDotFunc"); }; //: attrlist command, for returning the attribute list of a component. // attrlist(compview) -- return attribute list of component. class GrAttrListFunc : public ComFunc { public: GrAttrListFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s(compview) -- return attribute list of component."; } }; #endif /* !defined(_grdotfunc_h) */ ivtools-1.2.11a1/src/ComUnidraw/grfunc.cc000066400000000000000000001302471214471147700201660ustar00rootroot00000000000000/* * Copyright (c) 2001-2007 Scott E. Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define TITLE "GrFunc" /*****************************************************************************/ CreateGraphicFunc::CreateGraphicFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } Transformer* CreateGraphicFunc::get_transformer(AttributeList* al) { static int transform_symid = symbol_add("transform"); AttributeValue* transformv = nil; Transformer* rel = nil; AttributeValueList* avl = nil; if (al && (transformv=al->find(transform_symid)) && transformv->is_array() && (avl=transformv->array_val()) && avl->Number()==6) { float a00, a01, a10, a11, a20, a21; Iterator it; avl->First(it); a00=avl->GetAttrVal(it)->float_val(); avl->Next(it); a01=avl->GetAttrVal(it)->float_val(); avl->Next(it); a10=avl->GetAttrVal(it)->float_val(); avl->Next(it); a11=avl->GetAttrVal(it)->float_val(); avl->Next(it); a20=avl->GetAttrVal(it)->float_val(); avl->Next(it); a21=avl->GetAttrVal(it)->float_val(); rel = new Transformer(a00, a01, a10, a11, a20, a21); } else { rel = ((OverlayViewer*)_ed->GetViewer())->GetRel(); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } } return rel; } /*****************************************************************************/ CreateRectFunc::CreateRectFunc(ComTerp* comterp, Editor* ed) : CreateGraphicFunc(comterp, ed) { } void CreateRectFunc::execute() { const int x0 = 0; const int y0 = 1; const int x1 = 2; const int y1 = 3; const int n = 4; int coords[n]; ComValue& vect = stack_arg(0); if (!vect.is_type(ComValue::ArrayType) || vect.array_len() != n) { reset_stack(); push_stack(ComValue::nullval()); return; } ALIterator i; AttributeValueList* avl = vect.array_val(); avl->First(i); for (int j=0; jDone(i); j++) { coords[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); } AttributeList* al = stack_keys(); Resource::ref(al); reset_stack(); PasteCmd* cmd = nil; if (coords[x0] != coords[x1] || coords[y0] != coords[y1]) { BrushVar* brVar = (BrushVar*) _ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) _ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar"); Transformer* rel = get_transformer(al); SF_Rect* rect = new SF_Rect(coords[x0], coords[y0], coords[x1], coords[y1], stdgraphic); if (brVar != nil) rect->SetBrush(brVar->GetBrush()); if (patVar != nil) rect->SetPattern(patVar->GetPattern()); if (colVar != nil) { rect->FillBg(!colVar->GetBgColor()->None()); rect->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } rect->SetTransformer(rel); Unref(rel); RectOvComp* comp = new RectOvComp(rect); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval(new OverlayViewRef(comp), symbol_add("RectComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); } /*****************************************************************************/ CreateLineFunc::CreateLineFunc(ComTerp* comterp, Editor* ed) : CreateGraphicFunc(comterp, ed) { } void CreateLineFunc::execute() { const int x0 = 0; const int y0 = 1; const int x1 = 2; const int y1 = 3; const int n = 4; int coords[n]; ComValue& vect = stack_arg(0); if (!vect.is_type(ComValue::ArrayType) || vect.array_len() != n) { reset_stack(); push_stack(ComValue::nullval()); return; } ALIterator i; AttributeValueList* avl = vect.array_val(); avl->First(i); for (int j=0; jDone(i); j++) { coords[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); } AttributeList* al = stack_keys(); Resource::ref(al); reset_stack(); PasteCmd* cmd = nil; if (coords[x0] != coords[x1] || coords[y0] != coords[y1]) { BrushVar* brVar = (BrushVar*) _ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) _ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar"); Transformer* rel = get_transformer(al); ArrowVar* aVar = (ArrowVar*) _ed->GetState("ArrowVar"); ArrowLine* line = new ArrowLine(coords[x0], coords[y0], coords[x1], coords[y1], aVar->Head(), aVar->Tail(), _ed->GetViewer()->GetMagnification(), stdgraphic); if (brVar != nil) line->SetBrush(brVar->GetBrush()); if (colVar != nil) { line->FillBg(!colVar->GetBgColor()->None()); line->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } line->SetTransformer(rel); Unref(rel); ArrowLineOvComp* comp = new ArrowLineOvComp(line); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval(new OverlayViewRef(comp), symbol_add("ArrowLineComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); } /*****************************************************************************/ CreateEllipseFunc::CreateEllipseFunc(ComTerp* comterp, Editor* ed) : CreateGraphicFunc(comterp, ed) { } void CreateEllipseFunc::execute() { const int x0 = 0; const int y0 = 1; const int r1 = 2; const int r2 = 3; const int n = 4; int args[n]; ComValue& vect = stack_arg(0); if (!vect.is_type(ComValue::ArrayType) || vect.array_len() != n) { reset_stack(); push_stack(ComValue::nullval()); return; } ALIterator i; AttributeValueList* avl = vect.array_val(); avl->First(i); for (int j=0; jDone(i); j++) { args[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); } AttributeList* al = stack_keys(); Resource::ref(al); reset_stack(); PasteCmd* cmd = nil; if (args[r1] > 0 && args[r2] > 0) { BrushVar* brVar = (BrushVar*) _ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) _ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar"); Transformer* rel = get_transformer(al); SF_Ellipse* ellipse = new SF_Ellipse(args[x0], args[y0], args[r1], args[r2], stdgraphic); if (brVar != nil) ellipse->SetBrush(brVar->GetBrush()); if (patVar != nil) ellipse->SetPattern(patVar->GetPattern()); if (colVar != nil) { ellipse->FillBg(!colVar->GetBgColor()->None()); ellipse->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } ellipse->SetTransformer(rel); Unref(rel); EllipseOvComp* comp = new EllipseOvComp(ellipse); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval( new OverlayViewRef(comp), symbol_add("EllipseComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); } /*****************************************************************************/ // this one needs to get the string value, plus x,y location CreateTextFunc::CreateTextFunc(ComTerp* comterp, Editor* ed) : CreateGraphicFunc(comterp, ed) { } void CreateTextFunc::execute() { const int x0 = 0; const int y0 = 1; const int n = 2; int args[n]; ComValue& vect = stack_arg(0); ComValue& txtv = stack_arg(1); if (!vect.is_type(ComValue::ArrayType) || vect.array_len() != n) { reset_stack(); push_stack(ComValue::nullval()); return; } ALIterator i; AttributeValueList* avl = vect.array_val(); avl->First(i); for (int j=0; jDone(i); j++) { args[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); } const char* txt = symbol_pntr( txtv.symbol_ref() ); AttributeList* al = stack_keys(); Resource::ref(al); reset_stack(); PasteCmd* cmd = nil; if (txt) { ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar"); FontVar* fntVar = (FontVar*) _ed->GetState("FontVar"); Transformer* rel = get_transformer(al); TextGraphic* text = new TextGraphic(txt, stdgraphic); if (colVar != nil) { text->FillBg(!colVar->GetBgColor()->None()); text->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } if (fntVar != nil) text->SetFont(fntVar->GetFont()); text->SetTransformer(new Transformer()); text->Translate(args[x0], args[y0]); text->GetTransformer()->postmultiply(rel); Unref(rel); TextOvComp* comp = new TextOvComp(text); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval(new OverlayViewRef(comp), symbol_add("TextComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); } /*****************************************************************************/ CreateMultiLineFunc::CreateMultiLineFunc(ComTerp* comterp, Editor* ed) : CreateGraphicFunc(comterp, ed) { } void CreateMultiLineFunc::execute() { ComValue& vect = stack_arg(0); if (!vect.is_type(ComValue::ArrayType) || vect.array_len()==0) { reset_stack(); push_stack(ComValue::nullval()); return; } const int len = vect.array_len(); const int npts = len/2; int x[npts]; int y[npts]; ALIterator i; AttributeValueList* avl = vect.array_val(); avl->First(i); for (int j=0; jDone(i); j++) { x[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); y[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); } AttributeList* al = stack_keys(); Resource::ref(al); reset_stack(); PasteCmd* cmd = nil; if (npts) { BrushVar* brVar = (BrushVar*) _ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) _ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar"); Transformer* rel = get_transformer(al); ArrowVar* aVar = (ArrowVar*) _ed->GetState("ArrowVar"); ArrowMultiLine* multiline = new ArrowMultiLine(x, y, npts, aVar->Head(), aVar->Tail(), _ed->GetViewer()->GetMagnification(), stdgraphic); if (brVar != nil) multiline->SetBrush(brVar->GetBrush()); if (patVar != nil) multiline->SetPattern(patVar->GetPattern()); if (colVar != nil) { multiline->FillBg(!colVar->GetBgColor()->None()); multiline->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } multiline->SetTransformer(rel); Unref(rel); ArrowMultiLineOvComp* comp = new ArrowMultiLineOvComp(multiline); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval(new OverlayViewRef(comp), symbol_add("ArrowMultiLineComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); } /*****************************************************************************/ CreateOpenSplineFunc::CreateOpenSplineFunc(ComTerp* comterp, Editor* ed) : CreateGraphicFunc(comterp, ed) { } void CreateOpenSplineFunc::execute() { ComValue& vect = stack_arg(0); if (!vect.is_type(ComValue::ArrayType) || vect.array_len()==0) { reset_stack(); push_stack(ComValue::nullval()); return; } const int len = vect.array_len(); const int npts = len/2; int x[npts]; int y[npts]; ALIterator i; AttributeValueList* avl = vect.array_val(); avl->First(i); for (int j=0; jDone(i); j++) { x[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); y[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); } AttributeList* al = stack_keys(); Resource::ref(al); reset_stack(); PasteCmd* cmd = nil; if (npts) { BrushVar* brVar = (BrushVar*) _ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) _ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar"); Transformer* rel = get_transformer(al); ArrowVar* aVar = (ArrowVar*) _ed->GetState("ArrowVar"); ArrowOpenBSpline* openspline = new ArrowOpenBSpline(x, y, npts, aVar->Head(), aVar->Tail(), _ed->GetViewer()->GetMagnification(), stdgraphic); if (brVar != nil) openspline->SetBrush(brVar->GetBrush()); if (patVar != nil) openspline->SetPattern(patVar->GetPattern()); if (colVar != nil) { openspline->FillBg(!colVar->GetBgColor()->None()); openspline->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } openspline->SetTransformer(rel); Unref(rel); ArrowSplineOvComp* comp = new ArrowSplineOvComp(openspline); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval(new OverlayViewRef(comp), symbol_add("ArrowSplineComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); } /*****************************************************************************/ CreatePolygonFunc::CreatePolygonFunc(ComTerp* comterp, Editor* ed) : CreateGraphicFunc(comterp, ed) { } void CreatePolygonFunc::execute() { ComValue& vect = stack_arg(0); if (!vect.is_type(ComValue::ArrayType) || vect.array_len()==0) { reset_stack(); push_stack(ComValue::nullval()); return; } const int len = vect.array_len(); const int npts = len/2; int x[npts]; int y[npts]; ALIterator i; AttributeValueList* avl = vect.array_val(); avl->First(i); for (int j=0; jDone(i); j++) { x[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); y[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); } AttributeList* al = stack_keys(); Resource::ref(al); reset_stack(); PasteCmd* cmd = nil; if (npts) { BrushVar* brVar = (BrushVar*) _ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) _ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar"); Transformer* rel = get_transformer(al); SF_Polygon* polygon = new SF_Polygon(x, y, npts, stdgraphic); if (brVar != nil) polygon->SetBrush(brVar->GetBrush()); if (patVar != nil) polygon->SetPattern(patVar->GetPattern()); if (colVar != nil) { polygon->FillBg(!colVar->GetBgColor()->None()); polygon->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } polygon->SetTransformer(rel); Unref(rel); PolygonOvComp* comp = new PolygonOvComp(polygon); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval(new OverlayViewRef(comp), symbol_add("PolygonComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); } /*****************************************************************************/ CreateClosedSplineFunc::CreateClosedSplineFunc(ComTerp* comterp, Editor* ed) : CreateGraphicFunc(comterp, ed) { } void CreateClosedSplineFunc::execute() { ComValue& vect = stack_arg(0); if (!vect.is_type(ComValue::ArrayType) || vect.array_len()==0) { reset_stack(); push_stack(ComValue::nullval()); return; } const int len = vect.array_len(); const int npts = len/2; int x[npts]; int y[npts]; ALIterator i; AttributeValueList* avl = vect.array_val(); avl->First(i); for (int j=0; jDone(i); j++) { x[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); y[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); } AttributeList* al = stack_keys(); Resource::ref(al); reset_stack(); PasteCmd* cmd = nil; if (npts) { BrushVar* brVar = (BrushVar*) _ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) _ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar"); Transformer* rel = get_transformer(al); ArrowVar* aVar = (ArrowVar*) _ed->GetState("ArrowVar"); SFH_ClosedBSpline* closedspline = new SFH_ClosedBSpline(x, y, npts, stdgraphic); if (brVar != nil) closedspline->SetBrush(brVar->GetBrush()); if (patVar != nil) closedspline->SetPattern(patVar->GetPattern()); if (colVar != nil) { closedspline->FillBg(!colVar->GetBgColor()->None()); closedspline->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } closedspline->SetTransformer(rel); Unref(rel); ClosedSplineOvComp* comp = new ClosedSplineOvComp(closedspline); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval(new OverlayViewRef(comp), symbol_add("ClosedSplineComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); } /*****************************************************************************/ CreateRasterFunc::CreateRasterFunc(ComTerp* comterp, Editor* ed) : CreateGraphicFunc(comterp, ed) { } void CreateRasterFunc::execute() { const int x0 = 0; const int y0 = 1; const int x1 = 2; const int y1 = 3; const int n = 4; int coords[n]; ComValue& vect = stack_arg(0); if (!vect.is_type(ComValue::ArrayType) || vect.array_len() != n) { reset_stack(); push_stack(ComValue::nullval()); return; } ALIterator i; AttributeValueList* avl = vect.array_val(); avl->First(i); for (int j=0; jDone(i); j++) { coords[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); } AttributeList* al = stack_keys(); Resource::ref(al); reset_stack(); PasteCmd* cmd = nil; if (coords[x0] != coords[x1] || coords[y0] != coords[y1]) { float dcoords[n]; ((OverlayViewer*)GetEditor()->GetViewer())->ScreenToDrawing (coords[x0], coords[y0], dcoords[x0], dcoords[y0]); ((OverlayViewer*)GetEditor()->GetViewer())->ScreenToDrawing (coords[x1], coords[y1], dcoords[x1], dcoords[y1]); OverlayRaster* raster = new OverlayRaster((int)(dcoords[x1]-dcoords[x0]+1), (int)(dcoords[y1]-dcoords[y0]+1), 2 /* initialize with border of 2 */); OverlayRasterRect* rasterrect = new OverlayRasterRect(raster, stdgraphic); #if 1 Transformer* t = new Transformer(); t->Translate(dcoords[x0], dcoords[y0]); rasterrect->SetTransformer(t); Unref(t); #else Transformer* rel = get_transformer(al); #endif RasterOvComp* comp = new RasterOvComp(rasterrect); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval(new OverlayViewRef(comp), symbol_add("RasterComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); } /*****************************************************************************/ FontFunc::FontFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void FontFunc::execute() { ComValue fnum(stack_arg(0)); int fn = fnum.int_val(); reset_stack(); Catalog* catalog = unidraw->GetCatalog(); PSFont* font = catalog->ReadFont("font", fn); FontCmd* cmd = nil; if (font) { cmd = new FontCmd(_ed, font); execute_log(cmd); } } /*****************************************************************************/ FontByNameFunc::FontByNameFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } static char *psfonttoxfont(char* f) { /* convert a PS name to a X... */ char type[10]; int size=0; static char copy[256]; static char name[256]; const static char *wght[] = { "bold","demi","light","demibold","book",0 }; char *s; if (*f=='-') return f; strcpy(copy,f); s = copy; while (*s) { *s = tolower(*s); s++; } f = copy+strlen(copy); s = strchr(copy,'-'); if (!s) { strcpy(type,"medium-r"); } else { *s=0; s++; for (size=0;wght[size];size++) if (!strncmp(s,wght[size],strlen(wght[size]))) { strcpy(type,wght[size]); strcat(type,"-"); s+=strlen(wght[size]); break; } if (!wght[size]) strcpy(type,"medium-"); switch (*s) { case 'i': strcat(type,"i"); break; case 'o': strcat(type,"o"); break; default: strcat(type,"r"); break; } } size = 11; while (f[-1]>='0' && f[-1]<='9') f--; if (*f) size = atoi(f); f[0] = 0; if (f[-1]=='-') f[-1] = 0; sprintf(name,"-*-%s-%s-normal-*-%d-*", copy, type, size ); return name; } /*****************************************************************************/ void FontByNameFunc::execute() { ComValue& fontarg = stack_arg(0); const char* fontval = fontarg.string_ptr(); reset_stack(); char* fontvaldup=strdup(fontval); Catalog* catalog = unidraw->GetCatalog(); XDisplay* dpy =World::current()->display()->rep()->display_; XFontStruct* xfs = XLoadQueryFont(dpy, fontvaldup); PSFont* font = nil; if (!xfs){ char* xfontval=psfonttoxfont(fontvaldup); fontvaldup = strdup(xfontval); xfs = XLoadQueryFont(dpy,xfontval); if (!xfs){ fprintf(stderr, "Can not load font: %s, \n", fontval); fprintf(stderr, "Keeping the current font.\n"); } } if (xfs){ unsigned long value; char fontname[CHARBUFSIZE]; char fontsizeptr[CHARBUFSIZE]; char fontfullname[CHARBUFSIZE]; XGetFontProperty(xfs, XA_FULL_NAME, &value); strcpy(fontfullname, XGetAtomName(dpy, (Atom)value)); XGetFontProperty(xfs, XA_FONT_NAME, &value); strcpy(fontname, XGetAtomName(dpy, (Atom)value)); XGetFontProperty(xfs,XA_POINT_SIZE, &value); sprintf(fontsizeptr,"%d",(unsigned int)(value/10)); font = catalog->FindFont(fontvaldup,fontname,fontsizeptr); delete fontvaldup; } FontCmd* cmd = nil; if (font) { cmd = new FontCmd(_ed, font); execute_log(cmd); } } /*****************************************************************************/ ColorRgbFunc::ColorRgbFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void ColorRgbFunc::execute() { ComValue& fgarg = stack_arg(0); ComValue& bgarg = stack_arg(1); const char* fgname = fgarg.string_ptr(); const char* bgname = bgarg.string_ptr(); reset_stack(); PSColor* fgcolor=nil; PSColor* bgcolor=nil; Catalog* catalog = unidraw->GetCatalog(); fgcolor = catalog->FindColor(fgname); //This comparison is made because the user can set only the foreground color by calling //colorsrgb with one argument. if (bgname && strcmp(bgname,"sym")!=0){ bgcolor = catalog->FindColor(bgname); } ColorCmd* cmd = new ColorCmd(_ed, fgcolor, bgcolor); execute_log(cmd); } /*****************************************************************************/ BrushFunc::BrushFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void BrushFunc::execute() { ComValue& bnum =stack_arg(0); int bn = bnum.int_val(); reset_stack(); Catalog* catalog = unidraw->GetCatalog(); PSBrush* brush = catalog->ReadBrush("brush", bn); BrushCmd* cmd = nil; if (brush) { cmd = new BrushCmd(_ed, brush); execute_log(cmd); } } /*****************************************************************************/ PatternFunc::PatternFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PatternFunc::execute() { ComValue pnum(stack_arg(0)); int pn = pnum.int_val(); reset_stack(); Catalog* catalog = unidraw->GetCatalog(); PSPattern* pattern = catalog->ReadPattern("pattern", pn); PatternCmd* cmd = nil; if (pattern) { cmd = new PatternCmd(_ed, pattern); execute_log(cmd); } } /*****************************************************************************/ ColorFunc::ColorFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void ColorFunc::execute() { ComValue& fgv = stack_arg(0); ComValue& bgv = stack_arg(1); int fgn = fgv.int_val(); int bgn = bgv.int_val(); reset_stack(); Catalog* catalog = unidraw->GetCatalog(); PSColor* fgcolor = catalog->ReadColor("fgcolor", fgn); PSColor* bgcolor = catalog->ReadColor("bgcolor", bgn); ColorCmd* cmd = new ColorCmd(_ed, fgcolor, bgcolor); execute_log(cmd); } /*****************************************************************************/ SelectFunc::SelectFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void SelectFunc::execute() { static int all_symid = symbol_add("all"); ComValue all_flagv(stack_key(all_symid)); boolean all_flag = all_flagv.is_true(); static int clear_symid = symbol_add("clear"); ComValue clear_flagv(stack_key(clear_symid)); boolean clear_flag = clear_flagv.is_true(); Selection* sel = _ed->GetViewer()->GetSelection(); if (clear_flag) { sel->Clear(); unidraw->Update(); reset_stack(); return; } OverlaySelection* newSel = ((OverlayEditor*)_ed)->overlay_kit()->MakeSelection(); Viewer* viewer = _ed->GetViewer(); AttributeValueList* avl = new AttributeValueList(); if (all_flag) { GraphicView* gv = ((OverlayEditor*)_ed)->GetFrame(); Iterator i; int count=0; for (gv->First(i); !gv->Done(i); gv->Next(i)) { GraphicView* subgv = gv->GetView(i); newSel->Append(subgv); OverlayComp* comp = (OverlayComp*)subgv->GetGraphicComp(); ComValue* compval = new ComValue(new OverlayViewRef(comp), comp->classid()); avl->Append(compval); } } else if (nargs()==0) { Iterator i; int count=0; for (sel->First(i); !sel->Done(i); sel->Next(i)) { GraphicView* grview = sel->GetView(i); OverlayComp* comp = grview ? (OverlayComp*)grview->GetSubject() : nil; ComValue* compval = comp ? new ComValue(new OverlayViewRef(comp), comp->classid()) : nil; if (compval) { avl->Append(compval); } delete newSel; newSel = nil; } } else { for (int i=0; iGetSubject(); if (comp) { GraphicView* view = comp->FindView(viewer); if (view) { newSel->Append(view); ComValue* compval = new ComValue(new OverlayViewRef(comp), comp->classid()); avl->Append(compval); } } } else if (obj.is_array()) { Iterator it; AttributeValueList* al = obj.array_val(); al->First(it); while (!al->Done(it)) { if (al->GetAttrVal(it)->object_compview()) { ComponentView* comview = (ComponentView*)al->GetAttrVal(it)->obj_val(); OverlayComp* comp = (OverlayComp*)comview->GetSubject(); if (comp) { GraphicView* view = comp->FindView(viewer); if (view) { newSel->Append(view); ComValue* compval = new ComValue(new OverlayViewRef(comp), comp->classid()); avl->Append(compval); } } } al->Next(it); } } } } if (newSel){ sel->Clear(); delete sel; _ed->SetSelection(newSel); newSel->Update(viewer); unidraw->Update(); } reset_stack(); ComValue retval(avl); push_stack(retval); } /*****************************************************************************/ DeleteFunc::DeleteFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void DeleteFunc::execute() { Viewer* viewer = _ed->GetViewer(); int nf=nargsfixed(); if (nf==0) { reset_stack(); return; } Clipboard* delcb = new Clipboard(); for (int i=0; iGetSubject(); if (comp) delcb->Append(comp); } } DeleteCmd* delcmd = new DeleteCmd(GetEditor(), delcb); delcmd->Execute(); unidraw->Update(); delete delcmd; reset_stack(); } /*****************************************************************************/ MoveFunc::MoveFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void MoveFunc::execute() { ComValue& delxv = stack_arg(0); ComValue& delyv = stack_arg(1); int delx = delxv.int_val(); int dely = delyv.int_val(); reset_stack(); MoveCmd* cmd = nil; if (delx != 0 || dely != 0) { cmd = new MoveCmd(_ed, delx, dely); execute_log(cmd); } } /*****************************************************************************/ ScaleFunc::ScaleFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void ScaleFunc::execute() { ComValue& svx = stack_arg(0); ComValue& svy = stack_arg(1); double fx = svx.double_val(); double fy = svy.double_val(); reset_stack(); ScaleCmd* cmd = nil; if (fx > 0.0 || fy > 0.0) { cmd = new ScaleCmd(_ed, fx, fy); execute_log(cmd); } } /*****************************************************************************/ RotateFunc::RotateFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void RotateFunc::execute() { ComValue& rfv = stack_arg(0); double rf = rfv.double_val(); reset_stack(); RotateCmd* cmd = nil; cmd = new RotateCmd(_ed, rf); execute_log(cmd); } /*****************************************************************************/ PanFunc::PanFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PanFunc::execute() { ComValue& delxv = stack_arg(0); ComValue& delyv = stack_arg(1); int delx = delxv.int_val(); int dely = delyv.int_val(); reset_stack(); PanCmd* cmd = nil; if (delx != 0 || dely != 0) { cmd = new PanCmd(_ed, delx, dely); execute_log(cmd); } } /*****************************************************************************/ PanUpSmallFunc::PanUpSmallFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PanUpSmallFunc::execute() { reset_stack(); FixedPanCmd* cmd = new FixedPanCmd(_ed, NO_PAN, PLUS_SMALL_PAN); execute_log(cmd); } /*****************************************************************************/ PanDownSmallFunc::PanDownSmallFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PanDownSmallFunc::execute() { reset_stack(); FixedPanCmd* cmd = new FixedPanCmd(_ed, NO_PAN, MINUS_SMALL_PAN); execute_log(cmd); } /*****************************************************************************/ PanLeftSmallFunc::PanLeftSmallFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PanLeftSmallFunc::execute() { reset_stack(); FixedPanCmd* cmd = new FixedPanCmd(_ed, MINUS_SMALL_PAN, NO_PAN); execute_log(cmd); } /*****************************************************************************/ PanRightSmallFunc::PanRightSmallFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PanRightSmallFunc::execute() { reset_stack(); FixedPanCmd* cmd = new FixedPanCmd(_ed, PLUS_SMALL_PAN, NO_PAN); execute_log(cmd); } /*****************************************************************************/ PanUpLargeFunc::PanUpLargeFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PanUpLargeFunc::execute() { reset_stack(); FixedPanCmd* cmd = new FixedPanCmd(_ed, NO_PAN, PLUS_LARGE_PAN); execute_log(cmd); } /*****************************************************************************/ PanDownLargeFunc::PanDownLargeFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PanDownLargeFunc::execute() { reset_stack(); FixedPanCmd* cmd = new FixedPanCmd(_ed, NO_PAN, MINUS_LARGE_PAN); execute_log(cmd); } /*****************************************************************************/ PanLeftLargeFunc::PanLeftLargeFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PanLeftLargeFunc::execute() { reset_stack(); FixedPanCmd* cmd = new FixedPanCmd(_ed, MINUS_LARGE_PAN, NO_PAN); execute_log(cmd); } /*****************************************************************************/ PanRightLargeFunc::PanRightLargeFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PanRightLargeFunc::execute() { reset_stack(); FixedPanCmd* cmd = new FixedPanCmd(_ed, PLUS_LARGE_PAN, NO_PAN); execute_log(cmd); } /*****************************************************************************/ ZoomFunc::ZoomFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void ZoomFunc::execute() { ComValue zoomv(pop_stack()); double zoom = zoomv.double_val(); reset_stack(); ZoomCmd* cmd = nil; if (zoom > 0.0) { cmd = new ZoomCmd(_ed, zoom); execute_log(cmd); } ComValue retval(_ed->GetViewer()->GetMagnification()); push_stack(retval); } /*****************************************************************************/ ZoomInFunc::ZoomInFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void ZoomInFunc::execute() { reset_stack(); ZoomCmd* cmd = new ZoomCmd(_ed, 2.0); execute_log(cmd); ComValue retval(_ed->GetViewer()->GetMagnification()); push_stack(retval); } /*****************************************************************************/ ZoomOutFunc::ZoomOutFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void ZoomOutFunc::execute() { reset_stack(); ZoomCmd* cmd = new ZoomCmd(_ed, 0.5); execute_log(cmd); ComValue retval(_ed->GetViewer()->GetMagnification()); push_stack(retval); } /*****************************************************************************/ #ifndef NDEBUG #include #endif TileFileFunc::TileFileFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void TileFileFunc::execute() { ComValue ifilev(stack_arg(0)); ComValue ofilev(stack_arg(1)); ComValue five12(512); ComValue twidthv(stack_arg(2, false, five12)); ComValue theightv(stack_arg(3, false, five12)); reset_stack(); const char* ifile = symbol_pntr(ifilev.symbol_ref()); const char* ofile = symbol_pntr(ofilev.symbol_ref()); #ifndef NDEBUG cerr << "tilefile args - ifn: " << ifile << "ofn: " << ofile << ", twidth: " << twidthv.int_val() << ", theight: " << theightv.int_val() << "\n"; #endif if ( ifile && ofile && (twidthv.type() == ComValue::IntType) && (theightv.type() == ComValue::IntType) ) { int twidth = twidthv.int_val(); int theight = theightv.int_val(); Command* cmd = new TileFileCmd(_ed, ifile, ofile, twidth, theight); execute_log(cmd); } else { push_stack(ComValue::nullval()); } } /*****************************************************************************/ TransformerFunc::TransformerFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void TransformerFunc::execute() { ComValue objv(stack_arg(0)); ComValue transv(stack_arg(0)); reset_stack(); if (objv.object_compview()) { ComponentView* compview = (ComponentView*)objv.obj_val(); if (compview && compview->GetSubject()) { OverlayComp* comp = (OverlayComp*)compview->GetSubject(); Graphic* gr = comp->GetGraphic(); if (gr) { Transformer* trans = gr->GetTransformer(); if (transv.is_unknown() || !transv.is_array() || transv.array_val()->Number()!=6) { AttributeValueList* avl = new AttributeValueList(); float a00, a01, a10, a11, a20, a21; trans->matrix(a00, a01, a10, a11, a20, a21); avl->Append(new AttributeValue(a00)); avl->Append(new AttributeValue(a01)); avl->Append(new AttributeValue(a10)); avl->Append(new AttributeValue(a11)); avl->Append(new AttributeValue(a20)); avl->Append(new AttributeValue(a21)); ComValue retval(avl); push_stack(retval); } else { float a00, a01, a10, a11, a20, a21; AttributeValueList* avl = transv.array_val(); Iterator it; AttributeValue* av; avl->First(it); av = avl->GetAttrVal(it); a00 = av->float_val(); avl->Next(it); av = avl->GetAttrVal(it); a01 = av->float_val(); avl->Next(it); av = avl->GetAttrVal(it); a10 = av->float_val(); avl->Next(it); av = avl->GetAttrVal(it); a11 = av->float_val(); avl->Next(it); av = avl->GetAttrVal(it); a20 = av->float_val(); avl->Next(it); av = avl->GetAttrVal(it); a21 = av->float_val(); Transformer t(a00, a01, a10, a11, a20, a21); *gr->GetTransformer()=t; ComValue compval(new OverlayViewRef(comp), comp->class_symid()); push_stack(compval); } } } } } /*****************************************************************************/ GrParentFunc::GrParentFunc(ComTerp* comterp) : ComFunc(comterp) { } void GrParentFunc::execute() { ComValue compv(stack_arg(0)); reset_stack(); if(compv.is_object() && compv.object_compview()) { ComponentView* compview = (ComponentView*)compv.obj_val(); OverlayComp* comp = (OverlayComp*)compview->GetSubject(); if (comp && comp->GetParent()) { ComValue retval(new OverlayViewRef((OverlayComp*)comp->GetParent()), ((OverlayComp*)comp->GetParent())->classid()); push_stack(retval); return; } } push_stack(ComValue::nullval()); return; } /*****************************************************************************/ #ifdef LEAKCHECK #include CompLeakFunc::CompLeakFunc(ComTerp* comterp) : ComFunc(comterp) { } void CompLeakFunc::execute() { reset_stack(); ComValue retval(OverlayComp::_leakchecker->alive(), ComValue::IntType); push_stack(retval); } /*****************************************************************************/ ViewLeakFunc::ViewLeakFunc(ComTerp* comterp) : ComFunc(comterp) { } void ViewLeakFunc::execute() { reset_stack(); ComValue retval(OverlayView::_leakchecker->alive(), ComValue::IntType); push_stack(retval); } /*****************************************************************************/ AlistLeakFunc::AlistLeakFunc(ComTerp* comterp) : ComFunc(comterp) { } void AlistLeakFunc::execute() { reset_stack(); ComValue retval(AttributeValueList::_leakchecker ? AttributeValueList::_leakchecker->alive() : 0, ComValue::IntType); push_stack(retval); } /*****************************************************************************/ AttrvLeakFunc::AttrvLeakFunc(ComTerp* comterp) : ComFunc(comterp) { } void AttrvLeakFunc::execute() { reset_stack(); ComValue retval(AttributeValue::_leakchecker ? AttributeValue::_leakchecker->alive() : 0, ComValue::IntType); push_stack(retval); } /*****************************************************************************/ MlineLeakFunc::MlineLeakFunc(ComTerp* comterp) : ComFunc(comterp) { } void MlineLeakFunc::execute() { reset_stack(); ComValue retval(MultiLineObj::_leakchecker ? MultiLineObj::_leakchecker->alive() : 0, ComValue::IntType); push_stack(retval); } /*****************************************************************************/ GraphicLeakFunc::GraphicLeakFunc(ComTerp* comterp) : ComFunc(comterp) { } void GraphicLeakFunc::execute() { reset_stack(); ComValue retval(Graphic::_leakchecker ? Graphic::_leakchecker->alive() : 0, ComValue::IntType); push_stack(retval); } /*****************************************************************************/ CommandLeakFunc::CommandLeakFunc(ComTerp* comterp) : ComFunc(comterp) { } void CommandLeakFunc::execute() { reset_stack(); ComValue retval(Command::_leakchecker ? Command::_leakchecker->alive() : 0, ComValue::IntType); push_stack(retval); } #endif /*****************************************************************************/ HideCompFunc::HideCompFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void HideCompFunc::execute() { ComValue viewval(stack_arg(0)); reset_stack(); if (!viewval.is_object()) { push_stack(ComValue::nullval()); return; } ComponentView* view = (ComponentView*)viewval.obj_val(); OverlayComp* comp = (OverlayComp*)view->GetSubject(); if(comp) { comp->GetGraphic()->Hide(); comp->Notify(); } push_stack(viewval); } /*****************************************************************************/ ShowCompFunc::ShowCompFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void ShowCompFunc::execute() { ComValue viewval(stack_arg(0)); reset_stack(); if (!viewval.is_object()) { push_stack(ComValue::nullval()); return; } ComponentView* view = (ComponentView*)viewval.obj_val(); OverlayComp* comp = (OverlayComp*)view->GetSubject(); if(comp) { comp->GetGraphic()->Show(); comp->Notify(); } push_stack(viewval); } /*****************************************************************************/ DesensitizeCompFunc::DesensitizeCompFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void DesensitizeCompFunc::execute() { ComValue viewval(stack_arg(0)); reset_stack(); if (!viewval.is_object()) { push_stack(ComValue::nullval()); return; } ComponentView* view = (ComponentView*)viewval.obj_val(); OverlayComp* comp = (OverlayComp*)view->GetSubject(); if(comp) { comp->GetGraphic()->Desensitize(); comp->Notify(); } push_stack(viewval); } /*****************************************************************************/ SensitizeCompFunc::SensitizeCompFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void SensitizeCompFunc::execute() { ComValue viewval(stack_arg(0)); reset_stack(); if (!viewval.is_object()) { push_stack(ComValue::nullval()); return; } ComponentView* view = (ComponentView*)viewval.obj_val(); OverlayComp* comp = (OverlayComp*)view->GetSubject(); if(comp) { comp->GetGraphic()->Sensitize(); comp->Notify(); } push_stack(viewval); } /*****************************************************************************/ FlipHorizontalFunc::FlipHorizontalFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void FlipHorizontalFunc::execute() { reset_stack(); ScaleCmd* cmd = nil; cmd = new ScaleCmd(_ed, -1.0, 1.0); execute_log(cmd); } /*****************************************************************************/ FlipVerticalFunc::FlipVerticalFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void FlipVerticalFunc::execute() { reset_stack(); ScaleCmd* cmd = nil; cmd = new ScaleCmd(_ed, 1.0, -1.0); execute_log(cmd); } ivtools-1.2.11a1/src/ComUnidraw/grfunc.h000066400000000000000000000421031214471147700200210ustar00rootroot00000000000000/* * Copyright (c) 2001-2007 Scott E. Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1997,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(grfunc_h) #define _grfunc_h #include #include class Transformer; //: base class for graphic construction func's class CreateGraphicFunc : public UnidrawFunc { public: CreateGraphicFunc(ComTerp*,Editor*); Transformer* get_transformer(AttributeList*); }; //: rectangle drawing command for comdraw. // compview=rect(x0,y0,x1,y1) -- create a rectangle
// compview=rectangle(x0,y0,x1,y1) -- same as rect class CreateRectFunc : public CreateGraphicFunc { public: CreateRectFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(x0,y0,x1,y1) -- create a rectangle"; } }; //: line drawing command for comdraw. // compview=line(x0,y0,x1,y1) -- create a line
// compview=arrowline(x0,y0,x1,y1) -- same as line class CreateLineFunc : public CreateGraphicFunc { public: CreateLineFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(x0,y0,x1,y1) -- create a line"; } }; //: ellipse drawing command for comdraw. // compview=ellipse(x0,y0,r1,r2) -- create an ellipse class CreateEllipseFunc : public CreateGraphicFunc { public: CreateEllipseFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(x0,y0,r1,r2) -- create an ellipse"; } }; //: text drawing command for comdraw. // compview=text(x0,y0 textstr) -- create a text string class CreateTextFunc : public CreateGraphicFunc { public: CreateTextFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(x0,y0 textstr) -- create a text string"; } }; //: multiline drawing command for comdraw. // compview=multiline(x0,y0[,x1,y1,...]) -- create a multiline
// compview=arrowmultiline(x0,y0[,x1,y1,...]) -- same as multiline class CreateMultiLineFunc : public CreateGraphicFunc { public: CreateMultiLineFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(x0,y0[,x1,y1,...]) -- create a multiline"; } }; //: open spline drawing command for comdraw. // compview=openspline(x0,y0[,x1,y1,...]) -- create an open spline
// compview=arrowspline(x0,y0[,x1,y1,...]) -- same as openspline class CreateOpenSplineFunc : public CreateGraphicFunc { public: CreateOpenSplineFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(x0,y0[,x1,y1,...]) -- create an open spline"; } }; //: polygon drawing command for comdraw. // compview=polygon(x0,y0[,x1,y1,...]) -- create a polygon class CreatePolygonFunc : public CreateGraphicFunc { public: CreatePolygonFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(x0,y0[,x1,y1,...]) -- create a polygon"; } }; //: closed spline drawing command for comdraw. // compview=closedspline(x0,y0[,x1,y1,...]) -- create a closed spline class CreateClosedSplineFunc : public CreateGraphicFunc { public: CreateClosedSplineFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(x0,y0[,x1,y1,...]) -- create a closed spline"; } }; //: raster creation command for comdraw. // compview=raster(x0,y0,x1,y1) -- create an empty raster class CreateRasterFunc : public CreateGraphicFunc { public: CreateRasterFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(x0,y0,x1,y1) -- create an empty raster"; } }; //: command for setting font state variable in comdraw. // font(fontnum) -- set current font from menu order class FontFunc : public UnidrawFunc { public: FontFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(fontnum) -- set current font from menu order"; } }; //: command for setting font state variable by font name in comdraw. // fontbyname(fontname) -- set current font by name class FontByNameFunc : public UnidrawFunc { public: FontByNameFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(fontname) -- set current font by X font name"; } }; //: command for setting brush state variable in comdraw. // brush(brushnum) -- set current brush from menu order class BrushFunc : public UnidrawFunc { public: BrushFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(brushnum) -- set current brush from menu order"; } }; //: command for setting pattern state variable in comdraw. // pattern(patternnum) -- set current pattern from menu order class PatternFunc : public UnidrawFunc { public: PatternFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(patternnum) -- set current pattern from menu order"; } }; //: command for setting color state variables in comdraw. // colors(fgcolornum bgcolornum) -- set current colors from menu order class ColorFunc : public UnidrawFunc { public: ColorFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(fgcolornum bgcolornum) -- set current colors from menu order"; } }; //:comand for setting color state variables by RGB name in comdraw. // colorsrgb(fgcolorname bgcolorname). The colorname format is "#RRGGBB" class ColorRgbFunc : public UnidrawFunc { public: ColorRgbFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(fgcolorname bgcolorname) -- set current colors by RGB name.\nThe colorname format is \"#RGB\" for 4 bits, \"#RRGGBB\" for 8 bits,\n\"#RRRGGGBBB\" for 12 bits,\"#RRRRGGGGBBBB\" for 16 bits"; } }; //: command to select graphics in comdraw. // select([compview ...] :all :clear) -- make these graphics the current selection, // default returns current selection. class SelectFunc : public UnidrawFunc { public: SelectFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s([compview ... | compview,compview[,... compview]] :all :clear) -- make these graphics the current selection (dflt is current)"; } }; //: command to delete graphics in comdraw. // delete(compview [compview ...]) -- delete graphic(s) class DeleteFunc : public UnidrawFunc { public: DeleteFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s([compview ...]) -- delete graphic(s)"; } }; //: command to move current selection in comdraw // move(dx dy) -- move current selection class MoveFunc : public UnidrawFunc { public: MoveFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(dx dy) -- move current selection"; } }; //: command to scale current selection in comdraw // scale(xflt yflt) -- scale current selection class ScaleFunc : public UnidrawFunc { public: ScaleFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(xflt yflt) -- scale current selection"; } }; //: command to rotate current selection in comdraw // rotate(degflt) -- rotate current selection class RotateFunc : public UnidrawFunc { public: RotateFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(degflt) -- rotate current selection"; } }; //: command to pan viewer in comdraw. // pan(px py) -- pan viewer class PanFunc : public UnidrawFunc { public: PanFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(px py) -- pan viewer"; } }; //: command to pan viewer upward a small fixed amount in comdraw. // smallpanup() -- small pan up class PanUpSmallFunc : public UnidrawFunc { public: PanUpSmallFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- small pan up"; } }; //: command to pan viewer downward a small fixed amount in comdraw. // smallpandown() -- small pan down class PanDownSmallFunc : public UnidrawFunc { public: PanDownSmallFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- small pan down"; } }; //: command to pan viewer to the left a small fixed amount in comdraw. // smallpanleft() -- small pan left class PanLeftSmallFunc : public UnidrawFunc { public: PanLeftSmallFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- small pan left"; } }; //: command to pan viewer to the right a small fixed amount in comdraw. // smallpanright() -- small pan right class PanRightSmallFunc : public UnidrawFunc { public: PanRightSmallFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() - small pan right"; } }; //: command to pan viewer upward a large fixed amount in comdraw. // largepanup() -- large pan up class PanUpLargeFunc : public UnidrawFunc { public: PanUpLargeFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- large pan up"; } }; //: command to pan viewer downward a large fixed amount in comdraw. // largepandown() -- large pan down class PanDownLargeFunc : public UnidrawFunc { public: PanDownLargeFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- large pan down"; } }; //: command to pan viewer to the left a large fixed amount in comdraw. // largepanleft() -- large pan left class PanLeftLargeFunc : public UnidrawFunc { public: PanLeftLargeFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- large pan left"; } }; //: command to pan viewer to the right a large fixed amount in comdraw. // largepanright() -- large pan right class PanRightLargeFunc : public UnidrawFunc { public: PanRightLargeFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- large pan right"; } }; //: command to zoom viewer in comdraw. // zoom(zoomflt) -- zoom by factor class ZoomFunc : public UnidrawFunc { public: ZoomFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(zoomflt) -- zoom by factor"; } }; //: command to zoom-in by 2 in comdraw. // zoomin() -- zoom-in by 2. class ZoomInFunc : public UnidrawFunc { public: ZoomInFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- zoom-in by 2"; } }; //: command to zoom-out by 2 in comdraw. // zoomout() -- zoom-out by 2. class ZoomOutFunc : public UnidrawFunc { public: ZoomOutFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- zoom-out by 2"; } }; //: command to generate an internally tiled PGM/PPM file for drawtool or comdraw. // tilefile(inpath outpath [xsize] [ysiz]) -- tile pgm or ppm image file class TileFileFunc : public UnidrawFunc { public: TileFileFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(inpath outpath [xsize] [ysiz]) -- tile pgm or ppm image file"; } }; //: command to access a graphic's transformer // a00,a01,a10,a11,a20,a21=trans(compview [a00,a01,a10,a11,a20,a21]) -- set/get transformer associated with a graphic class TransformerFunc : public UnidrawFunc { public: TransformerFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "[compview|a00,a01,a10,a11,a20,a21]=trans(compview [a00,a01,a10,a11,a20,a21]) -- set/get transformer associated with a graphic"; } }; //: command to access a graphic's parent class GrParentFunc : public ComFunc { public: GrParentFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "compview=parent(compview) -- get parent of graphic"; } }; #ifdef LEAKCHECK //: command to return current number of OverlayComp's // compleak() -- current number of OverlayComp's class CompLeakFunc : public ComFunc { public: CompLeakFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s() -- current number of OverlayComp's"; } }; //: command to return current number of OverlayView's // viewleak() -- current number of OverlayView's class ViewLeakFunc : public ComFunc { public: ViewLeakFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s() -- current number of OverlayView's"; } }; //: command to return current number of AttributeValueList's // alistleak() -- current number of AttributeValueList's class AlistLeakFunc : public ComFunc { public: AlistLeakFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s() -- current number of AttributeValueList's"; } }; //: command to return current number of AttributeValue's // attrvleak() -- current number of AttributeValue's class AttrvLeakFunc : public ComFunc { public: AttrvLeakFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s() -- current number of AttributeValue's"; } }; //: command to return current number of MultiLineObj's // attrvleak() -- current number of MultiLineObj's class MlineLeakFunc : public ComFunc { public: MlineLeakFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s() -- current number of MultiLineObj's"; } }; //: command to return current number of Graphic's // attrvleak() -- current number of Graphic's class GraphicLeakFunc : public ComFunc { public: GraphicLeakFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s() -- current number of Graphic's"; } }; //: command to return current number of Command's // attrvleak() -- current number of Command's class CommandLeakFunc : public ComFunc { public: CommandLeakFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "%s() -- current number of Command's"; } }; #endif //: command to hide graphic // compview=hide(compview) -- hide graphic component class HideCompFunc : public UnidrawFunc { public: HideCompFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(compview) -- hide graphic component"; } }; //: command to show hidden graphic // compview=show(compview) -- show hidden graphic component class ShowCompFunc : public UnidrawFunc { public: ShowCompFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(compview) -- show hidden graphic component"; } }; //: command to desensitize graphic // compview=desensitize(compview) -- desensitize graphic component class DesensitizeCompFunc : public UnidrawFunc { public: DesensitizeCompFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(compview) -- desensitize graphic component"; } }; //: command to sensitize graphic // compview=sensitize(compview) -- sensitize graphic component class SensitizeCompFunc : public UnidrawFunc { public: SensitizeCompFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(compview) -- sensitize graphic component"; } }; //: command to horizontally flip current selection in comdraw // fliph() -- horizontally flip current selection class FlipHorizontalFunc : public UnidrawFunc { public: FlipHorizontalFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- horizontally flip current selection"; } }; //: command to vertically flip current selection in comdraw // flipv() -- vertically flip current selection class FlipVerticalFunc : public UnidrawFunc { public: FlipVerticalFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- vertically flip current selection"; } }; #endif /* !defined(_grfunc_h) */ ivtools-1.2.11a1/src/ComUnidraw/grlistfunc.cc000066400000000000000000000076071214471147700210650ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #define TITLE "GrListFunc" /*****************************************************************************/ GrListAtFunc::GrListAtFunc(ComTerp* comterp) : ComFunc(comterp) { } void GrListAtFunc::execute() { ComValue listv(stack_arg(0)); ComValue nv(stack_arg(1)); static int set_symid = symbol_add("set"); ComValue setv(stack_key(set_symid, false, ComValue::blankval(), true /* return blank if no :set */)); boolean setflag = !setv.is_blank(); static int ins_symid = symbol_add("ins"); ComValue insv(stack_key(ins_symid, false, ComValue::blankval(), true /* return blank if no :ins */)); boolean insflag = !insv.is_blank(); if (listv.object_compview()) { reset_stack(); if (setflag || insflag) { fprintf(stderr, ":set and :insert not yet supported for composite graphics\n"); push_stack(ComValue::nullval()); return; } ComponentView* compview = (ComponentView*)listv.obj_val(); OverlayComp* comp = (OverlayComp*)compview->GetSubject(); OverlaysComp* comps = (OverlaysComp*) (comp->IsA(OVERLAYS_COMP) ? comp : nil); if (comps && nv.int_val()>=0) { Iterator i; int count = 0; comps->First(i); while (!comps->Done(i)) { if (count==nv.int_val()) { OverlayComp* retcomp = (OverlayComp*)comps->GetComp(i); if (retcomp) { ComValue retval(new OverlayViewRef(retcomp), retcomp->classid()); push_stack(retval); return; } } comps->Next(i); count++; } } } else { ListAtFunc atfunc(comterp()); atfunc.exec(funcstate()->nargs(), funcstate()->nkeys(), pedepth()); return; } push_stack(ComValue::nullval()); } /*****************************************************************************/ GrListSizeFunc::GrListSizeFunc(ComTerp* comterp) : ComFunc(comterp) { } void GrListSizeFunc::execute() { ComValue listv(stack_arg(0)); if (listv.object_compview()) { reset_stack(); ComponentView* compview = (ComponentView*)listv.obj_val(); OverlayComp* comp = (OverlayComp*)compview->GetSubject(); OverlaysComp* comps = (OverlaysComp*) (comp->IsA(OVERLAYS_COMP) ? comp : nil); if (comps) { Iterator i; int count = 0; comps->First(i); while (!comps->Done(i)) { count++; comps->Next(i); } ComValue retval (count, ComValue::IntType); push_stack(retval); return; } } else { ListSizeFunc atfunc(comterp()); atfunc.exec(funcstate()->nargs(), funcstate()->nkeys(), pedepth()); return; } push_stack(ComValue::nullval()); } ivtools-1.2.11a1/src/ComUnidraw/grlistfunc.h000066400000000000000000000041321214471147700207150ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * at func for componentviews */ #if !defined(_grlistfunc_h) #define _grlistfunc_h #include //: list member command for ComUnidraw // val=at(list|attrlist|compview n :set val :ins val) -- return (or set or insert after) the nth item in a list. class GrListAtFunc : public ComFunc { public: GrListAtFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "val=at(list|attrlist|compview n :set val :ins val) -- return (or set or insert after) the nth item in a list"; } }; //: list size command for Unidraw // num=size(list|attrlist|str|compview) -- return size of a list (or string). class GrListSizeFunc : public ComFunc { public: GrListSizeFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "val=size(list|attrlist|str|compview) -- return the size of the list (or string)"; } }; #endif /* !defined(_grlistfunc_h) */ ivtools-1.2.11a1/src/ComUnidraw/groupfunc.cc000066400000000000000000000125431214471147700207100ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ GrowGroupFunc::GrowGroupFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void GrowGroupFunc::execute() { ComValue groupval(stack_arg(0)); ComValue grval(stack_arg(1)); reset_stack(); if (!groupval.object_compview() && !grval.object_compview()) return; OverlayViewer* viewer = (OverlayViewer*)GetEditor()->GetViewer(); ComponentView* groupview = (ComponentView*)groupval.obj_val(); OverlayComp* groupcomp = groupview ? (OverlayComp*)groupview->GetSubject() : nil; ComponentView* grview = (ComponentView*)grval.obj_val(); OverlayComp* grcomp = grview ? (OverlayComp*)grview->GetSubject() : nil; if (groupcomp && grcomp) { Iterator i; #if 0 /* first determine if group has non-zero members */ groupcomp->First(i); if (groupcomp->Done(i)) { push_stack(ComValue::nullval()); return; } #endif MacroCmd* mcmd = new MacroCmd(GetEditor()); /* ungroup */ Clipboard* ucb = new Clipboard(); ucb->Append(groupcomp); UngroupCmd* ucmd = new UngroupCmd(GetEditor()); ucmd->SetClipboard(ucb); mcmd->Append(ucmd); /* regroup */ Clipboard* gcb = new Clipboard(); for(groupcomp->First(i); !groupcomp->Done(i); groupcomp->Next(i)) gcb->Append(groupcomp->GetComp(i)); gcb->Append(grcomp); OvGroupCmd* gcmd = new OvGroupCmd(GetEditor()); OverlaysComp* grgroup = new OverlaysComp(); grgroup->SetAttributeList(groupcomp->attrlist()); gcmd->SetGroup(grgroup); gcmd->SetClipboard(gcb); mcmd->Append(gcmd); execute_log(mcmd); ComValue retval(new OverlayViewRef(grgroup), OverlaysComp::class_symid()); push_stack(retval); return; } push_stack(ComValue::nullval()); } /*****************************************************************************/ TrimGroupFunc::TrimGroupFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void TrimGroupFunc::execute() { ComValue groupval(stack_arg(0)); ComValue grval(stack_arg(1)); reset_stack(); if (!groupval.object_compview() && !grval.object_compview()) return; OverlayViewer* viewer = (OverlayViewer*)GetEditor()->GetViewer(); ComponentView* groupview = (ComponentView*)groupval.obj_val(); OverlayComp* groupcomp = groupview ? (OverlayComp*)groupview->GetSubject() : nil; ComponentView* grview = (ComponentView*)grval.obj_val(); OverlayComp* grcomp = grview ? (OverlayComp*)grview->GetSubject() : nil; if (groupcomp && grcomp) { /* first determine if individual graphic really is in the group graphic */ Iterator i; groupcomp->First(i); boolean found = false; while (!groupcomp->Done(i) && !found) { GraphicComp* subcomp = groupcomp->GetComp(i); if (subcomp==grcomp) found = true; groupcomp->Next(i); } if (!found) { push_stack(ComValue::nullval()); return; } MacroCmd* mcmd = new MacroCmd(GetEditor()); /* ungroup */ Clipboard* ucb = new Clipboard(); ucb->Append(groupcomp); UngroupCmd* ucmd = new UngroupCmd(GetEditor()); ucmd->SetClipboard(ucb); mcmd->Append(ucmd); /* regroup */ Clipboard* gcb = new Clipboard(); for(groupcomp->First(i); !groupcomp->Done(i); groupcomp->Next(i)) if (groupcomp->GetComp(i) != grcomp) gcb->Append(groupcomp->GetComp(i)); OvGroupCmd* gcmd = new OvGroupCmd(GetEditor()); OverlaysComp* grgroup = new OverlaysComp(); grgroup->SetAttributeList(groupcomp->attrlist()); gcmd->SetGroup(grgroup); gcmd->SetClipboard(gcb); mcmd->Append(gcmd); execute_log(mcmd); ComValue retval(new OverlayViewRef(grgroup), OverlaysComp::class_symid()); push_stack(retval); return; } push_stack(ComValue::nullval()); } ivtools-1.2.11a1/src/ComUnidraw/groupfunc.h000066400000000000000000000040451214471147700205500ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(groupfunc_h) #define _groupfunc_h #include //: command to add graphic to existing group graphic // newgroup=growgroup(groupview compview) -- add graphic to existing group graphic class GrowGroupFunc : public UnidrawFunc { public: GrowGroupFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "newgroup=%s(groupview compview) -- add graphic to existing group graphic"; } }; //: command to remove graphic from existing group graphic // newgroup=trimgroup(groupview compview) -- remove graphic from existing group graphic class TrimGroupFunc : public UnidrawFunc { public: TrimGroupFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "newgroup=%s(groupview compview) -- remove graphic from existing group graphic"; } }; #endif /* !defined(_groupfunc_h) */ ivtools-1.2.11a1/src/ComUnidraw/grstatfunc.cc000066400000000000000000000136121214471147700210560ustar00rootroot00000000000000/* * Copyright (c) 1994-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define TITLE "GrStatFunc" static int scrn_symid = symbol_add("scrn"); /*****************************************************************************/ CenterFunc::CenterFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void CenterFunc::execute() { static int xy_symval = symbol_add("xy"); static int yx_symval = symbol_add("yx"); static int x_symval = symbol_add("x"); static int y_symval = symbol_add("y"); boolean xy_flag = stack_key(xy_symval).is_true(); boolean yx_flag = stack_key(yx_symval).is_true(); boolean x_flag = stack_key(x_symval).is_true(); boolean y_flag = stack_key(y_symval).is_true(); if (!yx_flag && !x_flag && !y_flag) xy_flag = true; boolean return_an_array = xy_flag || yx_flag; boolean scrn_flag = stack_key(scrn_symid).is_true(); Viewer* viewer = _ed->GetViewer(); ComValue obj(stack_arg(0)); reset_stack(); if (obj.object_compview()) { ComponentView* compview = (ComponentView*)obj.obj_val(); if (compview && compview->GetSubject()) { Graphic* gr = ((GraphicComp*)compview->GetSubject())->GetGraphic(); if (gr) { float cx, cy; gr->GetCenter(cx, cy); if (scrn_flag) ((OverlayViewer*)viewer)->DrawingToScreen(cx, cy, cx, cy); if (return_an_array) { AttributeValueList* avl = new AttributeValueList(); ComValue* v1 = new ComValue(xy_flag ? cx : cy); ComValue* v2 = new ComValue(xy_flag ? cy : cx); avl->Append(v1); avl->Append(v2); ComValue retval(avl); push_stack(retval); } else { ComValue retval(x_flag ? cx : cy); push_stack(retval); } } } } } /*****************************************************************************/ MbrFunc::MbrFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void MbrFunc::execute() { static int lbrt_symval = symbol_add("lbrt"); static int lrbt_symval = symbol_add("lrbt"); boolean lbrt_flag = stack_key(lbrt_symval).is_true(); boolean lrbt_flag = stack_key(lrbt_symval).is_true(); boolean scrn_flag = stack_key(scrn_symid).is_true(); Viewer* viewer = _ed->GetViewer(); ComValue obj(stack_arg(0)); reset_stack(); if (obj.object_compview()) { ComponentView* compview = (ComponentView*)obj.obj_val(); if (compview && compview->GetSubject()) { Graphic* gr = ((GraphicComp*)compview->GetSubject())->GetGraphic(); if (gr) { float l, b, r, t; gr->GetBounds(l, b, r, t); if (scrn_flag) { ((OverlayViewer*)viewer)->DrawingToScreen(l, b, l, b); ((OverlayViewer*)viewer)->DrawingToScreen(r, t, r, t); } AttributeValueList* avl = new AttributeValueList(); ComValue* lval = new ComValue(l); ComValue* bval = new ComValue(b); ComValue* rval = new ComValue(r); ComValue* tval = new ComValue(t); avl->Append(lval); avl->Append(!lrbt_flag ? bval : rval); avl->Append(!lrbt_flag ? rval : bval); avl->Append(tval); ComValue retval(avl); push_stack(retval); } } } } /*****************************************************************************/ PointsFunc::PointsFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PointsFunc::execute() { Viewer* viewer = _ed->GetViewer(); ComValue obj(stack_arg(0)); reset_stack(); if (obj.object_compview()) { ComponentView* compview = (ComponentView*)obj.obj_val(); if (compview && compview->GetSubject()) { GraphicComp* comp = (GraphicComp*)compview->GetSubject(); Graphic* gr = comp ? comp->GetGraphic() : nil; AttributeValueList* avl = new AttributeValueList(); if (gr && comp->IsA(OVVERTICES_COMP)) { VerticesOvComp* vertcomp = (VerticesOvComp*)comp; Vertices* vertgr = vertcomp->GetVertices(); for(int i=0; icount(); i++) { ComValue* val = new ComValue(vertgr->x()[i]); avl->Append(val); val = new ComValue(vertgr->y()[i]); avl->Append(val); } } else if (gr && comp->IsA(OVLINE_COMP)) { LineOvComp* linecomp = (LineOvComp*)comp; Coord x0, y0, x1, y1; linecomp->GetLine()->GetOriginal(x0, y0, x1, y1); avl->Append(new ComValue(x0)); avl->Append(new ComValue(y0)); avl->Append(new ComValue(x1)); avl->Append(new ComValue(y1)); } ComValue retval(avl); push_stack(retval); } } } ivtools-1.2.11a1/src/ComUnidraw/grstatfunc.h000066400000000000000000000046771214471147700207330ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(grstatfunc_h) #define _grstatfunc_h #include //: command to return center of graphics in comdraw. // xylist=center(compview :xy :yx :x :y :scrn) -- center of compview (dflt :xy) class CenterFunc : public UnidrawFunc { public: CenterFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "xylist=%s(compview :xy :yx :x :y :scrn) -- center of compview (dflt :xy)"; } }; //: command to return minimum-bounding rectangle of graphics in comdraw. // rectlist=mbr(compview :lbrt :lrbt :scrn) -- minimum-bounding rectangle of compview (dflt :lbrt) class MbrFunc : public UnidrawFunc { public: MbrFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "rectlist=%s(compview :lbrt :lrbt :scrn) -- minimum-bounding rectangle of compview (dflt :lbrt :lrbt)"; } }; //: command to return point list associated with a graphic // ptlist=points(compview) -- return point list from compview graphic class PointsFunc : public UnidrawFunc { public: PointsFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "ptlist=%s(compview) -- return point list from compview graphic"; } }; #endif /* !defined(_grstatfunc_h) */ ivtools-1.2.11a1/src/ComUnidraw/grstrmfunc.cc000066400000000000000000000077341214471147700211000ustar00rootroot00000000000000/* * Copyright (c) 2011 Wave Semiconductor * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #define TITLE "GrStrmFunc" /*****************************************************************************/ int GrStreamFunc::_symid; GrStreamFunc::GrStreamFunc(ComTerp* comterp) : StreamFunc(comterp) { } void GrStreamFunc::execute() { ComValue convertv(stack_arg_post_eval(0)); if (convertv.object_compview()) { reset_stack(); static StreamNextFunc* snfunc = nil; if (!snfunc) { snfunc = new StreamNextFunc(comterp()); snfunc->funcid(symbol_add("stream")); } AttributeValueList* avl = new AttributeValueList(); Component* comp = ((ComponentView*)convertv.obj_val())->GetSubject(); if (!comp->IsA(OVERLAYS_COMP)) { push_stack(ComValue::nullval()); return; } OverlaysComp* ovcomps = (OverlaysComp*)comp; Iterator it; for(ovcomps->First(it); !ovcomps->Done(it); ovcomps->Next(it)) { OverlayComp* subcomp = (OverlayComp*) ovcomps->GetComp(it); AttributeValue* av = new AttributeValue(new OverlayViewRef(subcomp), subcomp->classid()); avl->Append(av); } ComValue stream(snfunc, avl); stream.stream_mode(-1); // for internal use (use by this func) push_stack(stream); } else { StreamFunc strmfunc(comterp()); strmfunc.exec(funcstate()->nargs(), funcstate()->nkeys(), pedepth()); return; } } #if 0 if (convertv.is_stream()) { /* stream copy */ AttributeValueList* old_avl = convertv.stream_list(); AttributeValueList* new_avl = new AttributeValueList(old_avl); ComValue retval(convertv.stream_func(), new_avl); retval.stream_mode(convertv.stream_mode()); push_stack(retval); } else { /* conversion operator */ static StreamNextFunc* snfunc = nil; if (!snfunc) { snfunc = new StreamNextFunc(comterp()); snfunc->funcid(symbol_add("stream")); } if (convertv.is_array()) { AttributeValueList* avl = new AttributeValueList(convertv.array_val()); ComValue stream(snfunc, avl); stream.stream_mode(-1); // for internal use (use by this func) push_stack(stream); } else if (convertv.is_attributelist()) { AttributeValueList* avl = new AttributeValueList(); AttributeList* al = (AttributeList*)convertv.obj_val(); Iterator i; for(al->First(i); !al->Done(i); al->Next(i)) { Attribute* attr = al->GetAttr(i); AttributeValue* av = new AttributeValue(Attribute::class_symid(), (void*)attr); avl->Append(av); } ComValue stream(snfunc, avl); stream.stream_mode(-1); // for internal use (use by this func) push_stack(stream); } } #endif ivtools-1.2.11a1/src/ComUnidraw/grstrmfunc.h000066400000000000000000000032361214471147700207330ustar00rootroot00000000000000/* * Copyright (c) 2011 Wave Semiconductor Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * collection of stream functions for graphic components */ #if !defined(_grstrmfunc_h) #define _grstrmfunc_h #include //: stream command for graphics class GrStreamFunc : public StreamFunc { public: GrStreamFunc(ComTerp*); virtual void execute(); virtual const char* docstring() { return "strm=%s(ostrm|list|attrlist|compview) -- copy stream or convert list"; } CLASS_SYMID("GrStreamFunc"); }; #endif /* !defined(_grstrmfunc_h) */ ivtools-1.2.11a1/src/ComUnidraw/highlightfunc.cc000066400000000000000000000043371214471147700215250ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #define TITLE "HighlightFunc" /*****************************************************************************/ HighlightFunc::HighlightFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void HighlightFunc::execute() { ComValue grv = stack_arg(0); ComValue gsv = stack_arg(1); reset_stack(); if (grv.object_compview() && gsv.object_compview()) { ComponentView* grcompview = (ComponentView*)grv.obj_val(); ComponentView* gscompview = (ComponentView*)gsv.obj_val(); if (grcompview && grcompview->GetSubject() && gscompview && gscompview->GetSubject()) { Graphic* grgs = ((GraphicComp*)gscompview->GetSubject())->GetGraphic(); if (grgs) { OverlayComp* grcomp = ((OverlayView*)grcompview)->GetOverlayComp(); OverlayView* grview = grcomp ? grcomp->FindView(_ed->GetViewer()) : nil; if (grview) grview->HighlightGraphic(grgs); } } } push_stack(grv); } ivtools-1.2.11a1/src/ComUnidraw/highlightfunc.h000066400000000000000000000032671214471147700213700ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(highlightfunc_h) #define _highlightfunc_h #include //: command to highlight a graphic given another graphic's state // highlight(compview compviewgs) -- set the highlight graphic state for a graphic class HighlightFunc : public UnidrawFunc { public: HighlightFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(compview compviewgs) -- set the highlight graphic state for a graphic"; } }; #endif /* !defined(_highlightfunc_h) */ ivtools-1.2.11a1/src/ComUnidraw/nfunc.cc000066400000000000000000000056541214471147700200160ustar00rootroot00000000000000/* * Copyright (c) 1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #define TITLE "NFunc" /*****************************************************************************/ NColsFunc::NColsFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void NColsFunc::execute() { reset_stack(); Canvas* canvas = GetEditor()->GetViewer()->GetCanvas(); if (canvas) { ComValue retval(canvas->pwidth()); push_stack(retval); } } /*****************************************************************************/ NRowsFunc::NRowsFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void NRowsFunc::execute() { reset_stack(); Canvas* canvas = GetEditor()->GetViewer()->GetCanvas(); if (canvas) { ComValue retval(canvas->pheight()); push_stack(retval); } } /*****************************************************************************/ NFontsFunc::NFontsFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void NFontsFunc::execute() { menulength_execute("font"); } /*****************************************************************************/ NBrushesFunc::NBrushesFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void NBrushesFunc::execute() { menulength_execute("brush"); } /*****************************************************************************/ NPatternsFunc::NPatternsFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void NPatternsFunc::execute() { menulength_execute("pattern"); } /*****************************************************************************/ NColorsFunc::NColorsFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void NColorsFunc::execute() { menulength_execute("fgcolor"); } ivtools-1.2.11a1/src/ComUnidraw/nfunc.h000066400000000000000000000062501214471147700176510ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 1998,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(_comunidraw_nfunc_h) #define _comunidraw_nfunc_h #include //: command to return number of onscreen columns in comdraw. // ncols() -- onscreen horizontal extent in pixels or class NColsFunc : public UnidrawFunc { public: NColsFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- onscreen horizontal extent in pixels"; } }; //: command to return number of onscreen rows in comdraw. // nrows() -- onscreen vertical extent in pixels class NRowsFunc : public UnidrawFunc { public: NRowsFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- onscreen vertical extent in pixels"; } }; //: command to return number of fonts in comdraw menu. // nfonts() -- return size of font menu class NFontsFunc : public UnidrawFunc { public: NFontsFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- return size of font menu"; } }; //: command to return number of brushes in comdraw menu. // nbrushes() -- return size of brush menu class NBrushesFunc : public UnidrawFunc { public: NBrushesFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- return size of brush menu"; } }; //: command to return number of patterns in comdraw menu. // npatterns() -- return size of pattern menu class NPatternsFunc : public UnidrawFunc { public: NPatternsFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- return size of pattern menu"; } }; //: command to return number of colors in comdraw menus. // ncolors() -- return size of color menus. class NColorsFunc : public UnidrawFunc { public: NColorsFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- return size of color menus"; } }; #endif /* !defined(_comunidraw_nfunc_h) */ ivtools-1.2.11a1/src/ComUnidraw/pixelfunc.cc000066400000000000000000000205461214471147700206770ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include /*****************************************************************************/ PixelPokeLineFunc::PixelPokeLineFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PixelPokeLineFunc::execute() { Viewer* viewer = _ed->GetViewer(); ComValue rastcompv(stack_arg(0)); ComValue xv(stack_arg(1)); ComValue yv(stack_arg(2)); ComValue vallistv(stack_arg(3)); int xval = xv.int_val(); int yval = yv.int_val(); if(!vallistv.is_type(ComValue::ArrayType) || vallistv.array_len() <= 1){ reset_stack(); push_stack(ComValue::nullval()); return; } ALIterator i; AttributeValueList* avl = vallistv.array_val(); avl->First(i); int wval = avl->Number(); int pixelvals[wval]; for (int j=0; jDone(i); j++){ pixelvals[j]= avl->GetAttrVal(i)->int_val(); avl->Next(i); } reset_stack(); RasterOvComp* rastcomp = (RasterOvComp*) rastcompv.geta(RasterOvComp::class_symid()); OverlayRasterRect* rastrect = rastcomp ? rastcomp->GetOverlayRasterRect() : nil; OverlayRaster* raster = rastrect ? rastrect->GetOriginal() : nil; if (raster) { for(int j=0; jdisplay(),colorname, r, g, b); raster->poke(xval+j, yval, r, g, b, 1.0); } push_stack(rastcompv); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ PixelPokeFunc::PixelPokeFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PixelPokeFunc::execute() { Viewer* viewer = _ed->GetViewer(); ComValue rastcompv(stack_arg(0)); ComValue xv(stack_arg(1)); ComValue yv(stack_arg(2)); ComValue valv(stack_arg(3)); reset_stack(); RasterOvComp* rastcomp = (RasterOvComp*) rastcompv.geta(RasterOvComp::class_symid()); OverlayRasterRect* rastrect = rastcomp ? rastcomp->GetOverlayRasterRect() : nil; OverlayRaster* raster = rastrect ? rastrect->GetOriginal() : nil; if (raster) { ColorIntensity r,g,b; int pixelcolor = valv.int_val(); char colorname[7]; sprintf(colorname,"#%06x",pixelcolor); Color::find(World::current()->display(),colorname, r, g, b); raster->poke(xv.int_val(), yv.int_val(), r, g, b, 1.0); push_stack(rastcompv); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ PixelPeekFunc::PixelPeekFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PixelPeekFunc::execute() { Viewer* viewer = _ed->GetViewer(); ComValue rastcompv(stack_arg(0)); ComValue xv(stack_arg(1)); ComValue yv(stack_arg(2)); reset_stack(); RasterOvComp* rastcomp = (RasterOvComp*) rastcompv.geta(RasterOvComp::class_symid()); OverlayRasterRect* rastrect = rastcomp ? rastcomp->GetOverlayRasterRect() : nil; OverlayRaster* raster = rastrect ? rastrect->GetOriginal() : nil; if (raster) { ComValue retval; raster->graypeek(xv.int_val(), yv.int_val(), retval); push_stack(retval); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ PixelColsFunc::PixelColsFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PixelColsFunc::execute() { Viewer* viewer = _ed->GetViewer(); ComValue rastcompv(stack_arg(0)); reset_stack(); RasterOvComp* rastcomp = (RasterOvComp*) rastcompv.geta(RasterOvComp::class_symid()); OverlayRasterRect* rastrect = rastcomp ? rastcomp->GetOverlayRasterRect() : nil; OverlayRaster* raster = rastrect ? rastrect->GetOriginal() : nil; if (raster) { ComValue retval(raster->pwidth()); push_stack(retval); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ PixelRowsFunc::PixelRowsFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PixelRowsFunc::execute() { Viewer* viewer = _ed->GetViewer(); ComValue rastcompv(stack_arg(0)); reset_stack(); RasterOvComp* rastcomp = (RasterOvComp*) rastcompv.geta(RasterOvComp::class_symid()); OverlayRasterRect* rastrect = rastcomp ? rastcomp->GetOverlayRasterRect() : nil; OverlayRaster* raster = rastrect ? rastrect->GetOriginal() : nil; if (raster) { ComValue retval(raster->pheight()); push_stack(retval); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ PixelFlushFunc::PixelFlushFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PixelFlushFunc::execute() { Viewer* viewer = _ed->GetViewer(); ComValue rastcompv(stack_arg(0)); reset_stack(); RasterOvComp* rastcomp = (RasterOvComp*) rastcompv.geta(RasterOvComp::class_symid()); OverlayRasterRect* rastrect = rastcomp ? rastcomp->GetOverlayRasterRect() : nil; OverlayRaster* raster = rastrect ? rastrect->GetOriginal() : nil; if (raster) { raster->flush(); viewer->GetDamage()->Incur(rastrect); ComValue retval(rastcompv); push_stack(retval); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ PixelClipFunc::PixelClipFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PixelClipFunc::execute() { Viewer* viewer = _ed->GetViewer(); ComValue rastcompv(stack_arg(0)); ComValue ptsv(stack_arg(1)); reset_stack(); RasterOvComp* rastcomp = (RasterOvComp*) rastcompv.geta(RasterOvComp::class_symid()); OverlayRasterRect* rastrect = rastcomp ? rastcomp->GetOverlayRasterRect() : nil; OverlayRaster* raster = rastrect ? rastrect->GetOriginal() : nil; if (rastrect && ptsv.is_array() && ptsv.array_val()->Number()>2 ) { int n = ptsv.array_val()->Number()/2; IntCoord x[n], y[n]; Iterator it; AttributeValueList* avl = ptsv.array_val(); avl->First(it); for( int i=0; iGetAttrVal(it)->int_val(); avl->Next(it); y[i] = avl->GetAttrVal(it)->int_val(); avl->Next(it); } rastrect->clippts(x, y, n); rastcomp->Notify(); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ AlphaTransFunc::AlphaTransFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void AlphaTransFunc::execute() { Viewer* viewer = _ed->GetViewer(); ComValue rastcompv(stack_arg(0)); ComValue alphav(stack_arg(1)); reset_stack(); RasterOvComp* rastcomp = (RasterOvComp*) rastcompv.geta(RasterOvComp::class_symid()); OverlayRasterRect* rastrect = rastcomp ? rastcomp->GetOverlayRasterRect() : nil; if (rastrect ) { if (alphav.is_numeric()) { rastrect->alphaval(alphav.float_val()); rastcomp->Notify(); } ComValue retval(rastrect->alphaval()); push_stack(retval); } else push_stack(ComValue::nullval()); } ivtools-1.2.11a1/src/ComUnidraw/pixelfunc.h000066400000000000000000000077101214471147700205370ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(pixelfunc_h) #define _pixelfunc_h #include //: command to poke a line of pixel values into raster // pokeline(compview x y vallist) -- poke pixel values of a line listed in vallist into raster. class PixelPokeLineFunc : public UnidrawFunc { public: PixelPokeLineFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(compview x y vallist) -- poke list of values into a raster line."; } }; //: command to poke pixel values into raster // poke(compview x y val) -- poke pixel value into raster class PixelPokeFunc : public UnidrawFunc { public: PixelPokeFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(compview x y val) -- poke pixel value into raster"; } }; //: command to peek pixel values from raster // val=peek(compview x y) -- peek pixel value into raster class PixelPeekFunc : public UnidrawFunc { public: PixelPeekFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "val=%s(compview x y) -- peek pixel value from raster"; } }; //: command to return number of columns in a raster // pcols(compview) -- number of columns in a raster class PixelColsFunc : public UnidrawFunc { public: PixelColsFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(compview) -- number of columns in a raster"; } }; //: command to return number of rows in a raster // pcols(compview) -- number of rows in a raster class PixelRowsFunc : public UnidrawFunc { public: PixelRowsFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(compview) -- number of rows in a raster"; } }; //: command to flush pixels poked in a raster // pflush(compview) -- flush pixels poked into a raster class PixelFlushFunc : public UnidrawFunc { public: PixelFlushFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(compview) -- flush pixels poked into a raster"; } }; //: command to clip raster with polygon // pclip(compview x1,y1,x2,y2,x3,y3[,...,xn,yn]) -- clip raster with polygon class PixelClipFunc : public UnidrawFunc { public: PixelClipFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(compview x1,y1,x2,y2,x3,y3[,...,xn,yn]) -- clip raster with polygon"; } }; //: command to set/get raster alpha transparency // alpha(compview [alphaval]) -- set/get alpha transparency value class AlphaTransFunc : public UnidrawFunc { public: AlphaTransFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(compview [alphaval]) -- set/get alpha transparency value"; } }; #endif /* !defined(_pixelfunc_h) */ ivtools-1.2.11a1/src/ComUnidraw/plotfunc.cc000066400000000000000000000074721214471147700205370ustar00rootroot00000000000000/* * Copyright (c) 1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #define TITLE "PlotFunc" using std::ofstream; /*****************************************************************************/ BarPlotFunc::BarPlotFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void BarPlotFunc::execute() { static int title_symid = symbol_add("title"); static int valtitle_symid = symbol_add("valtitle"); static int xtitle_symid = symbol_add("xtitle"); static int ytitle_symid = symbol_add("ytitle"); static int newview_symid = symbol_add("newview"); if (Component::use_unidraw()) { boolean ok; char* tmpfilename = tempnam(NULL,"plot"); ofstream out(tmpfilename); ComValue title(stack_key(title_symid)); ComValue xtitle(stack_key(xtitle_symid)); ComValue ytitle(stack_key(ytitle_symid)); ComValue vtitle(stack_key(valtitle_symid)); ComValue newview_flag(stack_key(newview_symid)); const char* ts = ""; const char* xs = ""; const char* ys = ""; const char* vs = ""; if (title.is_string()) ts = (char*)title.string_ptr(); if (xtitle.is_string()) xs = (char*)xtitle.string_ptr(); if (ytitle.is_string()) ys = (char*)ytitle.string_ptr(); if (vtitle.is_string()) vs = (char*)vtitle.string_ptr(); out << "$ DATA=BARCHART\n"; out << "% toplabel = \"" << ts << "\"\n"; out << "% xlabel = \"" << xs << "\"\n"; out << "% ylabel = \"" << ys << "\"\n"; out << "\t\"" << vs << "\"\n"; for (int i = 0; i < nargsfixed(); i += 2) { ComValue var(stack_arg(i)); ComValue val(stack_arg(i+1)); if (var.is_string() && val.is_num()) { char* vars = (char*)var.string_ptr(); double v = val.double_val(); out << "\"" << vars << "\" " << v << "\n"; } } out << "$ END\n"; out.flush(); out.close(); char cmd[256]; char* pstmp = tempnam(NULL,"ps"); sprintf(cmd, "plotmtv -noxplot -color -o %s %s", pstmp, tmpfilename); FILE* plotp = popen(cmd, "w"); fprintf(plotp, "n\n"); pclose(plotp); char* idtmp = tempnam(NULL,"idraw"); sprintf(cmd, "pstoedit -f idraw < %s > %s", pstmp, idtmp); fprintf(stderr, "%s\n", cmd); system(cmd); ComEditor* ed = nil; if (newview_flag.is_true()) { ed = new ComEditor((const char*)nil); unidraw->Open(ed); } else ed = (ComEditor*) GetEditor(); OvImportCmd* imp = new OvImportCmd(ed); imp->pathname(idtmp); imp->Execute(); unlink(pstmp); unlink(tmpfilename); } reset_stack(); } ivtools-1.2.11a1/src/ComUnidraw/plotfunc.h000066400000000000000000000034561214471147700203770ustar00rootroot00000000000000/* * Copyright (c) 1998,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(_plotfunc_h) #define _plotfunc_h #include //: command to plot a barchart in comdraw using plotmtv/pstoedit // barplot([var_str value_float] [...] :title title_str :xtitle xtitle_str :ytitle ytitle_str :valtitle valtitle_str :newview) -- display a barplot class BarPlotFunc : public UnidrawFunc { public: BarPlotFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s([var_str value_float] [...] :title title_str :xtitle xtitle_str :ytitle ytitle_str :valtitle valtitle_str :newview) -- display a barplot"; } }; #endif /* !defined(_plotfunc_h) */ ivtools-1.2.11a1/src/ComUnidraw/unifunc.cc000066400000000000000000000651651214471147700203570ustar00rootroot00000000000000/* * Copyright (c) 2000 Vectaport Inc, IET Inc. * Copyright (c) 1994-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifdef HAVE_ACE #include #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __GNUC__>=3 #include #endif #include #include using std::cerr; #define TITLE "UnidrawFunc" /*****************************************************************************/ UnidrawFunc::UnidrawFunc(ComTerp* comterp, Editor* ed) : ComFunc(comterp) { _ed = ed; } void UnidrawFunc::execute_log(Command* cmd) { #if 0 if (cmd != nil) { cmd->Execute(); if (cmd->Reversible()) { cmd->Log(); } else { delete cmd; } } #else unidraw->ExecuteCmd(cmd); #endif } void UnidrawFunc::menulength_execute(const char* kind) { reset_stack(); int itemcount=0; Catalog* catalog = unidraw->GetCatalog(); while(catalog->GetAttribute(catalog->Name(kind, itemcount+1))) itemcount++; ComValue retval(itemcount); push_stack(retval); } /*****************************************************************************/ UpdateFunc::UpdateFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void UpdateFunc::execute() { reset_stack(); unidraw->Update(true); } /*****************************************************************************/ HandlesFunc::HandlesFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void HandlesFunc::execute() { ComValue& flag = stack_arg(0); if (flag.int_val()) ((OverlaySelection*)_ed->GetSelection())->EnableHandles(); else ((OverlaySelection*)_ed->GetSelection())->DisableHandles(); reset_stack(); } /*****************************************************************************/ PasteFunc::PasteFunc(ComTerp* comterp, Editor* ed, OverlayCatalog* catalog) : UnidrawFunc(comterp, ed) { _catalog = catalog; } void PasteFunc::execute() { ComValue viewv(stack_arg(0)); ComValue xscalev(stack_arg(1)); ComValue yscalev(stack_arg(2)); ComValue xoffv(stack_arg(3)); ComValue yoffv(stack_arg(4)); reset_stack(); /* extract comp and scale/translate before pasting */ ComponentView* view = (ComponentView*)viewv.obj_val(); OverlayComp* comp = view ? (OverlayComp*)view->GetSubject() : nil; Graphic* gr = comp ? comp->GetGraphic() : nil; if (gr) { if (xscalev.is_num() && yscalev.is_num()) { float af[6]; af[0] = xscalev.float_val(); af[1] = af[2] = 0.0; af[3] = yscalev.float_val(); if (xoffv.is_num() && yoffv.is_num()) { af[4] = xoffv.float_val(); af[5] = yoffv.float_val(); } else af[4] = af[5] = 0.0; gr->SetTransformer(new Transformer(af[0],af[1],af[2],af[3],af[4],af[5])); } else if (xscalev.is_array()) { ComValue& tranv = xscalev; AttributeValueList* avl = tranv.array_val(); Iterator i; avl->First(i); int num = tranv.array_len(); float af[6]; for (int j=0; j<6; j++) { af[j] = jGetAttrVal(i)->float_val() : 0.0; avl->Next(i); } gr->SetTransformer(new Transformer(af[0],af[1],af[2],af[3],af[4],af[5])); } } else { push_stack(ComValue::nullval()); return; } /* set creator for gvupdater to use and disable unidraw (!use_unidraw) */ /* then restore server/viewer state (use_unidraw) and original creator */ PasteCmd* cmd = new PasteCmd(_ed, new Clipboard(comp)); Creator* oldcreator = Creator::instance(); if (_catalog && _catalog->GetCreator()) Creator::instance(_catalog->GetCreator()); boolean uflag = Component::use_unidraw(); Component::use_unidraw(_catalog ? false : true); execute_log(cmd); Creator::instance(oldcreator); Component::use_unidraw(uflag); push_stack(viewv); } /*****************************************************************************/ int PasteModeFunc:: _paste_mode = 0; PasteModeFunc::PasteModeFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void PasteModeFunc::execute() { static int get_symid = symbol_add("get"); boolean get_flag = stack_key(get_symid).is_true(); if (get_flag) { reset_stack(); int mode = paste_mode(); ComValue retval(mode, ComValue::IntType); push_stack(retval); } else { if (nargs()==0) { reset_stack(); int mode = !paste_mode(); paste_mode(mode); ComValue retval(mode, ComValue::IntType); push_stack(retval); } else { ComValue retval(stack_arg(0)); reset_stack(); paste_mode(retval.int_val()); push_stack(retval); } } } /*****************************************************************************/ ReadOnlyFunc::ReadOnlyFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void ReadOnlyFunc::execute() { ComValue viewval(stack_arg(0)); static int clear_symid = symbol_add("clear"); ComValue clear(stack_key(clear_symid)); reset_stack(); ComponentView* view = (ComponentView*)viewval.obj_val(); OverlayComp* comp = (OverlayComp*)view->GetSubject(); AttributeList* al = comp->GetAttributeList(); al->add_attr("readonly", ComValue::trueval()); push_stack(viewval); } /*****************************************************************************/ SaveFileFunc::SaveFileFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } Command* SaveFileFunc::save(const char* path) { if (!path) { OvSaveCompCmd* cmd = new OvSaveCompCmd(editor()); cmd->Execute(); return cmd->component() ? cmd : nil; } else { OvSaveCompAsCmd* cmd = new OvSaveCompAsCmd(editor()); cmd->pathname(path); cmd->Execute(); return cmd->component() ? cmd : nil; } } void SaveFileFunc::execute() { const char* path = nil; if (nargs()>0) { ComValue pathnamev(stack_arg(0)); path = pathnamev.string_ptr(); } reset_stack(); push_stack( save(path) ? ComValue::oneval() : ComValue::zeroval()); } /*****************************************************************************/ ImportFunc::ImportFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } OvImportCmd* ImportFunc::import(const char* path, boolean popen) { OvImportCmd* cmd = new OvImportCmd(editor()); cmd->pathname(path, popen); cmd->Execute(); if (cmd->component()) { ((OverlayComp*)cmd->component())->SetPathName(path); ((OverlayComp*)cmd->component())->SetByPathnameFlag(!popen); } return cmd; } void ImportFunc::execute() { static char* lastpath = nil; ComValue pathnamev(stack_arg(0)); static int popen_symid = symbol_add("popen"); boolean popen_flag = stack_key(popen_symid).is_true(); static int next_symid = symbol_add("next"); boolean next_flag = stack_key(next_symid).is_true(); reset_stack(); if (next_flag) { if (lastpath) { char* ptr = lastpath + strlen(lastpath) - 1; while ((*ptr < '0' || *ptr > '9') && ptr > lastpath ) ptr--; if (*ptr >= '0' && *ptr <= '9') { do { if (*ptr >= '0' && *ptr <= '8') *ptr = ++*ptr; else *ptr = '0'; } while (*ptr == '0' && --ptr > lastpath); } } else { lastpath = strnew(pathnamev.string_ptr()); } } else { delete lastpath; lastpath = nil; } if (!next_flag && pathnamev.is_string()) lastpath = strnew(pathnamev.string_ptr()); OvImportCmd* cmd; if (!pathnamev.is_array()) { if (nargs()==1 || next_flag) { if ((cmd = import(next_flag ? lastpath : pathnamev.string_ptr(), popen_flag)) && cmd->component()) { ComValue compval(new OverlayViewRef((OverlayComp*)cmd->component()), ((OverlayComp*)cmd->component())->classid()); delete cmd; push_stack(compval); } else push_stack(ComValue::nullval()); } else { for (int i=0; icomponent()), ((OverlayComp*)cmd->component())->classid()); delete cmd; push_stack(compval); } else push_stack(ComValue::nullval()); } } else { AttributeValueList* outlist = new AttributeValueList(); AttributeValueList* inlist = pathnamev.array_val(); Iterator it; inlist->First(it); while(!inlist->Done(it)) { cmd = import(inlist->GetAttrVal(it)->string_ptr(), popen_flag); ComValue* val = new ComValue(new OverlayViewRef((OverlayComp*)cmd->component()), ((OverlayComp*)cmd->component())->classid()); delete cmd; outlist->Append(val); inlist->Next(it); } } } /*****************************************************************************/ ExportFunc::ExportFunc(ComTerp* comterp, Editor* editor, const char* appname) : UnidrawFunc(comterp, editor) { _appname = appname; _docstring = nil; } const char* ExportFunc::docstring() { const char* df = #ifdef HAVE_ACE "%s(compview[,compview[,...compview]] [path] :host host_str :port port_int :socket :string|:str :eps :idraw) -- export in %s format "; #else "%s(compview[,compview[,...compview]] [path] :string|:str :eps :idraw) -- export in %s format "; #endif if (!_docstring) { _docstring = new char[strlen(df)+strlen(appname())+1]; sprintf(_docstring, df, "%s", appname() ); } return _docstring; } void ExportFunc::execute() { static int _host_symid = symbol_add("host"); static int _port_symid = symbol_add("port"); static int _sock_symid = symbol_add("socket"); static int _string_symid = symbol_add("string"); static int _str_symid = symbol_add("str"); static int _eps_symid = symbol_add("eps"); static int _idraw_symid = symbol_add("idraw"); ComValue compviewv(stack_arg(0)); ComValue file(stack_arg(1)); ComValue host(stack_key(_host_symid)); ComValue port(stack_key(_port_symid)); ComValue sock(stack_key(_sock_symid)); ComValue string(stack_key(_string_symid)); ComValue str(stack_key(_str_symid)); ComValue eps_flag(stack_key(_eps_symid)); ComValue idraw_flag(stack_key(_idraw_symid)); reset_stack(); if (nargs()==0 || compviewv.null() || compviewv.type() == ComValue::BlankType) { push_stack(ComValue::nullval()); return; } #ifdef HAVE_ACE ACE_SOCK_Stream* socket = nil; #endif #if __GNUC__<3 filebuf fbuf; if (file.is_type(ComValue::StringType)) fbuf.open(file.string_ptr(), "w"); else if (sock.is_true()) { #ifdef HAVE_ACE ComTerpServ* terp = (ComTerpServ*)comterp(); ComterpHandler* handler = (ComterpHandler*)terp->handler(); if (handler) { ACE_SOCK_Stream peer = handler->peer(); fbuf.attach(peer.get_handle()); } else #endif fbuf.attach(fileno(stdout)); } else { #ifdef HAVE_ACE const char* hoststr = nil; const char* portstr = nil; hoststr = host.type()==ComValue::StringType ? host.string_ptr() : nil; portstr = port.type()==ComValue::StringType ? port.string_ptr() : nil; u_short portnum = portstr ? atoi(portstr) : port.ushort_val(); if (portnum) { socket = new ACE_SOCK_Stream; ACE_SOCK_Connector conn; ACE_INET_Addr addr (portnum, hoststr); if (conn.connect (*socket, addr) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "open")); fbuf.attach(socket->get_handle()); } else if (comterp()->handler() && comterp()->handler()->get_handle()>-1) { fbuf.attach(comterp()->handler()->get_handle()); } else #endif fbuf.attach(fileno(stdout)); } #else filebuf* pfbuf; FILE* ofptr = nil; if (file.is_type(ComValue::StringType)) { pfbuf = new filebuf(); pfbuf->open(file.string_ptr(), input); } else if (sock.is_true()) { #ifdef HAVE_ACE ComTerpServ* terp = (ComTerpServ*)comterp(); ComterpHandler* handler = (ComterpHandler*)terp->handler(); if (handler) { ACE_SOCK_Stream peer = handler->peer(); ofptr = fdopen(peer.get_handle(), "r"); pfbuf = new fileptr_filebuf(ofptr, output); } else #endif pfbuf = new fileptr_filebuf(stdout, output); } else { #ifdef HAVE_ACE const char* hoststr = nil; const char* portstr = nil; hoststr = host.type()==ComValue::StringType ? host.string_ptr() : nil; portstr = port.type()==ComValue::StringType ? port.string_ptr() : nil; u_short portnum = portstr ? atoi(portstr) : port.ushort_val(); if (portnum) { socket = new ACE_SOCK_Stream; ACE_SOCK_Connector conn; ACE_INET_Addr addr (portnum, hoststr); if (conn.connect (*socket, addr) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "open")); pfbuf = new fileptr_filebuf(ofptr = fdopen(socket->get_handle(), "r"), output); } else if (comterp()->handler() && comterp()->handler()->get_handle()>-1) { pfbuf = new fileptr_filebuf(comterp()->handler()->rdfptr(), output); } else #endif pfbuf = new fileptr_filebuf(stdout, output); } #endif ostream* out; if (string.is_true()||str.is_true()) out = new std::strstream(); else #if __GNUC__<3 out = new ostream(&fbuf); #else out = new ostream(pfbuf); #endif if (!compviewv.is_array()) { ComponentView* view = (ComponentView*)compviewv.obj_val(); OverlayComp* comp = view ? (OverlayComp*)view->GetSubject() : nil; if (!comp) return; if (!eps_flag.is_true() && !idraw_flag.is_true()) { *out << appname() << "(\n"; compout(comp, out); *out << ")\n"; } else { OverlayPS* psv = (OverlayPS*) comp->Create(POSTSCRIPT_VIEW); psv->idraw_format(idraw_flag.is_true()); comp->Attach(psv); psv->Update(); psv->Emit(*out); comp->Detach(psv); delete psv; } } else { if (!eps_flag.is_true() && !idraw_flag.is_true()) { *out << appname() << "(\n"; AttributeValueList* avl = compviewv.array_val(); Iterator i; for(avl->First(i);!avl->Done(i); ) { ComponentView* view = (ComponentView*)avl->GetAttrVal(i)->obj_val(); OverlayComp* comp = view ? (OverlayComp*)view->GetSubject() : nil; if (!comp) break; compout(comp, out); avl->Next(i); if (!avl->Done(i)) *out << ",\n"; } *out << ")\n"; } else { AttributeValueList* avl = compviewv.array_val(); Iterator i; for(avl->First(i);!avl->Done(i); ) { ComponentView* view = (ComponentView*)avl->GetAttrVal(i)->obj_val(); OverlayComp* comp = view ? (OverlayComp*)view->GetSubject() : nil; if (!comp) break; OverlayPS* psv = (OverlayPS*) comp->Create(POSTSCRIPT_VIEW); comp->Attach(psv); psv->Update(); psv->Emit(*out); comp->Detach(psv); delete psv; avl->Next(i); } } } if (string.is_true()||str.is_true()) { *out << '\0'; out->flush(); ComValue retval(((std::strstream*)out)->str()); push_stack(retval); } delete out; #if __GNUC__>=3 delete pfbuf; #endif #ifdef HAVE_ACE if (sock.is_false() && socket) { if (socket->close () == -1) ACE_ERROR ((LM_ERROR, "%p\n", "close")); delete(socket); } #endif } void ExportFunc::compout(OverlayComp* comp, ostream* out) { OverlayScript* ovsv = (OverlayScript*) comp->Create(SCRIPT_VIEW); comp->Attach(ovsv); ovsv->Update(); ovsv->Definition(*out); delete ovsv; AttributeList* attrlist = comp->GetAttributeList(); *out << *attrlist; out->flush(); } /*****************************************************************************/ SetAttrFunc::SetAttrFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void SetAttrFunc::execute() { ComValue viewval(stack_arg(0)); AttributeList* al = stack_keys(); reset_stack(); if (!viewval.is_object()) { push_stack(ComValue::nullval()); return; } ComponentView* view = (ComponentView*)viewval.obj_val(); OverlayComp* comp = (OverlayComp*)view->GetSubject(); AttributeList* comp_al = comp ? comp->attrlist() : nil; if (!comp_al && comp) comp->SetAttributeList(al); else if (comp_al) { comp_al->merge(al); delete al; } push_stack(viewval); } /*****************************************************************************/ FrameFunc::FrameFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void FrameFunc::execute() { ComValue indexv(stack_arg(0, false, ComValue::minusoneval())); reset_stack(); OverlayEditor* ed = (OverlayEditor*)GetEditor(); OverlaysView* frameview = ed->GetFrame(indexv.int_val()); if (frameview && frameview->GetSubject()) { OverlayComp* comp = (OverlayComp*)frameview->GetSubject(); ComValue retval(new OverlayViewRef(comp), comp->classid()); push_stack(retval); } else push_stack(ComValue::nullval()); } /*****************************************************************************/ UnidrawPauseFunc::UnidrawPauseFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void UnidrawPauseFunc::execute() { ComValue msgstrv(stack_arg(0)); static int usec_symid = symbol_add("usec"); ComValue usecv(stack_key(usec_symid)); reset_stack(); comterpserv()->npause()++; long usec = usecv.is_numeric() ? usecv.long_val() : -1; ComTextEditor* te = (ComTextEditor*) ((OverlayEditor*)GetEditor())->TextEditor(); if (te) { ComTE_View* tv = te->comtextview(); if (tv) { if (msgstrv.is_string()) { tv->insert_string((char*)msgstrv.string_ptr(), strlen(msgstrv.string_ptr())); tv->insert_char('\n'); } long old_sec, old_usec; ((OverlayUnidraw*)unidraw)->get_timeout(old_sec,old_usec); if(usec<0) { std::ostrstream sbuf_s; sbuf_s << "pause(" << comterpserv()->npause() << "): enter command or press C/R to continue\n"; sbuf_s.put('\0'); tv->insert_string(sbuf_s.str(), strlen(sbuf_s.str())); ((OverlayUnidraw*)unidraw)->set_timeout(-1, -1); } else ((OverlayUnidraw*)unidraw)->set_timeout(0,usec); int remote_pause = (comterpserv()->handler() && comterpserv()->handler()->get_handle()>0); comterpserv()->push_servstate(); boolean nested = comterpserv()->force_nested(); comterpserv()->force_nested(1); unidraw->Run(); comterpserv()->force_nested(nested); if (!unidraw->alive()) comterpserv()->exit(); comterpserv()->pop_servstate(); if(usec<0) { std::ostrstream sbuf_e; sbuf_e << "end of pause(" << comterpserv()->npause()+1 << ")\n"; sbuf_e.put('\0'); tv->insert_string(sbuf_e.str(), strlen(sbuf_e.str())); } ((OverlayUnidraw*)unidraw)->set_timeout(old_sec,old_usec); } } else { cerr << "this version of pause command only works with ComTextEditor\n"; } push_stack(ComValue::blankval()); } /*****************************************************************************/ AddToolButtonFunc::AddToolButtonFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void AddToolButtonFunc::execute() { ComValue pathnamev(stack_arg(0)); reset_stack(); OverlayEditor* ed = (OverlayEditor*)GetEditor(); OverlayComp* comp = ed->overlay_kit()->add_tool_button(pathnamev.symbol_ptr()); if (comp) { ComValue retval(new OverlayViewRef(comp), comp->classid()); push_stack(retval); } else { push_stack(ComValue::nullval()); } } /*****************************************************************************/ ScreenToDrawingFunc::ScreenToDrawingFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void ScreenToDrawingFunc::execute() { ComValue coordsv(stack_arg(0)); reset_stack(); OverlayEditor* ed = (OverlayEditor*)GetEditor(); OverlayViewer* viewer = ed ? (OverlayViewer*)ed->GetViewer() : nil; if (viewer && coordsv.is_array() && coordsv.array_len()==2) { AttributeValueList *avl = coordsv.array_val(); Iterator i; avl->First(i); float sx = avl->GetAttrVal(i)->float_val(); avl->Next(i); float sy = avl->GetAttrVal(i)->float_val(); float dx, dy; viewer->ScreenToDrawing(sx, sy, dx, dy); AttributeValueList* navl = new AttributeValueList(); ComValue retval(navl); navl->Append(new ComValue(dx)); navl->Append(new ComValue(dy)); push_stack(retval); } } /*****************************************************************************/ DrawingToScreenFunc::DrawingToScreenFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void DrawingToScreenFunc::execute() { ComValue coordsv(stack_arg(0)); reset_stack(); OverlayEditor* ed = (OverlayEditor*)GetEditor(); OverlayViewer* viewer = ed ? (OverlayViewer*)ed->GetViewer() : nil; if (viewer && coordsv.is_array() && coordsv.array_len()==2) { AttributeValueList *avl = coordsv.array_val(); Iterator i; avl->First(i); float dx = avl->GetAttrVal(i)->float_val(); avl->Next(i); float dy = avl->GetAttrVal(i)->float_val(); float sx, sy; viewer->DrawingToScreen(dx, dy, sx, sy); AttributeValueList* navl = new AttributeValueList(); ComValue retval(navl); navl->Append(new ComValue(/* (int) */sx)); navl->Append(new ComValue(/* (int) */sy)); push_stack(retval); } } /*****************************************************************************/ GraphicToDrawingFunc::GraphicToDrawingFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void GraphicToDrawingFunc::execute() { ComValue viewval(stack_arg(0)); ComValue coordsv(stack_arg(1)); reset_stack(); if (!viewval.is_object()) { push_stack(ComValue::nullval()); return; } ComponentView* view = (ComponentView*)viewval.obj_val(); OverlayComp* comp = view ? (OverlayComp*)view->GetSubject() : nil; Graphic* gr = comp ? comp->GetGraphic() : nil; OverlayEditor* ed = (OverlayEditor*)GetEditor(); OverlayViewer* viewer = ed ? (OverlayViewer*)ed->GetViewer() : nil; if (gr && viewer && coordsv.is_array() && coordsv.array_len()==2) { AttributeValueList *avl = coordsv.array_val(); Iterator i; avl->First(i); float gx = avl->GetAttrVal(i)->float_val(); avl->Next(i); float gy = avl->GetAttrVal(i)->float_val(); float sx, sy, dx, dy; viewer->GraphicToScreen(gr, gx, gy, sx, sy); viewer->ScreenToDrawing(sx, sy, dx, dy); AttributeValueList* navl = new AttributeValueList(); ComValue retval(navl); navl->Append(new ComValue(dx)); navl->Append(new ComValue(dy)); push_stack(retval); } } /*****************************************************************************/ DrawingToGraphicFunc::DrawingToGraphicFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void DrawingToGraphicFunc::execute() { ComValue viewval(stack_arg(0)); ComValue coordsv(stack_arg(1)); reset_stack(); if (!viewval.is_object()) { push_stack(ComValue::nullval()); return; } ComponentView* view = (ComponentView*)viewval.obj_val(); OverlayComp* comp = view ? (OverlayComp*)view->GetSubject() : nil; Graphic* gr = comp ? comp->GetGraphic() : nil; OverlayEditor* ed = (OverlayEditor*)GetEditor(); OverlayViewer* viewer = ed ? (OverlayViewer*)ed->GetViewer() : nil; if (gr && viewer && coordsv.is_array() && coordsv.array_len()==2) { AttributeValueList *avl = coordsv.array_val(); Iterator i; avl->First(i); float dx = avl->GetAttrVal(i)->float_val(); avl->Next(i); float dy = avl->GetAttrVal(i)->float_val(); float sx, sy, gx, gy; viewer->DrawingToScreen(dx, dy, sx, sy); viewer->ScreenToGraphic(sx, sy, gr, gx, gy); AttributeValueList* navl = new AttributeValueList(); ComValue retval(navl); navl->Append(new ComValue(/* (int) */gx)); navl->Append(new ComValue(/* (int) */gy)); push_stack(retval); } } /*****************************************************************************/ GravityFunc::GravityFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void GravityFunc::execute() { ComValue flag(stack_arg(0)); reset_stack(); GravityVar* gravity = (GravityVar*) GetEditor()->GetState("GravityVar"); if(flag.is_known() && flag.is_true() != gravity->IsActive()) gravity->Activate(!gravity->IsActive()); ComValue retval(gravity->IsActive(), ComValue::IntType); push_stack(retval); } /*****************************************************************************/ GridSpacingFunc::GridSpacingFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void GridSpacingFunc::execute() { ComValue xsizev(stack_arg(0)); ComValue ysizev(stack_arg(1)); reset_stack(); Editor* ed = GetEditor(); Viewer* viewer = ed->GetViewer(); if (xsizev.is_known() && ysizev.is_known()) { viewer->GetGrid()->SetSpacing(xsizev.int_val(), ysizev.int_val()); viewer->Draw(); } AttributeValueList* avl = new AttributeValueList(); float xs, ys; viewer->GetGrid()->GetSpacing(xs, ys); avl->Append(new AttributeValue((int)xs, AttributeValue::IntType)); avl->Append(new AttributeValue((int)ys, AttributeValue::IntType)); ComValue retval(avl); push_stack(retval); } ivtools-1.2.11a1/src/ComUnidraw/unifunc.h000066400000000000000000000223371214471147700202130ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1994-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(_unifunc_h) #define _unifunc_h #include #include class Command; class ComTerp; class OverlayComp; class OvImportCmd; class OvSaveCompCmd; class OverlayCatalog; //: base class for interpreter commands in comdraw. class UnidrawFunc : public ComFunc { public: UnidrawFunc(ComTerp*,Editor*); void execute_log(Command*); Editor* GetEditor() { return editor(); } Editor* editor() { return _ed; } protected: void menulength_execute(const char* kind); Editor* _ed; }; //: command to update Unidraw from comdraw. // update() -- update viewers class UpdateFunc : public UnidrawFunc { public: UpdateFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- update viewers"; } }; //: command to turn on or off the selection tic marks in comdraw. // handles(flag) -- enable/disable current selection tic marks and/or highlighting class HandlesFunc : public UnidrawFunc { public: HandlesFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(flag) -- enable/disable current selection tic marks and/or highlighting"; } }; //: command to paste a graphic in comdraw. // compview=paste(compview [xscale yscale xoff yoff | a00,a01,a10,a11,a20,a21]) -- paste graphic into the viewer" class PasteFunc : public UnidrawFunc { public: PasteFunc(ComTerp*,Editor*,OverlayCatalog* = nil); virtual void execute(); virtual const char* docstring() { return "compview=%s(compview [xscale yscale xoff yoff | a00,a01,a10,a11,a20,a21]) -- paste graphic into the viewer"; } protected: OverlayCatalog* _catalog; }; //: command for toggling or setting paste mode // val=paste([flag] :val) -- toggle or set paste mode, default is 0, always paste new graphics class PasteModeFunc : public UnidrawFunc { public: PasteModeFunc(ComTerp*, Editor*); virtual void execute(); virtual const char* docstring() { return "val=%s([flag] :val) -- toggle or set paste mode, default is 0, always paste new graphics"; } static int paste_mode() { return _paste_mode; } static void paste_mode(int mode) { _paste_mode = mode; } protected: static int _paste_mode; }; //: command to make a graphic read-only in comdraw. // compview=readonly(compview :clear) -- set or clear the readonly attribute of a graphic component class ReadOnlyFunc : public UnidrawFunc { public: ReadOnlyFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(compview :clear) -- set or clear the readonly attribute of a graphic component"; } }; //: command to save document (to pathname) //error=save([path]) -- save editor document (to pathname). class SaveFileFunc : public UnidrawFunc { public: SaveFileFunc(ComTerp*,Editor*); Command* save(const char* path); // helper method to import from path virtual void execute(); virtual const char* docstring() { return "error=%s([path]) -- save editor document (to pathname)"; } }; //: command to import a graphic file // compview=import(pathname :popen :next) -- import graphic file from pathname or URL, or from a command if :popen // (:next imports next in numeric series). class ImportFunc : public UnidrawFunc { public: ImportFunc(ComTerp*,Editor*); OvImportCmd* import(const char* path, boolean popen=false); // helper method to import from path virtual void execute(); virtual const char* docstring() { return "compview=%s(pathname :popen :next) -- import graphic file from pathname or URL, or from a command if :popen\n(:next imports next in numeric series)"; } }; //: command to export a graphic file // export(compview[,compview[,...compview]] [path] :host host_str :port port_int :socket :string|:str :eps :idraw) -- export in drawtool (or other) format "; class ExportFunc : public UnidrawFunc { public: ExportFunc(ComTerp* c, Editor* e, const char* appname=nil); virtual ~ExportFunc() { delete _docstring; } virtual void execute(); virtual const char* docstring(); const char* appname() { return _appname ? _appname : "drawtool"; } void appname(const char* name) { _appname = name; delete _docstring; _docstring=nil;} protected: void compout(OverlayComp*, ostream*); const char* _appname; char* _docstring; }; //: command to set attributes on a graphic // compview=setattr(compview [:keyword value [:keyword value [...]]]) -- set attributes of a graphic component. class SetAttrFunc : public UnidrawFunc { public: SetAttrFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(compview [:keyword value [:keyword value [...]]]) -- set attributes of a graphic component"; } }; //: command to composite component for a frame, defaults to current // compview=frame([index]) -- return composite component for a frame, defaults to current class FrameFunc : public UnidrawFunc { public: FrameFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s([index]) -- return composite component for a frame, defaults to current"; } }; //: command to pause script execution until C/R // pause -- pause script execution until C/R class UnidrawPauseFunc : public UnidrawFunc { public: UnidrawPauseFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "pause(:usec usec) -- pause script execution until C/R (or usec)"; } }; //: command to add button to custom toolbar // compview=addtool(pathname) -- add button to toolbar based on zero-centered idraw drawing. class AddToolButtonFunc : public UnidrawFunc { public: AddToolButtonFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "compview=%s(pathname) -- add button to toolbar based on zero-centered idraw drawing."; } }; //: command to convert from screen to drawing coordinates // dx,dy=stod(sx,sy) -- convert from screen to drawing coordinates class ScreenToDrawingFunc : public UnidrawFunc { public: ScreenToDrawingFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "dx,dy=%s(sx,sy) -- convert from screen to drawing coordinates."; } }; //: command to convert from drawing to screen coordinates // sx,sy=dtos(dx,dy) -- convert from drawing to screen coordinates class DrawingToScreenFunc : public UnidrawFunc { public: DrawingToScreenFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "sx,sy=%s(dx,dy) -- convert from drawing to screen coordinates."; } }; //: command to convert from graphic to drawing coordinates // dx,dy=gtod(compview gx,gy) -- convert from graphic to drawing coordinates class GraphicToDrawingFunc : public UnidrawFunc { public: GraphicToDrawingFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "dx,dy=%s(compview gx,gy) -- convert from graphic to drawing coordinates."; } }; //: command to convert from drawing to graphic coordinates // gx,gy=dtog(compview dx,dy) -- convert from drawing to graphic coordinates class DrawingToGraphicFunc : public UnidrawFunc { public: DrawingToGraphicFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "gx,gy=%s(compview dx,dy) -- convert from drawing to graphic coordinates."; } }; //: command to turn on or off drawing editor gravity // gravity([flag]) -- enable/disable drawing editor gravity class GravityFunc : public UnidrawFunc { public: GravityFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s([flag]) -- enable/disable drawing editor gravity"; } }; //: command to set or get drawing editor grid spacing // gridspacing([xsize ysize]) -- set/get drawing editor grid spacing class GridSpacingFunc : public UnidrawFunc { public: GridSpacingFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s([xsize ysize]) -- set/get drawing editor grid spacing"; } }; #endif /* !defined(_unifunc_h) */ ivtools-1.2.11a1/src/ComUtil/000077500000000000000000000000001214471147700156705ustar00rootroot00000000000000ivtools-1.2.11a1/src/ComUtil/_lexscan.cc000066400000000000000000000642761214471147700200120ustar00rootroot00000000000000/* * Copyright (c) 2005 Scott E. Johnston * Copyright (c) 2000 IET Inc. * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* lexscan.c Lexical scanner Externals: int lexscan() Summary: Lexical scanning routine to recognize C-like tokens History: Written by Scott E. Johnston, March 1989 */ #include #include #include #include #include #include "comutil.ci" extern int _continuation_prompt; extern int _continuation_prompt_disabled; unsigned _token_state_save = TOK_WHITESPACE; /* variable to save token state between calls */ int _ignore_numerics = 0; int _token_eol = 0; int _colon_ident = 1; int _percent_ident = 0; int _ignore_chars = 0; /* MACROS */ /* States for parsing floating point numbers */ #define FLOAT_INTEGER 0 #define FLOAT_FRACTION 1 #define FLOAT_NEWEXPON 2 #define FLOAT_EXPONENT 3 #define FLOAT_IS_STARTING( ch1, ch2 ) \ (((ch1) == '.' && (ch2) != '.' ) || (ch1) == 'E' || (ch1) == 'e') #define LOOKS_LIKE_LONG( ch1, ch2 ) \ (((ch1) == 'l' || (ch1) == 'L') && !(isdigit(ch2) || isident(ch2))) #define ADVANCE_PAST_QUOTE \ while( CURR_CHAR != '\n' && \ CURR_CHAR != ( token_state == TOK_STRING ? '"' : '\'' )) \ ADVANCE_CHAR; ADVANCE_CHAR /*! lexscan Lexical scanning routine to recognize C-like tokens Summary: #include */ int lexscan(void * infile,char * (*infunc)(char*, int, void*),int (*eoffunc)(void*), int (*errfunc)(void*), void * outfile,int (*outfunc)(const char*, void*), const char * begcmt,const char * endcmt, char linecmtchr, const char* linecmtstr, char * buffer,unsigned bufsiz,unsigned * bufptr,char * token, unsigned toksiz, unsigned * toklen,unsigned * toktype, unsigned * tokstart,unsigned * linenum ) /*! Return Value: 0 if OK, -1 if Error  Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void * infile ;/* I Pointer to input text source. Typically a `FILE *`. */ char * (*infunc)() ;/* I Function for reading input text source (typically `fgets`). */ int (*eoffunc)();/* I Function for checking end-of-file condition (typically `ffeof`). */ int (*errfunc)();/* I Function for checking for error on file I/O (typically `fferror`). */ void * outfile ;/* I Pointer to output text source. Typically a `FILE *` (disabled with a NULL). */ int (*outfunc)();/* I Function for writing output text (typically `fputs`). */ const char * begcmt ;/* I String that begins comment. */ const char * endcmt ;/* I String that ends comment. */ char linecmtchr;/* I Character to start comment. */ const char * linecmtstr;/* I Character string to start comment line. */ char * buffer ;/* I Buffer or file I/O. */ unsigned bufsiz ;/* I Size of `buffer` in bytes. */ unsigned * bufptr ;/* O Current location in `buffer`.*/ char * token ;/* O Token string. */ unsigned toksiz ;/* I Maximum possible token size. */ unsigned * toklen ;/* O Actual token size. */ unsigned * toktype ;/* O Token type. */ unsigned * tokstart ;/* O Starting offset of token in `buffer`. */ unsigned * linenum ;/* IO Current line number of input file (initialize by setting to zero). */ #endif /*! Description: `lexscan` scans an input text source, recognizing the following token types (defined in "ComUtil/comutil.h"): TOK_NONE No token found (error occurred) TOK_IDENTIFIER Identifier, i.e. command name TOK_OPERATOR Operator TOK_STRING Character string constant TOK_CHAR Character constant TOK_DFINT Default integer, i.e. of type "int" TOK_DFUNS Default unsigned integer, i.e. of type "unsigned" TOK_LNINT Long integer, i.e. of type "long" TOK_LNUNS Long unsigned integer, i.e. of type "long unsigned" TOK_DOUBLE Double-size floating point number, i.e. of type "double" TOK_EOF End of file `infunc`, `eoffunc`, and `errfunc` are a set of functions that allow `lexscan` to access new lines of text as required. If `infunc` is `NULL`, scanning is done on the contents of `buffer` only. In this case the contents of `buffer` must terminate with a '\n'. !*/ { register char ch; /* For efficient access of latest char */ unsigned double_state = FLOAT_INTEGER; /* Extra state variable for float parsing */ BOOLEAN long_num = FALSE; /* Indicates long integer to be used */ unsigned token_state = TOK_WHITESPACE; /* Internal token state variable */ unsigned begcmt_len = /* Number of characters in comment beginning */ (begcmt != NULL ? strlen(begcmt) : 0 ); unsigned endcmt_len = /* Number of characters in comment ending */ (endcmt != NULL ? strlen(endcmt) : 0 ); unsigned no_comment = /* TRUE if comments are disabled */ (begcmt_len == 0 || endcmt_len == 0); int index; char* infunc_retval; /* ----------------------------------------------------------------------- */ /* Initialize */ /* ----------------------------------------------------------------------- */ /* Safety check */ #ifdef SAFETY_FIRST if( bufsiz < 3 || toksiz < sizeof(double) ) KAPUT( "Ridiculous buffer sizes" ); #endif /* Initialize */ *toktype = TOK_NONE; *tokstart = 0; if (_token_state_save != TOK_STRING) *toklen = 0; else *toklen = strlen(token); token_state = _token_state_save; _token_state_save = TOK_WHITESPACE; /* Initialize if linenumber is 0 */ if( *linenum == 0 ) { *bufptr = 0; if( infunc != NULL ) buffer[0] = '\0'; else { *linenum = 1; #if 0 if( outfile != NULL ) if( (*outfunc)( buffer, outfile ) != 0 ) return ERR_OUTFILE; #endif } } CURR_CHAR = buffer[*bufptr]; /* Check if end-of-file condition is true */ if( (infunc != NULL && (*eoffunc)( infile )) || (infunc == NULL && CURR_CHAR == '\0' )) { *toktype = TOK_EOF; return FUNCOK; } /* Check if error occurred previously */ if( infunc != NULL && (*errfunc)( infile )) { *toktype = TOK_NONE; return ERR_INFILE; } /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */ /* Loop until next token is finished */ /* ----------------------------------------------------------------------- */ while( TRUE ) { /* ----------------- GET NEXT CHARACTER -------------------- */ /* Get New Line of Text */ if( CURR_CHAR == '\0' ) { /* If infunc is NULL, emulate end-of-file */ if( infunc == NULL ) { *toktype = TOK_EOF; if( token_state == TOK_COMMENT ) return ERR_EOFCOMMENT; if( token_state == TOK_STRING || token_state == TOK_CHAR) return ERR_EOFSTRING; return FUNCOK; } /* Clear next to last byte for "line too long" check */ buffer[bufsiz-2] = '\0'; /* If error returned from infunc, return current token as is */ if( token_state != TOK_STRING && token_state != TOK_CHAR ) *tokstart = 0; if (_continuation_prompt && outfunc) { if (!_continuation_prompt_disabled) (*outfunc) ( "> ", outfile); _continuation_prompt = 0; } if (linecmtchr || linecmtstr) while( (infunc_retval = (*infunc)( buffer, bufsiz, infile )) != NULL && (buffer[0] == linecmtchr || strncmp(buffer, linecmtstr, strlen(linecmtstr))==0)) { (*linenum)++; /* skip all script comments */ } else infunc_retval = (*infunc)( buffer, bufsiz, infile ); if( infunc_retval == NULL ) { if( *toklen > 0 ) goto token_return; else { if( (*eoffunc)( infile )) { *toktype = TOK_EOF; if( token_state == TOK_COMMENT ) return ERR_EOFCOMMENT; if( token_state == TOK_STRING || token_state == TOK_CHAR ) return ERR_EOFSTRING; return FUNCOK; } /* File error check */ else if( (*errfunc)( infile )) { *toktype = TOK_NONE; return ERR_INFILE; } } } /* If end-of-file was encountered, yet a legimitate read */ /* occurred, warn the user that last line in file does */ /* not end with new-line char */ if (buffer[0]!='\0') ++*linenum; // probably for dealing with sockets if( (*eoffunc)( infile )) return ERR_EOFNEWLINE; /* In order to detect if line is too long for buffer */ /* the next to last byte was nulled. If after the */ /* call to infunc this byte is anything but '\n' the */ /* line of input was too long for the buffer. */ if( buffer[bufsiz-2] != '\0' && buffer[bufsiz-2] != '\n' ) { /* Get the rest of the line and toss it */ while( buffer[bufsiz-2] != '\0' && buffer[bufsiz-2] != '\n' ) { buffer[bufsiz-2] = '\0'; if (_continuation_prompt && outfunc) { if (!_continuation_prompt_disabled) (*outfunc) ( "> ", outfile); _continuation_prompt = 0; } (*infunc)( buffer, bufsiz, infile ); } *bufptr = 0; buffer[0] = '\0'; return ERR_LINELENGTH; } /* Reset pointer to front of buffer */ *bufptr = 0; CURR_CHAR = buffer[0]; if (CURR_CHAR == '\0') { if (token_state == TOK_COMMENT || token_state == TOK_STRING) { _token_state_save = token_state; token[*toklen] = '\0'; } return FUNCOK; } /* Echo source line if so desired */ #if 0 if( outfile != NULL ) if( (*outfunc)( buffer, outfile ) == EOF ) return ERR_OUTFILE; #endif } /* -------------------- TOKEN STATE SWITCH ------------------ */ switch ( token_state ) { /*-WHITESPACE-WHITESPACE-WHITESPACE-WHITESPACE-WHITESPACE-WHITESPACE-*/ case TOK_WHITESPACE: /* Check for new-line token if desired */ if(_token_eol && CURR_CHAR=='\n') { token_state = TOK_EOL; TOKEN_ADD('\n'); ADVANCE_CHAR; goto token_return; } /* This could be the start of something */ *tokstart = *bufptr; /* Still whitespace */ if( isspace( CURR_CHAR )) { } /* Start of comment */ else if( !no_comment && strncmp( begcmt, buffer+*bufptr, begcmt_len ) == 0 ) { token_state = TOK_COMMENT; for( index=1; index 0 ) if( NEXT_CHAR == '\'' ) { ADVANCE_CHAR; ADVANCE_CHAR; goto token_return; } else { ADVANCE_PAST_QUOTE; return ERR_BADCHAR; } break; /* end of TOK_CHAR and TOK_STRING case */ /*-DFINT-DFINT-DFINT-DFINT-DFINT-DFINT-DFINT-DFINT-DFINT-DFINT-DFINT-*/ case TOK_DFINT: /* Default integer */ if( isdigit( CURR_CHAR )) TOKEN_ADD( CURR_CHAR ) else if( FLOAT_IS_STARTING( ch, NEXT_CHAR )) { token_state = TOK_DOUBLE; TOKEN_ADD( CURR_CHAR ); } else if( LOOKS_LIKE_LONG( ch, NEXT_CHAR )) { long_num = TRUE; ADVANCE_CHAR; goto token_return; } else if( isident( CURR_CHAR )) return ERR_BADINT; else goto token_return; break; /* end of TOK_DFINT case */ /*-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-*/ case TOK_OCT: /* Octal token */ if( *toklen == 0 && CURR_CHAR == '0' ) {} else if( isodigit( CURR_CHAR )) TOKEN_ADD( CURR_CHAR ) else if( FLOAT_IS_STARTING( ch, NEXT_CHAR )) { token_state = TOK_DOUBLE; if( *toklen == 0 ) TOKEN_ADD( '0' ); TOKEN_ADD( CURR_CHAR ); } else if( LOOKS_LIKE_LONG( ch, NEXT_CHAR )) { long_num = TRUE; ADVANCE_CHAR; if( *toklen == 0 ) { token_state = TOK_DFINT; TOKEN_ADD( '0' ); goto token_return; } goto token_return; } else if( isdigit( CURR_CHAR ) || isident( CURR_CHAR )) return ERR_BADOCT; else if( *toklen == 0 ) { token_state = TOK_DFINT; TOKEN_ADD( '0' ); goto token_return; } else goto token_return; break; /* end of TOK_OCT case */ /*-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-*/ case TOK_HEX: /* Hexadecimal token */ if( isxdigit( CURR_CHAR )) TOKEN_ADD( CURR_CHAR ) else if( LOOKS_LIKE_LONG( ch, NEXT_CHAR ) && *toklen > 0 ) { long_num = TRUE; ADVANCE_CHAR; goto token_return; } else if( isident( CURR_CHAR ) || *toklen == 0 ) return ERR_BADHEX; else goto token_return; break; /* end of TOK_HEX case */ /*-DOUBLE-DOUBLE-DOUBLE-DOUBLE-DOUBLE-DOUBLE-DOUBLE-DOUBLE-DOUBLE-*/ case TOK_DOUBLE: /* Double-size floating point number */ /* First time here */ if( double_state == FLOAT_INTEGER ) if( token[*toklen-1] == '.' ) double_state = FLOAT_FRACTION; else double_state = FLOAT_NEWEXPON; /* Completing the fractional part */ if( double_state == FLOAT_FRACTION ) { if( isdigit( CURR_CHAR )) TOKEN_ADD( CURR_CHAR ) else if( CURR_CHAR == 'E' || CURR_CHAR == 'e' ) { TOKEN_ADD( CURR_CHAR ); ADVANCE_CHAR; double_state = FLOAT_NEWEXPON; } else if( isident( CURR_CHAR )) return ERR_BADFLOAT; else goto token_return; } /* Starting the exponent */ if( double_state == FLOAT_NEWEXPON ) { if( CURR_CHAR == '+' || CURR_CHAR == '-' ) { TOKEN_ADD( CURR_CHAR ); ADVANCE_CHAR; } if( isdigit( CURR_CHAR )) double_state = FLOAT_EXPONENT; else return ERR_BADFLOAT; } /* Completing the exponent */ if( double_state == FLOAT_EXPONENT ) { if( isdigit( CURR_CHAR )) TOKEN_ADD( CURR_CHAR ) else if( isident( CURR_CHAR )) return ERR_BADFLOAT; else goto token_return; } break; /* end of TOK_DOUBLE case */ default: break; } /* Advance to Next Character */ ADVANCE_CHAR; } /* ----------------------------------------------------------------------- */ /* Done looping until next token is finished */ /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ /* ----------------------------------------------------------------------- */ /* Finalize token value */ /* ----------------------------------------------------------------------- */ token_return: /* Append null-byte to finish the token */ TOKEN_ADD( '\0' ); /* Check to make sure a constant is not butted up against another */ if ( token_state != TOK_OPERATOR ) if ( CURR_CHAR == '"' || CURR_CHAR == '\'' || isdigit( CURR_CHAR ) || ( CURR_CHAR == '.' && isdigit( NEXT_CHAR ))) return ERR_CONSTSEP; switch( token_state ) { /*-DFINT-DFINT-DFINT-DFINT-DFINT-DFINT-DFINT-DFINT-DFINT-DFINT-DFINT-*/ case TOK_DFINT: /* Output to default sized integer */ #if SHORT_INT_MACHINE || 1 if( !long_num && ( *toklen-1 < DFINT_MAX_DIGITS || ( *toklen-1 == DFINT_MAX_DIGITS && strcmp( DFINT_MAX_STRING, token ) >= 0 ))) { int value; value = atoi( token ); *(int *)token = value; *toklen = sizeof( int ); } else #endif /* Output to long sized integer handling */ { long value; if( *toklen-1 > LNINT_MAX_DIGITS || ( *toklen-1 == LNINT_MAX_DIGITS && strcmp( LNINT_MAX_STRING, token ) < 0 )) return ERR_TOOBIGINT; value = atol( token ); *(long *)token = value; *toklen = sizeof( long ); token_state = TOK_LNINT; } break; /*-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-OCT-*/ case TOK_OCT: { unsigned long value; /* Output to default sized integer */ #if SHORT_INT_MACHINE || 1 if( !long_num && ( *toklen-1 < DFOCTS_MAX_DIGITS || ( *toklen-1 == DFOCTS_MAX_DIGITS && strcmp( DFOCTS_MAX_STRING, token ) >= 0 ))) { value = atoo( token ); *(int *)token = (int) value; *toklen = sizeof( int ); token_state = TOK_DFINT; } /* Output to default sized unsigned integer */ else if ( !long_num && ( *toklen-1 < DFOCTU_MAX_DIGITS || ( *toklen-1 == DFOCTU_MAX_DIGITS && strcmp( DFOCTU_MAX_STRING, token ) >= 0 ))) { value = atoo( token ); *(unsigned *)token = (unsigned) value; *toklen = sizeof( unsigned ); token_state = TOK_DFUNS; } else #endif /* Output to long sized integer */ if ( *toklen-1 < LNOCTS_MAX_DIGITS || ( *toklen-1 == LNOCTS_MAX_DIGITS && strcmp( LNOCTS_MAX_STRING, token ) >= 0 )) { value = atoo( token ); *(long *)token = (long) value; *toklen = sizeof( long ); token_state = TOK_LNINT; } /* Output to long sized unsigned integer */ else { if( *toklen-1 > LNOCTU_MAX_DIGITS || ( *toklen-1 == LNOCTU_MAX_DIGITS && strcmp( LNOCTU_MAX_STRING, token ) < 0 )) return ERR_TOOBIGOCT; value = atoo( token ); *(unsigned long *)token = (unsigned long) value; *toklen = sizeof( unsigned long ); token_state = TOK_LNUNS; } } break; /*-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-HEX-*/ case TOK_HEX: { unsigned long value; /* Output to default sized integer */ #if SHORT_INT_MACHINE || 1 if( !long_num && ( *toklen-1 < DFHEXS_MAX_DIGITS || ( *toklen-1 == DFHEXS_MAX_DIGITS && strcasecmp( DFHEXS_MAX_STRING, token ) >= 0 ))) { value = atox( token ); *(int *)token = (int) value; *toklen = sizeof( int ); token_state = TOK_DFINT; } /* Output to default sized unsigned integer */ else if ( !long_num && ( *toklen-1 < DFHEXU_MAX_DIGITS || ( *toklen-1 == DFHEXU_MAX_DIGITS && strcasecmp( DFHEXU_MAX_STRING, token ) >= 0 ))) { value = atox( token ); *(unsigned *)token = (unsigned) value; *toklen = sizeof( unsigned ); token_state = TOK_DFUNS; } else #endif /* Output to long sized integer */ if ( *toklen-1 < LNHEXS_MAX_DIGITS || ( *toklen-1 == LNHEXS_MAX_DIGITS && strcasecmp( LNHEXS_MAX_STRING, token ) >= 0 )) { value = atox( token ); *(long *)token = (long) value; *toklen = sizeof( long ); token_state = TOK_LNINT; } /* Output to long sized unsigned integer */ else { if( *toklen-1 > LNHEXU_MAX_DIGITS || ( *toklen-1 == LNHEXU_MAX_DIGITS && strcasecmp( LNHEXU_MAX_STRING, token ) < 0 )) return ERR_TOOBIGHEX; value = atox( token ); *(unsigned long *)token = (unsigned long) value; *toklen = sizeof( unsigned long ); token_state = TOK_LNUNS; } } break; /*-DOUBLE-DOUBLE-DOUBLE-DOUBLE-DOUBLE-DOUBLE-DOUBLE-DOUBLE-DOUBLE-*/ case TOK_DOUBLE: { double value; sscanf( token, DOUBL_SCFORM, &value ); *(double *)token = value; *toklen = sizeof( double ); } break; default: break; } /* ----------------------------------------------------------------------- */ /* Assign token type and return */ /* ----------------------------------------------------------------------- */ *toktype = token_state; return FUNCOK; } ivtools-1.2.11a1/src/ComUtil/_parser.cc000066400000000000000000001360621214471147700176420ustar00rootroot00000000000000/* * Copyright (c) 2005-2007 Scott E. Johnston * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* parser.c COMTERP postfix parsing routine Externals: int parser() Summary: History: Written by Scott E. Johnston, April 1989 */ #define DYNAMIC_COMMANDS // allow for executing commands to resolve a command name #include #include #include #include "comterp.ci" int _continuation_prompt; int _continuation_prompt_disabled = 0; int _skip_shell_comments = 0; infuncptr _oneshot_infunc = NULL; int _detail_matched_delims = 0; int _sticky_matched_delims = 0; int _no_bracesplus = 0; int _empty_statement = 1; int _whitespace_binding = 0; static int get_next_token(void *infile, char *(*infunc)(char*, int, void*), int (*eoffunc)(void*), int (*errfunc)(void*), FILE *outfile, int (*outfunc)(const char*, void*), char *buffer, unsigned bufsiz, unsigned *bufptr, char *token, unsigned toksiz, unsigned *toklen, unsigned *toktype, unsigned *tokstart, unsigned *linenum, int *op_ids, unsigned nop_ids); /* TYPDEFS for oper stack - should be put in comterp/comterp.h? */ #define OPERATOR 0 #define LEFTPAREN 1 #define KEYWORD 2 /* Static Variables */ #define EXTERN_VISIBILITY #ifdef EXTERN_VISIBILITY #define static /**/ void* parser_client = NULL; /* pointer to current client */ #endif static unsigned expecting; /* Type of operator expected next */ static paren_stack *ParenStack = NULL; /* Stack to count args and keywords */ static int TopOfParenStack = -1; /* Top of ParenStack */ static int SizeOfParenStack; /* Allocated size of ParenStack */ static oper_stack *OperStack = NULL; /* Operator stack */ static int TopOfOperStack = -1; /* Top of OperStack */ static int SizeOfOperStack; /* Allocated size of OperStack */ static unsigned NextBufptr; /* Variables for look-ahead token */ static char *NextToken = NULL; static unsigned NextToklen; static unsigned NextToktype; static unsigned NextTokstart; static unsigned NextLinenum; static int NextOp_ids[OPTYPE_NUM]; #ifdef EXTERN_VISIBILITY #undef static #endif /* Parenthesis stack macros */ #define INITIAL_PAREN_STACK_SIZE 32 #ifdef PAREN_STACK_EXPERIMENT #define PARENSTK_PUSH( paren_val, comm_val, nids_val ) {\ if( ++TopOfParenStack == SizeOfParenStack ) {\ SizeOfParenStack *= 2;\ dmm_realloc_size(sizeof(paren_stack));\ if( dmm_realloc( (void **) &ParenStack, (long)SizeOfParenStack )) {\ COMERR_SET( ERR_MEMORY );\ goto error_return;}}\ ParenStack[TopOfParenStack].paren_type = paren_val;\ ParenStack[TopOfParenStack].narg = 0;\ ParenStack[TopOfParenStack].nkey = 0;\ ParenStack[TopOfParenStack].nids = nids_val;\ ParenStack[TopOfParenStack].pfnum = *pfnum;\ ParenStack[TopOfParenStack].comm_id = comm_val;} #else #define PARENSTK_PUSH( paren_val, comm_val, nids_val ) {\ if( ++TopOfParenStack == SizeOfParenStack ) {\ SizeOfParenStack *= 2;\ dmm_realloc_size(sizeof(paren_stack));\ if( dmm_realloc( (void **) &ParenStack, (long)SizeOfParenStack )) {\ COMERR_SET( ERR_MEMORY );\ goto error_return;}}\ ParenStack[TopOfParenStack].paren_type = paren_val;\ ParenStack[TopOfParenStack].narg = 0;\ ParenStack[TopOfParenStack].nkey = 0;\ ParenStack[TopOfParenStack].nids = nids_val;\ ParenStack[TopOfParenStack].comm_id = comm_val;} #endif /* Operator stack macros */ #define INITIAL_OPER_STACK_SIZE 32 #define OPERSTK_PUSH( oper_id, type_val ) {\ if( ++TopOfOperStack == SizeOfOperStack ) {\ SizeOfOperStack *= 2;\ dmm_realloc_size(sizeof(oper_stack));\ if( dmm_realloc( (void **) &OperStack, (long)SizeOfOperStack )) {\ COMERR_SET( ERR_MEMORY );\ goto error_return;}}\ OperStack[TopOfOperStack].id = oper_id;\ OperStack[TopOfOperStack].oper_type = type_val;} #define OPERSTK_POP( oper_id ) {\ if( TopOfOperStack < 0 )\ KAPUT( "Unexpected empty operator stack" );\ oper_id = OperStack[TopOfOperStack--].id;} #define OPERSTK_FLUSH \ {\ while( (OperStack[TopOfOperStack].oper_type != LEFTPAREN) &&\ ( TopOfOperStack >=0) )\ {\ if (OperStack[TopOfOperStack].oper_type == OPERATOR)\ {\ OPERSTK_POP( temp_id );\ PFOUT( TOK_COMMAND, opr_tbl_commid( temp_id ),\ (opr_tbl_optype( temp_id ) == OPTYPE_BINARY ? 2 : 1), 0, 1 );\ }\ else\ {\ OPERSTK_POP( temp_id );\ PFOUT( TOK_KEYWORD, temp_id, 1, 0, 0);\ }\ }} #define LOOK_AHEAD {\ char *(*infunc2)(char*, int, void*); \ if( TopOfParenStack < 0 ) infunc2 = NULL;\ else infunc2 = infunc;\ NextBufptr=*bufptr;\ NextLinenum=*linenum;\ status = get_next_token(\ infile, infunc2, eoffunc, errfunc, outfile, outfunc,\ buffer, bufsiz, &NextBufptr, NextToken, toksiz, \ &NextToklen, &NextToktype, &NextTokstart, &NextLinenum,\ NextOp_ids, OPTYPE_NUM );\ if( status != 0 ) goto error_return;} #define UNEXPECTED_RPAREN_ERROR( toktype ){\ int errid;\ if( toktype == TOK_RPAREN ) \ errid = ERR_UNEXPECTED_RPAREN;\ else if( toktype == TOK_RBRACKET )\ errid = ERR_UNEXPECTED_RBRACKET;\ else if( toktype == TOK_RBRACE )\ errid = ERR_UNEXPECTED_RBRACE;\ else if( toktype == TOK_RANGBRACK )\ errid = ERR_UNEXPECTED_RANGBRACK;\ else\ errid = ERR_UNEXPECTED_RANGBRACK2;\ COMERR_SET1( errid, *linenum );\ goto error_return;} #define UNEXPECTED_LPAREN_ERROR( toktype ){\ int errid;\ if( toktype == TOK_LPAREN ) \ errid = ERR_UNEXPECTED_LPAREN;\ else if( toktype == TOK_LBRACKET )\ errid = ERR_UNEXPECTED_LBRACKET;\ else if( toktype == TOK_LBRACE )\ errid = ERR_UNEXPECTED_LBRACE;\ else if( toktype == TOK_LANGBRACK )\ errid = ERR_UNEXPECTED_LANGBRACK;\ else\ errid = ERR_UNEXPECTED_LANGBRACK2;\ COMERR_SET1( errid, *linenum );\ goto error_return;} #define INSTACK_PRIORITY_HIGHER( incoming_priority ) rkg_instack( incoming_priority) #define LEFT_PAREN( toktype ) \ (toktype == TOK_LPAREN || toktype == TOK_LBRACKET || toktype == TOK_LBRACE || toktype == TOK_LANGBRACK || toktype== TOK_LANGBRACK2) #define RIGHT_PAREN( toktype ) \ (toktype == TOK_RPAREN || toktype == TOK_RBRACKET || toktype == TOK_RBRACE || toktype == TOK_RANGBRACK || toktype == TOK_RANGBRACK2) #define PROCEEDING_WHITESPACE( tokstart ) \ (tokstart == 0 || isspace( buffer[tokstart-1] )) #define TRAILING_WHITESPACE( bufptr ) \ (isspace( buffer[bufptr] )) #define UNEXPECTED_NEW_EXPRESSION \ (TopOfParenStack >= 0 && \ ((ParenStack[ TopOfParenStack ].comm_id < 0 && (!_detail_matched_delims^_whitespace_binding)) || \ ParenStack[ TopOfParenStack ].nkey > 0 )) #define UNARY_AMBIGUITY( op_ids )\ (op_ids[OPTYPE_UNARY_PREFIX]>=0 && op_ids[OPTYPE_UNARY_POSTFIX]>=0) #define BINARY_AMBIGUITY( op_ids )\ (op_ids[OPTYPE_UNARY_PREFIX]>=0 && op_ids[OPTYPE_BINARY]>=0) #define AMBIGUITY( op_ids )\ (UNARY_AMBIGUITY(op_ids)||BINARY_AMBIGUITY(op_ids)) static int parens_symid = -1; static int brackets_symid = -1; static int braces_symid = -1; static int angbracks_symid = -1; static int dblangbracks_symid = -1; static int parensplus_symid = -1; static int bracketsplus_symid = -1; static int bracesplus_symid = -1; static int angbracksplus_symid = -1; static int dblangbracksplus_symid = -1; static int empty_symid = -1; /* === Static functions ================================================== */ /* Check for instack priority higher */ static int rkg_instack(int prior) { int x; switch(OperStack[TopOfOperStack].oper_type) { case LEFTPAREN: case KEYWORD: return(0); case OPERATOR: x = opr_tbl_priority(OperStack[TopOfOperStack].id)*2; x += (opr_tbl_rtol(OperStack[TopOfOperStack].id)?-1:1); return( x > prior*2 ); default: printf ("rkg_instack: unknown type\n"); return -1; } } /* Output a token in its postfix order */ #define PFOUT( toktype, tokid, narg_val, nkey_val, nids_val ) {\ if(pfout(pfbuf,pfsiz,pfnum,toktype,tokid,narg_val,nkey_val,nids_val))\ goto error_return;} static int pfout( postfix_token** pfbuf, /* Double pointer to buffer to receive postfix expression. */ unsigned * pfsiz, /* Size of `pfbuf`. */ unsigned * pfnum, /* Number of tokens returned in `pfbuf`. */ unsigned toktype, /* Token type */ int tokid, /* Identifier that corresponds to this token */ unsigned narg_val,/* Number of arguments associated with this token */ unsigned nkey_val,/* Number of keywords associated with this token */ unsigned nids_val /* Number of ids associated with this token */ ) { /* Increase size of output buffer if necessary by doubling it */ if( *pfnum+1 == *pfsiz ) { *pfsiz *= 2; dmm_realloc_size(sizeof(postfix_token)); if( dmm_realloc( (void **)pfbuf, (long)*pfsiz )) { COMERR_SET( ERR_MEMORY ); return FUNCBAD; } } /* Fill in postfix token structure */ (*pfbuf+*pfnum)->nids = nids_val; (*pfbuf+*pfnum)->type = toktype; (*pfbuf+*pfnum)->narg = narg_val; (*pfbuf+*pfnum)->nkey = nkey_val; (*pfbuf+*pfnum)->v.symbolid = tokid; ++*pfnum; return FUNCOK; } /* set value in literal token */ #define PFOUT_LITERAL( toktype, token ) {\ if(pfout_literal(pfbuf,pfsiz,pfnum,toktype,token))\ goto error_return;} #define EMPTY_OPER_STACK {\ while( TopOfOperStack >= 0 ) \ {\ if (OperStack[TopOfOperStack].oper_type == OPERATOR)\ {\ OPERSTK_POP( temp_id );\ PFOUT( TOK_COMMAND, opr_tbl_commid( temp_id ),\ (opr_tbl_optype( temp_id ) == OPTYPE_BINARY ? 2 : 1), 0, 1 );\ }\ else\ {\ OPERSTK_POP( temp_id );\ PFOUT( TOK_KEYWORD, temp_id, 1, 0, 0);\ }\ }\ } static int pfout_literal( postfix_token** pfbuf, /* Double pointer to buffer to receive postfix expression. */ unsigned * pfsiz, /* Size of `pfbuf`. */ unsigned * pfnum, /* Number of tokens returned in `pfbuf`. */ unsigned toktype,/* Token type */ char * token /* Token buffer */ ) { if(pfout(pfbuf,pfsiz,pfnum,toktype,0,0,0,0)) return FUNCBAD; memcpy(&(*pfbuf+*pfnum-1)->v.doublval, token, sizeof(double)); return FUNCOK; } /* Check if the following tokens on this line can be resolved without */ /* ambiguity. Used when one ambiguous operator has already been found */ #define STRING_OF_AMBIGUITY_CHECK( ambiguous ) {\ status = string_of_ambiguity_check( &ambiguous, &NextBufptr, *bufptr, \ &NextLinenum, *linenum, buffer, bufsiz, NextToken, toksiz, \ &NextToklen, &NextToktype, &NextTokstart, NextOp_ids ); \ if( status != 0 ) goto error_return;} static int string_of_ambiguity_check( BOOLEAN *ambiguous, /* flag returned TRUE if operators are ambiguous */ unsigned *next_bufptr, /* pointer to variable to use for temp bufptr */ unsigned bufptr, /* current value of bufptr */ unsigned *next_linenum, /* pointer to variable to use for temp linenum */ unsigned linenum, /* current value of linenum */ char *buffer, /* pointer to input character buffer */ unsigned bufsiz, /* size of buffer */ char *next_token, /* pointer to temporary token buffer */ unsigned toksiz, /* size of next_token */ unsigned *next_toklen, /* pointer to temporary token length variable */ unsigned *next_toktype, /* pointer to temporary token type variable */ unsigned *next_tokstart,/* pointer to temporary token start variable */ int *next_op_ids /* pointer to temporary token op ids array */ ) { int status; /* Set ambiguity flag, and set out to disprove starting with next token */ *ambiguous = TRUE; *next_bufptr=bufptr; *next_linenum=linenum; /* Loop until end of this line of input, or ambiguity is proven or disproven */ do{ status = get_next_token( NULL, NULL, NULL, NULL, NULL, NULL, buffer, bufsiz, next_bufptr, next_token, toksiz, next_toklen, next_toktype, next_tokstart, next_linenum, next_op_ids, OPTYPE_NUM ); if( status != 0 ) return FUNCBAD; /* If a token is found that is not an operator or its an operator */ /* with no ambiguity, the search is over, ambiguity does not reign */ if( *next_toktype != TOK_OPERATOR || !AMBIGUITY( next_op_ids ) ) *ambiguous = FALSE; } while( *ambiguous && *next_toktype != TOK_EOF && !TRAILING_WHITESPACE( *next_bufptr )); /* Done looping until end of this line of input */ /* Reset length indicator for next token, to throw away any look-ahead tokens */ *next_toklen = 0; return FUNCOK; } /*! get_next_token Get next token with operators fully typed and expanded to maximum length. Summary: #include */ static int get_next_token( void * infile,char * (*infunc)(char*, int, void*),int (*eoffunc)(void*),int (*errfunc)(void*), FILE * outfile, int (*outfunc)(const char*, void*),char * buffer,unsigned bufsiz, unsigned * bufptr,char * token,unsigned toksiz,unsigned * toklen, unsigned * toktype, unsigned * tokstart, unsigned * linenum, int * op_ids, unsigned nop_ids ) /*! Return Value: 0 if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void * infile ;/* I Pointer to input text source. Typically a `FILE *`. */ char * (*infunc)() ;/* I Function for reading input text source (typically `fgets`). */ int (*eoffunc)();/* I Function for checking end-of-file condition (typically `ffeof`). */ int (*errfunc)();/* I Function for checking for error on file I/O (typically `fferror`). */ FILE * outfile ;/* I Output file pointer for source listing (disabled with a NULL). */ int (*outfunc)();/* I Function for writing output text (typically `fputs`). */ char * buffer ;/* I Buffer or file I/O. */ unsigned bufsiz ;/* I Size of `buffer` in bytes. */ unsigned * bufptr ;/* O Current location in `buffer`.*/ char * token ;/* O Buffer for parsing tokens. */ unsigned toksiz ;/* I Maximum possible token size. */ unsigned * toklen ;/* O Actual token size. */ unsigned * toktype ;/* O Token type. */ unsigned * tokstart ;/* O Starting offset of token in `buffer`. */ unsigned * linenum ;/* IO Current line number of input file (initialize by setting to zero). */ int * op_ids ;/* O Array of operator ids associated with a given operator. */ unsigned nop_ids ;/* I Length of `nop_ids` -- should be 3. */ #endif /*! Description: `get_next_token` is a static function to return the next token from the input stream, with any operators fully typed (binary versus unary prefix/postfix) and expanded to maximum length. !*/ { unsigned int nchar; /* Number of characters in operator */ int status; /* Read token from input file */ status = scanner( infile, infunc, eoffunc, errfunc, outfile, outfunc, buffer, bufsiz, bufptr, token, toksiz, toklen, toktype, tokstart, linenum ); if( status != 0 ) return FUNCBAD; /* Expand operator token to longest possible match */ if( *toktype == TOK_OPERATOR ) { /* Get ids of commands associated with this operator */ if( opr_tbl_entries( buffer+*tokstart, op_ids, nop_ids, &nchar )) return FUNCBAD; /* Augment token to entire operator */ if( nchar > 1 ) if( toksiz > nchar ) { strncat( token, buffer+*tokstart+1, nchar-1 ); *bufptr += nchar - 1; } else KAPUT( "Token too short for expanded operator" ); } /* Replace identifiers, keywords, and strings with symbol id's */ else if( *toktype == TOK_IDENTIFIER || *toktype == TOK_KEYWORD || *toktype == TOK_STRING ) { *toklen = sizeof(int); *(int *)token = symbol_add( token ); if( *(int *) token < 0 ) { COMERR_SET( ERR_MEMORY ); return FUNCBAD; } } return FUNCOK; } /*! parser Return next expression from input text source, in postfix order Summary: #include */ int parser(void * infile,char * (*infunc)(char*, int, void*),int (*eoffunc)(void*),int (*errfunc)(void*), FILE * outfile,int (*outfunc)(const char*, void*),char * buffer,unsigned bufsiz, unsigned * bufptr,char * token,unsigned toksiz,unsigned * linenum, postfix_token ** pfbuf,unsigned * pfsiz,unsigned * pfnum) /*! Return Value: 0 if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void * infile ;/* I Pointer to input text source. Typically a `FILE *`. */ char * (*infunc)() ;/* I Function for reading input text source (typically `fgets`). */ int (*eoffunc)();/* I Function for checking end-of-file condition (typically `ffeof`). */ int (*errfunc)();/* I Function for checking for error on file I/O (typically `fferror`). */ FILE * outfile ;/* I Output file pointer for source listing (disabled with a NULL). */ int (*outfunc)();/* I Function for writing output text (typically `fputs`). */ char * buffer ;/* I Buffer or file I/O. */ unsigned bufsiz ;/* I Size of `buffer` in bytes. */ unsigned * bufptr ;/* O Current location in `buffer`.*/ char * token ;/* O Buffer for parsing tokens. */ unsigned toksiz ;/* I Maximum possible token size. */ unsigned * linenum ;/* IO Current line number of input file (initialize by setting to zero). */ postfix_token** pfbuf ;/* O Double pointer to buffer to receive postfix expression. */ unsigned * pfsiz ;/* IO Size of `pfbuf`. */ unsigned * pfnum ;/* IO Number of tokens returned in `pfbuf`. */ #endif /*! Description: `parser` parses the input file (pointed to by `infile`) and outputs a buffer of postfix ordered tokens. The possible token types are as follows (defined in "comutil.h"): TOK_NONE No token found (error occurred) TOK_KEYWORD Keyword for free format parameters, i.e. ":SIZE" TOK_COMMAND Command name TOK_STRING Character string constant TOK_CHAR Character constant TOK_DFINT Default integer, i.e. of type "int" TOK_DFUNS Default unsigned integer, i.e. of type "unsigned" TOK_LNINT Long integer, i.e. of type "long" TOK_LNUNS Long unsigned integer, i.e. of type "long unsigned" TOK_DOUBLE Double-size floating point number, i.e. of type "double" TOK_EOF End of file `infunc`, `eoffunc`, and `errfunc` are a set of functions that allow `parser` to access new lines of text as required. If `infunc` is `NULL`, parsing is done on the contents of `buffer` only. In this case the contents of `buffer` must terminate with a '\n'. Reference: Horowitz, E. and S. Sahni, "Fundamentals of Data Structures", Computer Science Press Inc., Potomac, MD, 1976, pp. 91-97. See Also: scanner, opr_tbl_create, opr_tbl_insert !*/ { int op_ids[OPTYPE_NUM]; /* Array of potential operator ids */ int optype; /* Operator type that was decided on. */ unsigned toklen; /* Length of current token */ unsigned toktype; /* Type of current token */ unsigned tokstart; /* Start of current token in buffer */ BOOLEAN done; /* Set true when expression is complete */ BOOLEAN ambiguous; /* Used to indicate string of amb. ops. */ int temp_id; /* Temporary variables */ int index; int status; /* Static initialization */ if( *linenum == 0 ) { /* Allocate space for look-ahead token */ NextToklen = 0; if( NextToken == NULL ) { if( dmm_calloc( (void **)&NextToken, (long)toksiz, (long)sizeof(char))) { COMERR_SET( ERR_MEMORY ); goto error_return; } } /* Initialize parenthesis stack */ TopOfParenStack = -1; if( ParenStack == NULL ) { SizeOfParenStack = INITIAL_PAREN_STACK_SIZE; if( dmm_calloc( (void **)&ParenStack, (long)SizeOfParenStack, (long)sizeof(paren_stack) )) { COMERR_SET( ERR_MEMORY ); goto error_return; } } else if( SizeOfParenStack > INITIAL_PAREN_STACK_SIZE ) { SizeOfParenStack = INITIAL_PAREN_STACK_SIZE; dmm_realloc_size(sizeof(paren_stack)); if( dmm_realloc( (void **)&ParenStack, (long)SizeOfParenStack )) KAPUT( "Unable to shrink ParenStack" ); } /* Initialize operator stack */ TopOfOperStack = -1; if( OperStack == NULL ) { SizeOfOperStack = INITIAL_OPER_STACK_SIZE; if( dmm_calloc( (void **)&OperStack, (long)SizeOfOperStack, (long)sizeof(oper_stack) )) { COMERR_SET( ERR_MEMORY ); goto error_return; } } else if( SizeOfOperStack > INITIAL_OPER_STACK_SIZE ) { SizeOfOperStack = INITIAL_OPER_STACK_SIZE; dmm_realloc_size(sizeof(oper_stack)); if( dmm_realloc( (void **)&OperStack, (long)SizeOfOperStack )) KAPUT( "Unable to shrink OperStack" ); } } /* Ensure initialization has occurred */ else if( ParenStack == NULL ) KAPUT( "Needs to be called with linenum set to 0" ); /* Auto variable initialization */ if (TopOfOperStack == -1 && TopOfParenStack == -1) { *pfnum = 0; expecting = OPTYPE_UNARY_PREFIX; } done = FALSE; /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */ /* Loop through tokens until an expression is complete */ /* ----------------------------------------------------------------------- */ do { /* Get current token, either from 'Next' variables if they are full */ /* or directly from the scanner */ if( NextToklen == 0 ) { status = get_next_token( infile, infunc, eoffunc, errfunc, outfile, outfunc, buffer, bufsiz, bufptr, token, toksiz, &toklen, &toktype, &tokstart, linenum, op_ids, OPTYPE_NUM ); if( status != 0 ) goto error_return; } else { *bufptr = NextBufptr; for( index=0; index= 0 ) optype = OPTYPE_UNARY_PREFIX; else { COMERR_SET2( ERR_UNEXPECTED_OPERATOR, *linenum, token ); goto error_return; } } /* expecting binary. What did we really get? */ else { /* Resolve ambiguous binary/prefix operators */ if( op_ids[OPTYPE_BINARY] >= 0 && op_ids[OPTYPE_UNARY_PREFIX] >= 0 ) { if( PROCEEDING_WHITESPACE( tokstart ) && !TRAILING_WHITESPACE( *bufptr ) ) optype = OPTYPE_UNARY_PREFIX; else optype = OPTYPE_BINARY; } /* Resolve ambiguous prefix/postfix operators */ else if( op_ids[OPTYPE_UNARY_PREFIX] >= 0 && op_ids[OPTYPE_UNARY_POSTFIX] >= 0 ) { if( !PROCEEDING_WHITESPACE( tokstart ) ) optype = OPTYPE_UNARY_POSTFIX; else if( !TRAILING_WHITESPACE( *bufptr ) ) { STRING_OF_AMBIGUITY_CHECK( ambiguous ); if( ambiguous ) { COMERR_SET2( ERR_AMBIGUOUS_OPERATOR, *linenum, NextToken ); goto error_return; } optype = OPTYPE_UNARY_PREFIX; } else { COMERR_SET2( ERR_AMBIGUOUS_OPERATOR, *linenum, token ); goto error_return; } } /* Binary only */ else if( op_ids[OPTYPE_BINARY] >= 0 ) { optype = OPTYPE_BINARY; } /* Prefix only */ else if( op_ids[OPTYPE_UNARY_PREFIX] >= 0 ) { if( PROCEEDING_WHITESPACE( tokstart )) optype = OPTYPE_UNARY_PREFIX; else { COMERR_SET2( ERR_UNEXPECTED_OPERATOR, *linenum, symbol_pntr( *(int *)token ) ); goto error_return; } } /* Postfix only */ else if( op_ids[OPTYPE_UNARY_POSTFIX] >= 0 ) { optype = OPTYPE_UNARY_POSTFIX; } } /* If unary prefix, but no new expression expected, raise an error */ if( expecting == OPTYPE_BINARY && optype == OPTYPE_UNARY_PREFIX ) { if( UNEXPECTED_NEW_EXPRESSION ) { COMERR_SET2( ERR_UNEXPECTED_OPERATOR, *linenum, token ); goto error_return; } /* End of an argument */ /* Clear the stack back down to the paren */ if( TopOfParenStack >= 0 ) { ParenStack[ TopOfParenStack ].narg++; OPERSTK_FLUSH; } } /* Set up for next operator */ if( optype == OPTYPE_UNARY_PREFIX || optype == OPTYPE_BINARY ) expecting = OPTYPE_UNARY_PREFIX; else expecting = OPTYPE_BINARY; /* Take all operators off the stack of higher priority than this one */ while ( TopOfOperStack >= 0 && INSTACK_PRIORITY_HIGHER(opr_tbl_priority(op_ids[optype]))) { if (OperStack[TopOfOperStack].oper_type == OPERATOR) { OPERSTK_POP( temp_id ); PFOUT( TOK_COMMAND, opr_tbl_commid( temp_id ), (opr_tbl_optype( temp_id ) == OPTYPE_BINARY ? 2 : 1), 0, 1 ); } else { OPERSTK_POP( temp_id ); PFOUT( TOK_KEYWORD, temp_id, 1, 0, 0); } } /* Postfix operators do not go on stack */ if( opr_tbl_optype( op_ids[ optype ] ) == OPTYPE_UNARY_POSTFIX ) { PFOUT( TOK_COMMAND, opr_tbl_commid( op_ids[optype] ), 1, 0, 1 ); break; } /* Place this one on the stack */ OPERSTK_PUSH( op_ids[optype], OPERATOR ); break; /*-LITERALS-LITERALS-LITERALS-LITERALS-LITERALS-LITERALS-LITERALS-LITERALS-*/ default: /* Expecting a binary is either an error, or an indicator of */ /* separation between free format parameters */ if( expecting == OPTYPE_BINARY ) { if( !PROCEEDING_WHITESPACE( tokstart ) || UNEXPECTED_NEW_EXPRESSION ) { strncpy( token, buffer+tokstart, *bufptr-tokstart ); token[*bufptr-tokstart] = '\0'; COMERR_SET2( ERR_UNEXPECTED_LITERAL, *linenum, token); goto error_return; } /* End of an argument */ /* Clear the stack back down to the paren */ if( TopOfParenStack >= 0 ) { ParenStack[ TopOfParenStack ].narg++; OPERSTK_FLUSH; } } /* Output a literal */ PFOUT_LITERAL( toktype, token ); /* Setup for binary operator */ expecting = OPTYPE_BINARY; break; /*-IDENTIFIER-IDENTIFIER-IDENTIFIER-IDENTIFIER-IDENTIFIER-IDENTIFIER-*/ case TOK_IDENTIFIER: /* Expecting a binary is either an error, or an indicator of */ /* separation between free format parameters */ if( expecting == OPTYPE_BINARY ) { /* whitespace could bind things together here */ int whitespace_bound=0; if( !PROCEEDING_WHITESPACE( tokstart ) && !_detail_matched_delims || UNEXPECTED_NEW_EXPRESSION ) { if (UNEXPECTED_NEW_EXPRESSION && _whitespace_binding) { OPERSTK_PUSH( 0, OPERATOR); whitespace_bound=1; } else { COMERR_SET2( ERR_UNEXPECTED_IDENTIFIER, *linenum, symbol_pntr( *(int *)token ) ); goto error_return; } } /* End of an argument */ /* Clear the stack back down to the paren */ if( TopOfParenStack >= 0 && !whitespace_bound) { ParenStack[ TopOfParenStack ].narg++; OPERSTK_FLUSH; } } LOOK_AHEAD; if (0 && (NextToktype == TOK_OPERATOR) && (*NextToken == '.') /* && (NextToklen == 1)*/ ) { int i, ids[20]; int nids = 0; ids[nids++] = *(int *)token; while ( (NextToktype == TOK_OPERATOR) && (*NextToken == '.') ) { *bufptr = NextBufptr; *linenum = NextLinenum; NextToklen = 0; LOOK_AHEAD; if (NextToktype != TOK_IDENTIFIER) { printf("Error in parsing - expected an identifier\n"); printf("NextToktype: %d\n",NextToktype); return(FUNCBAD); } ids[nids++] = *(int *)NextToken; *bufptr = NextBufptr; *linenum = NextLinenum; NextToklen = 0; LOOK_AHEAD; } /* If next token is a left paren, this identifier is part of */ /* a command name, so save the command id on the paren stack */ /* which will trigger the counting of narg and nkey to begin. */ if( LEFT_PAREN( NextToktype )) { for (i = 0 ; i < nids; i++) { PARENSTK_PUSH( NextToktype, ids[i], nids ); } OPERSTK_PUSH ( -NextToktype, LEFTPAREN ); *bufptr = NextBufptr; *linenum = NextLinenum; NextToklen = 0; expecting = OPTYPE_UNARY_PREFIX; } else { for (i = nids ; i > 0; i--) PFOUT( TOK_COMMAND, ids[i-1], 0, 0, nids ); expecting = OPTYPE_BINARY; } } else { /* If next token is a left paren, this identifier is part of */ /* a command name, so save the command id on the paren stack */ /* which will trigger the counting of narg and nkey to begin. */ if( LEFT_PAREN( NextToktype )) { #if defined(DYNAMIC_COMMANDS) if ( TopOfOperStack >=0 && INSTACK_PRIORITY_HIGHER(1000)) { /* Take all operators off the stack with priority higher than 1000 */ while ( TopOfOperStack >= 0 && INSTACK_PRIORITY_HIGHER(1000)) { expecting = OPTYPE_BINARY; PFOUT( TOK_COMMAND, *(int *)token, 0, 0, 1 ); if (OperStack[TopOfOperStack].oper_type == OPERATOR) { OPERSTK_POP( temp_id ); PFOUT( TOK_COMMAND, opr_tbl_commid( temp_id ), (opr_tbl_optype( temp_id ) == OPTYPE_BINARY ? 2 : 1), 0, 1 ); } else { OPERSTK_POP( temp_id ); PFOUT( TOK_KEYWORD, temp_id, 1, 0, 0); } } } else { #endif PARENSTK_PUSH( NextToktype, *(int *)token, 1 ); OPERSTK_PUSH ( -NextToktype, LEFTPAREN ); *bufptr = NextBufptr; *linenum = NextLinenum; NextToklen = 0; expecting = OPTYPE_UNARY_PREFIX; #if defined(DYNAMIC_COMMANDS) } #endif } else { expecting = OPTYPE_BINARY; PFOUT( TOK_COMMAND, *(int *)token, 0, 0, 1 ); } } break; /*-KEYWORD-KEYWORD-KEYWORD-KEYWORD-KEYWORD-KEYWORD-KEYWORD-KEYWORD-KEYWORD-*/ case TOK_KEYWORD: /* Must be inside parenthesis associated with a command */ /* for a keyword to be legal */ if( TopOfParenStack < 0 || ParenStack[ TopOfParenStack ].comm_id < 0 ) { COMERR_SET2( ERR_UNEXPECTED_KEYWORD, *linenum, symbol_pntr( *(int *)token ) ); goto error_return; } /* Increment the number of keywords associated with this */ /* level of parens */ ParenStack[ TopOfParenStack ].nkey++; /* Its an error if anything is on the operator */ /* stack and a unary prefix was expected. */ if( OperStack[TopOfOperStack].oper_type == OPERATOR && expecting == OPTYPE_UNARY_PREFIX ) { COMERR_SET2( ERR_UNEXPECTED_KEYWORD, *linenum, symbol_pntr( *(int *) token ) ); goto error_return; } /* If a binary was expected, this means that a previous */ /* argument was underway. Increment number of arguments */ if( expecting == OPTYPE_BINARY ) { ParenStack[ TopOfParenStack ].narg++; OPERSTK_FLUSH; } /* If next token type is KEY or right_paren just output this keyword */ /* because it has no argument. Otherwise place this one on the stack */ /* Note that this means that a Keyword on the stack implies that it */ /* has an argument. */ LOOK_AHEAD; if ( (NextToktype == TOK_KEYWORD) || (RIGHT_PAREN(NextToktype))) { PFOUT( TOK_KEYWORD, *(int *)token, 0, 0, 0 ); } else { OPERSTK_PUSH( *(int *)token, KEYWORD ); } expecting = OPTYPE_UNARY_PREFIX; break; /*-LPAREN-LPAREN-LPAREN-LPAREN-LPAREN-LPAREN-LPAREN-LPAREN-LPAREN-LPAREN-*/ /*-LBRACKET-LBRACKET-LBRACKET-LBRACKET-LBRACKET-LBRACKET-LBRACKET-LBRACKET-*/ /*-LBRACE-LBRACE-LBRACE-LBRACE-LBRACE-LBRACE-LBRACE-LBRACE-LBRACE-LBRACE-*/ /*-LANGBRACK-LANGBRACK-LANGBRACK-LANGBRACK-LANGBRACK-LANGBRACK-LANGBRACK-*/ /*-LANGBRACK2-LANGBRACK2-LANGBRACK2-LANGBRACK2-LANGBRACK2-LANGBRACK2-LANGBRACK2-*/ case TOK_LPAREN: case TOK_LBRACKET: case TOK_LBRACE: case TOK_LANGBRACK: case TOK_LANGBRACK2: /* Expecting a binary is either an error, or an indicator of */ /* separation between free format parameters */ if( expecting == OPTYPE_BINARY ) { if( (!PROCEEDING_WHITESPACE( tokstart ) && !_detail_matched_delims) || UNEXPECTED_NEW_EXPRESSION ) { UNEXPECTED_LPAREN_ERROR( toktype ); } /* End of an argument */ if( TopOfParenStack >= 0) { ParenStack[ TopOfParenStack ].narg++; } } /* If left paren was encountered without a proceeding identifier */ /* it is not to be associated with a command. Push it on the */ /* paren stack with a -1 indicator for the command id to show such.*/ /* Push the negated value of the token type onto the operator */ /* stack, in order to distinguish it from the other operators. */ PARENSTK_PUSH( toktype, -1, 1 ); OPERSTK_PUSH( -toktype, LEFTPAREN ); /* Setup for unary prefix operator */ expecting = OPTYPE_UNARY_PREFIX; break; /*-RPAREN-RPAREN-RPAREN-RPAREN-RPAREN-RPAREN-RPAREN-RPAREN-RPAREN-RPAREN-*/ /*-RBRACKET-RBRACKET-RBRACKET-RBRACKET-RBRACKET-RBRACKET-RBRACKET-RBRACKET-*/ /*-RBRACE-RBRACE-RBRACE-RBRACE-RBRACE-RBRACE-RBRACE-RBRACE-RBRACE-RBRACE-*/ /*-RANGBRACK-RANGBRACK-RANGBRACK-RANGBRACK-RANGBRACK-RANGBRACK-RANGBRACK-*/ /*-RANGBRACK2-RANGBRACK2-RANGBRACK2-RANGBRACK2-RANGBRACK2-RANGBRACK2-RANGBRACK2-*/ case TOK_RPAREN: case TOK_RBRACKET: case TOK_RBRACE: case TOK_RANGBRACK: case TOK_RANGBRACK2: /* Parenthesis integrity checking */ if( TopOfParenStack < 0 || #if 0 ParenStack[TopOfParenStack].narg == 0 && ParenStack[TopOfParenStack].nkey == 0 && expecting == OPTYPE_UNARY_PREFIX || #endif toktype == TOK_RPAREN && ParenStack[TopOfParenStack].paren_type != TOK_LPAREN || toktype == TOK_RBRACKET && ParenStack[TopOfParenStack].paren_type != TOK_LBRACKET || toktype == TOK_RBRACE && ParenStack[TopOfParenStack].paren_type != TOK_LBRACE || toktype == TOK_RANGBRACK && ParenStack[TopOfParenStack].paren_type != TOK_LANGBRACK || toktype == TOK_RANGBRACK2 && ParenStack[TopOfParenStack].paren_type != TOK_LANGBRACK2 ) { if (!_empty_statement) { UNEXPECTED_RPAREN_ERROR(toktype); } else { if( TopOfParenStack >= 0) { ParenStack[ TopOfParenStack ].narg++; } if(empty_symid==-1) empty_symid=symbol_add("empty"); PFOUT( TOK_COMMAND, empty_symid, 0, 0, 0); } } /* Its an error if anything is on the operator stack, and a */ /* unary prefix was expected */ if( OperStack[TopOfOperStack].oper_type == OPERATOR && expecting == OPTYPE_UNARY_PREFIX ) { if (!_empty_statement) { UNEXPECTED_RPAREN_ERROR(toktype); } else { if( TopOfParenStack >= 0) { ParenStack[ TopOfParenStack ].narg++; } if(empty_symid==-1) empty_symid=symbol_add("empty"); PFOUT( TOK_COMMAND, empty_symid, 0, 0, 0); } } /* Take everything off of the operator stack until the matching */ /* parenthesis is found. */ while ( (OperStack[TopOfOperStack].oper_type != LEFTPAREN) && (TopOfOperStack >= 0 )) { if (OperStack[TopOfOperStack].oper_type == OPERATOR) { OPERSTK_POP( temp_id ); PFOUT( TOK_COMMAND, opr_tbl_commid( temp_id ), (opr_tbl_optype( temp_id ) == OPTYPE_BINARY ? 2 : 1), 0, 1 ); } else { OPERSTK_POP( temp_id ); PFOUT( TOK_KEYWORD, temp_id, 1, 0, 0); } } OPERSTK_POP( temp_id ); /* If this parenthesis corresponds to a command, set up the */ /* the number of embedded arguments and keywords, and output */ if( ParenStack[TopOfParenStack].comm_id >= 0 || _detail_matched_delims) { if( expecting == OPTYPE_BINARY) { /* End of an argument */ if( TopOfParenStack >= 0) { ParenStack[ TopOfParenStack ].narg++; } } if (ParenStack[TopOfParenStack].nids > 0) { int i, lp; lp = (ParenStack[TopOfParenStack].nids); for (i = 0; i < lp; i++) { if (!_detail_matched_delims) { PFOUT( TOK_COMMAND, ParenStack[TopOfParenStack].comm_id, ParenStack[TopOfParenStack].narg, ParenStack[TopOfParenStack].nkey, ParenStack[TopOfParenStack].nids ); } else { if (parens_symid==-1) { parens_symid = symbol_add("()"); parensplus_symid = symbol_add("+()"); brackets_symid = symbol_add("[]"); bracketsplus_symid = symbol_add("+[]"); braces_symid = symbol_add("{}"); bracesplus_symid = symbol_add("+{}"); angbracks_symid = symbol_add("<>"); angbracksplus_symid = symbol_add("+<>"); dblangbracks_symid = symbol_add("<<>>"); dblangbracksplus_symid = symbol_add("+<<>>"); } int commandid = ParenStack[TopOfParenStack].comm_id; if (commandid<0) { #ifdef PAREN_STACK_EXPERIMENT if (ParenStack[TopOfParenStack].pfnum==0 || TopOfParenStack>0 && ParenStack[TopOfParenStack-1].narg==0) { #else if (*pfnum==0 || TopOfParenStack>0 && ParenStack[TopOfParenStack-1].narg==0) { #endif if (toktype==TOK_RPAREN) commandid = parens_symid; else if (toktype==TOK_RBRACKET) commandid = brackets_symid; else if (toktype==TOK_RBRACE) commandid = braces_symid; else if (toktype==TOK_RANGBRACK) commandid = angbracks_symid; else commandid = dblangbracks_symid; } else { ParenStack[TopOfParenStack].narg++; // assume associated symbol (or stream) will be on stack #ifdef PAREN_STACK_EXPERIMENT if (TopOfParenStack>0) ParenStack[TopOfParenStack-1].narg--; #endif if (toktype==TOK_RPAREN) commandid = parensplus_symid; else if (toktype==TOK_RBRACKET) commandid = bracketsplus_symid; else if (toktype==TOK_RBRACE) { if(_no_bracesplus) { commandid = braces_symid; ParenStack[TopOfParenStack].narg--; if (TopOfParenStack>0) ParenStack[TopOfParenStack-1].narg++; } else commandid = bracesplus_symid; } else if (toktype==TOK_RANGBRACK) commandid = angbracksplus_symid; else commandid = dblangbracksplus_symid; } } PFOUT( TOK_COMMAND, commandid, ParenStack[TopOfParenStack].narg, ParenStack[TopOfParenStack].nkey, toktype ); } --TopOfParenStack; } } else { PFOUT( TOK_COMMAND, ParenStack[TopOfParenStack].comm_id, ParenStack[TopOfParenStack].narg, ParenStack[TopOfParenStack].nkey, 1); --TopOfParenStack; } } else { PFOUT_LITERAL( TOK_BLANK, token ); --TopOfParenStack; #if 0 if (TopOfParenStack>=0) { ParenStack[TopOfParenStack].narg++; } #endif } /* Set up to expect a binary */ expecting = OPTYPE_BINARY; break; /*-EOF-EOF-EOF-EOF-EOF-EOF-EOF-EOF-EOF-EOF-EOF-EOF-EOF-EOF-EOF-EOF-EOF-EOF-*/ case TOK_EOF: PFOUT( TOK_EOF, 0, 0, 0, 0); if( TopOfParenStack >= 0 ) { COMERR_SET1( ERR_UNEXPECTED_EOF, *linenum ); goto error_return; } done = TRUE; break; /*-NONE-NONE-NONE-NONE-NONE-NONE-NONE-NONE-NONE-NONE-NONE-NONE-NONE-NONE-*/ case TOK_NONE: done = TRUE; break; } /* End of switch on token type */ /* --------------------------------------*/ /* Make determination if expression is finished. This happens under the */ /* following conditions: */ /* 1) All nested parenthesis are closed */ /* 2) A binary operator is expected next */ /* 3) The next token on the current line of input is separated by */ /* whitespace from the current token. */ /* 4) If the next token is an operator, it is not a binary operator */ /* 5) If _sticky_matched_delims is true, and the next token is not an */ /* operator, then it can't be a matching delimeter. */ if( !done && TopOfParenStack < 0 && expecting == OPTYPE_BINARY ) { if( NextToklen == 0 ) LOOK_AHEAD; if( NextToktype == TOK_KEYWORD ) { COMERR_SET2( ERR_UNEXPECTED_KEYWORD, *linenum, symbol_pntr( *(int *)NextToken )); goto error_return; } if( RIGHT_PAREN( NextToktype )) UNEXPECTED_RPAREN_ERROR( NextToktype ); if( NextToktype == TOK_EOF ) done = TRUE; if( (!_sticky_matched_delims || !LEFT_PAREN( NextToktype)) && PROCEEDING_WHITESPACE( NextTokstart ) ) if( NextToktype != TOK_OPERATOR ) done = TRUE; else if( NextOp_ids[OPTYPE_UNARY_PREFIX] >= 0 ) if( NextOp_ids[OPTYPE_BINARY ] >= 0 || NextOp_ids[OPTYPE_UNARY_POSTFIX ] ) { /* If no trailing whitespace, then the current expression */ /* is done. However, it is an error if no trailing */ /* whitespace is in itself caused by a string of ambiguous*/ /* operators concatenated together */ if( !TRAILING_WHITESPACE( NextBufptr ) ) { STRING_OF_AMBIGUITY_CHECK( ambiguous ); if( ambiguous ) { COMERR_SET2( ERR_AMBIGUOUS_OPERATOR, *linenum, NextToken ); goto error_return; } done = TRUE; } } else done = TRUE; } } while( !done ); _continuation_prompt = 0; /* ----------------------------------------------------------------------- */ /* Done looping until an expression is finished */ /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ /* Raise exception if expression is incomplete */ if (toktype == TOK_NONE) { if ((void*)infunc != (void*)_oneshot_infunc) { COMERR_SET( ERR_INCOMPLETE_EXPRESSION ); goto error_return; } else { goto ok_return; } } /* Put what remains on the operator stack onto the output */ EMPTY_OPER_STACK; ok_return: return FUNCOK; error_return: NextToklen = 0; while( buffer[*bufptr] != '\0' ) ++*bufptr; _continuation_prompt = 0; EMPTY_OPER_STACK; TopOfParenStack = -1; return FUNCBAD; } int print_pfbuf( postfix_token *pfbuf, int index ) { int counter; fprintf(stdout,"%d: ",index); switch( pfbuf[index].type ) { case TOK_KEYWORD: fprintf( stdout, "KEYWORD (%s) narg: %d\n", symbol_pntr( pfbuf[index].v.symbolid), pfbuf[index].narg); break; case TOK_COMMAND: counter = fprintf( stdout, "COMMAND (%s", symbol_pntr( pfbuf[index].v.symbolid )); while( ++counter < 32 ) putc( ' ', stdout ); fprintf( stdout, ") narg %d nkey %d nids: %d\n", pfbuf[index].narg, pfbuf[index].nkey, pfbuf[index].nids ); break; case TOK_STRING: fprintf( stdout, "STRING (%s)\n", symbol_pntr( pfbuf[index].v.symbolid )); break; case TOK_CHAR: fprintf( stdout, "CHAR (%c:%d)\n", pfbuf[index].v.char_val, pfbuf[index].v.char_val ); break; case TOK_DFINT: fprintf( stdout, "DFINT (" ); print_type( stdout, DFINTPAR, (char *)&pfbuf[index].v.dfintval, 0 ); fprintf( stdout, ")\n" ); break; case TOK_DFUNS: fprintf( stdout, "DFUNS (" ); print_type( stdout, DFUNSPAR, (char *)&pfbuf[index].v.dfunsval, 0 ); fprintf( stdout, ")\n" ); break; case TOK_LNINT: fprintf( stdout, "LNINT (" ); print_type( stdout, LNINTPAR, (char *)&pfbuf[index].v.lnintval, 0 ); fprintf( stdout, ")\n" ); break; case TOK_LNUNS: fprintf( stdout, "LNUNS (" ); print_type( stdout, LNUNSPAR, (char *)&pfbuf[index].v.lnunsval, 0 ); fprintf( stdout, ")\n" ); break; case TOK_DOUBLE: fprintf( stdout, "DOUBLE (" ); print_type( stdout, DOUBLPAR, (char *)&pfbuf[index].v.doublval, 0 ); fprintf( stdout, ")\n" ); break; case TOK_EOF: fprintf( stdout, "EOF\n" ); break; case TOK_BLANK: fprintf( stdout, "BLANK\n" ); break; default: break; } fflush( stdout ); return(0); } ivtools-1.2.11a1/src/ComUtil/_scanner.cc000066400000000000000000000240511214471147700177710ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* scanner.c COMTERP scanning routine Externals: int scanner() Summary: Scanning routine(s) developed to do the low-level scanning of textual input for the COMTERP language. History: Written by Scott E. Johnston, March 1989 */ #include #include #include #include #include "comterp.ci" int _angle_brackets = 0; /*! scanner Return next token from COMTERP input text stream Summary: #include */ int scanner(void * infile,char * (*infunc)(char*, int, void*),int (*eoffunc)(void*), int (*errfunc)(void*),FILE * outfile,int (*outfunc)(const char*, void*), char * buffer,unsigned bufsiz,unsigned * bufptr, char * token,unsigned toksiz,unsigned * toklen, unsigned * toktype,unsigned * tokstart,unsigned * linenum) /*! Return Value: 0 if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void * infile ;/* I Pointer to input text source. Typically a `FILE *`. */ char * (*infunc)() ;/* I Function for reading input text source (typically `fgets`). */ int (*eoffunc)();/* I Function for checking end-of-file condition (typically `ffeof`). */ int (*errfunc)();/* I Function for checking for error on file I/O (typically `fferror`). */ FILE * outfile ;/* I Output file pointer for source listing (disabled with a NULL). */ int (*outfunc)();/* I Function for writing output text (typically `fputs`). */ char * buffer ;/* I Buffer or file I/O. */ unsigned bufsiz ;/* I Size of `buffer` in bytes. */ unsigned * bufptr ;/* O Current location in `buffer`.*/ char * token ;/* O Token string. */ unsigned toksiz ;/* I Maximum possible token size. */ unsigned * toklen ;/* O Actual token size. */ unsigned * toktype ;/* O Token type. */ unsigned * tokstart ;/* O Starting offset of token in `buffer`. */ unsigned * linenum ;/* IO Current line number of input file (initialize by setting to zero). */ #endif /*! Description: `scanner` scans the input file (pointed to by `infile`) until it completes a token and returns its value. The possible token types are as follows (defined in "comterp/comterp.h"): TOK_NONE No token found (error occurred) TOK_LPAREN Left parenthesis TOK_RPAREN Right parenthesis TOK_LBRACKET Left bracket TOK_RBRACKET Right bracket TOK_LBRACE Left brace TOK_RBRACE Right brace TOK_LANGBRACK Left angle bracket TOK_RANGBRACK Right angle bracket TOK_KEYWORD Keyword for free format parameters, i.e. ":SIZE" TOK_IDENTIFIER Identifier, i.e. command name TOK_OPERATOR Operator TOK_STRING Character string constant TOK_CHAR Character constant TOK_DFINT Default integer, i.e. of type "int" TOK_DFUNS Default unsigned integer, i.e. of type "unsigned" TOK_LNINT Long integer, i.e. of type "long" TOK_LNUNS Long unsigned integer, i.e. of type "long unsigned" TOK_DOUBLE Double-size floating point number, i.e. of type "double" TOK_EOF End of file `infunc`, `eoffunc`, and `errfunc` are a set of functions that allow `scanner` to access new lines of text as required. If `infunc` is `NULL`, scanning is done on the contents of `buffer` only. In this case the contents of `buffer` must terminate with a '\n'. See Also: lexscan !*/ { /* Constants for state machine to search for format string */ #define LOOK_START 0 /* Looking for start of comment or keyword */ #define LOOK_KEYWORD 1 /* Looking for keyword body */ #define LOOK_DONE 2 /* No more looking */ int search_state = LOOK_START; /* State of what has been found */ /* in error file */ int status; /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */ /* Loop through tokens and return one at a time */ /* ----------------------------------------------------------------------- */ do { /* Use lexical scanner to provide next token in input file */ /* Don't worry about status return, because token_type */ /* will be set to TOK_NONE */ status = lexscan( infile, infunc, eoffunc, errfunc, outfile, outfunc, "/*", "*/", '#', "//", buffer, bufsiz, bufptr, token, toksiz, toklen, toktype, tokstart, linenum ); if( status != 0 ) goto end; /* State machine that searches for the right format string */ switch ( search_state ) { case LOOK_START: if( *toktype != TOK_OPERATOR ) search_state = LOOK_DONE; else switch( token[0] ) { case '(' : *toktype = TOK_LPAREN; search_state = LOOK_DONE; break; case ')' : *toktype = TOK_RPAREN; search_state = LOOK_DONE; break; case '[' : *toktype = TOK_LBRACKET; search_state = LOOK_DONE; break; case ']' : *toktype = TOK_RBRACKET; search_state = LOOK_DONE; break; case '{' : *toktype = TOK_LBRACE; search_state = LOOK_DONE; break; case '}' : *toktype = TOK_RBRACE; search_state = LOOK_DONE; break; case '<' : if (_angle_brackets) { if (buffer[*bufptr]=='<') { (*bufptr)++; *toktype = TOK_LANGBRACK2; } else *toktype = TOK_LANGBRACK; } search_state = LOOK_DONE; break; case '>' : if (_angle_brackets) { if (buffer[*bufptr]=='>') { (*bufptr)++; *toktype = TOK_RANGBRACK2; } else *toktype = TOK_RANGBRACK; } search_state = LOOK_DONE; break; case ':' : if( isident( buffer[*bufptr] )) search_state = LOOK_KEYWORD; else search_state = LOOK_DONE; break; default: search_state = LOOK_DONE; break; } break; case LOOK_KEYWORD: if( *toktype == TOK_IDENTIFIER ) { *toktype = TOK_KEYWORD; search_state = LOOK_DONE; } else { status = ERR_BADKEYWORD; goto end; } break; } } while( search_state != LOOK_DONE ); /* ----------------------------------------------------------------------- */ /* Done looping until next token is finished */ /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ return FUNCOK; /* ----------------------------------------------------------------------- */ /* Handle error if one occurred and return */ /* ----------------------------------------------------------------------- */ end: switch ( status ) { case ERR_EOFCOMMENT: case ERR_EOFSTRING: case ERR_BADKEYWORD: case ERR_BADCHAR: case ERR_NOTOCTDIGIT: case ERR_NOTHEXDIGIT: case ERR_BADOCTCHAR: case ERR_BADHEXCHAR: case ERR_BADINT: case ERR_BADOCT: case ERR_BADHEX: case ERR_BADFLOAT: case ERR_TOOBIGINT: case ERR_TOOBIGOCT: case ERR_TOOBIGHEX: case ERR_TOOBIGFLOAT: case ERR_TOOSMLFLOAT: case ERR_NLINSTRING: case ERR_NLINCHAR: case ERR_CONSTSEP: case ERR_OUTFILE: case ERR_INFILE: case ERR_EOFNEWLINE: COMERR_SET1( status, *linenum ); break; case ERR_LINELENGTH: COMERR_SET2( status, *linenum, bufsiz-2 ); break; case ERR_TOKENLENGTH: COMERR_SET2( status, *linenum, toksiz-1 ); break; case ERR_ILLEGALCHAR: COMERR_SET2( status, *linenum, buffer[*tokstart] ); break; default: break; } return FUNCBAD; } ivtools-1.2.11a1/src/ComUtil/atox.cc000066400000000000000000000074561214471147700171660ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representation about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* atox.c Routines to convert hex and octal strings to internal numbers Externals: unsigned long atox(), unsigned long atoo() History: Written by Scott E. Johnston, March 1989 */ #include #include #include #include #include "comutil.ci" /*! atox Convert character string of hexadecimal digits to an unsigned long Summary: #include */ unsigned long atox(char * string ) /*! Return Value: returns the unsigned long value Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC char * string ;/* I String to be converted. */ #endif /*! Description: `atox` converts a character string of hexadecimal digits to an unsigned long value. Conversion is limited to the number of hexadecimal digits supported by an unsigned long, and is terminated if a non-hexadecimal digit is encountered. No indication of either condition is given, because `atox` is designed for use in situations where the extent and content of the hexadecimal string has already been verified. !*/ { int string_length; unsigned long value = 0; int index; string_length = MIN( sizeof(unsigned long) * 2, strlen( string )); for( index=0; index */ unsigned long atoo( char * string ) /*! Return Value: returns the unsigned long value  Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC char * string ;/* I String to be converted. */ #endif /*! Description: `atoo` converts a character string of octal digits to an unsigned long value. Conversion is limited to the number of octal digits supported by an unsigned long, and is terminated if a non-octal digit is encountered. No indication of either condition is given, because `atoo` is designed for use in situations where the extent and content of the octal string has already been verified. !*/ { int string_length; unsigned long value = 0; int index; string_length = MIN( sizeof(unsigned long) * 8 / 3, strlen( string )); for( index=0; index #include "comutil.ci" /* Local Statics */ static int ErrorId = -1; /*! comerr_read Read error format string from COMTERP error file Summary: #include */ const char * comerr_read( unsigned errnum ) /*! Return Value: Pointer to format string Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned errnum ;/* I Number of error message to search for. */ #endif /*! Description: `comerr_read` reads a format string from the COMTERP error file, which can be used to build an error message using `sprintf`. See Also: comerr_set, comerr_get, comerr_chk, err_read !*/ #undef TITLE #define TITLE "comerr_read" { /* Initialize if necessary */ if( ErrorId == -1 ) ErrorId = err_open( "comterp.err" ); /* Retrieve string */ return err_read( ErrorId, errnum ); } /*! comerr_set Submit COMTERP error to error system Summary: #include */ void comerr_set( unsigned errnum, unsigned errlen ) /*! Return Value: none Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned errnum ;/* I Number of error message being submitted. */ unsigned errlen ;/* I Length of error message string just printed via `fprintf` to file pointer returned from `err_fileio`. */ #endif /*! Description: `comerr_set` submits an COMTERP error to the error system. `errnum` is the error number associated with the error. `errlen` is the length of the error message that was just printed via `fprintf` to the file pointer returned by `err_fileio`. See Also: comerr_read, comerr_get, comerr_chk, err_set !*/ #undef TITLE #define TITLE "comerr_set" { /* Initialize if necessary */ if( ErrorId == -1 ) ErrorId = err_open( "comterp.err" ); /* Retrieve string */ return err_set( ErrorId, errnum, errlen ); } /*! comerr_get Get last error if from COMTERP Summary: #include */ int comerr_get() /*! Return Value: error number if last error was from COMTERP, otherwise 0 Parameters: none /*! Description: `comerr_get` returns the number of the most recent error to be submitted to the error system, if it was from COMTERP. See Also: comerr_read, comerr_set, comerr_chk, err_get !*/ #undef TITLE #define TITLE "comerr_get" { unsigned int get_errnum; int get_errid; /* If non-initialized, answer must be 0 */ if( ErrorId == -1 ) return 0; /* Retrieve error number */ err_get( &get_errid, &get_errnum ); if( get_errid != ErrorId ) return 0; else return get_errnum; } /*! comerr_chk Check if specific COMTERP error just occurred Summary: #include */ BOOLEAN comerr_chk( unsigned errnum ) /*! Return Value: `TRUE` if last error was from COMTERP, and equal to `errnum`, otherwise `FALSE` Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned errnum ;/* I Error number to check for */ #endif /*! Description: `comerr_chk` checks if a specific COMTERP error just occurred, meaning that it would be the topmost error within the error system. See Also: comerr_read, comerr_set, comerr_get, err_get !*/ #undef TITLE #define TITLE "comerr_chk" { unsigned int get_errnum; int get_errid; /* If non-initialized, answer must be FALSE */ if( ErrorId == -1 ) return FALSE; /* Retrieve error number */ err_get( &get_errid, &get_errnum ); if( get_errid != ErrorId ) return FALSE; else if( get_errnum == errnum ) return TRUE; else return FALSE; } ivtools-1.2.11a1/src/ComUtil/comterp.arg000066400000000000000000000046421214471147700200420ustar00rootroot00000000000000/* DSPCOM function prototypes */ /* SCANNER.C */ #ifdef __cplusplus int scanner(void *infile,char *(*infunc)(char*,int,void*), int (*eoffunc)(void*),int (*errfunc)(void*), FILE *outfile,int (*outfunc)(const char*,void*), char *buffer,unsigned bufsiz, unsigned *bufptr,char *token,unsigned toksiz,unsigned *toklen, unsigned *toktype,unsigned *tokstart,unsigned *linenum ); #else int scanner(void *infile,char *(*infunc)(),int (*eoffunc)(),int (*errfunc)(), FILE *outfile,int (*outfunc)(),char *buffer,unsigned bufsiz, unsigned *bufptr,char *token,unsigned toksiz,unsigned *toklen, unsigned *toktype,unsigned *tokstart,unsigned *linenum ); #endif /* OPTABLE.C */ int opr_tbl_create(unsigned maxop); int opr_tbl_insert(const char *opstr,const char *command,unsigned priority,BOOLEAN rtol, unsigned optype); int opr_tbl_print(FILE *outfile,unsigned by); int opr_tbl_entries(char *opstr,int *op_ids,unsigned nop_ids,unsigned *nchars); int opr_tbl_operid(unsigned opnum); int opr_tbl_commid(unsigned opnum); int opr_tbl_priority(unsigned opnum); int opr_tbl_rtol(unsigned opnum); int opr_tbl_optype(unsigned opnum); unsigned opr_tbl_maxprior(); int opr_tbl_default(); int opr_tbl_opstr(unsigned commid); int opr_tbl_topstr(); void* opr_tbl_ptr_get(); void opr_tbl_ptr_set(void* ptr); unsigned opr_tbl_numop_get(); void opr_tbl_numop_set(unsigned numop); unsigned opr_tbl_maxop_get(); void opr_tbl_maxop_set(unsigned maxop); unsigned opr_tbl_maxpri_get(); void opr_tbl_maxpri_set(unsigned maxpri); int opr_tbl_lastop_get(); void opr_tbl_lastop_set(int lastop); /* PARSER.C */ #ifdef __cplusplus int parser(void *infile,char *(*infunc)(char*,int,void*), int (*eoffunc)(void*),int (*errfunc)(void*), FILE *outfile,int (*outfunc)(const char*,void*), char *buffer,unsigned bufsiz, unsigned *bufptr,char *token,unsigned toksiz,unsigned *linenum, postfix_token **pfbuf,unsigned *pfsiz,unsigned *pfnum); #else int parser(void *infile,char *(*infunc)(),int (*eoffunc)(),int (*errfunc)(), FILE *outfile,int (*outfunc)(),char *buffer,unsigned bufsiz, unsigned *bufptr,char *token,unsigned toksiz,unsigned *linenum, postfix_token **pfbuf,unsigned *pfsiz,unsigned *pfnum); #endif int print_pfbuf(postfix_token *pfbuf,int index); /* TYPES.C */ int type_add(int nids,int *idlist); int type_symid(int forwhat); int type_typeid(int forwhat); int type_find(int nids,int *idlist); int type_get(int which, int id); ivtools-1.2.11a1/src/ComUtil/comterp.ci000066400000000000000000000024431214471147700176610ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representation about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* External include file */ #include /* Internal includes */ ivtools-1.2.11a1/src/ComUtil/comterp.err000066400000000000000000000122241214471147700200540ustar00rootroot00000000000000/* COMTERP Error Messages */ #define ERROR_FILE "comterp.err" #define ERR_MEMORY 1000 /* "Memory limits exceeded" */ #define ERR_LINELENGTH 1100 /* "(%d) Line greater than %d characters long" */ #define ERR_TOKENLENGTH 1101 /* "(%d) Token longer than maximum length of %d" */ #define ERR_EOFCOMMENT 1102 /* "(%d) End of file encountered within comment" */ #define ERR_EOFSTRING 1103 /* "(%d) End of file encountered within string or character constant" */ #define ERR_BADKEYWORD 1104 /* "(%d) Illegal keyword" */ #define ERR_BADCHAR 1105 /* "(%d) Illegal character constant" */ #define ERR_NOTOCTDIGIT 1106 /* "(%d) Non-octal digit in octal character constant" */ #define ERR_NOTHEXDIGIT 1107 /* "(%d) Hexadecimal digit must follow \\x" */ #define ERR_BADOCTCHAR 1108 /* "(%d) Octal character constant larger than one byte" */ #define ERR_BADHEXCHAR 1109 /* "(%d) Hexadecimal character constant larger than one byte" */ #define ERR_BADINT 1110 /* "(%d) Illegal integer constant" */ #define ERR_BADOCT 1111 /* "(%d) Illegal octal constant" */ #define ERR_BADHEX 1112 /* "(%d) Illegal hexadecimal constant" */ #define ERR_BADFLOAT 1113 /* "(%d) Illegal floating-point constant" */ #define ERR_TOOBIGINT 1114 /* "(%d) Integer constant exceeds maximum possible size" */ #define ERR_TOOBIGOCT 1115 /* "(%d) Octal constant exceeds maximum possible size" */ #define ERR_TOOBIGHEX 1116 /* "(%d) Hexadecimal constant exceeds maximum possible size" */ #define ERR_TOOBIGFLOAT 1117 /* "(%d) Floating point constant exceeds maximum possible size" */ #define ERR_TOOSMLFLOAT 1118 /* "(%d) Floating point constant exceeds minimum possible size" */ #define ERR_ILLEGALCHAR 1119 /* "(%d) Illegal character (ASCII %d)" */ #define ERR_NLINSTRING 1120 /* "(%d) Unexpected newline in string constant" */ #define ERR_NLINCHAR 1121 /* "(%d) Unexpected newline in character constant" */ #define ERR_CONSTSEP 1122 /* "(%d) Insufficient separation from trailing constant" */ #define ERR_OUTFILE 1123 /* "(%d) Error in writing to output file" */ #define ERR_INFILE 1124 /* "(%d) Error in reading input file" */ #define ERR_EOFNEWLINE 1125 /* "(%d) New-line expected before end-of-file" */ #define ERR_ILLEGALOP 1200 /* "Illegal operator (%c)" */ #define ERR_OPRTBLMAXED 1201 /* "Maximum number of operators exceeded (%d)" */ #define ERR_NO_POSTFIX 1202 /* "Postfix version of %s can't coexist with binary and prefix versions" */ #define ERR_NO_BINARY 1203 /* "Binary version of %s can't coexist with both unary versions" */ #define ERR_NO_POSTFIX_WITH_BINARY 1204 /* "Postfix version of %s can't coexist with binary version" */ #define ERR_NO_BINARY_WITH_POSTFIX 1205 /* "Binary version of %s can't coexist with postfix version" */ #define ERR_NO_OPTABLE 1206 /* "Operator table has not been created" */ #define ERR_PRIORITY_RANGE 1207 /* "Priority (%d) out of range" */ #define ERR_UNEXPECTED_OPERATOR 1300 /* "(%d) Unexpected operator (%s)" */ #define ERR_UNEXPECTED_IDENTIFIER 1301 /* "(%d) Unexpected identifier (%s)" */ #define ERR_UNEXPECTED_LITERAL 1302 /* "(%d) Unexpected literal constant (%s)" */ #define ERR_UNEXPECTED_KEYWORD 1303 /* "(%d) Unexpected keyword (%s)" */ #define ERR_UNEXPECTED_EOF 1304 /* "(%d) Unexpected end-of-file" */ #define ERR_UNEXPECTED_RPAREN 1305 /* "(%d) Unexpected right parenthesis" */ #define ERR_UNEXPECTED_RBRACKET 1306 /* "(%d) Unexpected right bracket" */ #define ERR_UNEXPECTED_RBRACE 1307 /* "(%d) Unexpected right brace" */ #define ERR_AMBIGUOUS_OPERATOR 1308 /* "(%d) Ambiguous operator (%s)" */ #define ERR_UNEXPECTED_LPAREN 1309 /* "(%d) Unexpected left parenthesis" */ #define ERR_UNEXPECTED_LBRACKET 1310 /* "(%d) Unexpected left bracket" */ #define ERR_UNEXPECTED_LBRACE 1311 /* "(%d) Unexpected left brace" */ #define ERR_UNEXPECTED_RANGBRACK 1312 /* "(%d) Unexpected right angle bracket" */ #define ERR_UNEXPECTED_LANGBRACK 1313 /* "(%d) Unexpected left angle bracket" */ #define ERR_UNEXPECTED_RANGBRACK2 1314 /* "(%d) Unexpected double right angle bracket" */ #define ERR_UNEXPECTED_LANGBRACK2 1315 /* "(%d) Unexpected double left angle bracket" */ #define ERR_TYPE_BADPARAMS 5201 /* "Bad parameters in function call" */ #define ERR_TYPE_SYMIDBAD 5202 /* "Illegal symbol identifier in type list" */ #define ERR_TYPE_BADSIMPLE 5203 /* "Illegal simple type in type identifier list" */ #define ERR_TYPE_BADAGGREGATE 5204 /* "Illegal aggregate type; must be ARRAY or STREAM only" */ #define ERR_TYPE_TYPEIDBAD 5205 /* "Type identifier is outside table limits" */ #define ERR_TYPE_TYPEIDEMPTY 5206 /* "Type identifier is for an empty table entry" */ #define ERR_TXTUT_FNOTOPEN 6000 /* "Attempted read/write before file open" */ #define ERR_TXTUT_DELIM 6001 /* "Input string begins with internal delimeter: .!#ID#" */ #define ERR_TXTUT_FOPEN 6002 /* "Error during file open" */ #define ERR_UNKNOWN_COMMAND 3000 /* "Unknown command supplied to interpreter: %s" */ #define ERR_DIV_BY_ZERO 3001 /* "Divide by zero" */ #define ERR_INCOMPLETE_EXPRESSION 3002 /* "Incomplete expression" */ #define ERR_MOD_BY_ZERO 3003 /* "Mod by zero" */ ivtools-1.2.11a1/src/ComUtil/comterp.h000066400000000000000000000123771214471147700175240ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representation about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef COMTERP_INCLUDED #define COMTERP_INCLUDED #include /* ** GLOBAL debug flag */ extern int com_debug; /* C Function macros for COMTERP */ #define COMCFUNC(name) name(flag, argc, argv) int flag,argc; void *argv[]; #define IOPNTR(comtype) ((comtype *)argv[0]) /* Token types returned from SCANNER.C */ #define TOK_LPAREN 17 /* Left parenthesis */ #define TOK_RPAREN 18 /* Right parenthesis */ #define TOK_LBRACKET 19 /* Left bracket */ #define TOK_RBRACKET 20 /* Right bracket */ #define TOK_LBRACE 21 /* Left brace */ #define TOK_RBRACE 22 /* Right brace */ #define TOK_LANGBRACK 23 /* left angle bracket (less than) */ #define TOK_RANGBRACK 24 /* right angle bracket (greater than) */ #define TOK_LANGBRACK2 25 /* double left angle bracket */ #define TOK_RANGBRACK2 26 /* double right angle bracket */ #define TOK_KEYWORD 27 /* Keyword for free format parameters */ /* Token types returned from OPTABLE.C */ #define TOK_COMMAND 28 /* Command name */ #define TOK_BLANK 29 /* generated by empty parens: () */ /* OPTABLE.C Constants */ /* Kind of operator in operator table */ #define OPTYPE_BINARY 0 #define OPTYPE_UNARY_PREFIX 1 #define OPTYPE_UNARY_POSTFIX 2 #define OPTYPE_NUM 3 /* Ways to print operator table */ #define OPBY_PRIORITY 0 #define OPBY_OPERATOR 1 #define OPBY_COMMAND 2 /* TYPES.C Constants/Enums */ /* simple type strings */ #define TYPE_STRING_CHAR "CHAR" #define TYPE_STRING_SHORT "SHORT" #define TYPE_STRING_INT "INT" #define TYPE_STRING_LONG "LONG" #define TYPE_STRING_UCHAR "UCHAR" #define TYPE_STRING_USHORT "USHORT" #define TYPE_STRING_UINT "UINT" #define TYPE_STRING_ULONG "ULONG" #define TYPE_STRING_FLOAT "FLOAT" #define TYPE_STRING_DOUBLE "DOUBLE" #define TYPE_STRING_BOOLEAN "BOOLEAN" #define TYPE_STRING_SYMBOL "SYMBOL" #define TYPE_STRING_ENUM "ENUM" /* aggregate type strings */ #define TYPE_STRING_ARRAY "ARRAY" #define TYPE_STRING_STREAM "STREAM" /* simple type flag identifiers */ #define TYPE_CHAR 0 #define TYPE_SHORT 1 #define TYPE_INT 2 #define TYPE_LONG 3 #define TYPE_UCHAR 4 #define TYPE_USHORT 5 #define TYPE_UINT 6 #define TYPE_ULONG 7 #define TYPE_FLOAT 8 #define TYPE_DOUBLE 9 #define TYPE_BOOLEAN 10 #define TYPE_SYMBOL 11 #define TYPE_ENUM 12 /* Number of simple types: UPDATE IF YOU ADD OR REMOVE ANY */ #define TYPE_NUM_SIMPLES 13 /* aggregate type strings */ #define TYPE_ARRAY 100 #define TYPE_STREAM 101 /* other type defines */ #define TYPE_FIRST 1 #define TYPE_NEXT 2 /* Reference Parameter Structure */ typedef struct { void (*comfunc)(); void *valptr; } REFPARAM; /* Union for data storage */ typedef union data_value_union { int dfintval; unsigned int dfunsval; long lnintval; unsigned long lnunsval; double doublval; char char_val; int symbolid; void * ptrval; } data_value; /* Structure for token in postfix expression */ typedef struct postfix_token_struct { data_value v; /* Location to store data value */ unsigned type; /* Token type */ int narg; /* Number of arguments to command */ int nkey; /* Number of keywords to command */ int nids; /* Number of ids in compound command name */ } postfix_token; #define PAREN_STACK_EXPERIMENT /* Structure of stack to count command arguments and keywords */ typedef struct _paren_stack paren_stack; struct _paren_stack { unsigned nids; unsigned narg; unsigned nkey; unsigned paren_type; int comm_id; #ifdef PAREN_STACK_EXPERIMENT int pfnum; // to keep track of postfix output prior this paren pushed on stack #endif }; /* Structure of stack to store operators and keywords */ typedef struct _oper_stack oper_stack; struct _oper_stack { int id; int oper_type; }; /* Package function prototypes */ #if !defined(OSK) #include #endif #endif /* not COMTERP_INCLUDED */ ivtools-1.2.11a1/src/ComUtil/comutil.arg000066400000000000000000000067171214471147700200520ustar00rootroot00000000000000#include /* NUTIL function prototypes */ /* MBLOCK.C */ int mblock_open(unsigned nel,unsigned size); int mblock_close(int id); int mblock_resize(int id,unsigned nel); void *mblock_pntr(int id); int mblock_sizes(int id,unsigned *nel,unsigned *size,unsigned long *nbytes); /* SYMBOLS.C */ int symbol_add(const char *string); int symbol_find(const char *string); int symbol_del (int id); int symbol_reference (int id); int symbol_len (int id); const char *symbol_pntr(int id); int symbol_instances(int id); int symbol_max(); int symbol_refcount(int id); /* DMM.C */ int dmm_mblock_alloc(unsigned long nbytes); int dmm_mblock_free(void); int dmm_mblock_pack(int ipackflag); int dmm_mblock_stats(void * *mpntr,unsigned long *total,unsigned long *used,unsigned long *free,unsigned long *system); int dmm_malloc(void * *pntr,unsigned long nrecs,unsigned int nsize); int dmm_calloc(void * *pntr,unsigned long nrecs,unsigned int nsize); int dmm_realloc(void * *pntr,unsigned long nrecs); int dmm_realloc_size(int); int dmm_free(void * *pntr); int dmm_clear(void * *pntr); int dmm_pntr(int ptype,void * *pntr,unsigned long nrecs,unsigned int nsize,int (*cond)()); int dmm_free_pntr(void * *pntr); int dmm_ichk(void); int dmm_walk(dmmwalk *ret); int dmm_movrecs(void **pntr,unsigned long dstrec,unsigned long srcrec,unsigned long nrecs); /* XDLL.C */ int xdll_open(void *beg,int nlinks,int nsize); int xdll_reopen(int newflag,void *beg,int nlinks,int newhead); int xdll_use(int id); int xdll_in_use(void); int xdll_close(int allflag); void *xdll_curr(void); void *xdll_head(void); void *xdll_next(void); void *xdll_prev(void); void *xdll_tail(void); void *xdll_insert(int before); int xdll_delete(int flag); void *xdll_goto(void *pos); int xdll_clear(int flag,void (*userfunc)()); int xdll_links_left(void); int xdll_links_num(void); /* ATOX.C */ unsigned long atox(char *string); unsigned long atoo(char *string); /* FUNCPTRS.C */ extern "C" { int ffeof(FILE *stream); int fferror(FILE *stream); } /* LEXSCAN.C */ int lexscan(void *infile,char *(*infunc)(char*,int,void*), int (*eoffunc)(void*),int (*errfunc)(void*), void *outfile,int (*outfunc)(const char*,void*), const char *begcmt,const char *endcmt,char linecmtchr,const char* linecmtstr, char *buffer,unsigned bufsiz,unsigned *bufptr,char *token, unsigned toksiz,unsigned *toklen,unsigned *toktype, unsigned *tokstart,unsigned *linenum ); /* ERRFILE.C */ char *err_readfile( FILE *errfile, unsigned errnum); /* ERRSYS.C */ int err_open(const char *errfile); const char *err_read(int errid,unsigned errnum); void err_set(int errid,unsigned errnum,unsigned errlen); void err_get(int *errid,unsigned *errnum); void err_print(FILE *outstream,const char *command); void err_str(char *errbuf,int bufsiz,const char *command); void err_clear(); void err_level(unsigned level); FILE *err_fileio(); int err_cnt(); /* COMERR.C */ const char *comerr_read(unsigned errnum); void comerr_set(unsigned errnum,unsigned errlen); int comerr_get(); BOOLEAN comerr_chk(unsigned errnum); /* TXTUTIL.C */ unsigned int txtstore(int new_entry,char *txtstr); unsigned int txtread(unsigned int id,char *txtstr); unsigned int txtopenclose(int openclose); unsigned int txtkwsrch(char *keyword,int bol,char *rdstr); unsigned int txtprint(unsigned int id,char *ignorestr,unsigned int pause,unsigned int *nlines); /* TYPES.C */ int print_type(FILE* fptr,unsigned dtype,char* dptr,int offset); /* POPEN2.C */ pid_t popen2(const char *shell_cmd, int *p_fd_in, int *p_fd_out); ivtools-1.2.11a1/src/ComUtil/comutil.ci000066400000000000000000000126001214471147700176600ustar00rootroot00000000000000/* * Copyright (c) 1993 Vectaport * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of the authors not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. The authors make no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef COMUTIL_CI /* External include file */ #include /* include files needed for macros; use ifdef's to speed things up */ #if !defined(STDLIB_INCLUDED) #include #endif #if !defined(MALLOC_INCLUDED) #include #endif #if !defined(STRING_INCLUDED) #include #endif #if defined(MSDOS) & !defined(DOS_INCLUDED) #include #endif /* Definitions for DMM.C */ /* this one for pointer-to-abs and back conversion */ /* these must be used before performing arithmetic on pointers */ /* this is especially a problem in Microsoft C and DOS, not so much in OS9 */ #if defined(MSDOS) typedef unsigned long ABSPNTR; #define PNTR_TO_ABS(pntr,abs) { \ abs = (((unsigned long)FP_SEG(pntr)) << 4) + (unsigned long)FP_OFF(pntr); \ } /* this puts pointer within 16 bytes of the start of the segment */ #define ABS_TO_PNTR(abs,pntr) { \ FP_SEG(pntr) = (unsigned) ((abs) >> 4); \ FP_OFF(pntr) = (unsigned) ((abs) & 0xf); \ } /* this converts a huge address to a regular address */ /* with an offset address less than 15 */ #define ADDRALIGN(pntr) {\ ABSPNTR abs;\ PNTR_TO_ABS(pntr,abs);\ ABS_TO_PNTR(abs,pntr); } #endif #if !defined(MSDOS) /* no problem in OSK */ typedef unsigned long ABSPNTR; #define PNTR_TO_ABS(pntr,abs) { abs = (ABSPNTR) (pntr); } #define ABS_TO_PNTR(abs,pntr) { ((ABSPNTR) (pntr)) = abs; } /* OSK has no problems with addressing; not like dumb Intel */ #define ADDRALIGN(pntr) { /* does nothing to it */ } #endif /* Add single character to token */ #define TOKEN_ADD( ch ) \ { if( *toklen < toksiz ) token[(*toklen)++]= ch; \ else { while( isident(CURR_CHAR) || isdigit(CURR_CHAR)) ADVANCE_CHAR;\ return ERR_TOKENLENGTH; }} /* Advance pointer in buffer */ #define ADVANCE_CHAR (ch = buffer[++*bufptr]) /* Get at current, previous, and next character in buffer */ #define CURR_CHAR (ch) #define PREV_CHAR (buffer[*bufptr-1]) #define NEXT_CHAR (buffer[*bufptr+1]) /* Macros to convert octal and hex characters to internal representation */ #define OCTVAL( ch ) ((ch) - 0x30) #define HEXVAL( ch ) ((ch) - (isdigit(ch) ? 0x30 : (isupper(ch) ? 0x37 : 0x57 ))) /* Maximum values of data structures */ #define SHINT_MAX_DIGITS 5 #define SHINT_MAX_STRING "32767" #define SHOCTS_MAX_DIGITS 5 #define SHOCTS_MAX_STRING "77777" #define SHOCTU_MAX_DIGITS 6 #define SHOCTU_MAX_STRING "177777" #define SHHEXS_MAX_DIGITS 4 #define SHHEXS_MAX_STRING "7FFF" #define SHHEXU_MAX_DIGITS 4 #define SHHEXU_MAX_STRING "FFFF" #if __WORDSIZE == 64 #define LNINT_MAX_DIGITS 19 #define LNINT_MAX_STRING "9223372036854775807" #define LNOCTS_MAX_DIGITS 21 #define LNOCTS_MAX_STRING "777777777777777777777" #define LNOCTU_MAX_DIGITS 22 #define LNOCTU_MAX_STRING "1777777777777777777777" #define LNHEXS_MAX_DIGITS 16 #define LNHEXS_MAX_STRING "7FFFFFFFFFFFFFFF" #define LNHEXU_MAX_DIGITS 16 #define LNHEXU_MAX_STRING "FFFFFFFFFFFFFFFF" #else #define LNINT_MAX_DIGITS 10 #define LNINT_MAX_STRING "2147383547" #define LNOCTS_MAX_DIGITS 11 #define LNOCTS_MAX_STRING "17777777777" #define LNOCTU_MAX_DIGITS 11 #define LNOCTU_MAX_STRING "37777777777" #define LNHEXS_MAX_DIGITS 8 #define LNHEXS_MAX_STRING "7FFFFFFF" #define LNHEXU_MAX_DIGITS 8 #define LNHEXU_MAX_STRING "7FFFFFFF" #endif #if defined(MSDOS) #define DFINT_MAX_DIGITS SHINT_MAX_DIGITS #define DFINT_MAX_STRING SHINT_MAX_STRING #define DFOCTS_MAX_DIGITS SHOCTS_MAX_DIGITS #define DFOCTS_MAX_STRING SHOCTS_MAX_STRING #define DFOCTU_MAX_DIGITS SHOCTU_MAX_DIGITS #define DFOCTU_MAX_STRING SHOCTU_MAX_STRING #define DFHEXS_MAX_DIGITS SHHEXS_MAX_DIGITS #define DFHEXS_MAX_STRING SHHEXS_MAX_STRING #define DFHEXU_MAX_DIGITS SHHEXU_MAX_DIGITS #define DFHEXU_MAX_STRING SHHEXU_MAX_STRING #endif #if !defined(MSDOS) #define DFINT_MAX_DIGITS LNINT_MAX_DIGITS #define DFINT_MAX_STRING LNINT_MAX_STRING #define DFOCTS_MAX_DIGITS LNOCTS_MAX_DIGITS #define DFOCTS_MAX_STRING LNOCTS_MAX_STRING #define DFOCTU_MAX_DIGITS LNOCTU_MAX_DIGITS #define DFOCTU_MAX_STRING LNOCTU_MAX_STRING #define DFHEXS_MAX_DIGITS LNHEXS_MAX_DIGITS #define DFHEXS_MAX_STRING LNHEXS_MAX_STRING #define DFHEXU_MAX_DIGITS LNHEXU_MAX_DIGITS #define DFHEXU_MAX_STRING LNHEXU_MAX_STRING #endif #define SHORT_INT_MACHINE (DFINT_MAX_DIGITS != LNINT_MAX_DIGITS) #endif /* !COMUTIL_CI */ ivtools-1.2.11a1/src/ComUtil/comutil.h000066400000000000000000000144471214471147700175270ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef COMUTIL_INCLUDED #define COMUTIL_INCLUDED #include #include #include #include /* ================================================================== */ /* ============== START of Macro and Definitions ==================== */ #define DMM_OFF /* Macro to supply system-independent terminal name */ #if defined(MSDOS) #define TERMINAL "CON" #endif #if defined(OSK) #define TERMINAL "/t1" #endif /* This declares a pointer reference with no conditional function */ #define dmm_pntr_scalar(pntr) dmm_pntr(0,(void **)(pntr),1L,0,NULL) #define dmm_pntr_array(pntr,nrecs,nsize) \ dmm_pntr(1,(void **)(pntr),(unsigned long)(nrecs),(unsigned)(nsize),NULL) #define dmm_pntr_alloc(pntr) dmm_pntr(-1,(void **)(pntr),0L,0,NULL) /* Flags used as returns from dmm_walk() in DMM.C */ #define DMM_WALK_OK 0 #define DMM_WALK_BAD -1 #define DMM_WALK_EMPTY -2 #define DMM_WALK_END -3 /* Token types returned from LEXSCAN.C */ #define TOK_NONE 0 /* No token found */ #define TOK_IDENTIFIER 1 /* Identifier, i.e. command name */ #define TOK_OPERATOR 2 /* Operator */ #define TOK_STRING 3 /* Character string constant */ #define TOK_CHAR 4 /* Character constant */ #define TOK_DFINT 5 /* Default integer */ #define TOK_DFUNS 6 /* Default unsigned integer */ #define TOK_LNINT 7 /* Long integer */ #define TOK_LNUNS 8 /* Long unsigned integer */ #define TOK_FLOAT 9 /* Floating point number */ #define TOK_DOUBLE 10 /* Double-size floating point number */ #define TOK_EOF 11 /* End of file */ #define TOK_EOL 12 /* End of line -- only returned if _token_eol is true */ /* Token types never returned from LEXSCAN.C */ #define TOK_WHITESPACE 13 /* Spaces, tabs, new-lines, control chars */ #define TOK_OCT 14 /* Octal token */ #define TOK_HEX 15 /* Hexadecimal token */ #define TOK_COMMENT 16 /* Comment */ /* Levels for error system output */ #define USER_LEVEL 0 #define PROG_LEVEL 1 /* Character type checking */ extern int _colon_ident; extern int _percent_ident; #define isident( ch ) ( isalpha( ch ) || (ch) == '_' || \ _colon_ident && (ch) == ':' || _percent_ident && (ch) == '%') #define isodigit( ch ) ( (ch) >= '0' && (ch) <= '7' ) #define isquote( ch ) ( (ch) == '\'' || (ch) == '"' ) #define isrparen( ch ) ( (ch) == ')' || (ch) == ']' || (ch) == '}') /* Error handling macros */ #define COMERR_SET( status )\ comerr_set( status, fprintf( err_fileio(), comerr_read( status ))) #define COMERR_SET1( status, val1 )\ comerr_set( status, fprintf( err_fileio(), comerr_read( status ), val1 )) #define COMERR_SET2( status, val1, val2 )\ comerr_set( status, fprintf( err_fileio(), comerr_read( status ), val1, val2 )) #define COMERR_SET3( status, val1, val2, val3 )\ comerr_set( status, fprintf( err_fileio(), comerr_read( status ), val1, val2, val3 )) /* =================== END of Macro and Definitions ================ */ /* ================================================================== */ /* ================ START of Structure Declarations ================ */ /* === For XDLL.C ==== */ /* This structure is used by the linked list routines XDLL.C */ /* They use int's instead of pointers to be easily relocatable */ /* This means max link list is 32K bytes; but that's ok for now */ typedef struct _xdllink xdllink; struct _xdllink { /* these are BYTE OFFSETS */ int prev; /* prev link in the chain; <0 is top */ int next; /* next link in the chain; <0 is end */ }; /* === structure used with dmm_walk() routine in DMM.C === */ typedef struct _dmmwalk dmmwalk; struct _dmmwalk { int useflag; /* false (0) is FREE, true (1) means USED */ void *mentry; /* entry point address for area allocated */ unsigned long nbytes; /* total bytes in the alloc'd area */ unsigned long nrecs; /* actual records in the area */ unsigned int nsize; /* actual size of each record */ }; /* ======= END of Structure Declarations ======= */ /* Package function prototypes */ #if !defined(OSK) #include #endif #if defined(OSK) /* -- Insert definitions of any function that does not return an integer -- */ /* DMM.C */ /* All int functions */ int dmm_mblock_free(); /* XDLL.C */ void *xdll_curr(); void *xdll_head(); void *xdll_next(); void *xdll_prev(); void *xdll_tail(); void *xdll_insert(); void *xdll_goto(); /* SYMBOLS.C */ char *symbol_pntr(); /* ERRFILE.C */ char *err_readfile(); /* ERRSYS.C */ char *err_read(); FILE *err_fileio(); /* COMERR.C */ char *comerr_read(); /* FUNCPTRS */ int ffeof(); int fferror(); /* TXTUTIL */ unsigned int txtstore(); unsigned int txtread(); unsigned int txtopenclose(); unsigned int txtkwsrch(); /* unsigned int txtprint(); */ #endif typedef char* (*infuncptr)(char*,int,void*); typedef int (*eoffuncptr)(void*); typedef int (*errfuncptr)(void*); typedef int (*outfuncptr)(const char*, void*); extern infuncptr _oneshot_infunc; /* to inform parser of one-shot infunc */ #endif /* not COMUTIL_INCLUDED */ ivtools-1.2.11a1/src/ComUtil/dmm.cc000066400000000000000000002712231214471147700167630ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* DMM.C Dynamic Memory Management Routines Externals: See NUTIL.ARG Summary: These function support dynamic memory management. They allow memory to be allocated and reallocated in a deterministic manner by supporting automatic memory packing and allocated memory pointer updating. This differs from malloc() and realloc() routines which are not guaranteed to be able to take maximum efficiency of all memory and may fail to be able to allocate memory since they are unable to move existing allocated areas to new areas of memory (i.e., can't pack). More details are in the dmm_mblock_alloc() function. History: Written by Robert C. Fitch, March 1989 3 Apr '89, R.Fitch Made dmm_update more general. Add function dmm_movrecs(). 21 Apr '89 R.Fitch >> operator does not work in OS9. Replaced >>1 usage with /2 division. Works OK. */ /** DMM_TEST should be set to decrease values for easier testing **/ #if 0 #define DMM_TEST #endif #include #include "comutil.ci" /* comutil.ci includes of ComUtil/comutil.h, util.h, dos.h, string.h, stdlib.h, malloc.h */ #ifndef DMM_OFF /* ========================================== */ typedef char huge * HPNTR; /* huge pointer to character */ typedef struct _dmmpntr huge * PNTRPNTR; typedef struct _dmmpntr dmmpntr; /* allocation Table structure */ struct _dmmpntr { xdllink link; /* link list support */ short int allocflag; /* 1 if points into alloc'd array */ /* 0 if not in alloc'd area */ void huge **user; /* user's duplicate pointer address */ unsigned long nrecs; /* number of records if pntr array */ /* >1 an array, ==1 a scalar pointer */ unsigned nsize; /* bytes to next pointer if nrecs>1 */ /* set to 0 if scalar pointer */ int (*cond)(); /* checks condition in user */ }; /* cond() is called with a pointer to each alloc'd structures elements */ /* it is a user function that returns true to update or false to skip */ /** A real waste for scalar pointers; add another struct for scalars someday */ /* ========================================== */ /* the doubly-linked allocation table */ /* linked to avoid moving memory to add and delete blocks; just the */ /* links have to be changed. Saves time */ typedef struct _dmmalloc huge * ALLOCPNTR; typedef struct _dmmalloc dmmalloc; /* allocation Table structure */ struct _dmmalloc { xdllink link; /* for link list support (XDLL.C) */ /* these are for the memory allocated */ void **user; /* pointer to users declared pointer */ HPNTR mentry;/* address of alloc'd area in mblock */ unsigned nsize; /* size of each alloc'd area in bytes */ unsigned long nrecs; /* number of records allocated */ unsigned long tsize; /* total bytes alloc`d for the area */ }; /* ========================================== */ static int fatal_error = 0; /* fatal error indicator */ /* not fully implmented yet */ static HPNTR mblock = NULL; /* must be huge type in Microsoft C */ static HPNTR mblock_beg; /* first usable address on page boundary */ static HPNTR mblock_end; /* last usable location in mblock */ static unsigned long mblock_size; /* number of bytes in mblock */ static int alloc_id; /* id for alloc link table */ static ALLOCPNTR alloc_beg; /* address of entry into alloc table */ static int pntr_id; /* for pntr link table usage */ static PNTRPNTR pntr_beg; /* start of memory for pntr lists */ /* statics used between dmm_gap_*() static functions */ static HPNTR gapbeg; /* address of beginning of gap */ static unsigned long gap_size; /* bytes in a gap */ static ALLOCPNTR gap_alloc; /* allocation table entry prior to a gap */ /* Used to indicate that a realloc has occured; used in dmm_mblock_pack() */ static int realloc_flag; /* static used to communicate new alloc position between realloc and malloc */ static ALLOCPNTR new_curr; /* Used by dmm_ichk() to sum up bytes; used by dmm_mblock_stats() */ static unsigned long used_bytes; /* total bytes used in mblock */ static unsigned long free_bytes; /* total free bytes in mblock */ static unsigned long system_bytes; /* bytes used by system in mblock */ /* Static Functions: */ static long dmm_sub_pntrs (); static HPNTR dmm_add_offset (); static int dmm_update (); static ALLOCPNTR dmm_find_alloc(); static PNTRPNTR dmm_find_pntr(); static ALLOCPNTR dmm_find_pntr_to_alloc(); static int dmm_memcpy(); static int dmm_memset(); static unsigned long dmm_gap_size(); static HPNTR dmm_gap_search(); static void dmm_update_pntr(); static int dmm_not_portable(); static void dmm_pack_range(); /* DMM MACROS */ /* DMM_PAGE defines the boundaries that alloc'd areas must start on */ /* for MSDOS, it must be on 16 byte boundaries */ /* for OS9 and others, integer boundaries is OK */ /* define alloc page boundaries */ #if defined(MSDOS) #define DMM_PAGE 16 /* every 16 bytes in Microsoft C and Intel x86's */ #else #define DMM_PAGE sizeof(int) /* on integer boundaries in most machines */ #endif /* ROUNDUP does a ceiling function on lsize to the next DMM_PAGE */ /* This way everything will always end up starting on a page boundary and */ /* will always be an integral number of pages in size */ #define ROUNDUP(num) ( ((num)+(DMM_PAGE-1)) & ( ~(DMM_PAGE-1) ) ) /* these save and restore the currently used linked-list in xdll_*() */ typedef struct _savestruct savestruct; struct _savestruct { /* this structure used to save current dll state */ int id; /* identifier used by linked list routines */ void *curr; /* current position */ }; /* These two just save the id */ #define SAVE_CURR_LINK_ID(save) { \ save.id = xdll_in_use(); } #define RESTORE_CURR_LINK_ID(save) { \ xdll_use(save.id); } /* These two save id and current position */ #define SAVE_CURR_LINK_POS(save) { \ save.id = xdll_in_use();\ save.curr = xdll_curr(); } #define RESTORE_CURR_LINK_POS(save) { \ xdll_use(save.id); \ xdll_goto(save.curr); } /* This checks to see if the fatal_error flag is true */ #define FATALCHECK {if(fatal_error) goto error_return;} /* this is the shift increment for tables to alloc */ #ifdef DMM_TEST #define DMM_SHIFT ((unsigned) 1) #else #define DMM_SHIFT ((unsigned) 6) #endif #define DMM_INCR ((unsigned long) (1L << DMM_SHIFT)) /* This is a portable max unsigned int */ #define DMM_MAXUNSIGNED ( (unsigned int) (~(unsigned) 0) ) /* I'm using a half unsigned number to keep away from limits of unsigned for */ /* memory moves which can only xfer 1 less than 64 K bytes */ /* This is half a maximum unsigned integer plus 1 */ /* its 0x8000 for 16-bit machines , 0x80000000 for 32-bit machines */ /* Could use a bigger number, but this moves on nice even boundaries */ /* I originally used '>> 1' in this, but it did not work in OS9, so */ /* now I use a '/2' instead and that works OK */ #ifdef DMM_TEST #define DMM_MAXCOUNT 16 #else #define DMM_MAXCOUNT ( (DMM_MAXUNSIGNED/2) + 1 ) #endif /* This determines how many pages of maximum unsigned ints are */ /* in a unsigned long. Also the remainder. Machine portable */ /* Uses DMM_MAXCOUNT to determine maximum size of a page */ #define DMM_PAGES(ulong,pages,remains) { \ pages = (unsigned) ((unsigned long)(ulong)/ (unsigned long) DMM_MAXCOUNT);\ remains = (unsigned) ((unsigned long)(ulong)% (unsigned long) DMM_MAXCOUNT);\ } /* Used to add a byte offset to a pointer and subtract two pointers to */ /* generate a byte offset. This works for both int and long size */ /* byte offsets (even microsoft allows both with huge pointers! */ /* C_terp doesn't support huge, so here's another kludge */ #if defined(MSDOS) #define ADDHOFFSET(hpntr,offset) dmm_add_offset((HPNTR)(hpntr),(long)(offset)) #else #define ADDHOFFSET(hpntr,offset) ((HPNTR) (hpntr) + (long) (offset)) #endif /* This macro returns a LONG ! */ /* must use the first one with Microsoft, but second one is OK with OSK */ /* Second may be used if Microsoft changes return to long instead of int */ #if defined(MSDOS) #define SUBHPNTRS(pntr1,pntr2) dmm_sub_pntrs((HPNTR)(pntr1),(HPNTR)(pntr2)) #else #define SUBHPNTRS(pntr1,pntr2) ( (long) (((HPNTR)(pntr1)) - ((HPNTR)(pntr2))) ) #endif /* Macro to align an address relative to a unsigned offset base address */ /* This uses normal pointer adding of positive offsets; */ /* This is currently needed for xdll_*() routines which do not support */ /* huge arithmetic on pointers */ #define BASEALIGN(base,offset) ((HPNTR)((char *)(base)+(unsigned int)(offset))) /* Microsoft 5.0 requires structure sizes to be a power of 2 if the */ /* size of an allocated area exceeds 64K. This is a pain in the butt */ /* So, this kludge is needed to limit the user from allocating more than */ /* 64K since I don't feel like figuring out if the sizeof rec is a power of 2 */ /* Note that this essentially does nothing for 32-bit machines and OS-9 */ #if defined(MSDOS) #define CHECKSIZE(size) {\ if ((unsigned long) (size) > 65535L ) goto error_return; } #else /* nothing for other systems like OS-9 and 32-bit ones */ #define CHECKSIZE(size) #endif #endif /* #ifndef DMM_OFF */ /* ========================================== */ /*! dmm_mblock_alloc Allocate the dynamic memory block. Summary: #include */ int dmm_mblock_alloc (unsigned long nbytes) /*! Return Value: 0 if OK, -1 if insufficient memory or mblock already exists. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned long nbytes ;/* I Total number of bytes of memory to alloc */ #endif #ifdef DOC /* look for this in dmm1.doc */ #endif /* DOC */ { #ifdef DMM_OFF return 0; #else ABSPNTR abs; savestruct save; SAVE_CURR_LINK_ID(save); /* save current link list in use */ /* should be at least enough for DMM_INCR alloc's, pntrs and dups */ if (mblock != NULL || /* if already allocated */ nbytes < DMM_INCR*(sizeof(dmmalloc)+sizeof(dmmpntr)) || dmm_not_portable() ) goto error_return; fatal_error = 0; /* reset fatal error indicator */ alloc_id = pntr_id = -1; /* set these for proper error_return */ mblock_size = ROUNDUP(nbytes); /* round to next multiple of page size */ /* allocate memory with halloc(); halloc is calloc in 32-bit systems */ /* grab an extra page for page offsetting the start of mblock */ if ( (mblock = (HPNTR)halloc(mblock_size+DMM_PAGE,1)) == NULL) goto error_return; /* insufficient memory */ #ifndef C_terp /* Inform C-terp this memory can be written to */ bl_alloc((char *)mblock,mblock_size+DMM_PAGE); #endif /* memory is cleared by halloc() */ /* make sure mblock starts on a page boundary */ PNTR_TO_ABS(mblock,abs); /* convert to an absolute */ mblock_beg = ADDHOFFSET(mblock,(ROUNDUP(abs) - abs)); /* round address up */ mblock_end = ADDHOFFSET(mblock_beg,(mblock_size - 1)); /* allocate allocation table at the start of mblock */ /* bootstrap first entry to point to the alloc table itself */ alloc_beg = (ALLOCPNTR)mblock_beg; /* for now, the start of mblock */ /* create linked list for DMM_INCR elements. */ /* also create reopen type entries for dup's and pntr's */ if ( (alloc_id = xdll_open((void *)alloc_beg,(unsigned)DMM_INCR,sizeof(dmmalloc))) < 0 ) goto error_return; /* xdll blew it */ xdll_use (alloc_id); /* use this one */ xdll_insert(0); /* insert the head of the list; guaranteed to fit */ /* now add data for head */ xdll_head(); /* shouldn't need this */ alloc_beg->user = (void **) (&alloc_beg); /* user pntr to update */ alloc_beg->mentry = (HPNTR) alloc_beg; /* start of table */ alloc_beg->nrecs = DMM_INCR; /* grab this many records for now */ alloc_beg->nsize = sizeof(dmmalloc); /* size of an entry */ alloc_beg->tsize = ROUNDUP(alloc_beg->nrecs * alloc_beg->nsize); /* put on page boundary */ /* if size is always on page boundaries, then memory will always start on */ /* page boundaries; other routines rely on this happening */ /* Alloc table is bootstrapped. OK to use dmm_malloc(), etc. now */ /* Create the link lists for pointers */ if ( dmm_calloc((void**)&pntr_beg,DMM_INCR,sizeof(dmmpntr)) != 0) goto error_return; /* insufficient memory */ ADDRALIGN(pntr_beg); /* align address; address still pnts to same */ if((pntr_id = xdll_open(pntr_beg,(unsigned)DMM_INCR,sizeof(dmmpntr))) < 0) goto error_return; RESTORE_CURR_LINK_ID(save); /* restore current link list id */ return(FUNCOK); error_return: /* return an error code */ dmm_mblock_free(); /* free what's been done so far */ RESTORE_CURR_LINK_ID(save); /* restore current link list id */ return (FUNCBAD); #endif } /*! dmm_mblock_free Free the entire memory block. Summary: #include */ int dmm_mblock_free () /*! Return Value: 0 if OK, -1 if no mem block has been allocated or already free. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ /*! Description: Free the memory block created by dmm_mblock_alloc(). See also: dmm_mblock_alloc() Example: !*/ { #ifdef DMM_OFF return 0; #else savestruct save; if (mblock == NULL) /* error return if block has not been alloc */ goto error_return; /* close link lists used by this routine */ SAVE_CURR_LINK_ID(save); /* save current link list in use */ xdll_use(alloc_id); xdll_close(0); /* release linked list definitions */ xdll_use(pntr_id); xdll_close(0); /* release linked list definitions */ RESTORE_CURR_LINK_ID(save); /* restore current link list id */ /* free block */ hfree (mblock); /* free the memory and everything allocated in it */ #ifndef C_terp /* Inform C-terp this memory has been freed */ bl_free((char *)mblock); #endif mblock = NULL; /* set so you know its a goner */ return (FUNCOK); error_return: return (FUNCBAD); /* error return */ #endif } /*! dmm_mblock_pack Pack the entire memory block so there are not gaps. Summary: #include */ int dmm_mblock_pack (int ipackflag) /*! Return Value: 0 if Pack done OK, <0 if no memory block has been allocated, >0 if incremental pack is completed (only if ipackflag is true). Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int ipackflag ;/* I true - do an incremental pack */ /* false - pack entire memory */ #endif /*! Description: Pack the memory block so that there are no gaps between allocated memory blocks. This will maximize memory usage efficiency. The pack can be either incremental or entire depending on the condition of the boolean flag `ipackflag`. An incremental pack will eliminate one gap at a time everytime a call is made while the entire pack will eliminate all gaps. Any reallocate will restart an incremental pack and a return value of >0 means the incremental pack is done. Notes: `realloc_flag` is a trigger that indicates a pack is needed or an incremental pack should be restarted. `packed` indicates that the memory is entirely packed and does not have to be packed again until another true `realloc_flag`. `realloc_flag` is reset after an entire pack and after an incremental pack restarts. `realloc_flag` is set anytime there is a memory reallocation, allocation or free. See also: Example: !*/ { #ifdef DMM_OFF return 0; #else static int apos; /* current allocation table entry number */ static int packed=1; /* flag indicating memory is packed */ ALLOCPNTR beg,end,next; int i; savestruct save; int retval = -1; /* error code */ SAVE_CURR_LINK_ID(save); /* save current link list in use */ FATALCHECK; if (mblock == NULL) /* error return if block has not been alloc */ goto error_return; xdll_use(alloc_id); if (!ipackflag && realloc_flag) /* if not an incremental pack */ { /* no pack needed unless reallocation has occured */ dmm_pack_range (NULL,NULL,0); /* pack entire memory down */ packed = 1; /* set pack flag true */ retval = realloc_flag = 0; /* reset reallocation flag */ } else /* incremental pack */ { if (realloc_flag) /* set true everytime an allocation occurs */ { /* you have to restart if any reallocation has occured */ beg = NULL; /* restart the incremental pack */ apos = packed = 0; /* indicate not packed */ next = (ALLOCPNTR) xdll_head(); /* next is head */ } else if (!packed) /* continue from current position */ { /* search for next entry */ for (i=0; i */ int dmm_mblock_stats (void ** mpntr, unsigned long * total, unsigned long * used, unsigned long * free, unsigned long * system) /*! Return Value: 0 if OK, -1 if no memory block has been allocated or allocation tables are corrupt. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void ** mpntr ;/* I Beginning address of memory block */ unsigned long *total ;/* I Total number of bytes in memory block */ unsigned long *used ;/* I Number of bytes the user has allocated */ unsigned long *free ;/* I Num of bytes free */ unsigned long *system ;/* I Num of bytes used by the alloc system */ #endif /*! Description: Returns the total number of bytes available in memory `total`, the number of bytes already used by the user (`used`), the number of bytes used by the dmm_*() system (`system`) and the number of bytes that are free (`free`). The relation between the two are: *total = *used + *system + *free If any of the pointer arguments are NULL, no value will be returned for those which are. So to just get the total number of bytes in memory, do a `dmm_mblock_stats(NULL,&total,NULL,NULL,NULL,NULL)`. Some key measures can be derived from these numbers: System Overhead : *system / *used Memory Utilization: *used / *total These are returned in the arguments, so DON'T FORGET THE `&` in front of the variables. The beginning address of the memory block is returned by this routine also in the `mpntr` parameter. See also: Example: !*/ { #ifdef DMM_OFF return 0; #else savestruct save; int retval = FUNCBAD; SAVE_CURR_LINK_ID(save); /* save current link list in use */ if (mblock == NULL) /* not block, error */ goto error_return; if( dmm_ichk() != FUNCOK) /* exit if tables corrupt */ goto error_return; if (used != NULL) *used = used_bytes; /* used_bytes set by dmm_ichk() */ if (free != NULL) *free = free_bytes; /* free_bytes set by dmm_ichk() */ if (system != NULL) *system = system_bytes; /* system_bytes set by dmm_ichk() */ if (total != NULL) *total = used_bytes + free_bytes; /* total is used plus free */ if (mpntr != NULL) *mpntr = (void *) mblock_beg; /* return pointer also */ retval = FUNCOK; error_return: RESTORE_CURR_LINK_ID(save); return (retval); /* error return */ #endif } /*! dmm_malloc Allocate an area of memory. Summary: #include */ int dmm_malloc (void ** pntr,unsigned long nrecs,unsigned nsize) /*! Return Value: 0 if OK, -1 if no memory block has been allocated or insufficient memory. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void **pntr ;/* I Address of location to put start of area */ /* allocated. */ unsigned long nrecs ;/* I Number of records to be allocated */ unsigned nsize ;/* I Size of each record in bytes */ #endif /*! Description: Allocates an area in the memory space generated by dmm_mblock_alloc(). Unlike `calloc()` which returns a pointer to the allocated area, this routine returns the pointer in the location pointed to by the `pntr` argument. This `pntr` should not be an autovariable since the stack is volatile; it should be in a static, global or allocated area. The definitions of `nrecs` and `nsize` are the same as for `calloc()`. In addition to allocating the memory requested, the address of `pntr` are remembered so that it can be automatically updated if this memory block must move. For pointers inside the memory block record allocated, you must declare them as pointers-to-be-updated using the `dmm_pntr()` function. Only pointers which reference memory locations within areas created by `dmm_calloc()` must be declared this way, but if a pointer is declared that points outside these areas, it will cause no problem. The basic algorithm used to allocated is as follows: - Look for a gap large enough to hold the memory requested. If found, insert a zero size memory block on the end. - If no gap is large enough, search for any gap and use that one and again insert a zero size memory block there. - Call dmm_realloc() to resize this zero size memory block to have nrecs records of nsize size. See also: dmm_mblock_alloc(), dmm_pntr(), dmm_free(), dmm_realloc(). Example: See example in dmm_mblock_alloc() !*/ { #ifdef DMM_OFF *pntr = malloc(nrecs*nsize); return *pntr ? 0 : -1; #else savestruct save; ALLOCPNTR curr,curr1; HPNTR gap; ABSPNTR agap; int retval = FUNCBAD; unsigned long size; int before; SAVE_CURR_LINK_ID(save); /* save current link list in use */ FATALCHECK; /* now see if pntr already in the allocation table or params out of range */ if ( mblock == NULL || pntr == NULL || nrecs < 1 || nsize < 1 || dmm_find_alloc(pntr) != NULL) goto error_return; size = nrecs * nsize; /* size needed */ CHECKSIZE(size); /* size check for MSDOS */ /* note: there is always guaranteed to be 1 entry in the alloc table */ xdll_use(alloc_id); /* use alloc table */ if (xdll_links_left() == 0) /* if no more links, then */ goto error_return; /* you are out of memory and you are screwed */ /* Could realloc here but pntr could be pointing into the memory block and */ /* I'm too lazy to figure out where it is so I'm allocating afterwards */ /* first search for a gap large enough for the entire block */ if ( (gap = dmm_gap_search(size)) == NULL) /* find one ? */ { /* no, just look for anywhere to put it */ /* look for any gap you can find */ if ( (gap = dmm_gap_search((long)DMM_PAGE)) == NULL) /* if no gaps anywhere */ goto error_return; /* sorry, must be out of memory */ } before = (gap_alloc == NULL); if (before) /* is it a gap at head of list */ xdll_head(); /* move to first entry */ else xdll_goto((void *)gap_alloc); /* move to entry before gap */ curr = (ALLOCPNTR) xdll_insert(before); /* insert new entry */ curr->nrecs = curr->tsize = 0L; /* make it a zero size memory */ curr->nsize = nsize; /* for reallocating to new size */ curr->user = pntr; /* remember where user's pointer */ ADDRALIGN(gap); /* align gap address */ *(curr->user)=(void *)(curr->mentry=gap); /* set to gap for now; user too */ if (dmm_realloc(pntr,nrecs) != 0) /* could it realloc ? */ { /* if it fails, nothing will have been updated at all */ xdll_goto( (void *)curr); /* return to current position in alloc table */ *(curr->user) = NULL; /* set users pointer back to NULL */ xdll_delete(0); /* and delete this partially completed entry */ goto error_return; } curr = new_curr; /* this is where curr before is now */ /* after this point, the contents of `pntr` and curr are no longer valid */ /* now expand the table if adding one more will overflow */ if (xdll_links_left() == 0) /* if no more links, then */ { /* realloc some more before you really need them */ curr1 = dmm_find_alloc(&alloc_beg); /* set curr to pntr_beg */ if (dmm_realloc((void**)&alloc_beg,(nrecs=curr1->nrecs+DMM_INCR)) != 0) { /* big one won't fit, add a single sized one */ if (dmm_realloc((void**)&alloc_beg,(nrecs=curr1->nrecs+1L)) != 0 ) { /* out of memory, quitting time */ /* nothing moved or changed */ /* first try for DMM_INCR and then just 1 and then give up */ xdll_goto((void *)curr);/* return to current position in alloc table */ *(curr->user) = NULL; /* set users pointer back to NULL */ xdll_delete(0); /* and delete this partially completed entry */ goto error_return; /* you are out of memory and you are screwed */ } } /* reopen alloc_id and change size */ xdll_reopen (0,(void *) alloc_beg,(unsigned) nrecs,-1); } retval = FUNCOK; error_return: RESTORE_CURR_LINK_ID(save); return (retval); /* error return */ #endif } /*! dmm_calloc Allocate and clear an area of memory. Summary: #include */ int dmm_calloc (void ** pntr,unsigned long nrecs,unsigned nsize) /*! Return Value: 0 if OK, -1 if no memory block has been allocated or insufficient memory. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void **pntr ;/* I Address of location to put start of area */ /* allocated. */ unsigned long nrecs ;/* I Number of records to allocated */ unsigned nsize ;/* I Size of each record in bytes */ #endif /*! Description: Same as dmm_malloc() except it also clears memory. It calls dmm_malloc() followed by a dmm_clear() to clear the allocated memory. See also: dmm_malloc(), dmm_clear(). Example: !*/ { #ifdef DMM_OFF *pntr = calloc(nrecs,nsize); return *pntr ? 0 : -1; #else if (dmm_malloc(pntr,nrecs,nsize) == FUNCOK && dmm_clear(pntr) == FUNCOK ) return(FUNCOK); return (FUNCBAD); /* error return */ #endif } #ifdef DMM_OFF static int _dmm_realloc_size; int dmm_realloc_size(int size) { int oldsize = _dmm_realloc_size; _dmm_realloc_size=size; return oldsize; } #endif /*! dmm_realloc Re-Allocate an area of memory. Summary: #include */ int dmm_realloc (void ** pntr,unsigned long nrecs) /*! Return Value: 0 if OK, -1 if no memory block has been allocated or insufficient memory. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void **pntr ;/* I Address of location to put start of area */ /* allocated. */ unsigned long nrecs ;/* I Number of records to be allocated */ #endif /*! Description: Re-Allocates an area in the memory space generated by dmm_mblock_alloc(). Same as `dmm_calloc()` except `pntr` must be for an existing allocated array. Also, only the number of records can be changed at present. The new number of records to have is in `nrecs`. On exit, the static global `new_curr` will have the position of the new current allocation table entry. The basic algorithm is: - Find area in allocation table that references `&pntr`. If not, error. - If shrinking in size, just reduce the size and exit. - First see if there is enough room immediately after to expand. If so, do it and leave. - Otherwise, memory must be moved. - First see if there is a gap large enough to move the new memory size. if so, move it and exit. - If not, search for strings of gaps that go around the region you are trying to reallocate. Choose the one that has the minimum cost in memory movement and push memory regions around to create a gap that the desired memory can move into. See also: dmm_calloc(), dmm_free(). Example: See example in dmm_mblock_alloc() !*/ { #ifdef DMM_OFF *pntr = realloc(*pntr, nrecs*_dmm_realloc_size); return *pntr ? 0 : -1; #else unsigned long old_size,new_size; PNTRPNTR ppntr; HPNTR gap,beg,end; ALLOCPNTR min_beg,min_end,curr,old_curr,begcurr,next; long nbytes, delta; unsigned long move_cost,min_move_cost,tsize,gap_nbytes; unsigned long offset,goffset,offset1,oldnrecs; int passed_old_curr,found,before,is_old_curr; int retval = FUNCBAD; savestruct save; SAVE_CURR_LINK_ID(save); /* save current link list in use */ FATALCHECK; /* now find pntr in the allocation table */ if ( mblock == NULL || pntr == NULL || nrecs < 1 || (old_curr = dmm_find_alloc(pntr)) == NULL) goto error_return; offset = SUBHPNTRS(old_curr,alloc_beg); old_size = (oldnrecs = old_curr->nrecs) * old_curr->nsize; /* zero if malloc'ing */ new_size = nrecs * old_curr->nsize; CHECKSIZE(new_size); /* size check for MSDOS */ delta = new_size - old_size; /* if shrinking or following gap large enough, just reduce size and exit */ if (delta > 0L && dmm_gap_size(0,old_curr) < delta ) { /* new one is bigger and insufficient gap afterwards */ /* look for a new area to move it to */ if ( (gap = dmm_gap_search(new_size)) != NULL) { /* found one, but I have to move old_curr memory to it */ /* move existing memory block */ /* determine #bytes to move, update pointers and move the memory */ nbytes = SUBHPNTRS(gap,old_curr->mentry); goffset = SUBHPNTRS(gap_alloc,alloc_beg); /* save this offset to gap */ before = (gap_alloc == NULL); dmm_update (1,old_curr,nbytes,-1L,-1L); /* update pntrs and move memory */ /* now relocate old_curr to gap region */ old_curr = (ALLOCPNTR) BASEALIGN(alloc_beg,offset); /* align to the base address */ xdll_goto((void *) old_curr); /* go to this entry again */ xdll_delete(0); /* delete it */ /* note: user data in old_curr is still valid until I wreck it */ if (before) /* is it a gap at head of list */ xdll_head(); /* move to first entry */ else { gap_alloc = (ALLOCPNTR) BASEALIGN(alloc_beg,goffset); /* recover gap_alloc */ xdll_goto((void *) gap_alloc); /* move to entry before gap */ } curr = (ALLOCPNTR) xdll_insert(before); /* insert new entry */ /* this is guarenteed to be inserted without any memory problem */ /* the following works since deletes do not destroy user contents */ /* note that curr and old_curr could be the same sometimes ,so */ /* do it if they are equal */ if (SUBHPNTRS(curr,old_curr) != 0L) /* if old_curr to be vacated */ { /* move values and clear old_curr pointers */ curr->user = old_curr->user; /* move old values */ curr->mentry = old_curr->mentry; curr->nsize = old_curr->nsize; } new_curr = curr; /* new_curr is a global */ } else /* uh oh, you got to pack memory */ { min_beg = NULL; /* null means there is none yet */ min_move_cost = mblock_size+1; /* max movement */ delta = new_size - old_curr->tsize; /* amount of bytes needed */ for (begcurr = old_curr, found=0,xdll_goto((void *)old_curr); ; /* see end of loop for break condition */ xdll_goto((void *)begcurr), begcurr = (ALLOCPNTR)xdll_prev() ) { /* processing begcurr == NULL is required */ for (curr = begcurr, move_cost=gap_nbytes=0L, passed_old_curr=0; ; /* see end of loop for break condition */ curr = next ) { /* count gap sizes from curr */ gap_nbytes += dmm_gap_size(1,curr); /* total gap size */ if (curr == NULL) { is_old_curr = 0; /* false: old_curr can't be NULL */ next = (ALLOCPNTR) xdll_head(); /* next is head if NULL */ } else { is_old_curr = (SUBHPNTRS(curr,old_curr) == 0L); if (is_old_curr) passed_old_curr = 1; /* set this as you pass old_curr */ next = (ALLOCPNTR) xdll_next(); /* go to next */ } /* the cost of the gap immediately after old_curr costs nothing */ /* cost is based on size of next memory after the gap and if */ /* next is NULL, there is not next memory to cost you */ if (!is_old_curr && next != NULL) move_cost += next->tsize; /* cost is size of memory to move */ if( gap_nbytes >= delta) /* has total of gaps exceeded needed */ { /* yes, if past or up to old_curr, accum cost and break loop */ if (passed_old_curr || (next != NULL && SUBHPNTRS(next,old_curr) == 0L) ) { /* no break until you get past or up to old_curr */ if(min_move_cost > move_cost) /* accum one with min cost */ { /* you are less than min cost so far; remember it */ found = 1; /* I found one big enough to fit */ min_move_cost = move_cost; min_beg = begcurr; /* save range to pack over */ min_end = next; } break; /* bread for (curr.. */ } } /* end if */ if (next == NULL) break; /* bread if next one is NULL */ } /* end for (curr...) */ if (begcurr == NULL || /* already processed head */ (found && !passed_old_curr) ) /* or found what we need */ break; /* break if old_curr not in the sum anymore */ } /* end for (begcurr...) */ if (!found) /* couldn't find one big enough ?*/ goto error_return; /* that's bad news; completely out of mem */ /* now pack the memory down and up around old_curr */ xdll_goto( (void *)old_curr); /* go to this position */ next = (ALLOCPNTR) xdll_next(); /* go to next one */ offset1 = SUBHPNTRS(min_end,alloc_beg); /* save this offset */ dmm_pack_range(min_beg,next,0); /* pack down including old_curr*/ old_curr = (ALLOCPNTR) ADDHOFFSET(alloc_beg,offset); /* restore new old_curr */ min_end = (ALLOCPNTR) ADDHOFFSET(alloc_beg,offset1); /* restore min_end */ dmm_pack_range(old_curr,min_end,1); /* pack up, not old_curr */ /* now the gap after old_curr is large enough to expand memory size */ new_curr = (ALLOCPNTR) ADDHOFFSET(alloc_beg,offset); /* restore new old_curr */ } /* else uh oh */ } else new_curr = old_curr; /* its the same */ new_curr->nrecs = nrecs; /* just change records and */ tsize = new_curr->tsize = ROUNDUP(new_size); /* put on a page boundary */ /* if size of memory expanded, clear the new end of memory */ if ( tsize > old_size) dmm_memset(ADDHOFFSET(new_curr->mentry,old_size),0,tsize-old_size); /* clear trailing nbytes including unused ones */ if (oldnrecs > nrecs) /* if removing records */ { /* you have to free the records that are being removed */ dmm_update(0,new_curr,0L,nrecs,oldnrecs-1L); /* free them */ } /* Now update sizes of pointer arrays that point to the realloc'd area */ /* reallocation automatically adjusts records entry for pointers */ /* that are arrays in allocated areas */ beg = new_curr->mentry; end = ADDHOFFSET(beg,tsize - 1L); xdll_use(pntr_id); /* update makes sure this still works after move */ for (ppntr = (PNTRPNTR) xdll_head(); /* go through all pntrs in table */ ppntr != NULL; ppntr = (PNTRPNTR) xdll_next() ) { /* search through all pointers to this */ if (ppntr->allocflag != (short int) 0 && /* only if array alloc'd area */ SUBHPNTRS(ppntr->user,beg) >= 0L && SUBHPNTRS(ppntr->user,end) <= 0L ) ppntr->nrecs = nrecs; /* set to the new number of records */ } realloc_flag = 1; /* set to indicate that a reallocation occured */ retval = FUNCOK; error_return: RESTORE_CURR_LINK_ID(save); return (retval); /* error return */ #endif } /*! dmm_free Free an allocated memory area. Summary: #include */ int dmm_free (void ** pntr) /*! Return Value: 0 if OK, -1 if no memory block has been allocated or insufficient memory. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void **pntr ;/* I Address of location of alloc'd area. */ #endif /*! Description: This frees an allocated area of memory and all associated duplicate pointers and pointer references. It also sets any other pointer references in the allocation table to NULL if they are pointing to the area being free'd. See also: dmm_calloc(). Example: See example in dmm_mblock_alloc() !*/ { #ifdef DMM_OFF free(*pntr); return 0; #else savestruct save; ALLOCPNTR curr; int retval = FUNCBAD; SAVE_CURR_LINK_ID(save); /* save current link list in use */ FATALCHECK; if ( mblock == NULL || pntr == NULL || (curr = dmm_find_alloc(pntr)) == NULL) goto error_return; /* curr now points at one you are freeing */ dmm_update(0,curr,0L,-1L,-1L); /* this frees all memory and pointers */ /* also NULL's any pointers into the memory area being freed */ /* nothing will move in memory as a result of this call */ /* but all pointers to area being freed will be set to NULL */ xdll_goto((void *) curr); /* return to the entry found above */ xdll_delete(0); /* delete the entry from alloc table */ /* now release all entries which have NULL user entries */ /* NULL user means it was stored in an area that was free'd */ while (dmm_find_pntr(NULL) != 0) { /* returns positioned on NULL entry, so just delete it */ xdll_delete(0); /* remove it from the list its hopeless */ } while (dmm_find_alloc(NULL) != 0) { /* returns positioned on NULL entry, so just delete it */ xdll_delete(0); /* remove it from the list its hopeless */ } /* put some table shrink stuff in here someday */ realloc_flag = 1; /* set to indicate that memory reallocation */ /* has occurred */ retval = FUNCOK; error_return: RESTORE_CURR_LINK_ID(save); return (retval); /* error return */ #endif } #ifndef DMM_OFF /*! dmm_clear Clear an allocated memory area. Summary: #include */ int dmm_clear (void ** pntr) /*! Return Value: 0 if OK, -1 if no memory block has been allocated or insufficient memory. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void **pntr ;/* I Address of location of alloc'd area. */ #endif /*! Description: This zeroes out the allocated memory block. It uses the somewhat general routine `dmm_memset()` to do so. See also: dmm_calloc(), dmm_memset(). Example: See example in dmm_mblock_alloc() !*/ { savestruct save; ALLOCPNTR curr; int retval = FUNCBAD; SAVE_CURR_LINK_ID(save); /* save current link list in use */ FATALCHECK; /* now find pntr in the allocation table */ if ( mblock == NULL || pntr == NULL || (curr = dmm_find_alloc(pntr)) == NULL) goto error_return; dmm_memset(curr->mentry,0,curr->tsize); /* call set routine */ retval = FUNCOK; error_return: RESTORE_CURR_LINK_ID(save); return (retval); /* error return */ } /*! dmm_pntr Declare a pointer to be automatically updated. Summary: #include */ int dmm_pntr (int ptype,void ** pntr,unsigned long nrecs, unsigned nsize,int (*cond)()) /*! Return Value: 0 if OK, -1 if no memory block has been allocated or insufficient memory. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int ptype ;/* I 0 - single scalar pointer */ /* >0 - array of pointers outside mem block */ /* <0 - array of pointers in alloc'd area */ void **pntr ;/* I Address of pointer */ unsigned long nrecs ;/* I Number of pointers; 1L if single */ /* which means use alloc'd regions nrecs,nsize */ unsigned nsize ;/* I Step between pointers if nrecs > 1L */ int (*cond)() ;/* I Function that returns: */ /* 0 - to update pointer, */ /* 1 - to not update pointer */ /* If cond NULL, then always update */ #endif #ifdef DOC /* look for this dmm2.doc */ #endif /* DOC */ { #ifdef DMM_OFF return 0; #else PNTRPNTR ppntr; ALLOCPNTR curr; savestruct save; int retval = FUNCBAD; SAVE_CURR_LINK_ID(save); /* save current link list in use */ FATALCHECK; if (mblock == NULL || pntr == NULL || /* no NULLs allowed */ dmm_find_alloc(pntr) != NULL || /* already used as alloc'd pntr */ dmm_find_pntr(pntr) != NULL) /* or already defined */ goto error_return; /* the big beeper */ /* now see if pointer is stored in an allocated region */ /* if so, and its an array and you must use the alloc regions sizes,records */ if ( ptype < 0) { /* must be an array that is allocated */ if ( (curr = dmm_find_pntr_to_alloc(pntr)) != NULL) { /* its to an allocated area; use its values */ if (SUBHPNTRS(pntr,curr->mentry) >= (nsize = curr->nsize) ) goto error_return; /* must point into first structure element */ nrecs = curr->nrecs; } else goto error_return; } if (ptype == 0) /* if scalar specified */ nrecs = 1L; /* set for scalar (nsize will not be used ever) */ else if ( nrecs == 0L || nsize < 1 ) /* don't check for scalar */ goto error_return; /* it is guaranteed by design that another pntr will fit in the list */ xdll_use (pntr_id); /* switch to pointer link list */ if (xdll_links_left() == 0) /* if no more links, then */ goto error_return; /* can't try realloc because pntr may be in memory that moves and I'll */ /* lose it. This could be changed eventually, but probably not a big deal */ xdll_tail(); /* go to tail; OK if NULL list */ ppntr = (PNTRPNTR) xdll_insert(0); /* insert it this time for sure */ ppntr->allocflag = (ptype < 0) ? (short int) 1 : (short int) 0; ppntr->user = pntr; ppntr->nrecs = nrecs; ppntr->nsize = (nrecs == 0L) ? 0L : nsize; /* zero for scalar */ ppntr->cond = cond; /* save function pointer */ /* now expand the table if adding one more will overflow */ if (xdll_links_left() == 0) /* if no more links, then */ { /* realloc some more before you really need them */ curr = dmm_find_alloc(&pntr_beg); /* set curr to pntr_beg */ xdll_use(pntr_id); /* dmm_find_alloc corrupts table in use */ if (dmm_realloc((void**)&pntr_beg,(nrecs=curr->nrecs+DMM_INCR)) != 0) { /* try a smaller increment if this one doesn't fit */ if(dmm_realloc((void**)&pntr_beg,(nrecs=curr->nrecs+1)) != 0 ) goto error_return; /* you are out of memory and you are screwed */ } xdll_reopen (0,(void *) pntr_beg,(unsigned) nrecs,-1); } retval = FUNCOK; error_return: RESTORE_CURR_LINK_ID(save); return (retval); #endif } /*! dmm_free_pntr Remove a pointer refernce. Summary: #include */ int dmm_free_pntr (void ** pntr) /*! Return Value: 0 if OK, -1 no memory block has been allocated or pntr does not exist in allocation table. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void **pntr ;/* I Address of location of pntr reference */ #endif /*! Description: Remove a pointer reference previously specified by dmm_pntr() function. Duplicate pointers take memory. They should be removed when you are finished with them otherwise they will tend to accumulate. See also: dmm_calloc(), dmm_pntr(). Example: !*/ { savestruct save; int retval = FUNCBAD; SAVE_CURR_LINK_ID(save); /* save current link list in use */ FATALCHECK; if (mblock == NULL || pntr == NULL) /* error return if block has not been alloc or pntr NULL */ goto error_return; /* now go after the one you really want to free */ if (dmm_find_pntr(pntr) != NULL) /* if found it */ { xdll_delete(0); /* delete this entry */ retval = FUNCOK; } /* PUT IN TABLE SHRINK STUFF HERE SOMEDAY */ error_return: RESTORE_CURR_LINK_ID(save); return (retval); /* error return */ } /*! dmm_ichk Do an integrity check on the allocation tables. Summary: #include */ int dmm_ichk () /*! Return Value: 0 if OK, -1 if the table is corrupted. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ /*! Description: Check to see if the allocation table has been corrupted for any reason. It does this by doing a `dmm_walk()` through the table and checking status returns. This routine also sums up the used and free bytes and puts these sums in statics `used_bytes`,`free_bytes` and `system_bytes' for the `dmm_mblock_stats()` routine to used. See also: dmm_mblock_alloc(), dmm_walk() Example: !*/ { int retval = FUNCBAD; dmmwalk ret; int n; if (mblock == NULL) /* no memory; i.e., no table */ goto error_return; system_bytes = used_bytes = free_bytes = 0L; ret.mentry = NULL; /* set to start at beginning of allocation table */ while ( (n=dmm_walk(&ret)) != DMM_WALK_END) { if (n != DMM_WALK_OK) /* if not OK or END, its corrupted */ goto error_return; /* tables blown */ if (ret.useflag) /* sum up bytes used and free */ used_bytes += ret.nbytes; /* total bytes used */ else free_bytes += ret.nbytes; /* total bytes free */ /* now see if its either alloc_beg or pntr_beg's entry */ if (SUBHPNTRS(alloc_beg,ret.mentry) == 0L || /* alloc table */ SUBHPNTRS(pntr_beg,ret.mentry) == 0L ) /* or pntr_beg */ system_bytes += ret.nbytes; /* total bytes used by system */ } retval = FUNCOK; error_return: return (retval); /* error return */ } /*! dmm_walk Walk through the allocation tables and return information. Summary: #include */ int dmm_walk (dmmwalk ret) /*! Return Value: DMM_WALK_OK if OK, DMM_WALK_BAD if table corrupted, DMM_WALK_EMPTY if table empty, DMM_WALK_END if at end of table. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC dmmwalk *ret ;/* O Val returned in structure pointed to by ret */ #endif #ifdef DOC /*! Description: This is similar to the Microsoft `heapwalk` routine, but has a slightly different structure return. If `ret->mentry` is NULL, it starts at the beginning of the table. If it is not NULL, it continues from the last position. Returned are information for either allocated areas or free areas (free areas are also called gaps sometimes). Free areas are the number of bytes between allocated areas since the table entries are always in the order of memory. Since only non-NULL returns are legal for `ret->mentry`, subsequent calls with the same ret strucuture will continue through the table. Returns information in the `dmmwalk` structure as follows: typedef struct _dmmwalk dmmwalk; struct _dmmwalk { int useflag; /* false (0) is FREE, true (1) means USED */ void *mentry; /* entry point address for area allocated */ unsigned long nbytes; /* total bytes in the alloc'd area */ unsigned long nrecs; /* actual records in the area */ unsigned int nsize; /* actual size of each record */ }; See also: dmm_mblock_alloc(). Example: !*/ #endif /* DOC */ { static ALLOCPNTR curr=NULL; /* current position; NULL means end */ static int gapflag; /* true if checking on a gap size (i.e., free mem) */ savestruct save; HPNTR pntr; unsigned long gapsize; int flag; int retval = DMM_WALK_BAD; SAVE_CURR_LINK_ID(save); /* save current link list in use */ xdll_use(alloc_id); if (mblock == NULL || xdll_head() == NULL) { /* no memory or no table in memory */ retval = DMM_WALK_EMPTY; goto error_return; } /* table is guaranteed to have at least one entry if mblock allocated */ flag = (ret->mentry == NULL); /* true if starting at beginning of list */ if (flag) { gapflag = 1; /* set to check start gap */ gapsize = dmm_gap_size(1,NULL); /* get gap at the head of memory */ } else if (curr != NULL) { xdll_goto((void *) curr); /* go to this position */ gapsize = dmm_gap_size(1,curr); } else /* curr == NULL */ { retval = DMM_WALK_END; goto error_return; } if (gapflag) /* if to check the gap */ { /* skip them if they are zero size */ if (gapsize == 0L) /* if there is no gap */ gapflag = 0; /* set so that it picks up next entry */ else { ret->useflag = 0; /* free */ ret->mentry = (void *) gapbeg; /* start of this memory block */ ret->nrecs = ret->nbytes = gapsize; /* set to gap size */ ret->nsize = 1; /* byte size records */ } curr = (ALLOCPNTR) ((flag) ? xdll_head() : xdll_next() ); /* if start of list, next is head, else next is next */ /* curr of NULL means hit end of the list */ } if (!gapflag) /* this is not a gap */ { /* check eot again since gapflag may have changed since last check */ if (curr == NULL) /* hit eot? */ { retval = DMM_WALK_END; goto error_return; } ret->useflag = 1; /* used */ pntr = curr->mentry; ret->mentry = (void *) pntr; /* start of this memory block */ ret->nrecs = curr->nrecs; ret->nsize = curr->nsize; ret->nbytes = curr->tsize; /* do an integrity check on ->tsize and ->mentry */ if ((curr->tsize % DMM_PAGE) != 0L || /* must be zero or error */ curr->nrecs == 0L || curr->nsize == 0L || /* zero sizes */ (curr->nrecs * curr->nsize) > curr->tsize || /* illegal size */ pntr == NULL || /* NULL memory address */ SUBHPNTRS(pntr,mblock_beg) < 0L || /* do range check on mblock */ SUBHPNTRS(pntr,mblock_end) > 0L ) { /* returns != 0 if &pntr, pntr NULL or pntr not pointing to mblock */ retval = DMM_WALK_BAD; /* out of range, table is goofed */ ret->mentry = NULL; /* set NULL for eot and restart */ fatal_error = 1; /* sorry, this is fatal */ goto error_return; } } gapflag = !gapflag; /* toggle gap flag */ retval = DMM_WALK_OK; error_return: RESTORE_CURR_LINK_ID(save); return (retval); /* error return */ } /*! dmm_movrecs Move a block of records in an allocated memory area. Summary: #include */ int dmm_movrecs(void ** pntr,unsigned long dstrec,unsigned long srcrec, unsigned long nrecs) /*! Return Value: 0 if OK, -1 no memory block has been allocated or pntr does not exist in allocation table. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void **pntr ;/* I Address of location of alloc'd area */ unsigned long dstrec ;/* I Destination record number */ unsigned long srcrec ;/* I Source record number */ unsigned long nrecs ;/* I Number of records to move */ #endif /*! Description: Moves a consecutive block of records in an existing allocated memory block to another location in the same block. This would typically be used when inserting a new records in an existing record stream or packing records in memory. This routine will update all pointer references in the records and those that point to the records being moved. The `pntr` parameter is the one specified in either the `dmm_malloc` or `dmm_calloc` function calls and must have been allocated. The destination record number is given by `dstrec` and the source record number is given by `srcrec`. The number of records to move is `nrecs`. Note all record numbers are `longs`. See also: dmm_calloc(), dmm_malloc(). Example: !*/ { int retval = FUNCBAD; long nbytes,delta; unsigned long start,end; ALLOCPNTR curr; FATALCHECK; if (mblock == NULL || pntr == NULL || /* no NULLs allowed */ (curr = dmm_find_alloc(pntr)) == NULL || /* must exist */ (srcrec+nrecs) > curr->nrecs || /* out of range */ (dstrec+nrecs) > curr->nrecs ) /* out of range */ goto error_return; delta = dstrec - srcrec; /* difference; could be pos or neg */ /* pos if dst above src and negative is dst below src */ if (delta != 0L && nrecs > 0L)/* don't do anything unless somethings moving */ { /* zero delta means not moving; zero nrecs means no records to move */ nbytes = curr->nsize * delta; /* bytes of delta for dmm_update */ /* now update and move the records */ if(dmm_update(1,curr,nbytes,srcrec,srcrec+nrecs-1) ) goto error_return; /* now free evacuated records */ /* there are 4 cases to consider related to direction and overlapping */ if (delta > 0) /* dst is above src in memory */ { start = srcrec; /* free from start of srcrec */ /* end depends on whether src overlaps dst or not */ /* only free up to the beginning of dst unless src doesn't hit it */ end = srcrec + ((nrecs <= delta) ? (nrecs-1L) : (delta-1L) ); } else /* dst is below src in memory */ { end = srcrec + (nrecs - 1L); /* free up to the end of srcrec */ /* start depends on whether dst overlaps src */ /* only free up to the end of dst */ start = (nrecs <= -delta) ? srcrec : (end + delta + 1L); } if(dmm_update(0,curr,0L,start,end)) /* free records from start to end */ goto error_return; } retval = FUNCOK; error_return: return (retval); /* error return */ } /* ========== Static Functions ============= */ /*! dmm_update Update all pointers in the table for an area being moved. Summary: #include */ static int dmm_update (int flag,ALLOCPNTR apntr,long nbytes,long srec,long erec) /*! Return Value: 0 if OK, -1 if apntr->nrecs was zero. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int flag ;/* I > 0 - Update pointers by adding nbytes */ /* < 0 - Update pointer but don't move memory */ /* == 0 - Free pointers and set to NULL */ ALLOCPNTR apntr ;/* I Pointer to area being moved */ long nbytes ;/* I How many bytes you are moving the */ /* *apntr memory entry */ /* can be pos or neg depending on direction */ long srec ;/* I Starting record number (<= 0 is start). */ long erec ;/* I Ending record num (< 0 if to last record) */ #endif /*! Description: To be used when moving the block identified to 'apntr' to another area in the mblock memory. It is also used for releasing pointers that point to apntr when the memory for apntr is being free'd by dmm_free(). A range of records to move or free can be specified by a starting records `srec` and an ending record `erec`. If `srec` is <= 0, it starts at the beginning of the allocated area. If `erec` is <0, it end at the last record in the allocated area (so to move the entire array, set `srec` to <= 0 and `erec` to -1L). Currently, if `srec` and `erec` are specified as non-zero, it is assumed that the records are being copied to another area in memory or being partially free'd (such as in a shrink realloc) and the current allocated area identified by `apntr` is left in position meaning the apntr area is not being free'd, just pointers to the area identified by the `srec` and `erec`. The number of bytes to move is given by `nbytes` and can be either positive or negative. If `flag` is 1, the pointers are updated by `nbytes` for a memory area being moved. If `flag` is -1, pointers are updated but the no memory movement is done (movement will be done elsewhere or not at all). If `flag` is 0, it is assumed that apntr's memory is being free'd and all pointers to apntr's memory are set to NULL. This includes all duplicates for apntr also. In addition to NULL'ing out pointer values, the links for the duplicates and pointers for the entry being free'd are also deleted. This will update all the pointers in the memory block for the entry being moved and selected by the entry identified by `apntr`. The number of bytes it is moving is given by `nbytes`. It can be either positive or negative. It is positive if moving to higher address and negative if moving to lower addresses. The technique used is as follows: - update or free the apntr->mentry pointer value (unless a record range was specified, then leave it alone). - update user entry for apntr. - update all dmmpntr references by searching the entire allocation table. If apntr->nrecs is zero, it is assumed that this memory has not been allocated as yet and is not being pointed to. Normally a zero size memory is not allowed, so the only case is when dmm_malloc() is making a new one by reallocating a zero size one. In this case, no update is made. See also: Example: !*/ { ALLOCPNTR curr; PNTRPNTR ppntr; savestruct save; HPNTR abeg,aend,hpntr,dest,base; unsigned long nrecs, movesize; unsigned int nsize; long delta; int updateall; int (*cond)(); /* users cond function in pointer list entry */ HPNTR *cpntr; /* this is a huge char ** type deal */ int retval = -1; long tempoff; SAVE_CURR_LINK_ID(save); /* save current link list in use */ if ((nrecs = apntr->nrecs) == 0L || /* zero means its being allocated */ apntr->mentry == NULL || apntr->tsize == 0L ) goto error_return; /* so nothing is pointing to it anywhere */ nsize = apntr->nsize; if (srec < 0L) srec = 0L; /* set to start */ if (erec < 0L) erec = nrecs - 1L; /* end of array */ updateall = (srec == 0L && erec == (nrecs-1L) ); /* true if copying all */ /* range check */ if (!updateall) { /* check legality of srec and erec if not copying all */ /* also limits move to be within existing allocated block */ delta = nbytes / (long) nsize; /* records to move by: must be an integer */ if (srec > erec || erec >= nrecs || (nbytes % (long) nsize) != 0 || /* must be a int of rec size */ (srec+delta) < 0L || (erec+delta) >= nrecs ) goto error_return; } abeg = ADDHOFFSET(apntr->mentry,(srec * (long)nsize)); tempoff = (erec == nrecs-1L) ? (apntr->tsize - 1L) : ((erec+1L)*(long)nsize - 1L); aend = ADDHOFFSET(apntr->mentry,tempoff); /* now adjust the base of area being moved; this is destination addr */ /* don't do it unless you are copying the entire memory block */ if (updateall) { dmm_update_pntr(flag,(HPNTR *)&apntr->mentry,nbytes,NULL); ADDRALIGN(apntr->mentry); /* align address; usually a NOP */ dest = apntr->mentry; /* this was offset by nbytes */ movesize = apntr->tsize; /* entire block */ } else { /* move is in place, don't touch apntr->mentry */ dest = ADDHOFFSET(abeg,nbytes); /* if moving in place */ movesize = (erec-srec+1)*(long)nsize; /* bytes to move */ } base = apntr->mentry; /* address to align offset to */ /* Update user pointers in the allocation table structures */ xdll_use(alloc_id); for (curr = (ALLOCPNTR) xdll_head(); curr != NULL; /* go through all entries in the table */ curr = (ALLOCPNTR) xdll_next() ) { /* first check what the user pointer is pointing at */ /* don't update user's alloc pointer unless updateall true */ /* assumed to always point at the beginning of alloc'd area */ if (updateall) { hpntr = *((HPNTR *)curr->user); if (SUBHPNTRS(hpntr,abeg) >= 0L && SUBHPNTRS(hpntr,aend) <= 0L) { /* only update if pointing into area being moved or free'd */ dmm_update_pntr(flag,(HPNTR *)curr->user,nbytes,base); } } /* repeat for where the pointer itself is */ /* updates if users pointer is in the area being moved or free'd */ hpntr = (HPNTR)curr->user; if (SUBHPNTRS(hpntr,abeg) >= 0L && SUBHPNTRS(hpntr,aend) <= 0L) { /* only update if pointing into area being moved or free'd */ dmm_update_pntr(flag,(HPNTR *)&curr->user,nbytes,base); } /* free or update pointer to new area */ } /* for curr */ /* update all pointer arrays */ xdll_use(pntr_id); /* use pointer linked-list */ for (ppntr = (PNTRPNTR) xdll_head(); /* go to head */ ppntr != NULL; ppntr = (PNTRPNTR) xdll_next() ) { nrecs = ppntr->nrecs; /* number of records in the structure */ nsize = ppntr->nsize; /* sizeof structure */ cond = ppntr->cond; /* user's function */ /* go through all pointers in structure and update their value */ for (cpntr = (HPNTR *) ppntr->user; /* starting byte */ /* cpntr now is address of start of a pointer to update */ nrecs-- > 0L; /* for all records in the structure */ cpntr = (HPNTR *) ADDHOFFSET(cpntr,nsize) ) /* next offset element in the structure */ { /* check what the structure is pointing too first */ hpntr = *((HPNTR *)cpntr); /* hpntr is contents of pointer */ /* convert pointer to an absolute address */ if (SUBHPNTRS(hpntr,abeg) >= 0L && SUBHPNTRS(hpntr,aend) <= 0L) { /* only update if pointing into area being moved or free'd */ /* if user cond func specified, update if it returns true */ /* if user cond func NULL, do update automatically */ if (cond == NULL || (*cond)(flag,(void **)cpntr) ) dmm_update_pntr(flag,(HPNTR *)cpntr,nbytes,base); } if (flag == 0) /* special case when freeing */ { /* see if you are pointing to area being free'd */ /* cpntr's can't be updated directly */ hpntr = (HPNTR)cpntr; /* convert pointer to an absolute address */ if (SUBHPNTRS(hpntr,abeg) >= 0L && SUBHPNTRS(hpntr,aend) <= 0L) *((HPNTR *)cpntr) = NULL; /* set to NULL contents */ } } /* for cpntr */ /* repeat for the pointer itself is */ /* this will update if the user's pointer is in an area being moved */ /* only update this is freeing or copying the entire alloc'd area */ /* or the pointer is a scalar (single record) pointer */ if (ppntr->nsize == 0L || /* always do it if scalar */ updateall ) /* or if copying the entire array */ { hpntr = (HPNTR)ppntr->user; if (SUBHPNTRS(hpntr,abeg) >= 0L && SUBHPNTRS(hpntr,aend) <= 0L) { /* only update if pointing into area being moved or free'd */ dmm_update_pntr(flag,(HPNTR *)&ppntr->user,nbytes,base); } } } /* for ppntr */ /* now move memory if not freeing */ if (flag > 0) /* if updating for a memory move */ dmm_memcpy(dest,abeg,movesize); /* reopen the link lists that may have moved */ /* just change entry points; sizes stay the same */ xdll_use(alloc_id); /* use pointer linked-list */ xdll_reopen (0,(void *) alloc_beg,0,-1); xdll_use(pntr_id); /* use pointer linked-list */ ADDRALIGN(pntr_beg); /* align address */ xdll_reopen (0,(void *)pntr_beg,0,-1); /* re-open in case it moved */ retval = 0; /* all pointers updated and memory moved */ error_return: RESTORE_CURR_LINK_ID(save); return(retval); } /*! dmm_update_pntr Add a value to a pointer if it points into mblock. Summary: #include */ static void dmm_update_pntr (int flag, HPNTR * pntr,long ldiff,HPNTR apntr) /*! Return Value: none Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int flag ;/* I true - add ldiff to pointer */ /* false - NULL out pointer */ HPNTR * pntr ;/* I Pointer to pointer to add to */ long ldiff ;/* I Value to add to it */ HPNTR apntr ;/* I Address to offset *pntr relative to */ /* Ignored if NULL */ #endif /*! Description: Add a constant `ldiff` to a pointer `pntr`. Will not add it if `pntr` is NULL. Note that `ldiff` can be either positive or negative. If `flag` is false, the pointer is just set to NULL. The `apntr` parameter is the base address of the area that `*pntr` is pointing to. This routine makes sure `*pntr` is equal to `apntr` plus the offset to `*pntr` so that is is aligned relative to this base address. This latter feature is only needed in wierd segment/offset type machines like Intel 386, etc., and normally is a total waste of time. It is assumed that `apntr` has already been corrected by `ldiff` before entering this routine. See also: Example: !*/ { unsigned long offset; if (pntr != NULL && *pntr != NULL) /* NULL's are out of there */ { if (flag) { /* update pointer; make sure its pointing inside mem block */ *pntr=ADDHOFFSET(*pntr,ldiff); /* point to new place */ if (apntr != NULL) /* align relative to apntr if not NULL */ { offset = SUBHPNTRS(*pntr,apntr); /* offset from aligned base */ /* offset is always >= 0 or something very wrong */ *pntr = (offset <= DMM_MAXUNSIGNED) ? /* base align if */ BASEALIGN(apntr,offset) : /* less than unsigned */ ADDHOFFSET(apntr,offset); /* align relative to base */ } } else *pntr = NULL; /* just set contents to NULL to indicate free */ } } /*! dmm_find_alloc Find an allocated memory area. Summary: #include */ static ALLOCPNTR dmm_find_alloc (void ** pntr) /*! Return Value: The address of alloc'd areas structure. NULL if not found. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void **pntr ;/* I Address of location of alloc'd area. */ #endif /*! Description: Searches through the allocation table for a `user` entry that matches `pntr`. It does this by searching the table. I considered having a current state so that mulitple calls with the same pntr would not have to research, but I don't see it being of much purpose and its a pain in the but to maintain. NOTE: this routine changes the current xdll table in use to `alloc_id` and does not restore the one used on entry, so be careful. See also: dmm_calloc(). Example: See example in dmm_mblock_alloc() !*/ { ALLOCPNTR curr; xdll_use (alloc_id); /* use allocation table link list */ for(curr = (ALLOCPNTR) xdll_head(); /* go to the head */ curr != NULL; /* while not at end or no list */ curr = (ALLOCPNTR) xdll_next() ) /* go to next one */ { if ((pntr == NULL && curr->user == NULL) || SUBHPNTRS(pntr,curr->user) == 0L) { /* diff of zero means equal of course */ return(curr); /* found it, return its address */ } } return (NULL); /* error return */ } /*! dmm_find_pntr Find a reference pointer. Summary: #include */ static PNTRPNTR dmm_find_pntr (void ** pntr) /*! Return Value: The address of pointer link-list structure. NULL if not found. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void **pntr ;/* I Address of pointer reference to find. */ #endif /*! Description: Searches through the pointer tables for a match with between `pntr` and the `user` entry. It does this by a linear search until it finds it or hits the end. Note that if `pntr` is NULL, it will find entries that point to no where (garbage). Returns positioned on the entry if found or NULL if not found. NOTE: This routine changes the current table in use to `pntr_id`. See also: Example: See example in dmm_mblock_alloc() !*/ { PNTRPNTR ppntr; PNTRPNTR retval=NULL; ABSPNTR abspntr,absbeg,absend; /* no doubt unsigned longs */ PNTR_TO_ABS(pntr,abspntr); /* used later */ xdll_use(pntr_id); /* use dup table */ for (ppntr = (PNTRPNTR) xdll_head(); /* through all dups */ ppntr != NULL; ppntr = (PNTRPNTR) xdll_next() ) { /* first see if pntr and ppntr->user are NULL (garbage entry) */ if (pntr == NULL && ppntr->user == NULL) { /* looks for first NULL entry if requested */ retval = ppntr; break; /* first NULL, break for loop and exit */ } /* make sure pntr is not equal to (ppntr->user) + i where */ /* i = 0,1,2,...,ppntr->nrecs-1 */ /* As you know, you cannot use modulo operators on pointers, so */ /* I am forced to use the PNTR_TO_ABS() macros */ /* the alternative is brute force search, which would be a dog */ PNTR_TO_ABS(ppntr->user,absbeg); /* beginning of memory area */ if (abspntr == absbeg) /* if equal to start, just exit */ { retval = ppntr; break; } if (ppntr->nsize > 0) /* if an array (i.e., not a scalar) */ { if (abspntr < absbeg || /* if before this memory block */ abspntr > (absend=absbeg+(ppntr->nrecs-1)*ppntr->nsize) ) /*last*/ continue; /* outside this memory section */ /* at this point you know its inside the address space of the array */ /* now comes the modulo operator; to find out if its in first element */ if ( (((unsigned long) (abspntr - absbeg)) % ppntr->nsize ) == 0L) { /* this means you found one of them in the pointer array */ retval = ppntr; /* found it, return links address */ break; /* break for loop, found it */ } } } return (retval); } /*! dmm_find_pntr_to_alloc See if a pntr is into the alloc table memory space. Summary: #include */ static ALLOCPNTR dmm_find_pntr_to_alloc (void ** pntr) /*! Return Value: The address of alloc link-list structure. NULL if not found. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void **pntr ;/* I Address of pointer reference to find. */ #endif /*! Description: Searches through the alloc table to see if `pntr` is in the memory space of an allocation table entry. If so, the address of the alloc table entry is returned. If not, a NULL is returned to indicate it does not point into this. This is handy for determining the number of records and size of the structure that a pointer points to. See also: Example: See example in dmm_mblock_alloc() !*/ { ALLOCPNTR curr; HPNTR beg,end; if (SUBHPNTRS(pntr,mblock_beg) >= 0L && SUBHPNTRS(pntr,mblock_end) <= 0L ) /* if in mblock */ { /* find out which curr entry it is in */ xdll_use(alloc_id); /* use alloc table */ for (curr = (ALLOCPNTR) xdll_head(); /* through all alloc entries */ curr != NULL; curr = (ALLOCPNTR) xdll_next() ) { beg = curr->mentry; end = ADDHOFFSET(beg,curr->tsize-1L); if (SUBHPNTRS(pntr,beg) >= 0L && SUBHPNTRS(pntr,end) <= 0L ) /* if in alloced area */ return(curr); /* return it */ } } return (NULL); } /*! dmm_gap_search Search for a gap >= size requested on a page boundary. Summary: #include */ static HPNTR dmm_gap_search (unsigned long size) /*! Return Value: Address of start of the gap if found, NULL if not found. (puts gap size in gap_size and preceeding alloc table entry in gap_alloc global statics ). Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned long size ;/* I Number of bytes to look for */ #endif /*! Description: Searches through the allocation table for a gap that is as large as or exceed the gap size requested. Leaves the alloc table positioned on the current gap. The gap must start on a page boundary. See also: Example: !*/ { ALLOCPNTR curr; savestruct save; HPNTR retval = NULL; /* static globals: unsigned long gap_size; ALLOCPNTR gap_alloc; */ SAVE_CURR_LINK_POS(save); /* save current link list in use */ xdll_use (alloc_id); /* use allocation table link list */ curr = NULL; /* start at beginning of memory */ do { if ((gap_size = dmm_gap_size(1,curr)) >= size) /* save gap_size */ { /* diff of zero means equal of course */ gap_alloc = curr; /* alloc'd area just before the gap;NULL beg mem */ retval = gapbeg; /* found one, return it */ break; /* break do {..} while */ } /* dmm_gap_size() sets gapbeg */ curr = (curr == NULL) ? /* first time through, set to head */ (ALLOCPNTR) xdll_head() : (ALLOCPNTR) xdll_next(); /* otherwise set to next */ } while (curr != NULL); RESTORE_CURR_LINK_POS(save); return (retval); /* return not found indicator */ } /*! dmm_gap_size Find size of memory gap after alloc_id alloc table entry. Summary: #include */ static unsigned long dmm_gap_size(int flag,ALLOCPNTR curr) /*! Return Value: Number of bytes in the gap. 0 if no gap. (beginning of gap left in gapbeg static ) Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int flag ;/* I true - find size of gap on next page */ /* boundary after curr */ /* false - find gap from end of user memory */ /* in curr */ ALLOCPNTR curr ;/* I Alloc table entry to check gap after */ /* NULL means check gap at head of memory */ #endif /*! Description: Finds the size of the memory gap after the current allocation table entry identified by the `curr` allocation table pointer. If `flag` is true, the beginning of the gap is on the first page after the end of `curr`. This is found by adding `curr->tsize` to the `curr->mentry`. If `flag` is false (0), then the gap is measured from the end of the user memory or `curr->mentry` + `curr->nrecs * curr->nsize`. A false value for `flag` is only used for walking through memory (actual user available memory) and for measuring the gap on the end of a memory to check if it can be expanded in size in place. Otherwise, gaps are almost always measure relative to a page boundary start (note that curr->tsize is always a multiple of the page size DMM_PAGE and that curr->mentry always starts on the boundary of at page; thus the gap size is always a multiple of the number of pages). See also: Example: !*/ { ALLOCPNTR next; HPNTR gapend; unsigned long size; /* static global: HPNTR gapbeg */ savestruct save; SAVE_CURR_LINK_POS(save); /* save current link list in use */ /* Look through ALL of the alloc entries dup links for duppntr */ xdll_use (alloc_id); /* use allocation table link list */ if (curr == NULL) /* head of memory indicator ? */ { gapbeg = mblock_beg; /* start of memory block */ next = (ALLOCPNTR) xdll_head(); /* head is next */ } else /* there is a block there */ { xdll_goto ((void *) curr); /* goto this location */ size = (flag) ? curr->tsize : (curr->nrecs * curr->nsize); gapbeg = ADDHOFFSET(curr->mentry, size); /* start of next gap */ next = (ALLOCPNTR) xdll_next(); /* goto next */ } if ( next == NULL) { /* end of memory, use end of mblock */ gapend = mblock_end; /* end of gap address */ } else /* there is a next entry */ { gapend = ADDHOFFSET(next->mentry,-1L); /* set to end of gap address */ } /* even though curr->tsize is the size of the allocated area, the */ /* real used area is size and the remaining bytes from size to tsize */ /* are considered part of a gap since they can be expanded into for reallocs */ /* but since this delta is less than a page size, it won't be used for alloc */ RESTORE_CURR_LINK_POS(save); return ((unsigned long) SUBHPNTRS(gapend,gapbeg) + 1 ); } /*! dmm_memcpy Copy any size block of potentially overlapping blocks of memory. Summary: #include */ static int dmm_memcpy (HPNTR dest,HPNTR src,unsigned long count) /*! Return Value: 0 if OK, -1 if illegal parameters. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC HPNTR dest ;/* I Destination Address */ HPNTR src ;/* I Source Address */ unsigned long count ;/* I Number of bytes to move */ #endif /*! Description: Copies any size block of memory from the `src` address to `dest`. The number of bytes to move is specified by `count`. Handles overlapping areas as well. Moving blocks up to size unsigned is handled by the MEMCPY macro, but sizes larger than unsigned (as is the case with MSDOS, but not OS9), you have to do fragmented block moves. The memory must be broken and moved in pages. Each page covering the range of an unsigned (or less as is the case with this implementation). This is no problem if the src and dest memory areas are not overlapping, but when they overlap, you have to move them is a way so that memory is not corrupted. There are two cases to consider: (1) src before dest in memory, overlapping, (2) dest before src in memory, overlapping. Case 1 must move pages in reverse from the end of src to the beginning of src. Case 2 is OK since the src moves up and won't corrupt. Note: These assume that pointer boolean and long add routines work for Microsoft-C huge pointers. See also: Example: !*/ { unsigned int pages,remains; HPNTR srcend,destend; unsigned maxcount = DMM_MAXCOUNT; if (dest == NULL || src == NULL) /* get those NULL's out of here */ goto error_return; if (count > 0 && SUBHPNTRS(src,dest) != 0) /* not very interesting if equal */ { /* determine number of pages and remainder */ srcend = ADDHOFFSET(src, (count - 1)); /* calculate ending addresses */ DMM_PAGES(count,pages,remains); /* check for case where there are pages and src is before dest and */ /* they overlap each other */ if (SUBHPNTRS(src,dest) < 0L && /* if src begin is before dest begin */ SUBHPNTRS(srcend,dest) >= 0L) /* and src end overlaps dest begin */ { /* move all full pages in reverse */ for ( srcend=ADDHOFFSET(srcend,1L), /* one past the end */ destend = ADDHOFFSET(dest,count); /* also one past the end */ pages > 0; /* for all pages */ pages-- ) { srcend=ADDHOFFSET(srcend,-maxcount);/* back up to start of block */ destend=ADDHOFFSET(destend,-maxcount); MEMCPY(destend,srcend,maxcount); } } else /* move all full pages forward */ { /* this is for non overlapping case and src above dest */ for ( ; /* src and dest point to start of move area */ pages > 0; /* for all pages */ pages--,src=ADDHOFFSET(src,maxcount), dest=ADDHOFFSET(dest,maxcount)) /* to next one */ { MEMCPY(dest,src,maxcount); } } /* src and dest point at start of what remains to be moved */ /* all pages moved, now move remains */ if (remains > 0) /* shouldn't need this */ MEMCPY(dest,src,remains); } /* end if src != dest */ return(FUNCOK); error_return: return (FUNCBAD); /* error return */ } /*! dmm_memset Set memory to value for huge pointers and long counts. Summary: #include */ static int dmm_memset (HPNTR dest,int c,unsigned long count) /*! Return Value: 0 if OK, -1 if illegal parameters. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC HPNTR dest ;/* I Destination Address */ int c ;/* I Char to set it to */ unsigned long count ;/* I Number of bytes to set */ #endif /*! Description: This sets a `count` bytes of a memory block starting at `dest` to a value `c`. It supports an unsigned long sized count, which `memset()` does not in Microsoft. It uses a paging method for machines which have less than 32-bit ints. Note that this is essentially a memset() function if the sizeof(long) is the same as sizeof(int). See also: Example: !*/ { unsigned int pages,remains; if (dest == NULL) goto error_return; /* clear all count bytes */ /* do it in pages for pitiful 16-bit machines */ DMM_PAGES(count,pages,remains); /* clear all whole pages */ for (; pages > 0; dest=ADDHOFFSET(dest,DMM_MAXCOUNT),--pages ) MEMSET(dest,c,DMM_MAXCOUNT); /* set all bytes to zero */ /* clear remainder of last page */ MEMSET(dest,c,remains); /* set all bytes to zero */ return(FUNCOK); error_return: return (FUNCBAD); /* error return */ } /*! dmm_pack_range Pack a range of the allocation table up or down. Summary: #include */ static void dmm_pack_range (ALLOCPNTR beg,ALLOCPNTR end,int upflag) /*! Return Value: None. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC ALLOCPNTR beg ;/* I Starting allocation table position */ /* NULL means from start of memory block */ ALLOCPNTR end ;/* I Ending allocation table position */ /* NULL means to the end of memory block */ int upflag ;/* I false - pack memory down in memory */ /* true - pack memory up in memory */ #endif /*! Description: Packs a range of memory bounded by the allocation table entries `beg` and `end`. It will eliminate all the gaps between these two allocation regions. The `upflag` when true will pack memory up against the start of the `end` memory, while if false will pack memory down agains the end of the `beg` memory. This routine is broken into two symmetric parts, one for each state of upflag. They are quite similar and maybe can be merged into one loop sometime by someone more clever than me. Improvements: - Add a total amount to pack parameter since the entire last gap on a pack does not necessarily have to be moved; this current implementation is pretty inefficient for large block packing. See also: Example: To pack all memory down, do a dmm_pack_range(NULL,NULL,0) !*/ { HPNTR abeg,aend; unsigned long offset; long nbytes; int error=0; savestruct save; SAVE_CURR_LINK_ID(save); /* save current link list in use */ xdll_use (alloc_id); /* use allocation table */ if (!upflag) /* if packing down */ { aend = (end == NULL) ? /* NULL means go to the end of memory */ ADDHOFFSET(mblock_end,1L) : /* 1 past the end; on a page */ end->mentry; /* go to beginning of end entry */ while (!error) /* can only get out by breaking out */ { if (beg != NULL) xdll_goto((void *)beg); /* get back where you were */ nbytes = dmm_gap_size(1,beg); /* get gap between me and next guy */ beg = (beg == NULL) ? /* NULL means start at beginning of memory */ /* this can only be done once in this while loop */ (ALLOCPNTR) xdll_head() : /* this is next entry */ (ALLOCPNTR) xdll_next(); /* move past end of gap */ /* if beg->mentry is >= end->mentry, break the while */ if (beg == NULL) /* nothing after gap, you're done */ break; if (SUBHPNTRS(beg->mentry,aend) >= 0L) /* you went past end marker,done */ break; offset = SUBHPNTRS(beg,alloc_beg); /* remember in case alloc moves */ dmm_update (1,beg,-nbytes,-1L,-1L); /* update the entry you are moving */ beg = (ALLOCPNTR) BASEALIGN(alloc_beg,offset); /* recover */ } /* end while () */ } /* end of if (!upflag) */ else /* upflag is true; pack memory up */ { abeg = (beg == NULL) ? /* NULL means go to the beg of memory */ ADDHOFFSET(mblock_beg,-1L) : /* one less than on a page boundary */ beg->mentry; /* go to end of beg entry */ while (!error) /* can only get out by breaking out */ { if (end != NULL) xdll_goto((void *)end); /* get back where you were */ end = (end == NULL) ? /* NULL means start at end of memory */ /* this can only be done once in this while loop */ (ALLOCPNTR) xdll_tail() : /* tail is next entry */ (ALLOCPNTR) xdll_prev(); /* move to prev to calc gap */ if (end == NULL) /* nothing before the gap, you're done */ break; if (SUBHPNTRS(end->mentry,abeg) <= 0L) /* you went past end marker,done */ break; nbytes = dmm_gap_size(1,end); /* get gap between me and next guy */ offset = SUBHPNTRS(end,alloc_beg); dmm_update (1,end,nbytes,-1L,-1L); /* update the entry you are moving */ end = (ALLOCPNTR) BASEALIGN(alloc_beg,offset); /* recover */ } /* end while () */ } /* end of if (!upflag) */ RESTORE_CURR_LINK_ID(save); } /*! dmm_sub_pntrs Take long difference of two huge pointers. Summary: #include */ static long dmm_sub_pntrs (HPNTR pntr1,HPTNR pntr2) /*! Return Value: The difference pntr1 - pntr2. Also returns compare states: 0 if pntr1 == pntr2, <0 if pntr1 < pntr2, >0 if pntr1 > pntr2. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC HPNTR pntr1 ;/* I Pointer 1 to compare */ HPNTR pntr2 ;/* I Pointer 2 to compare */ #endif /*! Description: Converts pointers to absolute addresses and subtracts them and returns the difference as a long integer. This routine is only needed due to Microsoft returning an int when differencing huge pointers instead of the more logical long that it should. Maybe new versions of their compiler will eliminate this routine. Currently I only use the macro SUBHPNTRS() to difference pointers; it in turn calls this functions. See also: Example: !*/ { ABSPNTR abs1,abs2; PNTR_TO_ABS(pntr1,abs1); /* macros */ PNTR_TO_ABS(pntr2,abs2); return( (long) (abs1 - abs2)); } /*! dmm_add_offset Add a long offset to a huge pointer. Summary: #include */ static HPNTR dmm_add_offset (HPNTR pntr,long offset) /*! Return Value: The pointer (pntr + offset). Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC HPNTR *pntr ;/* I Pointer to add offset to */ long offset ;/* I Amount to add (pos or neg) */ #endif /*! Description: Converts pointer to absolute address and adds a long offset. This routine is only needed due to C-terp not handling huge pointer arith. Use macro ADDHOFFSET(); not this direct call. See also: Example: !*/ { ABSPNTR abs; HPNTR retpntr; PNTR_TO_ABS(pntr,abs); /* macros */ abs += offset; /* add offset */ ABS_TO_PNTR(abs,retpntr); return ( retpntr); } /*! dmm_not_portable Check to make sure dmm routines are portable Summary: #include */ static int dmm_not_portable() /*! Return Value: 0 if portable, -1 if not portable. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ /*! Description: Checks to make sure assumptions about pointer sizes and their conversions are valid. Should check things pretty well for C_terp and Microsoft C on MSDOS and on OS-9. See also: Example: !*/ { #define DELTA 0x1ffffL /* some delta */ HPNTR pntr,pntr1,pntr2; ABSPNTR abs1,abs2; if (sizeof(ABSPNTR) < sizeof(HPNTR) || sizeof(ABSPNTR) < 4 ) /* basic size checks */ goto error_return; pntr1 = (HPNTR) 0x2fffffffL; /* some fake 30 bit address */ PNTR_TO_ABS(pntr1,abs1); pntr2 = ADDHOFFSET(pntr1,DELTA); /* add a big number */ PNTR_TO_ABS(pntr2,abs2); if ( SUBHPNTRS(pntr2,pntr1) != DELTA || SUBHPNTRS(pntr1,pntr2) != -DELTA || (abs2 - abs1) != DELTA || (abs1 - abs2) != -DELTA) goto error_return; ABS_TO_PNTR(abs1,pntr1); /* convert back */ ABS_TO_PNTR(abs2,pntr2); /* convert back */ if ( SUBHPNTRS(pntr2,pntr1) != DELTA || SUBHPNTRS(pntr1,pntr2) != -DELTA ) goto error_return; /* should still be same diff */ pntr = ADDHOFFSET(pntr2,-DELTA); PNTR_TO_ABS(pntr,abs2); /* see if same as abs1 again */ if (abs1 != abs2) /* better be same absolute address or else */ goto error_return; ADDRALIGN(pntr); /* see if align function works */ PNTR_TO_ABS(pntr,abs2); /* does not effect pntr abs value */ if (abs1 != abs2) /* better be same absolute address or else */ goto error_return; return(0); error_return: fatal_error = 1; /* this is a fatal error */ return(-1); } #endif /* #ifndef DMM_OFF */ /* === END OF FILE === */ ivtools-1.2.11a1/src/ComUtil/errfile.cc000066400000000000000000000157321214471147700176370ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* errfile.c Retrieve error format strings from file Externals: int err_readfile() History: Written by Scott E. Johnston, March 1989 */ #include #include #include #include "comutil.h" /* Manifest Constants */ #define MAX_FORMAT_LENGTH 80 /* Longest possible format string */ #define MAX_INPUT_LENGTH 132 /* Length of buffer for reading */ /* format string file */ /* Local Statics */ static char FormatBuffer[MAX_FORMAT_LENGTH+1]; /* Buffer for format string */ static char InputBuffer[MAX_INPUT_LENGTH+2]; /* Buffer for input text */ /*! err_readfile Read error message format string from file Summary: #include */ char * err_readfile(FILE* errstream,unsigned errnum ) /*! Return Value: Pointer to format string. NULL is never returned, because a substitute format string is constructed if `errnum` is not found. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC FILE * errstream ;/* I Error message format string file pointer. */ unsigned errnum ;/* I Number of error message to search for. */ #endif #ifdef DOC /*! Description: `err_readfile` reads a format string which can be used to build an error message. `errstream` is a pointer to the file which contains the format strings. The `errstream` file is designed to serve a dual role, to define constants for various `errnum`s in a C program, and to store the error message format strings for access once an error occurs. An example entry in this file is as follows: #define ERR_OUTOFBOUNDS 12 /* "process1: Input size parameter out of bounds (%d)" */ `err_readfile` searches for definitions of macros that begin with "ERR_", then reads the positive integer value that follows. When the entry that matches `errnum` is found, a C-format string buried in the following comment is extracted, and a pointer to this string is returned. See Also: err_open, err_submit, err_match, err_print, err_clear !*/ #endif /* DOC */ { /* Constants for state machine to search for format string */ #define LOOK_POUND 0 /* Looking for start of "#define" */ #define LOOK_DEFINE 1 /* Looking for "define" token next */ #define LOOK_ERRMACRO 2 /* Looking for "ERR_" macro next */ #define LOOK_DFINT 3 /* Looking for default integer next */ #define LOOK_SLASH 4 /* Looking for "/" to prestart comment */ #define LOOK_STAR 5 /* Looking for "*" to start comment */ #define LOOK_STRING 6 /* Looking for string in comment */ #define LOOK_DONE 7 /* Found everything needed */ int search_state = LOOK_POUND; /* State of what has been found */ /* in error file */ unsigned int token_type; /* Type of token returned from lexscan */ unsigned int linenum = 0; /* Current line number in error file */ unsigned int colnum = 0; /* Current location in buffer */ unsigned int token_length; /* Token length */ unsigned int token_start; /* Start of token in FormatBuffer */ int status; /* Status from lexscan */ /* Rewind error file */ rewind( errstream ); /* Search through tokens in error file until */ /* conditions are met, or end-of-file */ do { /* Use lexical scanner to provide next token in error file */ /* Don't worry about status return, because token_type */ /* will be set to TOK_NONE */ status = lexscan( errstream, (char* (*)(char*, int, void*)) fgets, (int (*)(void*)) ffeof, (int (*)(void*)) fferror, NULL, NULL, NULL, NULL, 0, NULL, InputBuffer, MAX_INPUT_LENGTH+2, &colnum, FormatBuffer, MAX_FORMAT_LENGTH+1, &token_length, &token_type, &token_start, &linenum ); /* State machine that searches for the right format string */ switch ( search_state ) { case LOOK_POUND: if( token_type == TOK_OPERATOR && FormatBuffer[0] == '#' && (token_start == 0 || isspace( InputBuffer[token_start-1] ))) search_state = LOOK_DEFINE; break; case LOOK_DEFINE: if( token_type == TOK_IDENTIFIER && strcmp( FormatBuffer, "define" ) == 0 && token_start > 0 && InputBuffer[token_start-1] == '#' ) search_state = LOOK_ERRMACRO; else search_state = LOOK_POUND; break; case LOOK_ERRMACRO: if( token_type == TOK_IDENTIFIER && strncmp( FormatBuffer, "ERR_", 4 ) == 0 ) search_state = LOOK_DFINT; else search_state = LOOK_POUND; break; case LOOK_DFINT: if( token_type == TOK_DFINT && *(int *)FormatBuffer == errnum ) search_state = LOOK_SLASH; else search_state = LOOK_POUND; break; case LOOK_SLASH: if( token_type == TOK_OPERATOR && FormatBuffer[0] == '/' ) search_state = LOOK_STAR; else search_state = LOOK_POUND; break; case LOOK_STAR: if( token_type == TOK_OPERATOR && FormatBuffer[0] == '*' && token_start > 0 && InputBuffer[token_start-1] == '/' ) search_state = LOOK_STRING; else search_state = LOOK_POUND; break; case LOOK_STRING: if( token_type == TOK_STRING ) search_state = LOOK_DONE; else search_state = LOOK_POUND; break; } } while( search_state != LOOK_DONE && status == 0 && token_type != TOK_EOF && !ferror( errstream )); /* Done searching through tokens in error file */ /* until conditions are met, or end-of-file */ /* Finalize format string (if necessary) and return pointer to it */ if( status != 0 ) sprintf( FormatBuffer, "Status %d returned from error system", status ); else if( token_type == TOK_EOF ) sprintf( FormatBuffer, "Error number %d (no error message)", errnum ); else if( ferror( errstream )) sprintf( FormatBuffer, "Error in accessing error message file" ); return FormatBuffer; } ivtools-1.2.11a1/src/ComUtil/errsys.cc000066400000000000000000000505631214471147700175370ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott E. Johnston * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* errsys.c General error handling support Externals: int err_open(), char * err_read(), void err_set(), void err_get(), void err_print(), void err_str(), void err_clear(), void err_level(), FILE *err_fileio(), int err_cnt() History: Written by Scott E. Johnston, March 1989 */ #include #include #include #include #include #include "comutil.ci" /* Manifest Constants */ #define MAX_ERROR_OPENS 16 /* Maximum number of err_open calls */ #define MAX_ERROR_MESSAGE 512 /* Room for error messages */ #define MAX_ERROR_SETS 16 /* Maximum depth of error messages */ #define ERROR_IO_FILE ".errsys.comterp" /* Path name of error I/O file */ /* Local Statics */ static FILE *ErrorStreams[MAX_ERROR_OPENS]; /* Buffer for error file ptrs */ static char ErrorMessages[MAX_ERROR_MESSAGE]; /* Buffer for error messages */ static struct { /* Buffer for error structs */ unsigned errid; unsigned errnum; unsigned erroff; unsigned errlen; } ErrorStructs[MAX_ERROR_SETS]; static int Initialize = TRUE; /* Triggers error system initialization */ static int TopError = -1; /* Topmost error on stack */ static int NextErrOff = 0; /* Next place to store error string */ static BOOLEAN TooManyErrors = FALSE; /* TRUE when ErrorStreams overflows */ static int ErrorLevel = USER_LEVEL; /* 0 = user level */ /* 1 = programmers level */ static FILE *ErrorIOFile = NULL; /* Pointer to error I/O file */ static struct { int id; const char* msg; } default_errmsgs[] = { {1000, "Memory limits exceeded"}, {1100, "(%d) Line greater than %d characters long"}, {1101, "(%d) Token longer than maximum length of %d"}, {1102, "(%d) End of file encountered within comment"}, {1103, "(%d) End of file encountered within string or character constant"}, {1104, "(%d) Illegal keyword"}, {1105, "(%d) Illegal character constant"}, {1106, "(%d) Non-octal digit in octal character constant"}, {1107, "(%d) Hexadecimal digit must follow \\x"}, {1108, "(%d) Octal character constant larger than one byte"}, {1109, "(%d) Hexadecimal character constant larger than one byte"}, {1110, "(%d) Illegal integer constant"}, {1111, "(%d) Illegal octal constant"}, {1112, "(%d) Illegal hexadecimal constant"}, {1113, "(%d) Illegal floating-point constant"}, {1114, "(%d) Integer constant exceeds maximum possible size"}, {1115, "(%d) Octal constant exceeds maximum possible size"}, {1116, "(%d) Hexadecimal constant exceeds maximum possible size"}, {1117, "(%d) Floating point constant exceeds maximum possible size"}, {1118, "(%d) Floating point constant exceeds minimum possible size"}, {1119, "(%d) Illegal character (ASCII %d)"}, {1120, "(%d) Unexpected newline in string constant"}, {1121, "(%d) Unexpected newline in character constant"}, {1122, "(%d) Insufficient separation from trailing constant"}, {1123, "(%d) Error in writing to output file"}, {1124, "(%d) Error in reading input file"}, {1125, "(%d) New-line expected before end-of-file"}, {1200, "Illegal operator (%c)"}, {1201, "Maximum number of operators exceeded (%d)"}, {1202, "Postfix version of %s can't coexist with binary and prefix versions"}, {1203, "Binary version of %s can't coexist with both unary versions"}, {1204, "Postfix version of %s can't coexist with binary version"}, {1205, "Binary version of %s can't coexist with postfix version"}, {1206, "Operator table has not been created"}, {1207, "Priority (%d) out of range"}, {1300, "(%d) Unexpected operator (%s)"}, {1301, "(%d) Unexpected identifier (%s)"}, {1302, "(%d) Unexpected literal constant (%s)"}, {1303, "(%d) Unexpected keyword (%s)"}, {1304, "(%d) Unexpected end-of-file"}, {1305, "(%d) Unexpected right parenthesis"}, {1306, "(%d) Unexpected right bracket"}, {1307, "(%d) Unexpected right brace"}, {1308, "(%d) Ambiguous operator (%s)"}, {1309, "(%d) Unexpected left parenthesis"}, {1310, "(%d) Unexpected left bracket"}, {1311, "(%d) Unexpected left brace"}, {1312, "(%d) Unexpected right angle bracket"}, {1313, "(%d) Unexpected left angle bracket"}, {1314, "(%d) Unexpected double right angle bracket"}, {1315, "(%d) Unexpected double left angle bracket"}, {5201, "Bad parameters in function call"}, {5202, "Illegal symbol identifier in type list"}, {5203, "Illegal simple type in type identifier list"}, {5204, "Illegal aggregate type; must be ARRAY or STREAM only"}, {5205, "Type identifier is outside table limits"}, {5206, "Type identifier is for an empty table entry"}, {6000, "Attempted read/write before file open"}, {6001, "Input string begins with internal delimeter: .!#ID#"}, {6002, "Error during file open"}, {3000, "Unknown command supplied to interpreter: %s"}, {3001, "Divide by zero"}, {3002, "Incomplete expression"}, {3003, "Mod by zero"}, {-1, NULL}}; /*! err_open Open access to error file through error system Summary: #include */ int err_open(const char * errfile ) /*! Return Value: unique identifier supplied to other error system calls, -1 if error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC const char * errfile ;/* I Filename of error file. */ #endif /*! Description: `err_open` opens a specific error file, then returns a unique identifier to be supplied to other error system calls. See Also: err_read, err_set, err_get, err_print, err_str, err_clear, err_level, err_fileio, err_cnt !*/ #undef TITLE #define TITLE "err_open" { char fullpath[PATH_LEN]; int findex; char *errpath; FILE *fptr = NULL; /* Initialize array of pointers to open error files */ if( Initialize ) { for( findex=0; findex */ const char * err_read(int errid,unsigned errnum) /*! Return Value: Pointer to format string. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int errid ;/* I Identifier generated by `err_open`. */ unsigned errnum ;/* I Number of format string to search for. */ #endif /*! Description: `err_read` reads a format string from an error file that is then used to build a final error message. See `err_readfile` for further details on the file format. Typically the pointer to the format string returned by `err_read` is supplied to `sprintf` for its format string argument, in order to build the final error message, then the result is passed to `err_set`, placing it on a stack of error messages that can be displayed to the user via `err_print and err_str`. See Also: err_readfile, err_open, err_set, err_get, err_print, err_str, err_clear, err_level, err_fileio, err_cnt !*/ { /* Error checking */ if( errid < 0 || errid >= MAX_ERROR_OPENS ) KANIL( "errid out of bounds" ); /* Allow for missing comterp.err file */ if( ErrorStreams[errid] == NULL ) { int i=0; while(default_errmsgs[i].msg!=NULL&&default_errmsgs[i].id!=errnum) i++; if (!default_errmsgs[i].msg) { KANIL1( "errnum not found", errnum ); } else return default_errmsgs[i].msg; } /* Retrieve and return the string */ return err_readfile( ErrorStreams[errid], errnum ); } /*! err_set Submit error to error system Summary: #include #include */ void err_set(int errid,unsigned errnum,unsigned errlen) /*! Return Value: no error return Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int errid ;/* I Identifier generated by `err_open`. */ unsigned errnum ;/* I Error number */ unsigned errlen ;/* I Length of error message string just printed by `fprintf` to file pointer returned from `err_fileio`. */ #endif /*! Description: `err_set` submits an error to the error system. `errnum` is the error number associated with the error. `errlen` is the length of the string just printed by `fprintf` to a file pointer returned from `err_fileio`. `errid` was returned from a previous call to `err_open`. See Also: err_open, err_read, err_get, err_print, err_str, err_clear, err_level, err_fileio, err_cnt !*/ { /* Error checking */ if( errid < 0 || errid >= MAX_ERROR_OPENS /* || ErrorStreams[errid] == NULL */) { KANRET( "errid out of bounds" ); return; } /* Add errid and errnum to stack, if they fit */ if( TopError+1 < MAX_ERROR_SETS ) { TopError++; ErrorStructs[TopError].errid = errid; ErrorStructs[TopError].errnum = errnum; ErrorStructs[TopError].erroff = NextErrOff; ErrorStructs[TopError].errlen = errlen; NextErrOff += errlen; } else TooManyErrors = TRUE; } /*! err_get Retrieve last error submitted to error system Summary: #include #include */ void err_get(int * errid,unsigned * errnum ) /*! Return Value: no error return Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int * errid ;/* I Identifier generated by `err_open`. */ unsigned * errnum ;/* I Positive error number, that should have a unique association with `errid`. */ #endif /*! Description: `err_get` retrieves information about the last error submitted to the error system. `errid` is the identifier used when `err_get` was called. `errnum` is the error number associated with the error. See Also: err_open, err_read, err_set, err_print, err_str, err_clear, err_level, err_fileio, err_cnt !*/ { /* Check if any errors are present */ if( TopError == -1 ) { *errid = -1; return; } /* Return errid and errnum */ *errid = ErrorStructs[TopError].errid; *errnum = ErrorStructs[TopError].errnum; return; } /*! err_print Print errors in error system Summary: #include #include */ void err_print(FILE * outstream,const char * command) /*! Return Value: no error return Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC FILE * outstream ;/* I File pointer for output of errors. */ char * command ;/* I Name of command where error occurred */ #endif /*! Description: `err_print` prints the current error message(s) to `outstream`. If `user_level` is false, every error message on the stack gets printed. If `user_level` is true, only the topmost error message gets printed, and the `command` name gets substituted for any function name at the front of the error message (function names are found by looking for a legal function name followed by a colon and at least one space). See Also: err_open, err_read, err_set, err_get, err_clear, err_level, err_fileio, err_cnt !*/ { int index; char *ptr; char buffer[BUFSIZ]; /* Abort if no errors have occurred */ if( TopError == -1 ) return; /* Rewind error I/O file */ if( ErrorIOFile == NULL ) return; rewind( ErrorIOFile ); /* Print overflow messages */ if( TooManyErrors ) { fprintf( outstream, "*** Warning: Error depth greater than %d ***\n", MAX_ERROR_SETS ); fprintf( outstream, " *** Unable to print all errors ***\n" ); } /* If programmer level error reporting dump the entire stack */ if( ErrorLevel == PROG_LEVEL ) { for( index=TopError; index>=0; index-- ) { fseek( ErrorIOFile, (long)ErrorStructs[index].erroff, SEEK_SET ); fgets( buffer, MIN( BUFSIZ, ErrorStructs[index].errlen+1), ErrorIOFile ); fprintf( outstream, "%s\n", buffer ); } fprintf( outstream, "%s: Error in execution\n", command ); } /* Else if user level error reporting, print the topmost error */ /* with command substituted for the function name */ else { fseek( ErrorIOFile, (long)ErrorStructs[TopError].erroff, SEEK_SET ); fgets( buffer, MIN( BUFSIZ, ErrorStructs[TopError].errlen+1), ErrorIOFile ); ptr = buffer; if( isident( *ptr )) ++ptr; while( isident( *ptr ) || isdigit( *ptr )) ++ptr; if( *ptr == ':' ) { ptr++; while( isspace( *ptr )) ptr++; } else ptr = buffer; fprintf( outstream, "%s: %s\n", command, ptr ); } /* Clear the error messages */ err_clear(); return; } /*! err_str return the errors as strings from the error system Summary: #include #include */ void err_str(char * errbuf,int bufsiz,const char * command) /*! Return Value: no error return Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC char * errbuf ;/* O Buffer to store formated error string */ int bufsiz ;/* I size of errbuf */ char * command ;/* I Name of command where error occurred */ #endif /*! Description: `err_str` formats the current error message(s) to `errbuf`. If `user_level` is false, every error message on the stack gets formatted. If `user_level` is true, only the topmost error message gets formatted, and the `command` name gets substituted for any function name at the front of the error message (function names are found by looking for a legal function name followed by a colon and at least one space). See Also: err_open, err_read, err_set, err_get, err_print, err_clear, err_level, err_fileio, err_cnt !*/ { int index; char *ptr; char buffer[bufsiz]; /* Abort if no errors have occurred */ if( TopError == -1 ) return; /* Rewind error I/O file */ if( ErrorIOFile == NULL ) return; rewind( ErrorIOFile ); /* Print overflow messages */ if( TooManyErrors ) { sprintf( errbuf, "*** Warning: Error depth greater than %d ***\n", MAX_ERROR_SETS ); sprintf( errbuf, " *** Unable to print all errors ***\n" ); } #if 0 /* If programmer level error reporting dump the entire stack */ if( ErrorLevel == PROG_LEVEL ) { for( index=TopError; index>=0; index-- ) { fseek( ErrorIOFile, (long)ErrorStructs[index].erroff, SEEK_SET ); fgets( buffer, MIN( BUFSIZ, ErrorStructs[index].errlen+1), ErrorIOFile ); fprintf( outstream, "%s\n", buffer ); } fprintf( outstream, "%s: Error in execution\n", command ); } /* Else if user level error reporting, print the topmost error */ /* with command substituted for the function name */ else { #endif fseek( ErrorIOFile, (long)ErrorStructs[TopError].erroff, SEEK_SET ); fgets( buffer, MIN( BUFSIZ, ErrorStructs[TopError].errlen+1), ErrorIOFile ); ptr = buffer; if( isident( *ptr )) ++ptr; while( isident( *ptr ) || isdigit( *ptr )) ++ptr; if( *ptr == ':' ) { ptr++; while( isspace( *ptr )) ptr++; } else ptr = buffer; sprintf( errbuf, "%s: %s", command, ptr ); #if 0 } #endif /* Clear the error messages */ err_clear(); return; } /*! err_clear Clear all errors in error system Summary: #include #include */ void err_clear( ) /*! Return Value: no error return Parameters: none /*! Description: `err_clear` clears all errors in the error system, restoring it to an initial state. See Also: err_open, err_read, err_set, err_get, err_print, err_str, err_level, err_fileio, err_cnt !*/ { /* Reset error stack */ TopError = -1; NextErrOff = 0; TooManyErrors = FALSE; fclose( ErrorIOFile ); ErrorIOFile = NULL; #if 0 unlink( ERROR_IO_FILE ); #endif return; } /*! err_level Set level of error printing by error system Summary: #include #include */ void err_level(unsigned level) /*! Return Value: no error return Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned level ;/* I USER_LEVEL or PROG_LEVEL */ #endif /*! Description: `err_level` sets the level of error printing performed by the error system when `err_print` or `err_str` is called. Two values can currently be supplied to `err_level` (defined in "ComUtil/comutil.h"): USER_LEVEL Output only topmost error message PROG_LEVEL Output entire stack of error messages See Also: err_open, err_read, err_set, err_get, err_print, err_str, err_clear, err_fileio, err_cnt !*/ { ErrorLevel = level; return; } /*! err_fileio Return pointer to file for error I/O Summary: #include #include */ FILE *err_fileio() /*! Return Value: pointer to error I/O file Parameters: none /*! Description: `err_fileio` returns a pointer to the file used for error I/O. In typical usage, this would be supplied as the first argument to `fprintf`. The second argument would be supplied by `err_read` (or its equivalent), and the rest of the arguments would be application specific. See Also: err_open, err_read, err_set, err_get, err_print, err_str, err_clear, err_level, err_cnt !*/ { #if 0 char *errpath; if( ErrorIOFile == NULL ) { errpath = tmpnam(nil); ErrorIOFile = fopen( errpath, "w+" ); if( ErrorIOFile == NULL ) KANIL1( "Unable to open error I/O file %s", errpath ); } return ErrorIOFile; #else if( ErrorIOFile == NULL ) { ErrorIOFile = tmpfile(); if( ErrorIOFile == NULL ) KANIL( "Unable to open error I/O file" ); } return ErrorIOFile; #endif } /*! err_cnt Return current count of error messages Summary: #include #include */ int err_cnt() /*! Return Value: count of current error messages Parameters: none /*! Description: `err_cnt` returns the number of error messages on the error message stack. See Also: err_open, err_read, err_set, err_get, err_print, err_str, err_clear, err_level, err_fileio !*/ { return TopError+1; } ivtools-1.2.11a1/src/ComUtil/funcptrs.cc000066400000000000000000000054651214471147700200550ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ extern "C" { /* funcptrs.c Routines to convert feof and ferror into function pointers Externals: int ffeof(), int fferror() History: Written by Scott E. Johnston, March 1989 */ #include #include "comutil.ci" /*! ffeof Function version of feof macro Summary: #include */ int ffeof(FILE * stream) /*! Return Value: 0 if not at end of file, otherwise non-zero  Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC FILE * stream ;/* I Pointer to `FILE` structure */ #endif /*! Description: `ffeof` determines whether the end of `stream` has been recognized. It is functionally similar to `feof`, except it is implemented as a function instead of a macro. This allows it to be passed as a function pointer to other functions. !*/ { return feof( stream ); } /*! fferror Function version of ferror macro Summary: #include */ int fferror(FILE * stream) /*! Return Value: 0 if not at end of file, otherwise non-zero  Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC FILE * stream ;/* I Pointer to `FILE` structure */ #endif /*! Description: `fferror` tests for an error in reading or writing `stream`. It is functionally similar to `ferror`, except it is implemented as a function instead of a macro. This allows it to be passed as a function pointer to other functions. !*/ { return ferror( stream ); } } ivtools-1.2.11a1/src/ComUtil/mblock.cc000066400000000000000000000271421214471147700174540ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* MBLOCK.C Allocate a memory block and return a unique identifier. Externals: Summary: Functions to support memory allocation and return unique integer identifiers to be used to point to the block. The identifier allows the memory block to be moved but still have the same identifier. A pointer to the start of the block would not be guaranteed to point always to the same place. History: Written by Robert C. Fitch, 26 Aug 1989 */ #include #include "comutil.ci" /* comutil.ci includes stdlib.h and malloc.h */ #ifndef DMM_OFF /* This contains all information for an open mblock */ typedef struct { unsigned nel; /* number of elements in the block */ unsigned size; /* size of the element in bytes */ /* 0 size means this id cell is available */ char *head; /* pointer to the start of the block */ } mblock; /* some pointers for the different open mblocks */ static mblock *mblock_head,*mblock_curr; /* updatable pointers */ static int nmblocks=0; /* number of lists in mblock id array */ /* this makes sure an id is valid and the entry has an allocated mem block */ #define CHECKID {\ if(id < 0 || id >= nmblocks) goto error_return;\ mblock_curr=mblock_head+id;\ if(mblock_curr->size == 0) goto error_return; } /*! mblock_open Open a memory block of specified size. Summary: #include */ int mblock_open (unsigned nel,unsigned size) /*! Return Value: != -1 identifier for this mblock structure, -1 if insufficient memory. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned nel ;/* I number of elements to allocate */ unsigned size ;/* I number of bytes per element */ #endif #ifdef DOC /*! Description: Allocates an area of memory (using the dmm_calloc() function) and returns a unique integer identifier that can be used to reference the starting address of the memory block. NOTE: it is ok to specify a memory block with `nel` of zero and increase its size later using mblock_resize(), but the `size` must always be greater than zero. See Also: mblock_close(), mblock_pntr(), mblock_resize(). Example: main() { int id1, id2 char *pntr1; int *pntr2; unsigned nel; unsigned long nbytes1,nbytes2; extern void *mblock_pntr(); /* open a memory block with 2000 bytes in it */ if ( (id1 = mblock_open(2000,sizeof(char))) == -1) { fprintf(stderr,"Couldn't open memory block #1\n"); return(-1); } /* open a 2nd memory block with 1000 integers */ if ( (id1 = mblock_open(1000,sizeof(int))) == -1) { fprintf(stderr,"Couldn't open memory block #2\n"); return(-1); } /* get the starting address of the memory blocks */ pntr1 = (char *) mblock_pntr(id1); pntr2 = (int *) mblock_pntr(id2); /* get the size of the memory blocks in bytes and print out */ /* get the number of elements in the mblock and the total */ /* number of bytes used for block 1 but do not get size of element */ /* get just the total bytes for block 2 */ mblock_sizes(id1,&nel1,NULL,&nbytes1); /* NULL says don't return it */ mblock_sizes(id2,NULL,NULL,&nbytes2); printf("Mblock 1 id# %d has %u records and %lu bytes\n", id1,nel,nbytes1); printf("Mblock 2 id# %d has %lu bytes\n",id2,nbytes2); /* increase the size of the second mem block to 3000 integers */ if ( mblock_resize(id2,3000)) != 0) { fprintf(stderr,"Couldn't increase size of memory block #2\n"); return(-1); } /* close both memory blocks */ mblock_close(id1); mblock_close(id2); } !*/ #endif /* DOC */ { int id,found; int retval = -1; #define ALLOC_NUM 4 /* alloc 4 id blocks at a time */ if (nmblocks <= 0) /* see if no callocing has been done yet */ { /* calloc ALLOC_NUM entires in mblock structure array */ if ( dmm_calloc((void **)&mblock_head,(long)ALLOC_NUM,sizeof(mblock)) != 0) goto error_return; /* goto error return; no message */ /* declare pointers */ if ( dmm_pntr_alloc(&mblock_head->head) != 0 || dmm_pntr_scalar(&mblock_curr) != 0 ) { dmm_free((void **)&mblock_head);/* free mblock and all alloc pointers */ goto error_return; } mblock_curr = mblock_head; /* set to be the same */ id = 0; /* set id to top of this list */ /* zeroes automatically null out everything */ nmblocks = ALLOC_NUM; /* One mblock so far */ } else /* nmblocks > 0 */ { /* first search current list for any empty ones and use them first */ for (id=found=0, mblock_curr=mblock_head; id < nmblocks; id++,mblock_curr++) { if (mblock_curr->size == 0) /* is it empty ?? */ { found = 1; /* set this flag true;OS9 didn't like it in 'if ()' */ break; /* found one, break for loop and use it */ } } if (!found) /* true if no empty ones found */ { /* which means you have to alloc some more space */ /* dmm_realloc() also clears new memory locations, so don't worry */ /* about them being zero; they are */ if ( dmm_realloc((void **)&mblock_head,(long)nmblocks+ALLOC_NUM) != 0) goto error_return; /* just return an error; no message */ /* can't have any more mblocks */ mblock_curr = mblock_head + nmblocks; /* position of newest entry */ mblock_curr->size = 0; /* make it empty */ id = nmblocks; /* use this as id, then incr number of mblocks by 1 */ nmblocks += ALLOC_NUM; /* update the total */ } } /* at this point id is the identifying index and mblock_curr points to */ /* an available mblock entry. Now calloc the mblock memory */ /* both structure arrays are cleared by calloc's which will automatically */ /* make all of their entries empty */ if ( dmm_calloc((void **)&mblock_curr->head,(long)nel,size) != 0) goto error_return; /* goto error return; no message */ /* set the sizes into the list and all done */ mblock_curr->nel = nel; mblock_curr->size = size; retval = id; error_return: /* return an error code */ return (retval); } /*! mblock_close Close the specified or all mblocks. Summary: #include */ int mblock_close (int id) /*! Return Value: 0 if close OK, -1 if error. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int id ;/* I id returned by mblock_open() to close or -1 if all mblocks are to be closed */ #endif /*! Description: Close the specified mblock. If id is -1,then close all open mblocks. See also: mblock_open() Example: See end of example in mblock_open (). !*/ { int i; int retval = -1; if (id != -1) /* just close one */ { if (id >= nmblocks) /* error if out of range */ goto error_return; i = id; } else i = 0; for (mblock_curr=mblock_head+i; isize > 0 ) /* see if opened */ { mblock_curr->size = 0; /* free this entry */ /* it is open, free internal pointers */ dmm_free ((void **)&mblock_curr->head); } if (id != -1) /* if only closing 1, exit */ break; } retval = 0; error_return: return (retval); /* error return */ } /*! mblock_resize Change the size of an already open'd mblock Summary: #include */ int mblock_resize (int id,unsigned nel) /*! Return Value: != -1 identifier for this mblock structure, -1 if insufficient memory. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int id ;/* I mblock identifier from mblock_open() */ unsigned nel ;/* I number of elements to change to */ #endif /*! Description: Changes the size of a memory block already allocated. The number of elements to change to is specified by `nel`. The size of each element stays the same as specified in mblock_open(). See Also: mblock_open() Example: !*/ { int retval = -1; CHECKID; /* make sure id is valid */ if ( dmm_realloc((void **)&mblock_curr->head,(long)nel) != 0) goto error_return; /* just return an error; no message */ mblock_curr->nel = nel; /* set new size in id structure */ retval = 0; error_return: /* return an error code */ return (retval); } /*! mblock_pntr Return pointer in specified mblock. Summary: #include */ void *mblock_pntr(int id) /*! Return Value: pntr to mblock position if OK, NULL if error. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int id ;/* I mblock identifier from mblock_open() */ #endif /*! Description: Returns a pointer to the position in the mblock specified by the `id`. A NULL is returned if the block is not in use. See also: Example: See end of example in mblock_open (). !*/ { void *retval = NULL; CHECKID; retval = (void *) (mblock_curr->head); error_return: return (retval); /* error return */ } /*! mblock_sizes Returns memory block size information. Summary: #include */ int mblock_sizes(int id,unsigned * nel,unsigned * size,unsigned long * nbytes) /*! Return Value: 0 if OK, -1 if error. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int id ;/* I mblock identifier from mblock_open() */ unsigned *nel ;/* O returns number of elements if NULL, do not return this value. */ unsigned *size ;/* O returns size of element in bytes if NULL, do not return this value. */ unsigned long *nbytes ;/* O returns total number of bytes in the block, if NULL, do not return this value. */ #endif /*! Description: Returns size information in the parameters `nel`,`size` and `nbytes'. If any of these pointers are NULL, no value is returned. The value returned for `nbytes` is just the product of `nel` and `size`, but is a long instead of just an unsigned. DON'T FORGET THOSE & symbols in your calling routine!!! See also: Example: See end of example in mblock_open (). !*/ { int retval=-1; CHECKID; if (nel != NULL) *nel = mblock_curr->nel; if (size != NULL) *size = mblock_curr->size; if (nbytes != NULL) *nbytes = ((unsigned long) mblock_curr->nel) * mblock_curr->size; retval = 0; error_return: return (retval); /* error return */ } #endif /* ifndef DMM_OFF */ ivtools-1.2.11a1/src/ComUtil/optable.cc000066400000000000000000000704471214471147700176410ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* optable.c COMTERP operator table support routines Externals: int opr_tbl_create(), int opr_tbl_insert(), int opr_tbl_print(), int opr_tbl_entries(), int opr_tbl_operid(), int opr_tbl_commid(), int opr_tbl_priority(), BOOLEAN opr_tbl_rtol(), int opr_tbl_optype(), int opr_tbl_default() Summary: History: Written by Scott E. Johnston, April 1989 */ #include #include #include #include #include #define TITLE "optable" /* Entry in operator table */ typedef struct _opr_tbl_entry opr_tbl_entry; struct _opr_tbl_entry { int operid; /* Id for string that defines operator */ int commid; /* Id for command associated with operator */ unsigned priority; /* Relative priority of operator */ BOOLEAN rtol; /* Flag for right-to-left operator associativity */ unsigned optype; /* Type of operator: OPTYPE_BINARY, OPTYPE_UNARY_PREFIX, or OPTYPE_UNARY_POSTFIX */ }; /* Static Variables */ static opr_tbl_entry /* The operator table */ *OperatorTable = NULL; static unsigned NumOperators; /* Number of operators currently in table */ static unsigned MaxOperators; /* Maximum number of operators */ static unsigned MaxPriority; /* Maximum priority encountered so far */ /* Minimum can always be considered zero */ static int last_operid = -1; /* variables for preserving default table once created */ static int opr_tbl_is_default = 0; static opr_tbl_entry* opr_tbl_default_table = NULL; static unsigned opr_tbl_default_numop; static unsigned opr_tbl_default_maxop; static unsigned opr_tbl_default_maxpri; static int opr_tbl_default_lastop; void* opr_tbl_ptr_get() { return (void*)OperatorTable; } void opr_tbl_ptr_set(void* ptr) { OperatorTable = (opr_tbl_entry*)ptr; } unsigned opr_tbl_numop_get() { return NumOperators; } void opr_tbl_numop_set(unsigned numop) { NumOperators = numop; } unsigned opr_tbl_maxop_get() { return MaxOperators; } void opr_tbl_maxop_set(unsigned maxop) { MaxOperators = maxop; } unsigned opr_tbl_maxpri_get() { return MaxPriority; } void opr_tbl_maxpri_set(unsigned maxpri) { MaxPriority = maxpri; } int opr_tbl_lastop_get() { return last_operid; } void opr_tbl_lastop_set(int lastop) { last_operid = lastop; } #define OPSTR( index ) (symbol_pntr(OperatorTable[index].operid)) #define OPSTR_LEN( index ) (symbol_len(OperatorTable[index].operid)) #define COMMAND( index ) (symbol_pntr(OperatorTable[index].commid)) #define breakpt() {} /* Default operator table */ struct _opr_tbl_default_entry { const char *opchars; const char *opname; unsigned priority; BOOLEAN rtol; unsigned optype; } DefaultOperatorTable[] = { {" ", "space", 140, FALSE, OPTYPE_BINARY }, {".", "dot", 130, FALSE, OPTYPE_BINARY }, {"`", "bquote", 125, TRUE, OPTYPE_UNARY_PREFIX }, {"$", "stream", 125, TRUE, OPTYPE_UNARY_PREFIX }, {"!", "negate", 110, TRUE, OPTYPE_UNARY_PREFIX }, {"~", "bit_not", 110, TRUE, OPTYPE_UNARY_PREFIX }, {"++", "incr", 110, TRUE, OPTYPE_UNARY_PREFIX }, {"++", "incr_after", 110, TRUE, OPTYPE_UNARY_POSTFIX }, {"-", "minus", 110, TRUE, OPTYPE_UNARY_PREFIX }, {"--", "decr", 110, TRUE, OPTYPE_UNARY_PREFIX }, {"--", "decr_after", 110, TRUE, OPTYPE_UNARY_POSTFIX }, {"**", "repeat", 90, FALSE, OPTYPE_BINARY }, {"..", "iterate", 80, FALSE, OPTYPE_BINARY }, {"%", "mod", 70, FALSE, OPTYPE_BINARY }, {"*", "mpy", 70, FALSE, OPTYPE_BINARY }, {"/", "div", 70, FALSE, OPTYPE_BINARY }, {"+", "add", 60, FALSE, OPTYPE_BINARY }, {"-", "sub", 60, FALSE, OPTYPE_BINARY }, {"<<", "lshift", 55, FALSE, OPTYPE_BINARY }, {">>", "rshift", 55, FALSE, OPTYPE_BINARY }, {"<", "lt", 50, FALSE, OPTYPE_BINARY }, {"<=", "lt_or_eq", 50, FALSE, OPTYPE_BINARY }, {">", "gt", 50, FALSE, OPTYPE_BINARY }, {">=", "gt_or_eq", 50, FALSE, OPTYPE_BINARY }, {"!=", "not_eq", 45, FALSE, OPTYPE_BINARY }, {"==", "eq", 45, FALSE, OPTYPE_BINARY }, {"&", "bit_and", 44, FALSE, OPTYPE_BINARY }, {"^", "bit_xor", 43, FALSE, OPTYPE_BINARY }, {"|", "bit_or", 42, FALSE, OPTYPE_BINARY }, {"&&", "and", 41, FALSE, OPTYPE_BINARY }, {"||", "or", 40, FALSE, OPTYPE_BINARY }, {",", "tuple", 35, FALSE, OPTYPE_BINARY }, {",,", "concat", 33, FALSE, OPTYPE_BINARY }, {"%=", "mod_assign", 30, TRUE, OPTYPE_BINARY }, {"*=", "mpy_assign", 30, TRUE, OPTYPE_BINARY }, {"+=", "add_assign", 30, TRUE, OPTYPE_BINARY }, {"-=", "sub_assign", 30, TRUE, OPTYPE_BINARY }, {"/=", "div_assign", 30, TRUE, OPTYPE_BINARY }, {"=", "assign", 30, TRUE, OPTYPE_BINARY }, {";", "seq", 10, FALSE, OPTYPE_BINARY }, }; /*! opr_tbl_create Create the operator table Summary: #include */ int opr_tbl_create(unsigned maxop) /*! Return Value: 0 if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned maxop ;/* I Maximum number of operators table will support. */ #endif /*! Description: `opr_tbl_create` creates the operator table, initializing its contents to an empty state. Does nothing if the table already exists. Use `opr_tlb_delete` first if a new table is desired. !*/ { int index; if( OperatorTable != NULL ) return FUNCOK; /* Allocate memory for operator table */ if( maxop == 0 ) OperatorTable = NULL; else if( dmm_calloc( (void **)&OperatorTable, (long) maxop, sizeof( opr_tbl_entry ))) { COMERR_SET( ERR_MEMORY ); return FUNCBAD; } /* Initialize table to an empty state */ NumOperators = 0; MaxOperators = maxop; MaxPriority = 0; last_operid = -1; opr_tbl_is_default = 0; return FUNCOK; } /*! opr_tbl_delete Delete the existing operator table Summary: #include */ int opr_tbl_delete() /*! Return Value: 0 if OK, -1 if Error Parameters: none Description: `opr_tbl_delete` deletes the operator table, initializing its contents to an empty state. If a previous operator table existed it is replaced by the new one. !*/ { int index; /* Free table if one existed previously */ if( OperatorTable != NULL ) { for (index=0; index */ int opr_tbl_insert(const char * opstr,const char * command,unsigned priority, BOOLEAN rtol,unsigned optype) /*! Return Value: 0 if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC const char * opstr ;/* I String of characters that define an operator. */ const char * command ;/* I Name of command associated with operator. */ unsigned priority ;/* I Relative operator priority. */ BOOLEAN rtol ;/* I Indicates whether operator associates right-to-left or left-to-right. */ unsigned optype ;/* I Type of operator: OPTYPE_BINARY, OPTYPE_UNARY_PREFIX, or OPTYPE_UNARY_POSTFIX (constants defined in "comterp.ci"). */ #endif /*! Description: `opr_tbl_insert` inserts an entry into the operator table. `opstr` is the string of characters that defines an operator, i.e. strings like "+", "++", or "+=". They must be special characters not previously reserved for in COMTERP, which means they cannot contain digits, letters, single colons, or any "parenthetical" character (i.e. "(", ")", "[", "]", "{", and "}"). `priority` specifies the relative priority of this operator. `rtol` indicates whether the operator associates right-to-left or left-to-right (the default). `optype` selects whether the operator is a binary or unary operator, and if it a unary operator whether it is prefix or postfix unary operator. `opr_tbl_insert` can be called once for each possible operator type, i.e. for the `-` operator it would be used once to set up the binary version, and a second time to set up the prefix unary version. If an operator entry already exists for the specified `opstr` and operator type, it will be replaced. !*/ { unsigned table_off = 0; /* Offset into operator table */ BOOLEAN in_place = FALSE; /* Indicates whether insertion is on top */ /* existing operator */ BOOLEAN optype_exists[3]; /* Flags to indicate if specific operator of given type already exists */ unsigned save_off; /* Temporary store for table_off */ int operid; /* Id of opstr in symbol table */ int commid; /* Id of command in symbol table */ /* Check if table exists */ if( OperatorTable == NULL ) { COMERR_SET( ERR_NO_OPTABLE ); return FUNCBAD; } /* Check that priority is in range */ if( priority > 32767 ) { COMERR_SET1( ERR_PRIORITY_RANGE, priority ); return FUNCBAD; } MaxPriority = MAX( MaxPriority, priority ); /* Search for place to insert operator */ while( table_off < NumOperators && strcmp( OPSTR( table_off ), opstr ) < 0 ) table_off++; /* Check if operator already exists */ if( table_off < NumOperators && strcmp( OPSTR( table_off ), opstr ) == 0 ) { /* Set flags to indicate what operators of this type exists */ optype_exists[OPTYPE_BINARY] = optype_exists[OPTYPE_UNARY_PREFIX] = optype_exists[OPTYPE_UNARY_POSTFIX] = FALSE; save_off = table_off; while( table_off < NumOperators && strcmp( OPSTR( table_off ), opstr ) == 0 ) { optype_exists[ OperatorTable[ table_off ].optype ] = TRUE; table_off++; } /* Position table offset at insert location */ table_off = save_off; while( table_off < NumOperators && strcmp( OPSTR( table_off ), opstr ) == 0 && OperatorTable[ table_off ].optype < optype ) table_off++; /* Operator replaces existing one, clear out old entry */ if( table_off < NumOperators && strcmp( OPSTR( table_off ), opstr ) == 0 && OperatorTable[ table_off ].optype == optype ) { if( symbol_del( OperatorTable[ table_off ].operid ) || symbol_del( OperatorTable[ table_off ].commid )) KAPUT( "Error in deleting symbols" ); in_place = TRUE; } /* If not a replacement, ensure it is compatible with existing operators */ /* The rule is a unary prefix operator can only be overdefined as a */ /* binary operator or unary postfix operator, but never both, and a */ /* binary operator can never be overdefined as a unary postfix operator */ /* (and visa versa) */ else { if( optype_exists[OPTYPE_UNARY_PREFIX] && optype_exists[OPTYPE_BINARY] ) { COMERR_SET1( ERR_NO_POSTFIX, opstr ); return FUNCBAD; } else if( optype_exists[OPTYPE_UNARY_PREFIX] && optype_exists[OPTYPE_UNARY_POSTFIX] ) { COMERR_SET1( ERR_NO_BINARY, opstr ); return FUNCBAD; } else if( optype_exists[OPTYPE_BINARY] && optype != OPTYPE_UNARY_PREFIX ) { COMERR_SET1( ERR_NO_POSTFIX_WITH_BINARY, opstr ); return FUNCBAD; } else if( optype_exists[OPTYPE_UNARY_POSTFIX] && optype != OPTYPE_UNARY_PREFIX ) { COMERR_SET1( ERR_NO_BINARY_WITH_POSTFIX, opstr ); return FUNCBAD; } } } /* If one too many operators, inform the user */ if( !in_place && NumOperators == MaxOperators ) { COMERR_SET1( ERR_OPRTBLMAXED, MaxOperators ); return FUNCBAD; } /* Slide the rest of the entries up by one */ if( !in_place && table_off < NumOperators ) #ifndef DMM_OFF if( dmm_movrecs( (void **)&OperatorTable, (long)(table_off+1), (long)(table_off), (long)(NumOperators-table_off))) KAPUT( "Error in attempt to move operator table entries" ); #else memmove((void*)(OperatorTable+table_off+1), (void*)(OperatorTable+table_off), (NumOperators-table_off)*sizeof( opr_tbl_entry )); #endif /* Get symbol ids for operator and command strings */ if(( operid = symbol_add( opstr )) < 0 || ( commid = symbol_add( command )) < 0 ) { COMERR_SET( ERR_MEMORY ); return FUNCBAD; } /* Fill table entry */ OperatorTable[ table_off ].operid = operid; OperatorTable[ table_off ].commid = commid; OperatorTable[ table_off ].priority = priority; OperatorTable[ table_off ].rtol = rtol; OperatorTable[ table_off ].optype = optype; last_operid = operid; if( !in_place ) ++NumOperators; return FUNCOK; } /*! opr_tbl_print Print contents of operator table Summary: #include */ int opr_tbl_print(FILE * outfile,unsigned by) /*! Return Value: 0 if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC FILE * outfile ;/* I File pointer for output. */ unsigned by ;/* I Ordering of output, by one of the following: OPBY_OPERATOR, OPBY_COMMAND, or OPBY_PRIORITY (constants defined in "comterp.ci"). */ #endif /*! Description: `opr_tbl_print` prints the contents of the operator table to `outfile`, in one of three modes: sorted by operator, sorted by command, or sorted by priority. !*/ { int index; int counter; /* Non-existent table */ if( OperatorTable == NULL ) { fprintf( outfile, "Non-existent operator table\n" ); return FUNCOK; } /* Empty table */ if( NumOperators == 0 ) { fprintf( outfile, "Empty operator table\n" ); return FUNCOK; } /* Print contents of table sorted by operator */ fprintf( outfile, "Operator Command Priority RtoL Type\n" ); fprintf( outfile, "-------- ------- -------- ---- ----\n" ); for( index=0; index */ int opr_tbl_entries(char * buffer,int * op_ids,unsigned nop_ids,unsigned * nchar) /*! Return Value: 0 if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC char * buffer ;/* I Buffer to look for operator within. */ int * op_ids ;/* I Array of command symbol ids. */ unsigned nop_ids ;/* I Size of `op_ids` (should be 3). */ unsigned * nchar ;/* O Number of characters in operator */ #endif /*! Description: `opr_tbl_entries` returns ids for all the operators in the table associated with a given operator string. `op_ids` will contain one entry for each type of operator: OPTYPE_BINARY, OPTYPE_UNARY_PREFIX, OPTYPE_UNARY_POSTFIX (defined in "ComUtil/comterp.h"). The operator is assumed to start at the first character within `buffer`. !*/ { int op_index = 0; /* Index into operator table */ int first_op; /* First operator in table that matches character */ int index; /* Error checking */ if( nop_ids != 3 ) KAPUT( "Number of operator ids must be 3" ); /* Null out operator ids */ for( index=0; index first_op && strncmp( buffer, OPSTR( op_index ), OPSTR_LEN( op_index )) != 0 ) op_index--; /* No operator found that fits this character */ if( strncmp( buffer, OPSTR( op_index ), OPSTR_LEN( op_index )) != 0 ) { COMERR_SET1( ERR_ILLEGALOP, *buffer ); return FUNCBAD; } /* Backup further to the first version of this operator */ /* At the same time load the command array */ do { op_ids[ OperatorTable[op_index].optype ] = op_index; --op_index; } while( op_index >= 0 && strcmp( OPSTR( op_index ), OPSTR( op_index+1 )) == 0 ); /* Return number of characters taken for this operator */ ++op_index; *nchar = OPSTR_LEN( op_index ); } /* No operator found that starts with initial character */ else { COMERR_SET1( ERR_ILLEGALOP, *buffer ); return FUNCBAD; } return FUNCOK; } /*! opr_tbl_operid Return id of operator symbol Summary: #include */ int opr_tbl_operid(unsigned opnum) /*! Return Value: 0 if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned opnum ;/* I Number of operator in table. */ #endif /*! Description: `opr_tbl_operid` returns the id of the operator symbol for a given entry in the operator table. !*/ { if( opnum < NumOperators ) return OperatorTable[opnum].operid; else return -1; } /*! opr_tbl_commid Return id of command symbol Summary: #include */ int opr_tbl_commid(unsigned opnum) /*! Return Value: 0 if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned opnum ;/* I Number of operator in table. */ #endif /*! Description: `opr_tbl_commid` returns the id of the command symbol for a given entry in the operator table. !*/ { if( opnum < NumOperators ) return OperatorTable[opnum].commid; else return -1; } /*! opr_tbl_priority Return priority of operator Summary: #include */ int opr_tbl_priority(unsigned opnum) /*! Return Value: priority if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned opnum ;/* I Number of operator in table. */ #endif /*! Description: `opr_tbl_priority` returns the priority of an operator in the operator table. !*/ { if( opnum < NumOperators ) return OperatorTable[opnum].priority; else return -1; } /*! opr_tbl_rtol Return right-to-left indicator for an operator Summary: #include */ int opr_tbl_rtol(unsigned opnum) /*! Return Value: TRUE or FALSE if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned opnum ;/* I Number of operator in table. */ #endif /*! Description: `opr_tbl_rtol` returns the right-to-left indicator of an operator in the operator table. !*/ { if( opnum < NumOperators ) return OperatorTable[opnum].rtol; else return -1; } /*! opr_tbl_optype Return type of operator Summary: #include */ int opr_tbl_optype(unsigned opnum) /*! Return Value: type of operator if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned opnum ;/* I Number of operator in table. */ #endif /*! Description: `opr_tbl_optype` returns the type of an operator in the operator table: OPTYPE_BINARY, OPTYPE_UNARY_PREFIX, OPTYPE_UNARY_POSTFIX (defined in "ComUtil/comterp.h"). !*/ { if( opnum < NumOperators ) return OperatorTable[opnum].optype; else return -1; } /*! opr_tbl_maxprior Return maximum priority in operator table Summary: #include */ unsigned int opr_tbl_maxprior() /*! Return Value: maximum priority in operator table Parameters: none /*! Description: `opr_tbl_maxprior` returns the maximum priority of all operators currently in the operator table. !*/ { return MaxPriority; } /*! opr_tbl_default Build a default operator table for COMTERP Summary: #include */ int opr_tbl_default() /*! Return Value: 0 if OK, -1 if Error Parameters: none /*! Description: `opr_tbl_default` builds a default operator table for the COMTERP language, as follows: Operator Command Priority RtoL Type -------- ------- -------- ---- ---- . dot 130 N BINARY ` bquote 125 Y UNARY PREFIX $ stream 125 Y UNARY PREFIX ! negate 110 Y UNARY PREFIX ~ bit_not 110 Y UNARY PREFIX ++ incr 110 Y UNARY PREFIX ++ incr_after 110 Y UNARY POSTFIX - minus 110 Y UNARY PREFIX -- decr 110 Y UNARY PREFIX -- decr_after 110 Y UNARY POSTFIX ** repeat 90 N BINARY .. iterate 80 N BINARY % mod 70 N BINARY * mpy 70 N BINARY / div 70 N BINARY + add 60 N BINARY - sub 60 N BINARY << lshift 55 N BINARY >> rshift 55 N BINARY < lt 50 N BINARY <= lt_or_eq 50 N BINARY > gt 50 N BINARY >= gt_or_eq 50 N BINARY != not_eq 45 N BINARY == eq 45 N BINARY & bit_and 44 N BINARY ^ bit_xor 43 N BINARY | bit_or 42 N BINARY && and 41 N BINARY || or 40 N BINARY , tuple 35 N BINARY ,, concat 33 N BINARY %= mod_assign 30 Y BINARY *= mpy_assign 30 Y BINARY += add_assign 30 Y BINARY -= sub_assign 30 Y BINARY /= div_assign 30 Y BINARY = assign 30 Y BINARY ; seq 10 N BINARY !*/ { int table_size = sizeof( DefaultOperatorTable ) / sizeof( struct _opr_tbl_default_entry ); int index; if (OperatorTable && opr_tbl_is_default) return 0; /* restore from saved pointers if previously constructed */ if (opr_tbl_default_table) { opr_tbl_ptr_set(opr_tbl_default_table); opr_tbl_numop_set(opr_tbl_default_numop); opr_tbl_maxop_set(opr_tbl_default_maxop); opr_tbl_maxpri_set(opr_tbl_default_maxpri); opr_tbl_lastop_set(opr_tbl_default_lastop); return 0; } OperatorTable = NULL; /* Initalize table to the right size */ if( opr_tbl_create( table_size ) != 0 ) KAPUT( "Unable to create default operator table" ); /* Fill it up */ for( index=0; index */ int opr_tbl_opstr(unsigned commid) /*! Return Value: >=0 if OK, -1 if Error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC unsigned commid ;/* I Symbol id of command name. */ #endif /*! Description: `opr_tbl_opstr` returns the id of the operator symbol that matches the command referred to by commid. !*/ { int opnum = 0; while ( opnum < NumOperators ) { if (opr_tbl_commid(opnum)==commid) return opnum; opnum++; } return -1; } /*! opr_tbl_topstr Return symbol id of last operator inserted Summary: #include */ int opr_tbl_topstr() /*! Return Value: >=0 if OK, -1 if Error Parameters: none */ /*! Description: `opr_tbl_opstr` returns the id of the operator symbol that was registered lastmatches the command referred to by commid. !*/ { return last_operid; } ivtools-1.2.11a1/src/ComUtil/popen2.cc000066400000000000000000000073041214471147700174060ustar00rootroot00000000000000/* * Copyright (c) 2012 Wave Semiconductor Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include // http://www.cs.ualberta.ca/~mburo/orts/doxygen/html/popen2_8c-source.html //FUNCTION DEFINITION: /* Pre: The shell command that should be executed is passed as a parameter. * Values of 0 for p_fd_in or p_fd_out indicates shell command doesn't * use stdin or stdout respectively, so they should be closed. * Post: Makes accessible both the standard input and output of the shell * process it creates. * Two pipes are created: one provides standard input for the shell * commmand, and the other for passing back its standard output. * The pipe file descriptors for the caller to use are pointed to by * p_fd_in and p_fd_out. */ pid_t popen2(const char *shell_cmd, int *p_fd_in, int *p_fd_out) { #if 0 //CREATING TWO PIPES: int fds_processInput[2]; //pipe for process input int fds_processOutput[2]; //pipe for process output if(pipe(fds_processInput) != 0) //create process input pipe { fprintf(stderr, "pipe (process input) failed\n"); exit(1); } if(pipe2(fds_processOutput, O_NONBLOCK) != 0) //create process output pipe { fprintf(stderr, "pipe (process output) failed\n"); exit(1); } //FORKING A CHILD PROCESS: pid_t pid; if((pid = fork()) < 0) { fprintf(stderr," fork failed\n"); exit(2); } //CONNECT THE CORRECT PIPE ENDS IN THE CHILD: if(pid == 0) //child process { //for process input pipe: close(fds_processInput[1]); //close output dup2(fds_processInput[0], 0); //close fd 0, fd 0 = fds_processInput[0] //for process output pipe: close(fds_processOutput[0]); //close input dup2(fds_processOutput[1], 1); //close fd 1, fd 1 = fds_processOutput[1] execl("/bin/sh", "sh", "-c", shell_cmd, 0 ); fprintf(stderr, "failed to run shell_cmd\n"); } else //parent process { //for process input pipe: close(fds_processInput[0]); //close input //for process output pipe: close(fds_processOutput[1]); //close output if(p_fd_in == 0) close(fds_processInput[1]); else *p_fd_in = fds_processInput[1]; if(p_fd_out == 0) close(fds_processOutput[0]); else *p_fd_out = fds_processOutput[0]; } return pid; #endif } ivtools-1.2.11a1/src/ComUtil/symbols.cc000066400000000000000000000324221214471147700176720ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * Copyright (c) 2010 Wave Semiconductor Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* SYMBOLS.C Symbol Table Functions. Externals: Summary: These functions support the structuring and accessing of a string based symbol table. It allows you to add, delete and find symbols of any size. History: Written by Robert C. Fitch, 10 April 1989 Complete rewritten by Scott Johnston, November 2010 */ #include #include #include #include "comutil.ci" /* comutil.ci includes ComUtil/comutil.h, util.h,stdlib.h and malloc.h */ /*=============*/ typedef struct _symid symid; struct _symid { unsigned nchars; /* number of characters is a string */ char* symstr; /* pointer to character string */ /* NULL means available entry */ unsigned instances; /* instances of this symbol */ }; /* instances is incremented every symbol_add() and decremented every */ /* symbol_del(). When it is zero after a symbol_del() the symbol is removed */ /*=============*/ /* Static Functions: */ /* some pointers for the different open lists */ static symid *symid_beg=NULL; /* start addr of symbol table id's */ static unsigned symid_nrecs; /* number of records in the table */ static int symid_alloc_num; #define LOTS_OF_MEM 32000 /* These are used when you don't have much memory */ #define SYMID_ALLOC_NUM_LOW 32 /* These are used when you have lots of memory */ #define SYMID_ALLOC_NUM_HIGH 256 /* reverse index to speed up symbol table insertion */ #define REVERSE_TABLE #if defined(REVERSE_TABLE) #include declareStrTable(ReverseSymbolTable,int) implementStrTable(ReverseSymbolTable,int) ReverseSymbolTable* _reverse_table = nil; #endif /*=============*/ /*! symbol_add Add a new symbol to the symbol table. Summary: #include */ int symbol_add (const char * string) /*! Return Value: >= 0 unique identifier for this symbol, -1 if insufficient memory. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC const char * string ;/* I NULL terminated string to add */ #endif #ifdef DOC /*! Description: Adds a symbol to the symbol table. The symbol must be a NULL terminated string in the `string` parameter. See Also: symbol_del(), symbol_find() Example: main() { int id1,id2,id3,id4,id5; id1 = symbol_add("symbol1"); id2 = symbol_add("symbol2"); id3 = symbol_add("symbol3"); id4 = symbol_add("symbol4"); /* find the third symbol */ if (symbol_find("symbol3") < 0) printf("ERROR: Can't find symbol3\n"); /* Print number of chars in symbol */ printf("symbol2 has %d characters\n",symbol_len(id2)); /* return a pointer to symbol4 and print it */ printf("Returned string for symbol4 is %s\n",symbol_pntr(id4)); /* now delete the second symbol */ symbol_del(id2); /* add symbol 4 again using symbol_id() */ symbol_id("symbol4"); /* delete symbol 4; it should not delete it since there are */ /* two instances */ symbol_del(id4); /* make sure you can find symbol 4 */ if (symbol_find("symbol4") < 0) printf("ERROR: Can't find symbol4\n"); /* now delete symbol 4 id5 */ symbol_del(id5); /* now symbol 4 should be gone */ if (symbol_find("symbol4") < 0) printf("ERROR: Symbol 4 should have been deleted but was found\n"); } #endif /* DOC */ /* !*/ { int n; int id; symid* pntr; /* don't allow NULL input string */ n = strlen(string); if (string == NULL) goto error_return; /* can't be NULL,zero len or too big */ if ( (id = symbol_find(string)) >= 0) /* found it */ { /* found an existing string; increment instances */ pntr = symid_beg + id; (pntr->instances)++; /* increment instances */ } else /* you have to add the symbol */ { int found; if (symid_beg == NULL) /* if NULL, allocate some space for symbol table */ { symid_alloc_num = SYMID_ALLOC_NUM_HIGH; if ( dmm_calloc((void**)&symid_beg,(long) symid_alloc_num,sizeof(symid)) != 0) goto error_return; /* goto error return; INSUFFICIENT MEMORY */ for (int i=0; isymstr == NULL) /* found one, break */ { found = 1; break; } } if (!found) /* have to realloc some more symid table space */ { /* realloc some more */ symid* symid_beg_after; if(!(symid_beg_after = (symid*)realloc(symid_beg, (long) (symid_nrecs + symid_alloc_num) * sizeof(symid)))) goto error_return; symid_beg = symid_beg_after; id = symid_nrecs; /* first new one allocated */ symid_nrecs += symid_alloc_num; for (int i=id; i < symid_nrecs; i++) symid_beg[i].symstr = NULL; /* set unused */ } pntr = symid_beg + id; /* index into entry of interest */ pntr->nchars = n; /* number of non-NULL characters */ pntr->symstr = strdup(string); /* make copy of string */ pntr->instances = 1; /* set first instance of this symbol */ /* add to reverse index */ if(!_reverse_table) _reverse_table = new ReverseSymbolTable(1024); _reverse_table->insert(pntr->symstr, id); } return id; error_return: /* return an error code */ return -1; } /*! symbol_del Delete a symbol in the symbol table. Summary: #include */ int symbol_del (int id) /*! Return Value: 0 if OK, -1 if error. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int id ;/* I Identifier returned by symbol_add() */ #endif /*! Description: Deletes a symbol previously added with a `symbol_add()` function call. You can delete a symbol by its string also by first using a `symbol_find()` call that returns the id. The symbol will not be deleted until the `instances` element of the `symid` structure goes to zero. See Also: symbol_add(), symbol_find() !*/ { symid *pntr; int retval = FUNCBAD; if(symid_beg == NULL || id < 0 || id >= symid_nrecs) /* params out of range */ goto error_return; if ( ((pntr = symid_beg+id)->symstr) != NULL && /* already deleted */ --(pntr->instances) == 0) /* only delete if instances zeroed */ { /* this will delete that actual symbol in the string table */ _reverse_table->remove(pntr->symstr); free(pntr->symstr); pntr->symstr = NULL; } retval = FUNCOK; error_return: /* return an error code */ return (retval); } /*! symbol_reference Increment reference counter for a symbol in the symbol table. Summary: #include */ int symbol_reference (int id) /*! Return Value: 0 if OK, -1 if error. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int id ;/* I Identifier returned by symbol_add() */ #endif /*! Description: Increments a reference counter for a symbol previously added with a `symbol_add()` function call. See Also: symbol_add(), symbol_del() !*/ { symid *pntr; int retval = FUNCBAD; unsigned n,offset; unsigned bytes_left; if(symid_beg == NULL || id < 0 || id >= symid_nrecs) /* params out of range */ goto error_return; if ( (pntr = symid_beg+id)->symstr != NULL) ++(pntr->instances); else goto error_return; retval = FUNCOK; error_return: /* return an error code */ return (retval); } /*! symbol_refcount Return current symbol reference count Summary: #include */ int symbol_refcount (int id) /*! Return Value: reference count, -1 if error Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int id ;/* I Identifier returned by symbol_add() */ #endif /*! Description: Returns current value of a reference counter for a symbol previously added with a `symbol_add()` function call. See Also: symbol_reference() !*/ { symid *pntr; int retval = FUNCBAD; unsigned n,offset; unsigned bytes_left; if(symid_beg == NULL || id < 0 || id >= symid_nrecs) /* params out of range */ goto error_return; if ( (pntr = symid_beg+id)->symstr != NULL) return pntr->instances; else goto error_return; error_return: /* return an error code */ return -1; } /*! symbol_find Find a symbol string in the symbol table and return id. Summary: #include */ int symbol_find (const char * string) /*! Return Value: >=0 unique identifier for symbol if symbol found, -1 if symbol does not exist. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC char * string ;/* I NULL terminated symbol string to find */ #endif /*! Description: Finds a symbol already in the symbol table that matches `string`. Will return the id of the symbol if found and -1 if not found. See Also: symbol_add(), symbol_del() !*/ { if (!_reverse_table) return -1; int sym; if(_reverse_table->find(sym, string)) return sym; else return -1; } /*! symbol_pntr Return a pointer to the NULL terminated symbol. Summary: #include */ const char * symbol_pntr (int id) /*! Return Value: Pointer to NULL terminated string if OK, NULL if error. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int id ;/* I Identifier returned by symbol_add() */ #endif /*! Description: Returns a pointer to the symbol string for the `id` parameter. CAUTION: DO NOT MODIFY THE STRING. See Also: symbol_add(), symbol_len() !*/ { symid *pntr; if (symid_beg == NULL || id < 0 || id >= symid_nrecs || (pntr = symid_beg+id)->symstr == NULL) return(NULL); return(pntr->symstr); } /*! symbol_len Return the number of characters in a symbol. Summary: #include */ int symbol_len (int id) /*! Return Value: >0 is number of chars in symbol if OK, -1 if none exists. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int id ;/* I Identifier returned by symbol_add() */ #endif /*! Description: Returns the number of characters in a symbol. This does not include any NULL terminator character. See Also: symbol_add(), symbol_pntr() !*/ { symid *pntr; if (symid_beg == NULL || id < 0 || id >= symid_nrecs || (pntr = symid_beg+id)->symstr == NULL) return(-1); return(pntr->nchars); } /*! symbol_instances Return the number of instances of a symbol. Summary: #include */ int symbol_instances (int id) /*! Return Value: >=0 is number of instances of symbol if OK, -1 if error. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int id ;/* I Identifier returned by symbol_add() */ #endif /*! Description: Returns the number of current instances of the symbol identified by id. This is how many times the same symbol has been added minus the times it has been deleted. Errors returned if the symbol table is empty or `id` is illegal. See Also: symbol_add(), symbol_pntr() !*/ { symid *pntr; if (symid_beg == NULL || id < 0 || id >= symid_nrecs) return(-1); /* error */ if ( (pntr = symid_beg+id)->symstr == NULL) return(0); /* no instances */ return(pntr->instances); } /*! symbol_max Maximum number of currently available symbols. Summary: #include */ int symbol_max () /*! Return Value: current size of symbol table. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC #endif /*! Description: Returns the current size of the symbol table. See Also: symbol_instances() !*/ { return(symid_nrecs); } ivtools-1.2.11a1/src/ComUtil/txtutil.cc000066400000000000000000000244621214471147700177240ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* txtutil.c TeXT storage UTILities Externals: unsigned int txtstore() unsigned int txtread() unsigned int txtopenclose() unsigned int txtkwsrch() unsigned int txtprint() Summary: Routines to manage the text storage table. Author: Rob Graber 7-89 */ #include #include #include #include "comutil.ci" #define TXT_STORE_PATH "$comtxt$.$$$" /* Local globals */ static int Currid = -1; static int Lastid = -1; static FILE *fd = NULL; static char tmpstr[256]; /*! txtstore STORE TeXT in text table Summary: */ unsigned int txtstore(int new_entry,char * txtstr) /*! Return Value: -1 = Error, # = Text ID Parameters: Type Name IO Description ---- ---- -- ----------- */ #ifdef DOC int new_entry ;/* I New entry flag. 1 = Start new entry 0 = Continue previous entry */ char * txtstr ;/* I String to write. */ #endif /*! Description: `txtstore` stores a text string in the text table and returns an ID for it. If the `new_entry` flag is set a new ID is created and returned, otherwise `txtstr` is appended to the previous entry. !*/ #undef TITLE #define TITLE "txtstore" { int index; /* Check for file open */ if (fd == NULL) { /* Text storage file not open */ COMERR_SET(ERR_TXTUT_FNOTOPEN); return(-1); } /* Check for string beginning with internal delimeter */ if ( !strncmp(txtstr, ".!#ID#",6)) { /* String begins with internal delimeter string */ COMERR_SET(ERR_TXTUT_DELIM); return(-1); } /* Check for new entry */ if (new_entry) { Lastid++; fprintf(fd,".!#ID#%d\n",Lastid); } /* Check for multiple \n's */ index = strlen(txtstr) - 1; if (txtstr[index] == '\n') txtstr[index] = '\0'; /* Write text string */ fprintf(fd,"%s\n",txtstr); /* Return */ return(Lastid); } /*! txtread READ TeXT from text table Summary: */ unsigned int txtread ( /*! Return Value: 0 = OK, -1 = ERROR Parameters: Type Name IO Description ---- ---- -- -----------*/ unsigned id ,/* I Text ID */ char * txtstr /* I String to write. */ ) /*! Description: `txtread` reads a text string from the text table. If `id` is the same as the previous `id` no seek is done and the next line from the file is returned (unless it is the end of the text segment). A -1 value for ID will cause the current file position to be reset. !*/ #undef TITLE #define TITLE "txtread" { char *tst, cmpstr[15]; /* Check for file open */ if (fd == NULL) { /* Text storage file not open */ COMERR_SET(ERR_TXTUT_FNOTOPEN); return(-1); } /* Check for file reset */ if (id == -1) { Currid = -1; return(0); } /* Check for new id */ if (id != Currid) { /* Reset current id pointer and seek to beginning of file */ Currid = id; fseek(fd,0L,SEEK_SET); /* Search for .!#ID#id delimeter */ sprintf( cmpstr, ".!#ID#%d\n",id); while( (tst = fgets(txtstr, 256, fd)) != NULL ) if (!strcmp(txtstr, cmpstr)) break; /* Check for id not found */ if (tst == NULL) { Currid = -1; return(-1); } } /* Read next line of file */ tst = fgets(txtstr, 256, fd); /* Check for end of text entry (or EOF) */ if ( (!strncmp(txtstr, ".!#ID#",6)) || (tst == NULL) ) { Currid = -1; txtstr[0] = '\0'; return(-1); } /* Return */ return(0); } /*! txtopenclose TeXT table file OPEN and CLOSE Summary: */ unsigned int txtopenclose(int openclose) /*! Return Value: 0 = OK, -1 = ERROR Parameters: Type Name IO Description ---- ---- -- ----------- */ #ifdef DOC int openclose ;/* I Txt file open close flag. 0 = open 1 = close */ #endif /*! Description: `txtopenclose` opens or closes the txt file based on the `openclose` flag. !*/ #undef TITLE #define TITLE "txtopenclose" { /* Check for open/close */ if (openclose == 0) { /* If file is not already open - open it */ if (fd == NULL) { fd = fopen(TXT_STORE_PATH,"w+"); if (fd == NULL) { /* Error opening text storage file */ COMERR_SET(ERR_TXTUT_FOPEN); return(-1); } } } else /* Close file and remove */ if (fd != NULL) { fclose(fd); unlink(TXT_STORE_PATH); } return(0); } /*! txtkwsrch TeXT Key Word SeaRCH Summary: */ unsigned int txtkwsrch(char * keyword,int bol,char * rdstr) /*! Return Value: -1 = ERROR, # = text ID Parameters: Type Name IO Description ---- ---- -- ----------- */ #ifdef DOC char * keyword ;/* I String to search table for */ int bol ;/* I Search flag 0 = whole line 1 = beginning only */ char * rdstr ;/* IO String to return value in. Must be alloced in calling program. If rdstr is NULL an internal string is used. */ #endif /*! Description: `txtkwsrch` searches the text table and returns the first next ID containing `keyword`. Use a NULL keyword to reset the file. NOTE: The file position can be changed by reading or writing using txtstore and txtread. The file needs to be opened using txtopenclose prior to calling kwsearch. !*/ #undef TITLE #define TITLE "txtkwsrch" { char *tst, *rdptr; int id, index; /* Check for file open */ if (fd == NULL) { /* Text storage file not open */ COMERR_SET(ERR_TXTUT_FNOTOPEN); return(-1); } /* Check for file reset */ if (keyword == NULL) { fseek(fd,0L,SEEK_SET); return(0); } /* Set which read buffer to use */ if (rdstr == NULL) rdptr = tmpstr; else rdptr = rdstr; id = -1; while( (tst = fgets(rdptr, 256, fd)) != NULL ) { /* Check for .!#ID#id delimeter */ if (!strncmp(rdptr, ".!#ID#",6)) id = atoi(&rdptr[6]); else { if (bol) { /* One check only */ if (!strncmp(rdptr, keyword, strlen(keyword))) if (id != -1) return(id); } else { /* Search line for string */ for (index = 0; index < strlen(rdptr); index++) if (!strncmp(&rdptr[index], keyword, strlen(keyword))) if (id != -1) return(id); } } } return(-1); } #if 0 /*! txtprint TeXT PRINT Summary: */ unsigned int txtprint(unsigned id,char * ignorestr,unsigned pause, unsigned * nlines) /*! Return Value: -1 if not found, 0 = OK Parameters: Type Name IO Description ---- ---- -- ----------- */ #ifdef DOC unsigned id ;/* I ID to print */ char * ignorestr ;/* I Strings beginning with ignorestr are not printed */ unsigned pause ;/* I Pause afeter 22 lines flag. 0 = no pause */ unsigned *nlines ;/* I/0 Number of lines printed prior to this call of txtrpint. Updated on output */ #endif /*! Description: `txtprint` searchs the text table and prints out entry `id`. Any string beginning with `ignorestr` are NOT printed. This is useful for user defined delimeters within a block of text, specifically the .!#KW# identifiers for COMTERP. !*/ #undef TITLE #define TITLE "txtprint" { int i, xsize, ysize; /* Illegal ID value */ if (id == -1) return(-1); /* Constants */ crt_size(&xsize, &ysize); /* Find first line */ txtread(-1,tmpstr); if (txtread(id, tmpstr) == -1) return(-1); txtread(-1,tmpstr); /* Print until end of id */ for (i = *nlines; txtread(id, tmpstr) != -1; i++) { if (strncmp(ignorestr, tmpstr, strlen(ignorestr))) { printf("%s",tmpstr); *nlines = *nlines+1; if (pause) if ( (i%ysize == 0) && (i != 0) ) key_to_continue(); } } return(0); } #endif ivtools-1.2.11a1/src/ComUtil/types.cc000066400000000000000000000100711214471147700173420ustar00rootroot00000000000000/* * Copyright (c) 1994 Vectaport * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* types.c Data type support Externals: int print_type() Summary: History: Written by Scott E. Johnston, September 1988 */ #include #include /*! print_type Print value of given type Summary: #include #include */ int print_type(FILE * fptr,unsigned dtype,char * dptr,int offset) /*! Return Value: Number of characters written Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC FILE * fptr ;/* I Output file pointer. */ unsigned dtype ;/* I Type of datum. */ char * dptr ;/* I Pointer to datum to print. */ int offset ;/* I Offset from `dptr`. */ #endif /*! Description: `print_type` prints the contents of a data structure pointed to by `dptr`, using a format indicated by `dtype`. `offset` increments `dptr` by the necessary amount, according to `type`. The supported types are defined by the following macros in `util.h`: Macro Definition C Equivalent Description ---------------- ------------ ----------- DFINTPAR int default signed integer DFUNSPAR unsigned default unsigned integer SHINTPAR short 16-bit signed integer SHUNSPAR unsigned short 16-bit unsigned integer LNINTPAR long 32-bit signed integer LNUNSPAR unsigned long 32-bit unsigned integer FLOATPAR float floating point number DOUBLPAR double double-precision floating point no. CHAR_PAR char character STRNGPAR char * character string BOOL_PAR unsigned boolean !*/ { switch (dtype) { case DFINTPAR: return fprintf( fptr, DFINT_PRFORM, *((int *)dptr+offset) ); case DFUNSPAR: return fprintf( fptr, DFUNS_PRFORM, *((unsigned int *)dptr+offset) ); case SHINTPAR: return fprintf( fptr, SHINT_PRFORM, *((short *)dptr+offset) ); case SHUNSPAR: return fprintf( fptr, SHUNS_PRFORM, *((unsigned short *)dptr+offset) ); case LNINTPAR: return fprintf( fptr, LNINT_PRFORM, *((long *)dptr+offset) ); case LNUNSPAR: return fprintf( fptr, LNUNS_PRFORM, *((unsigned long *)dptr+offset) ); case FLOATPAR: return fprintf( fptr, FLOAT_PRFORM, *((float *)dptr+offset) ); case DOUBLPAR: return fprintf( fptr, DOUBL_PRFORM, *((double *)dptr+offset) ); case CHAR_PAR: return fprintf( fptr, "%c", *(dptr+offset) ); case STRNGPAR: return fprintf( fptr, "%s", *((char **)dptr+offset) ); case BOOL_PAR: return fprintf( fptr, "%s", (*((BOOLEAN *)dptr+offset) ? "TRUE" : "FALSE" )); } return 0; } ivtools-1.2.11a1/src/ComUtil/util.cc000066400000000000000000000023741214471147700171620ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* low-level utility functions */ int Kaput_On = 1; int TITLE = 0; ivtools-1.2.11a1/src/ComUtil/util.h000066400000000000000000000443461214471147700170310ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef UTIL_INCLUDED #define UTIL_INCLUDED #ifdef MSDOS #define DFINT_SCFORM "%d" #define DFUNS_SCFORM "%u" #define SHINT_SCFORM "%hd" #define SHUNS_SCFORM "%hu" #define LNINT_SCFORM "%ld" #define LNUNS_SCFORM "%lu" #define FLOAT_SCFORM "%f" #define DOUBL_SCFORM "%lf" #define DFINT_PRFORM "%d" #define DFUNS_PRFORM "%u" #define SHINT_PRFORM "%hd" #define SHUNS_PRFORM "%hu" #define LNINT_PRFORM "%ld" #define LNUNS_PRFORM "%lu" #define FLOAT_PRFORM "%g" #define DOUBL_PRFORM "%g" #endif #ifndef MSDOS #define DFINT_SCFORM "%d" #define DFUNS_SCFORM "%d" #define SHINT_SCFORM "%hd" #define SHUNS_SCFORM "%hd" #define LNINT_SCFORM "%d" #define LNUNS_SCFORM "%d" #define FLOAT_SCFORM "%f" #define DOUBL_SCFORM "%lf" #define DFINT_PRFORM "%d" #define DFUNS_PRFORM "%u" #define SHINT_PRFORM "%d" #define SHUNS_PRFORM "%d" #define LNINT_PRFORM "%ld" #define LNUNS_PRFORM "%lu" #define FLOAT_PRFORM "%g" #define DOUBL_PRFORM "%g" #endif /* BOOLEAN DEFINITIONS */ #define BOOLEAN unsigned int #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif #if !defined(__cplusplus) #ifndef true #define true 1 #endif #ifndef false #define false 0 #endif #ifndef boolean #define boolean unsigned int #endif #else #include #endif /* Inverse of a NULL pointer */ #define LLUN ((char *)-1L) /* Extra general purpose stuff */ #ifndef nil #define nil NULL #endif /* Handles of standard files */ #define STDIN_HANDLE 0 #define STDOUT_HANDLE 1 #define STDERR_HANDLE 2 /* fseek constants */ #ifndef MSDOS #undef SEEK_SET #undef SEEK_CUR #undef SEEK_END #define SEEK_SET 0 #define SEEK_CUR 1 #define SEEK_END 2 #endif extern int Kaput_On; #ifndef TITLE extern int TITLE; #endif #if !defined(MIN) && !defined(COMUTIL_NOMINMAXDEF) #define MIN(a,b) (ab?a:b) #endif /* Return Status for functions */ #define FUNCOK 0 #define FUNCBAD -1 #define FUNCHELP 1 /* Miscellaneous Definitions */ #define MAXLINE 511 #if defined(MSDOS) #define PATH_LEN 78 #define DIR_DELIM '\\' #define PATH_DELIM ';' #define DEFAULT_MODE 3 #endif #if !defined(MSDOS) #define PATH_LEN 256 #define DIR_DELIM '/' #define PATH_DELIM ':' #define DEFAULT_MODE 256 #endif /* Standard location for rectangle coordinates */ #define XBEG 0 #define XEND 1 #define YBEG 2 #define YEND 3 /* Key codes for CRT.C */ #define KEY_EXIT 0x12D #define KEY_HELP 0x123 #define KEY_ABORT 0x01B #define KEY_UP 0x148 #define KEY_DN 0x150 #define KEY_RT 0x14D #define KEY_LF 0x14B #define KEY_RTWORD 0x174 #define KEY_LFWORD 0x173 #define KEY_BEGLINE 0x147 #define KEY_ENDLINE 0x14f #define KEY_BEGPAGE 0x177 #define KEY_ENDPAGE 0x175 #define KEY_UPPAGE 0x149 #define KEY_DNPAGE 0x151 #define KEY_BEGFILE 0x184 #define KEY_ENDFILE 0x176 #define KEY_GOTO 0x122 #define KEY_INS 0x152 #define KEY_DEL 0x153 #define KEY_BKSP 0x008 #define KEY_DELWORD 0x193 #define KEY_BKSPWORD 0x07F #define KEY_DELLINE 0x120 #define KEY_DELEOL 0x112 #define KEY_FINDSTR 0x121 #define KEY_NEXTSTR 0x131 #define KEY_REPLSTR 0x114 #define KEY_MARKBLK 0x125 #define KEY_CUTBLK 0x114 #define KEY_COPYBLK 0x12E #define KEY_PASTEBLK 0x132 #define KEY_RDFILE 0x113 #define KEY_WRFILE 0x111 #define KEY_INFILE 0x117 #define KEY_OPENWIN 0x118 #define KEY_SHUTWIN 0x11F #define KEY_JUMPWIN 0x124 /*-------------------------------------------------------------------------*/ /* DOUBLY-LINKED LIST DATA STRUCTURES */ /* Generic structure for node in doubly-linked list */ typedef struct _dlnode dlnode; struct _dlnode { dlnode * next; /* Pointer to next node in doubly-linked list, NULL if tail */ dlnode * prev; /* Pointer to previous node in doubly-linked list, NULL if head */ }; /* Doubly-linked list structure */ typedef struct _dllist dllist; struct _dllist { dlnode * head; /* Pointer to head of doubly-linked list */ dlnode * tail; /* Pointer to tail of doubly-linked list */ dlnode * curr; /* Pointer to current position in doubly-linked list */ unsigned len; /* Length of doubly-linked list */ }; /*-------------------------------------------------------------------------*/ /* COMMAND PARSING DEFINITIONS AND MACROS */ struct par_struct { char * name; /* Parameter name. '-' in first character indicates free format parameter.*/ char * defaults; /* Default parameter value. */ char * override; /* Override parameter value.*/ unsigned type; /* Type indicator */ unsigned array; /* Array indicator: 0 -- no array 1 -- arbitrary array length >1 -- required array length*/ char * valptr; /* Pointer to storage space for results of parsing.*/ unsigned nbytes; /* Number of bytes pointed to by value.*/ unsigned * nunits; /* Pointer for returning number of units filled into an array (not returned if NULL). */ char * range; /* String that defines ranges of values */ unsigned version; /* Comparse version number. */ }; typedef struct par_struct PAR_STRUCT; #define DFINTPAR 0 /* Default integer */ #define DFUNSPAR 1 /* Default unsigned integer */ #define SHINTPAR 2 /* Short integer. */ #define SHUNSPAR 3 /* Short unsigned integer. */ #define LNINTPAR 4 /* Long integer. */ #define LNUNSPAR 5 /* Long unsigned integer. */ #define FLOATPAR 6 /* Floating point. */ #define DOUBLPAR 7 /* Double floating point. */ #define CHAR_PAR 8 /* Character. */ #define STRNGPAR 9 /* Character string. */ #define BOOL_PAR 10 /* Boolean. */ #define ENUM_PAR 11 /* Enumerated type. */ #define REST_PAR 12 /* Rest of fixed format parameters */ #define REFERPAR 13 /* Reference parameter (pointer) */ /* can only be variables */ #define BLOCKPAR 14 /* Block of unevaluated commands */ #define FLAG_PAR 15 /* Keyword only parameter */ #define ULISTPAR 16 /* Unsigned list parameter */ #define PAR_STRUCT_SIZE( params )\ (params==NULL?0:sizeof(params)/sizeof(PAR_STRUCT)) /* define ENUM parameters */ #define PSX(name,defaults,override,type,array,valptr,nunits,consts)\ {name,defaults,override,type,array,(char*)(valptr),sizeof(valptr),nunits,consts,3} /* normal by-value parameters */ #define PSI(name,defaults,override,type,array,valptr,nunits)\ PSX(name,defaults,override,type,array,valptr,nunits,NULL) typedef struct { void *base; /* variable base address */ int nels; /* elements in the variable. 1 if scaler */ /* > 1 if array */ int elsize; /* size of an element in bytes */ int indx; /* index to this entry. -1 if no index spec'd */ } REFPAR; /* reference parameter type definition */ /*-------------------------------------------------------------------------*/ /* COMMAND INTERPRETING DEFINITIONS AND MACROS */ struct com_struct { char * name; /* Command name. */ int (* func )(); /* Function pointer. */ char * file; /* Source file for documentation */ /* NULL enables use of MAN-LINTARG system */ unsigned version; /* Comterp version number. */ }; typedef struct com_struct COM_STRUCT; #define COM_STRUCT_SIZE( commands )\ (commands==NULL?0:sizeof(commands)/sizeof(COM_STRUCT)) #define CSI(name,func,file)\ {name,func,file,1} #define COMTERP(commands)\ comterp(argc, argv, commands, COM_STRUCT_SIZE(commands)) /* EXPR definitions */ struct token { int tok_type; struct token *next; union { double value; int ft_ptr; int oper; int tlocs[2]; void *pntr; /* general pointer */ } tok_val; struct token *list; }; #define EXPR_TYPE struct token /* Error handling macros */ #define TITLE_PRINT {if( TITLE ) fprintf( stderr, "%s: ", TITLE ); } #define breakpt() {} #define KANRET( format_string )\ { if(Kaput_On)\ {TITLE_PRINT;\ fprintf( stderr, format_string );\ fprintf( stderr, "\n" );}\ breakpt();} #define KANRET1( format_string, val1 )\ { if(Kaput_On)\ {TITLE_PRINT;\ fprintf( stderr, format_string, val1 );\ fprintf( stderr, "\n" );}\ breakpt();} #define KANRET2( format_string, val1, val2 )\ { if(Kaput_On)\ {TITLE_PRINT;\ fprintf( stderr, format_string, val1, val2 );\ fprintf( stderr, "\n" );}\ breakpt();} #define KANRET3( format_string, val1, val2, val3 )\ { if(Kaput_On)\ {TITLE_PRINT;\ fprintf( stderr, format_string, val1, val2, val3 );\ fprintf( stderr, "\n" );}\ breakpt();} #define ERRJMP( format_string )\ {KANRET( format_string )\ goto error_return;} #define ERRJMP1( format_string, val1 )\ {KANRET1( format_string, val1 )\ goto error_return;} #define ERRJMP2( format_string, val1, val2 )\ {KANRET2( format_string, val1, val2 )\ goto error_return;} #define ERRJMP3( format_string, val1, val2, val3 )\ {KANRET3( format_string, val1, val2, val3 )\ goto error_return;} #define KAPUT( format_string )\ {KANRET( format_string )\ return -1; } #define KAPUT1( format_string, val1 )\ {KANRET1( format_string, val1 )\ return -1; } #define KAPUT2( format_string, val1, val2 )\ {KANRET2( format_string, val1, val2 )\ return -1; } #define KAPUT3( format_string, val1, val2, val3 )\ {KANRET3( format_string, val1, val2, val3 )\ return -1; } #define KANIL( format_string )\ {KANRET( format_string )\ return NULL; } #define KANIL1( format_string, val1 )\ {KANRET1( format_string, val1 )\ return NULL; } #define KANIL2( format_string, val1, val2 )\ {KANRET2( format_string, val1, val2 )\ return NULL; } #define KANIL3( format_string, val1, val2, val3 )\ {KANRET3( format_string, val1, val2, val3 )\ return NULL; } /* Macros to allocate and free memory */ #if !defined(C_terp) #define MAKE_SPACE( pointer, type, size ) { \ pointer = (type *) calloc( 1, size );\ if( pointer == NULL ) { \ KANRET( ALLOC_ERR );\ goto error_return; \ } \ bl_alloc((char *) pointer, size ); \ } #define FREE_SPACE( pointer ) { \ if( pointer != NULL ) {\ bl_free((char *) pointer ); \ free((char *) pointer ); \ pointer = NULL;\ } \ } #else #define MAKE_SPACE( pointer, type, size ) { \ pointer = (type *) calloc( 1, size );\ if( pointer == NULL ) { \ KANRET( ALLOC_ERR );\ goto error_return; \ }\ } #define FREE_SPACE( pointer ) { \ if( pointer != NULL ) {\ free((char *) pointer ); \ pointer = NULL;\ }\ } #endif #define TRIMSPACE( string, newlength )\ if( string == NULL ) newlength = 0; \ else for (newlength = strlen( string );\ (isspace(*(string+newlength-1)) && newlength>0);\ newlength--);if(*(string+newlength) != '\0') *(string+newlength)='\0' #define GETINT( string, integer, flag )\ flag = (sscanf( string, "%hd", &integer ) == 1);\ if (flag) while (isdigit(*string)) (string++) /* Vowel detection */ #define isvowel( ch )\ (ch=='a'||ch=='A'||ch=='e'||ch=='E'||ch=='i'||ch=='I'||\ ch=='o'||ch=='O'||ch=='u'||ch=='U') /* CURKEYS constants */ #define CUR_MOVE 1 #define CUR_RBUT 0 #define CUR_LBUT 2 #define CUR_MBUT 3 #define CUR_NONE -1 /* ANSI.SYS (and therefore VT-100) Escape Sequences */ #define CUH "\033\133\110" /* cursor home */ #define EEL "\033\133\113" /* erase to end-of-line */ #define CLS "\033\133\062\112" /* clear screen */ #define ATO "\033\133\060\155" /* attributes off */ #define BLD "\033\133\061\155" /* bold */ #define UDS "\033\133\064\155" /* underscore */ #define BLK "\033\133\065\155" /* blink */ #define RVS "\033\133\067\155" /* reverse image */ #define ECH "\033\133\070\155" /* echo off */ #define BKF "\033\133\063\060\155" /* black foreground */ #define RDF "\033\133\063\061\155" /* red foregroung */ #define GNF "\033\133\063\062\155" /* green foreground */ #define YWF "\033\133\063\063\155" /* yellow foreground */ #define BEF "\033\133\063\064\155" /* blue foreground */ #define MAF "\033\133\063\065\155" /* magnenta foreground */ #define CNF "\033\133\063\066\155" /* cyan foreground */ #define WEF "\033\133\063\067\155" /* white foreground */ #define BKB "\033\133\064\060\155" /* black background */ #define RDB "\033\133\064\061\155" /* red background */ #define GNB "\033\133\064\062\155" /* green background */ #define YWB "\033\133\064\063\155" /* yellow background */ #define BEB "\033\133\064\064\155" /* blue background */ #define MAB "\033\133\064\065\155" /* magnenta background */ #define CNB "\033\133\064\066\155" /* cyan background */ #define WEB "\033\133\064\067\155" /* white background */ #define SCU "\033\133\163" /* save cursor */ #define RCU "\033\133\165" /* restore cursor */ #ifdef MSDOS #define ptrtoabs(ptr) \ (((unsigned long) FP_SEG(ptr) << 4)+ (unsigned long) FP_OFF(ptr)) #endif /* MSDOS */ /* The `huge` define is needed for allocating large areas of memory */ /* in Microsoft C. OS9 and most other machines do not need it */ /* `huge` allows blocks up to sizeof(long) instead of sizeof(int) */ #if defined(MSDOS) /* memmove is the overlapping mem copy in Microsoft C */ #define MEMCPY(dest,src,count) \ memmove((void *)(dest),(const void *)(src),(size_t)(count)) #define MEMSET(dest,c,count) \ memset((void *)(dest),(int)(c),(size_t)(count)) #endif #if defined(C_terp) /* Microsoft halloc() has some problems. You're first alloc must be */ /* a halloc() or things will bomb out (you must be before start of heap) */ /* C_terp does not support halloc and hfree yet; Use calloc/free for test */ #define halloc(nrecs,nsize) calloc((size_t) (nrecs),(size_t) (nsize)) #define hfree(pntr) free((pntr)) #endif #if !defined(MSDOS) #if 0 /* leaved commented out if you don't need */ typedef int size_t; /* this is some ANSI type */ #endif #if defined(OSK) /* this is the non-overlapping mem copy used for OS-9 */ #define MEMCPY(dest,src,count) \ memcpy((char *)(dest),(char *)(src),(unsigned)(count)) #else #define MEMCPY(dest,src,count) \ bcopy((const void*)src,(void*)dest,(size_t)(count)) #endif #define MEMSET(dest,c,count) \ memset((char *)(dest),(int)(c),(unsigned)(count)) /* huge is defined as nothing: only necessary for MS-DOS */ #define huge /* map the Microsoft-C huge routines over if not already defined */ #define halloc(nrecs,nsize) calloc((unsigned)(nrecs), (unsigned)(nsize)) #define hfree(pntr) free(pntr) #endif /* defined(MSDOS) */ #define COMPARSE(params,string) {\ int status; \ status = comparse(argc,argv,params,PAR_STRUCT_SIZE(params),string); \ if (status==1) return FUNCOK; \ else if(status==-1) return FUNCBAD; } #define AF_COMPARSE(params,string) {\ int status; \ status = comparse(argc,argv,params,PAR_STRUCT_SIZE(params),string); \ if (status==1) return(FUNCHELP); \ else if(status==-1) return(FUNCBAD); } /*---------------------------------------------------------------------------*/ /* Remove these routines if running in C-terp */ #if defined(C_terp)||!defined(MSDOS) #define bl_alloc(p,n) #define bl_free(p) #endif /* Obsolete functions */ #define rodent(m1,m2,m3,m4) cmousel(m1,m2,m3,m4) #define video_state(ncols,mode,page) crt_getmode(mode) #define crt_mode(mode) crt_setmode(mode) #define set_cursor(row,col,page) crt_setcur(row,col) #define cur_disable_mouse(flag) cur_setmouse(flag) #if 0 /* Old file pointer conventions */ #define fileerr stderr #define fileout stdout #endif #ifdef MSDOS #include #endif #ifdef OSK EXPR_TYPE *getexpr(); EXPR_TYPE *postfix(); EXPR_TYPE *tokenize(); char *strsub(); char *findmat(); char *detab(); char *simple_path(); char *sp_gets(); char **dir(); FILE *fopen_path(); dlnode *dll_insert(); dlnode *dll_remove(); dlnode *dll_prev(); dlnode *dll_next(); dlnode *dll_head(); dlnode *dll_tail(); unsigned long TIMER_READ(); #endif #endif /* not UTIL_INCLUDED */ ivtools-1.2.11a1/src/ComUtil/xdll.cc000066400000000000000000000751521214471147700171540ustar00rootroot00000000000000/* * Copyright (c) 1993-1995 Vectaport Inc. * Copyright (c) 1989 Triple Vision, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* XDLL.C Extended Doubly-Linked List Support. Externals: Summary: These functions support the structuring and accessing of a doubly-linked list. They are a modified version of Scott's dll functions made more general. His should have been directly modified, but these routines were already laying around from another effort. History: Written by Robert C. Fitch, 4 Mar 1989 Improvements: - In xdll_open(): if `beg` is NULL, allocate the area for the user. (this is being held off to see if the dmm_*() dynamic allocation routines are going to be used for this purpose). - All: support for `huge` memory areas. These routines really only support normal size memory areas. Actually only int size since offsets are integers in xdllink structure (maybe should be longs). */ #include #include "comutil.ci" /* comutil.ci includes stdlib.h and malloc.h */ /*=============*/ /* This contains all information for an open linked list */ /* assumes the cells for the linked list are linear in memory */ /* i.e., from address `beg` to `end` */ typedef struct _xdllist xdllist; struct _xdllist { int size; /* size of node structure size */ /* 0 means cell is empty */ xdllink *beg; /* head of user's alloc structure */ int nlinks; /* max number of links in list */ xdllink *head; /* head node of the list; can be anywhere */ xdllink *curr; /* current level entry in link list */ }; #ifdef C_terp #define XDLL_LISTS 16 #else #define XDLL_LISTS 32 #endif static xdllist xdllist_array[XDLL_LISTS]; /* now a static array */ /* calloc/realloc removed */ /*=============*/ /* Static Functions: */ static int next_free_link(int flag); static int clear_links(xdllink * curr,int nlinks,void (*userfunc)(void*)); /* some pointers for the different open lists */ static xdllist *xdllist_beg,*xdllist_curr; static int nxdlls=0; /* number of lists in list_beg array */ static int xdllist_in_use_id = -1; /* current list in use; -1 is none in use */ /* this checks to make sure there is a list in use */ #define CHECKUSE { if (xdllist_in_use_id < 0) goto error_return; } /* These macros efficiently increment structure pointers by byte offsets */ /* this one returns a pointer to an xdllink structure entry in beg */ #define ADDBEG(nbytes) ( (xdllink *) (((char *)xdllist_curr->beg) + nbytes)) /* this one returns a byte offset from beginning of structure beg */ #define SUBBEG(pntr) ((int) (((char *) pntr) - ((char *) xdllist_curr->beg)) ) #define HEADID -2 /* this is identifier of a head node */ /*=============*/ /*! xdll_open Open a New doubly-linked-list structure. Summary: #include */ int xdll_open (void * beg,int nlinks,int nsize) /*! Return Value: >=0 identifier for this link structure, -1 if params out of range or insufficient memory. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void * beg ;/* I Pointer to link area alloc'd by user */ int nlinks ;/* I Max number of links in the list */ int nsize ;/* I Size of a link entry in bytes */ #endif #ifdef DOC /*! Description: Open's a new link list in an area of memory allocated by the user starting at address `beg`. The number of records (links) in the memory area is `nlinks` and the number of bytes per record (link) is `nsize`. This routine also sets the current linked-list in use to the identifier returned by this routine. /* Link Structure */ The links are done using the link structure array. It contains two elements, the first being a node pointer in to the node array. The second element is a link to the next entry in the link list. See `xdllink` structure. If the *node entry in listink is NULL, then this is an empty entry. /* List Pointer Reference Structure */ Another data structure declares a set of pointers for each link list. See `list` structure for details. =============== Two link lists: A <-> B <-> C -and- D <-> E links LINK Structure index prev next ------- ----- ----- L0 NULL L1 "A" L1 L0 L2 "B" L2 L1 NULL "C" end of this list L3 NULL L4 "D" L4 L3 NULL "E" end of this list =============== See Also: xdll_close() Example: /* Code to set up the earlier example */ main() { int i,id1,id2; static char *strings[5] = {"A","B","C","D","E"}; void *pos,*cpos; typedef struct _mystruct mystruct; /* define application struct */ struct _mystruct { xdllink node; /* must be first in struct */ char *string; /* to point to a string name */ } array1[3],array2[2],*mine; /* Note: no error checking shown. */ /* I'm assuming everything is legal. You shouldn't. */ id1 = xdll_open (array1,3,sizeof(mystruct)); id2 = xdll_open (array2,2,sizeof(mystruct)); xdll_use(id1); xdll_head(); for (i=0; i<=2; i++) /* add A,B,C */ { mine = (mystruct *) xdll_add (); /* add links to "A" parent for "B","C","D" */ mine->string = strings[i]; /* add to string info to structure */ /* note: you put your stuff in after you add the link */ if (i==1) /* if "C" */ cpos = xdll_curr (); /* save position of "B" entry */ } xdll_use(id2); xdll_head(); for (i=3; i<=4; i++) /* add D,E */ { mine = (mystruct *) xdll_add (); /* add links to "A" parent for "B","C","D" */ mine->string = strings[i]; /* add to string info to structure */ /* note: you put your stuff in after you add the link */ } xdll_use(id1); /* print number of nodes and links left; should both be zero */ printf ("links left = %d\n",xdll_links_left()); /* Delete "B" and its children "E" and "F" from the list */ xdll_goto (cpos); /* move to "C" entry saved earlier */ xdll_delete (1); /* delete it and its children from the list */ /* reposition on "B" */ xdll_close (); /* close and release memory */ } #endif /* DOC */ /* !*/ { int id; /* check input parameter ranges */ if (beg == NULL || nlinks < 1 || /* must have at least one node */ nsize < sizeof(xdllink) ) /* at least size of a link */ goto error_return; /* parameter error, get out of here */ /* Now make an entry in the list struct array; calloc it as needed */ if (nxdlls <= 0) /* see if this is the first call */ { for(id=0,xdllist_curr=xdllist_array; id < XDLL_LISTS; id++, xdllist_curr++) /* make all lists empty */ { xdllist_curr->size = 0; } /* 0 means empty */ xdllist_beg = xdllist_array; /* set beginning of list pointer */ nxdlls = XDLL_LISTS; /* set number of lists */ } /* first search current list for any empty ones and use them first */ for (id=0, xdllist_curr=xdllist_beg; id < nxdlls && xdllist_curr->size != 0; id++,xdllist_curr++) { /* no body */ } if (id >= nxdlls) /* true if no empty ones found */ goto error_return; /* out of memory ; all lists in use */ xdllist_curr->size = nsize; xdllist_curr->beg = (xdllink *) beg; /* set to user furnished pointer */ xdllist_curr->nlinks = nlinks; /* remember this too */ /* do this one with bytes since struct type is unknown */ /* set current position pointers to the start of the lists */ xdllist_curr->head = xdllist_curr->curr = NULL; /* set the head current link in the list to none */ /* this means they are empty */ clear_links((xdllink*)beg,nlinks,NULL); /* clear all links in the table */ return (xdllist_in_use_id = id); /* OK return */ error_return: /* return an error code */ return (FUNCBAD); } /*! xdll_reopen Re-Open an existing doubly-linked-list structure. Summary: #include */ int xdll_reopen (int newflag,void * beg,int nlinks,int newhead) /*! Return Value: 0 the id reopened if OK, -1 if params out of range or insufficient memory or no list is in use or head does not point to a head entry node. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int newflag ;/* I true - this is a new list (no head) */ /* false - this is an old list (use newhead)*/ void * beg ;/* I Pointer to link area alloc'd by user */ /* NULL means use current pntr value */ int nlinks ;/* I Max number of links in the list */ /* 0 means don't change number of links */ int newhead ;/* I Byte Offset to head of linked list */ /* < 0 means leave head at old offset */ #endif /*! Description: Reopen's an link list in an area of memory allocated by the user starting at address `beg`. The number of records (links) in the memory area is `nlinks` and the number of bytes per record (link) is `nsize`. The `head` parameter is used to specify the entry into the linked-list. If `head` is -1, the current position of the head is used. If `head` is >= 0, this is the new head; if the head is not a legal head an error is returned. If `newflag` is true, the list is set to empty and the `newhead` parameter is not used. The current position in the list is also set to the head. This call is mainly used to change the position and sizes of existing link lists. !*/ { int old_nlinks,delta; xdllink *curr; int oldhead; int retval = FUNCBAD; CHECKUSE; /* check that there is one open */ if(xdllist_curr->head != NULL) oldhead = SUBBEG(xdllist_curr->head); /* offset to current head */ old_nlinks = xdllist_curr->nlinks; /* what they are coming in */ if (beg != NULL) xdllist_curr->beg = (xdllink *) beg; if (nlinks > 0) xdllist_curr->nlinks = nlinks; /* remember this too */ curr = (newflag) ? NULL : /* no head if newflag true */ ((newhead >= 0) ? ADDBEG(newhead) : /* corrects for new beg */ ((xdllist_curr->head == NULL) ? NULL : ADDBEG(oldhead)) ); /* use current head offset or NULL if head param negative */ /* don't set head and curr if the head node asked for is not a head node */ if (curr != NULL && curr->prev != HEADID) goto error_return; /* illegal head, error returned */ xdllist_curr->head = xdllist_curr->curr = curr; /* set head and curr pos */ /* set current position pointers to the start of the lists */ delta = xdllist_curr->nlinks - old_nlinks; /* pos means it got bigger */ if (delta > 0) /* if size increased */ { /* yes, you have to clear the new links on the end */ curr = ADDBEG( (old_nlinks * xdllist_curr->size) ); /* move to where new part starts and clear it to the end */ clear_links(curr,delta,NULL); /* clear from curr to end */ } retval = FUNCOK; /* return will be OK */ error_return: /* return an error code */ return (retval); } /*! xdll_use Set the current linked list in use. Summary: #include */ int xdll_use (int id) /*! Return Value: >=0 id in use if OK, -1 if id is out-of-range or the linked list is undefined. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int id ;/* I identifier returned by xdll_open() */ #endif /*! Description: Sets the linked list to use for all other function calls. If `id` is negative or greater than the current number of entries in the link array (`nxdlls`) or the entry selected by the id is not defined, then the current identifier in use is set to and returned as a -1. See also: xdll_open(), xdll_in_use() Example: See end of example in xdll_open (). !*/ { if (id < 0 || id >= nxdlls) goto error_return; /* out of legal range */ xdllist_curr = xdllist_beg + id; /* go to this ones entry */ if (xdllist_curr->size == 0) goto error_return; /* selected list is not open */ xdllist_in_use_id = id; /* save identifier */ return (id); /* OK return */ error_return: xdllist_in_use_id = -1; /* make it so none are in use */ return (-1); /* error return */ } /*! xdll_in_use Return id of the current linked list in use. Summary: #include */ int xdll_in_use () /*! Return Value: >=0 id in use if OK, -1 if no link list in use. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ /*! Description: Returns the identifier (id) for the current linked list in use. If no linked list is in use, it returns a -1. This routine is mainly used for saving the current identifier in use and its associated state. See also: xdll_use() Example: !*/ { return (xdllist_in_use_id); /* pretty simple */ } /*! xdll_close Close the current linked list in use or close all lists. Summary: #include */ int xdll_close (int allflag) /*! Return Value: 0 (FUNCOK) if close OK, -1 (FUNCBAD) if error. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int allflag ;/* I allflag true, close all lists */ /* false, close list spec'd by id */ #endif /*! Description: This closes an already opened list structure. The user must have already free'd any alloc'd pointers in his structures before calling this routine. Improvements: - Add a free function parameter to be used to call user structure free. See also: xdll_open(), xdll_use() Example: See end of example in xdll_open (). !*/ { int i; if (!allflag) CHECKUSE; /* make sure one is in use */ for (i=0, xdllist_curr=xdllist_beg; isize = 0; /* free entry entry */ } xdllist_in_use_id = -1; /* set list in use to no list */ return (FUNCOK); /* OK return */ error_return: /* return an error code */ return (FUNCBAD); } /*! xdll_curr Return current list position. Summary: #include */ void *xdll_curr () /*! Return Value: current position if OK, NULL if list not opened. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ /*! Description: Returns current position in the list. See Also: xdll_use() !*/ { CHECKUSE; if (xdllist_curr->head == NULL) /* nothing in the list ? */ goto error_return; /* no, error */ return ((void *)xdllist_curr->curr); /* return current level */ /* it could also be NULL sometimes */ error_return: return (NULL); } /*! xdll_head Go to head entry in the link list. Summary: #include */ void *xdll_head () /*! Return Value: Head position if OK, NULL if error. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ /*! Description: Goes to the head position in the linked list (the top). Note that this does not always have to be the beginning of the list. See Also: xdll_open(). !*/ { CHECKUSE; if (xdllist_curr->head == NULL) /* nothing in the list ? */ goto error_return; /* no, error */ xdllist_curr->curr = xdllist_curr->head; return ((void *) xdllist_curr->head); error_return: return (NULL); } /*! xdll_next Go to next link in the list. Summary: #include */ void *xdll_next () /*! Return Value: New position if OK, NULL if no next. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ /*! Description: Goes to the next entry in the link list. If none, it returns NULL. See Also: xdll_use(). !*/ { xdllink *curr; CHECKUSE; if (xdllist_curr->head == NULL) /* nothing in the list ? */ goto error_return; /* no, error */ curr = xdllist_curr->curr; /* pointer to current entry */ if (curr->next < 0) goto error_return; return ((void *) (xdllist_curr->curr = ADDBEG(curr->next) ) ); error_return: return (NULL); } /*! xdll_prev Go to previous link in the list. Summary: #include */ void *xdll_prev () /*! Return Value: New position if OK, NULL if no previous. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ /*! Description: Goes to the previous entry in the link list. If none, it returns NULL. See Also: xdll_use(). !*/ { xdllink *curr; CHECKUSE; if (xdllist_curr->head == NULL) /* nothing in the list ? */ goto error_return; /* no, error */ curr = xdllist_curr->curr; /* pointer to current entry */ if (curr->prev < 0) goto error_return; return ((void *) (xdllist_curr->curr = ADDBEG(curr->prev)) ); error_return: return (NULL); } /*! xdll_tail Go to the last entry in the link list. Summary: #include */ void *xdll_tail () /*! Return Value: Last position if OK, NULL if error. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ /*! Description: Goes to the last position in the linked list (the bottom). See Also: !*/ { xdllink *curr,*next; CHECKUSE; if (xdllist_curr->head == NULL) /* nothing in the list ? */ goto error_return; /* no, error */ if ( (curr = (xdllink *) xdllist_curr->curr) == NULL)/* start from current */ xdll_head(); /* otherwise, start from head of list */ /* goto the end from current position */ while ( (next = (xdllink *) xdll_next()) != NULL) { curr = next; } return ((void *)curr); /* this is the last one */ error_return: return (NULL); } /*! xdll_insert Insert a(nother) link in the list relative to curr pos. Summary: #include */ void *xdll_insert (int before) /*! Return Value: position of new link if OK, NULL if error. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int before ;/* I flag, True - insert before current link */ /* False - insert after current link */ #endif /*! Description: Adds a link relative to the current position in the of the linked list currently in use. Returns the position of where the link was added. Returns a NULL if the list is full or no list is in use. Adds the link relative to the current position. The `before` parameter determines whether the child is inserted before or after the current position. If the current position is NULL, then the list is empty and the new link will be the first one added. See Also: xdll_use(). !*/ { xdllink *curr, *newl; int nnew,ncurr; CHECKUSE; /* first find a node that is empty */ if ( (nnew = next_free_link(1)) < 0 ) goto error_return; /* uh oh, out of memory; die */ newl = ADDBEG(nnew); if (xdllist_curr->head == NULL) /* if list is empty */ { /* first entry, make it the head */ xdllist_curr->head = xdllist_curr->curr = newl; /* set to start of list */ newl->prev = HEADID; /* HEADID means its the head node */ newl->next = -1; /* initialize */ } else /* there are already links in the table */ { if ( (curr = xdllist_curr->curr) == NULL) goto error_return; /* uh oh, NULL or ran out of space */ ncurr = SUBBEG(curr); if ( before ) /* if inserting before curr */ { if (curr->prev >= 0) /* not head of list ? */ ADDBEG(curr->prev)->next = nnew; else xdllist_curr->head = newl; /* new head of the list */ newl->prev = curr->prev; /* OK even if curr->prev is < 0 */ newl->next = ncurr; /* next is previous current entry */ curr->prev = nnew; } else /* !before (after) inserting after curr */ { if (curr->next >= 0) /* not tail of list ? */ ADDBEG(curr->next)->prev = nnew; newl->next = curr->next; /* OK even if curr->next is <0 */ newl->prev = ncurr; /* next is previous current entry */ curr->next = nnew; } } return ((void *) newl); /* return position added */ error_return: return (NULL); /* means out of memory or id not opened */ } /*! xdll_delete Delete the current link. Summary: #include */ int xdll_delete (int flag) /*! Return Value: FUNCOK if OK, FUNCBAD if error. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int flag ;/* I True - reposition to previous link */ /* False - reposition to next link */ #endif /*! Description: Deletes the current link. It repositions the link to either the previous link or next link depending on the state of `flag`. See Also: xdll_use(). !*/ { xdllink *prev,*curr,*next; CHECKUSE; if (xdllist_curr->head != NULL) /* if list is empty */ { /* no, go ahead and delete */ curr = xdllist_curr->curr; /* pointer to current entry */ if (curr == NULL) goto error_return; /* you forgot to position it */ if (curr->next < 0) next = NULL; else (next = ADDBEG(curr->next))->prev = curr->prev; if (curr->prev < 0) /* if curr is head of the list */ { prev = NULL; xdllist_curr->head = next; } else (prev = ADDBEG(curr->prev))->next = curr->next; curr->prev = curr->next = -1; /* delete this link */ xdllist_curr->curr = ( (flag) ? prev : next); /* set to either prev or next */ /* note: could be NULL position, but thats OK */ } return (FUNCOK); error_return: return (FUNCBAD); } /*! xdll_goto Change to (goto) a specific position in the link list. Summary: #include */ void *xdll_goto (void * pos) /*! Return Value: New position if OK, NULL if pos does not exist or is empty. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC void *pos ;/* I Pointer to position to goto */ #endif /*! Description: The moves the current position to a new absolute position in the list. It assumes that 'pos' was retrieved using other position returning functions. If the new position is not in the list or is an empty cell, then a NULL is returned. Otherwise, the new position is returned. See Also: !*/ { xdllink *curr; CHECKUSE; if (xdllist_curr->head == NULL) /* nothing in the list ? */ goto error_return; /* no, error */ curr = (xdllink *) pos; /* convert to link struct */ /* make sure its a legal position */ /* an empty or deleted position has curr->next and curr->prev set to -1 */ /* if curr->prev == HEADID, that means its a head entry */ if ( curr->next == -1 && curr->prev == -1) /* no prev,no next, not head */ goto error_return; /* return error code if going to empty node */ xdllist_curr->curr = (xdllink *) pos; return (pos); error_return: return (NULL); /* means out of memory or id not opened */ } /*! xdll_clear() Clear out a linked list. Summary: #include */ int xdll_clear(int flag,void (*userfunc)(void*)) /*! Return Value: 0 (FUNCOK) if OK, -1 (FUNCBAD) if no linked list in use. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int flag ;/* I true - clear entire linked list */ /* false - clear only from head to tail */ void (*userfunc)();/* I User function that is called for every */ /* link cleared with the pointer to the * /* user's structure; NULL if no user function */ #endif /*! Description: Clears all of the cells in a linked list for the currently link list is use (from xdll_use()). Also sets head and curr pointers to NULL to indicate that the list is clear. If `flag` is set, all the links everywhere in the entire list are cleared. If `flag` is false, on the links in the current connected list from xdll_head() to xdll_tail() are cleared (deleted). This does nothing to the user's portion of the structure; only the link info. To clear the user info, the user must walk through their own structure or use the `userfunc` parameter. The `userfunc` is called every entry that a link is released for. The address of the user's structure is called as a parameter to this function (the parameter is a `void *` type and must be promoted to the user's structure by the user routine). See Also: !*/ { xdllink *curr; CHECKUSE; if (flag) /* if true, clear entire linked list structure out */ clear_links(xdllist_curr->beg,xdllist_curr->nlinks,userfunc); else /* just clear from head to tail and null out head */ { for(curr = (xdllink *) xdll_head(); curr != NULL; curr = (xdllink *) xdll_head() ) { if (userfunc != NULL) (*userfunc)((void *) curr); /* call user func to clear */ xdll_delete(0); /* delete link. Repo after */ } } xdllist_curr->curr = xdllist_curr->head = NULL; /* this says its all empty */ return(FUNCOK); error_return: return (FUNCBAD); /* none there, exit */ } /*! xdll_links_left Returns number of free links left in the list. Summary: #include */ int xdll_links_left () /*! Return Value: Number of links if OK, -1 if no list in use. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ /*! Description: This utility routine returns the number of free links left in the list. If it is zero, the list is full. See Also: !*/ { int num; CHECKUSE; for (num=0; /* set to start search at top of the link structure */ next_free_link(num==0) >= 0; /* go until none left anymore */ num++); /* set to search from current pos, incr num */ return (num); error_return: return (FUNCBAD); /* means out of memory or id not opened */ } /*! xdll_links_num Returns the number of links in the current link list. Summary: #include */ int xdll_links_num () /*! Return Value: Number of links if OK, -1 if no list in use. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ /*! Description: Returns the maximum number of links possible in a tree. Its the same as `xdllist_curr->nlinks`. The number of links used can be found as `xdll_links_num() - xdll_links_left()'. See Also: !*/ { CHECKUSE; return (xdllist_curr->nlinks); error_return: return (FUNCBAD); /* means out of memory or id not opened */ } /*! next_free_link Returns position of next free link. Summary: #include */ static int next_free_link(int flag) /*! Return Value: Offset of next free link relative to beginning of link list, -1 if none left. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC int flag ;/* I If true, start at top of link structure */ /* If false, continue from last position */ #endif /*! Description: This internal routine returns the address of the next free position in the link structure. It searches from the start of the structure if flag is true or continues from the last position if the flag is false. The flag is normally set to true when looking for a place to add a node. It is set to false when counting the number of remaining cells. See Also: !*/ { static xdllink *curr = NULL; /* static to hold its value */ static int i; /* link number */ xdllink *tpntr; if (flag || curr == NULL) { curr = xdllist_curr->beg; /* start of the table */ i = 0; /* set to start at top of list */ } while (i++ <= xdllist_curr->nlinks) { tpntr = curr; /* current position */ curr = (xdllink *) (((char *)curr) + xdllist_curr->size); /* preincr */ /* an empty or deleted position has tpntr->next and tpntr->prev set to -1 */ /* if tpntr->prev == HEADID, that means its a head entry */ if ( tpntr->next == -1 && tpntr->prev == -1) return (SUBBEG(tpntr)); } /* if you leave while, there are no remaining links */ curr = NULL; return (-1); /* none there, exit */ } /*! clear_links Clear from position in link list a spec'd # of links Summary: #include */ static int clear_links(xdllink * curr,int nlinks,void (*userfunc)(void*)) /*! Return Value: 0 always. Parameters: Type Name IO Description ------------ ----------- -- ----------- */ #ifdef DOC xdllink *curr ;/* I Position to start clearing links for */ int nlinks ;/* I Number of links to clear */ void (*userfunc)() ;/* I User function to call to clear their own */ /* structure elements; NULL if none */ #endif /*! Description: This internal routine clears the links in a user structure for `nlinks` records starting at `curr` position in the link structure. It is used to clear open'd and expanding re-opened link areas. See Also: Examples: To clear the entire current link list: clear_links(xdllist_curr->beg,xdllist_curr->nlinks); !*/ { while (nlinks-- > 0) { curr->prev = curr->next = -1; /* clear the links */ if (userfunc != NULL) (*userfunc)((void *) curr); /* call user func to clear */ curr = (xdllink *) (((char *)curr) + xdllist_curr->size); /* preincr */ } /* if you leave while, there are no remaining links */ return(FUNCOK); } ivtools-1.2.11a1/src/Dispatch/000077500000000000000000000000001214471147700160535ustar00rootroot00000000000000ivtools-1.2.11a1/src/Dispatch/dispatcher.cc000066400000000000000000000445231214471147700205200ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ // Dispatcher provides an interface to the "select" system call. #include #include #include #include #include #include #include #undef NULL #include #if defined(AIXV3) || defined(svr4) || defined(AIXV4) #include #endif #include #include #include #include /* no standard place for this */ extern "C" { #if defined(hpux) // extern int select(size_t, int*, int*, int*, struct timeval*); #else #if !defined(AIXV3) && !defined(svr4) && !defined(__lucid) && !defined(linux) extern int select(int, fd_set*, fd_set*, fd_set*, struct timeval*); #endif #endif #if defined(__DECCXX) || defined(sun) #if !defined(__svr4__) extern int gettimeofday(struct timeval*, struct timezone*); #endif #endif #if defined(sun) extern int sigvec(int sig, struct sigvec* vec, struct sigvec* ovec); #endif } #if defined(__GLIBC__) && (__GLIBC__==2 && __GLIBC_MINOR__>0 || __GLIBC__>2) && __GNUC__<3 #define fds_bits __fds_bits #endif Dispatcher* Dispatcher::_instance; class FdMask : public fd_set { public: FdMask(); void zero(); void setBit(int); void clrBit(int); boolean isSet(int); boolean anySet() const; int numSet() const; }; FdMask::FdMask() { zero(); } void FdMask::zero() { Memory::zero(this, sizeof(FdMask)); } void FdMask::setBit(int fd) { FD_SET(fd,this); } void FdMask::clrBit(int fd) { FD_CLR(fd,this); } boolean FdMask::isSet(int fd) { return FD_ISSET(fd,this); } boolean FdMask::anySet() const { const int mskcnt = howmany(FD_SETSIZE,NFDBITS); for (int i = 0; i < mskcnt; i++) { if (fds_bits[i]) { return true; } } return false; } int FdMask::numSet() const { const int mskcnt = howmany(FD_SETSIZE,NFDBITS); int n = 0; for (int i = 0; i < mskcnt; i++) { if (fds_bits[i]) { for (int j = 0; j < NFDBITS; j++) { if ((fds_bits[i] & (1 << j)) != 0) { n += 1; } } } } return n; } /* * Operations on timeval structures. */ const long ONE_SECOND = 1000000; timeval operator+(timeval src1, timeval src2) { timeval sum; sum.tv_sec = src1.tv_sec + src2.tv_sec; sum.tv_usec = src1.tv_usec + src2.tv_usec; if (sum.tv_usec >= ONE_SECOND) { sum.tv_usec -= ONE_SECOND; sum.tv_sec++; } else if (sum.tv_sec >= 1 && sum.tv_usec < 0) { sum.tv_usec += ONE_SECOND; sum.tv_sec--; } return sum; } timeval operator-(timeval src1, timeval src2) { timeval delta; delta.tv_sec = src1.tv_sec - src2.tv_sec; delta.tv_usec = src1.tv_usec - src2.tv_usec; if (delta.tv_usec < 0) { delta.tv_usec += ONE_SECOND; delta.tv_sec--; } else if (delta.tv_usec >= ONE_SECOND) { delta.tv_usec -= ONE_SECOND; delta.tv_sec++; } return delta; } boolean operator>(timeval src1, timeval src2) { if (src1.tv_sec > src2.tv_sec) { return true; } else if (src1.tv_sec == src2.tv_sec && src1.tv_usec > src2.tv_usec) { return true; } else { return false; } } boolean operator<(timeval src1, timeval src2) { if (src1.tv_sec < src2.tv_sec) { return true; } else if (src1.tv_sec == src2.tv_sec && src1.tv_usec < src2.tv_usec) { return true; } else { return false; } } /* * Interface to timers. */ struct Timer { Timer(timeval t, IOHandler* h, Timer* n); timeval timerValue; IOHandler* handler; Timer* next; }; class TimerQueue { public: TimerQueue(); virtual ~TimerQueue(); boolean isEmpty() const; static timeval zeroTime(); timeval earliestTime() const; static timeval currentTime(); void insert(timeval, IOHandler*); void remove(IOHandler*); void expire(timeval); private: Timer* _first; static timeval _zeroTime; }; Timer::Timer(timeval t, IOHandler* h, Timer* n) : timerValue(t), handler(h), next(n) {} timeval TimerQueue::_zeroTime; TimerQueue::TimerQueue() : _first(nil) {} TimerQueue::~TimerQueue() { Timer* doomed = _first; while (doomed != nil) { Timer* next = doomed->next; delete doomed; doomed = next; } } inline boolean TimerQueue::isEmpty() const { return _first == nil; } inline timeval TimerQueue::zeroTime() { return _zeroTime; } inline timeval TimerQueue::earliestTime() const { return _first->timerValue; } timeval TimerQueue::currentTime() { timeval curTime; #if defined(svr4) && !defined(__GNUC__) gettimeofday(&curTime); #else struct timezone curZone; gettimeofday(&curTime, &curZone); #endif return curTime; } void TimerQueue::insert(timeval futureTime, IOHandler* handler) { if (isEmpty() || futureTime < earliestTime()) { _first = new Timer(futureTime, handler, _first); } else { Timer* before = _first; Timer* after = _first->next; while (after != nil && futureTime > after->timerValue) { before = after; after = after->next; } before->next = new Timer(futureTime, handler, after); } } void TimerQueue::remove(IOHandler* handler) { Timer* before = nil; Timer* doomed = _first; while (doomed != nil && doomed->handler != handler) { before = doomed; doomed = doomed->next; } if (doomed != nil) { if (before == nil) { _first = doomed->next; } else { before->next = doomed->next; } delete doomed; } } void TimerQueue::expire(timeval curTime) { while (!isEmpty() && earliestTime() < curTime) { Timer* expired = _first; _first = _first->next; expired->handler->timerExpired(curTime.tv_sec, curTime.tv_usec); delete expired; } } /* * Interface to child process handling. */ struct Child { Child(pid_t pid, IOHandler* h, Child* n); pid_t pid; // process's PID int status; // wait status IOHandler* handler; // associated handler Child* next; }; class ChildQueue { public: ChildQueue(); virtual ~ChildQueue(); boolean isEmpty() const; boolean isReady() const; void insert(pid_t, IOHandler*); void remove(IOHandler*); void notify(); void setStatus(pid_t, int status); private: Child* _first; // queue head boolean _ready; // something is ready }; Child::Child(pid_t p, IOHandler* h, Child* n) { pid = p; status = -1; handler = h; next = n; } ChildQueue::ChildQueue() { _first = nil; _ready = false; } ChildQueue::~ChildQueue() { Child* doomed = _first; while (doomed != nil) { Child* next = doomed->next; delete doomed; doomed = next; } } inline boolean ChildQueue::isEmpty() const { return _first == nil; } inline boolean ChildQueue::isReady() const { return _ready; } void ChildQueue::insert(pid_t p, IOHandler* handler) { if (isEmpty()) { _first = new Child(p, handler, _first); } else { Child* before = _first; Child* after = _first->next; while (after != nil && p > after->pid) { before = after; after = after->next; } before->next = new Child(p, handler, after); } } void ChildQueue::remove(IOHandler* handler) { Child* before = nil; Child* doomed = _first; while (doomed != nil && doomed->handler != handler) { before = doomed; doomed = doomed->next; } if (doomed != nil) { if (before == nil) { _first = doomed->next; } else { before->next = doomed->next; } delete doomed; } } void ChildQueue::setStatus(pid_t p, int status) { for (Child* c = _first; c != nil; c = c->next) { if (c->pid == p) { c->status = status; _ready = true; break; } } } void ChildQueue::notify() { Child** prev = &_first; Child* c; while ((c = *prev) != nil) { if (c->status != -1) { c->handler->childStatus(c->pid, c->status); *prev = c->next; delete c; } else { prev = &c->next; } } _ready = false; } #if defined(__svr4__) && defined(sun) && NOFILE==20 #undef NOFILE #define NOFILE 256 #endif Dispatcher::Dispatcher() { _nfds = 0; _rmask = new FdMask; _wmask = new FdMask; _emask = new FdMask; _rmaskready = new FdMask; _wmaskready = new FdMask; _emaskready = new FdMask; _rtable = new IOHandler*[NOFILE]; _wtable = new IOHandler*[NOFILE]; _etable = new IOHandler*[NOFILE]; _queue = new TimerQueue; _cqueue = new ChildQueue; for (int i = 0; i < NOFILE; i++) { _rtable[i] = nil; _wtable[i] = nil; _etable[i] = nil; } } Dispatcher::~Dispatcher() { delete _rmask; delete _wmask; delete _emask; delete _rmaskready; delete _wmaskready; delete _emaskready; delete [] _rtable; delete [] _wtable; delete [] _etable; delete _queue; delete _cqueue; } Dispatcher& Dispatcher::instance() { if (_instance == nil) { _instance = new Dispatcher; } return *_instance; } void Dispatcher::instance(Dispatcher* d) { _instance = d; } IOHandler* Dispatcher::handler(int fd, DispatcherMask mask) const { if (fd < 0 || fd >= NOFILE) { abort(); } IOHandler* cur = nil; if (mask == ReadMask) { cur = _rtable[fd]; } else if (mask == WriteMask) { cur = _wtable[fd]; } else if (mask == ExceptMask) { cur = _etable[fd]; } else { abort(); } return cur; } void Dispatcher::link(int fd, DispatcherMask mask, IOHandler* handler) { if (fd < 0 || fd >= NOFILE) { abort(); } attach(fd, mask, handler); } void Dispatcher::unlink(int fd) { if (fd < 0 || fd >= NOFILE) { abort(); } detach(fd); } void Dispatcher::attach(int fd, DispatcherMask mask, IOHandler* handler) { if (mask == ReadMask) { _rmask->setBit(fd); _rtable[fd] = handler; } else if (mask == WriteMask) { _wmask->setBit(fd); _wtable[fd] = handler; } else if (mask == ExceptMask) { _emask->setBit(fd); _etable[fd] = handler; } else { abort(); } if (_nfds < fd+1) { _nfds = fd+1; } } void Dispatcher::detach(int fd) { _rmask->clrBit(fd); _rtable[fd] = nil; _wmask->clrBit(fd); _wtable[fd] = nil; _emask->clrBit(fd); _etable[fd] = nil; if (_nfds == fd+1) { while (_nfds > 0 && _rtable[_nfds-1] == nil && _wtable[_nfds-1] == nil && _etable[_nfds-1] == nil ) { _nfds--; } } } void Dispatcher::startTimer(long sec, long usec, IOHandler* handler) { timeval deltaTime; deltaTime.tv_sec = sec; deltaTime.tv_usec = usec; _queue->insert(TimerQueue::currentTime() + deltaTime, handler); } void Dispatcher::stopTimer(IOHandler* handler) { _queue->remove(handler); } void Dispatcher::startChild(int pid, IOHandler* handler) { _cqueue->insert(pid, handler); } void Dispatcher::stopChild(IOHandler* handler) { _cqueue->remove(handler); } boolean Dispatcher::setReady(int fd, DispatcherMask mask) { if (handler(fd, mask) == nil) { return false; } if (mask == ReadMask) { _rmaskready->setBit(fd); } else if (mask == WriteMask) { _wmaskready->setBit(fd); } else if (mask == ExceptMask) { _emaskready->setBit(fd); } else { return false; } return true; } void Dispatcher::dispatch() { dispatch(nil); } boolean Dispatcher::dispatch(long& sec, long& usec) { timeval howlong; timeval prevTime; timeval elapsedTime; howlong.tv_sec = sec; howlong.tv_usec = usec; prevTime = TimerQueue::currentTime(); boolean success = dispatch(&howlong); elapsedTime = TimerQueue::currentTime() - prevTime; if (howlong > elapsedTime) { howlong = howlong - elapsedTime; } else { howlong = TimerQueue::zeroTime(); /* Used all of timeout */ } sec = howlong.tv_sec; usec = howlong.tv_usec; return success; } boolean Dispatcher::dispatch(timeval* howlong) { FdMask rmaskret; FdMask wmaskret; FdMask emaskret; int nfound; if (anyReady()) { nfound = fillInReady(rmaskret, wmaskret, emaskret); } else { nfound = waitFor(rmaskret, wmaskret, emaskret, howlong); } notify(nfound, rmaskret, wmaskret, emaskret); return (nfound != 0); } boolean Dispatcher::anyReady() const { return _rmaskready->anySet() || _wmaskready->anySet() || _emaskready->anySet(); } int Dispatcher::fillInReady( FdMask& rmaskret, FdMask& wmaskret, FdMask& emaskret ) { rmaskret = *_rmaskready; wmaskret = *_wmaskready; emaskret = *_emaskready; _rmaskready->zero(); _wmaskready->zero(); _emaskready->zero(); return rmaskret.numSet() + wmaskret.numSet() + emaskret.numSet(); } #if defined(__GNUC__) && !defined(__GNUC_MINOR__) void Dispatcher::sigCLD() { #else void Dispatcher::sigCLD(...) { #endif pid_t pid; int status; while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { Dispatcher::instance()._cqueue->setStatus(pid, status); } } #ifndef fxSIGHANDLER #define fxSIGHANDLER #endif #ifndef fxSIGVECHANDLER #define fxSIGVECHANDLER #endif #ifndef fxSIGACTIONHANDLER #define fxSIGACTIONHANDLER #endif #ifndef SA_INTERRUPT #define SA_INTERRUPT 0 #endif #ifndef SIGCLD /* attempt to correct for glibc2 signal names */ #define SIGCLD SIGCHLD #endif int Dispatcher::waitFor( FdMask& rmaskret, FdMask& wmaskret, FdMask& emaskret, timeval* howlong ) { int nfound; #ifdef SV_INTERRUPT /* BSD-style */ #if defined(sun) && defined(__GNUC__) static struct sigaction sv, osv; #else static struct sigvec sv, osv; #endif #else #ifdef SA_NOCLDSTOP /* POSIX */ static struct sigaction sa, osa; #else /* System V-style */ void (*osig)(); #endif #endif if (!_cqueue->isEmpty()) { #ifdef SV_INTERRUPT /* BSD-style */ #if defined(sun) && defined(__GNUC__) sv.sa_handler = fxSIGVECHANDLER(&Dispatcher::sigCLD); sv.sa_flags = SV_INTERRUPT; sigaction(SIGCLD, &sv, &osv); #else sv.sv_handler = (void (*)(int)) fxSIGVECHANDLER(&Dispatcher::sigCLD); sv.sv_flags = SV_INTERRUPT; sigvec(SIGCLD, &sv, &osv); #endif #else #ifdef SA_NOCLDSTOP /* POSIX */ #if defined(__CYGWIN__) || defined(hpux) || defined(linux) || defined(sun) && defined(__svr4__) sa.sa_handler = (void (*)(int))(&Dispatcher::sigCLD); #else sa.sa_handler = fxSIGACTIONHANDLER(&Dispatcher::sigCLD); #endif sa.sa_flags = SA_INTERRUPT; sigaction(SIGCLD, &sa, &osa); #else /* System V-style */ osig = (void (*)())signal(SIGCLD, fxSIGHANDLER(&Dispatcher::sigCLD)); #endif #endif } do { rmaskret = *_rmask; wmaskret = *_wmask; emaskret = *_emask; howlong = calculateTimeout(howlong); #if defined(hpux) nfound = select( _nfds, (int*)&rmaskret, (int*)&wmaskret, (int*)&emaskret, howlong ); #else nfound = select(_nfds, &rmaskret, &wmaskret, &emaskret, howlong); #endif } while (nfound < 0 && !handleError()); if (!_cqueue->isEmpty()) { #ifdef SV_INTERRUPT /* BSD-style */ #if defined(sun) && defined(__GNUC__) sigaction(SIGCLD, &osv, (struct sigaction*) 0); #else sigvec(SIGCLD, &osv, (struct sigvec*) 0); #endif #else #ifdef SA_NOCLDSTOP /* POSIX */ sigaction(SIGCLD, &osa, (struct sigaction*) 0); #else /* System V-style */ (void) signal(SIGCLD, fxSIGHANDLER(osig)); #endif #endif } return nfound; /* Timed out or input available */ } void Dispatcher::notify( int nfound, FdMask& rmaskret, FdMask& wmaskret, FdMask& emaskret ) { for (int i = 0; i < _nfds && nfound > 0; i++) { if (rmaskret.isSet(i)) { #if 0 int status = _rtable[i]->inputReady(i); #else int status = (_rtable[i] ? _rtable[i]->inputReady(i) : 0); #endif if (status < 0) { detach(i); } else if (status > 0) { _rmaskready->setBit(i); } nfound--; } if (wmaskret.isSet(i)) { #if 0 int status = _wtable[i]->outputReady(i); #else int status = (_wtable[i] ? _wtable[i]->outputReady(i) : 0); #endif if (status < 0) { detach(i); } else if (status > 0) { _wmaskready->setBit(i); } nfound--; } if (emaskret.isSet(i)) { #if 0 int status = _etable[i]->exceptionRaised(i); #else int status = (_etable[i] ? _etable[i]->exceptionRaised(i) : 0); #endif if (status < 0) { detach(i); } else if (status > 0) { _emaskready->setBit(i); } nfound--; } } if (!_queue->isEmpty()) { _queue->expire(TimerQueue::currentTime()); } if (_cqueue->isReady()) { _cqueue->notify(); } } timeval* Dispatcher::calculateTimeout(timeval* howlong) const { static timeval timeout; if (!_queue->isEmpty()) { timeval curTime; curTime = TimerQueue::currentTime(); if (_queue->earliestTime() > curTime) { timeout = _queue->earliestTime() - curTime; if (howlong == nil || *howlong > timeout) { howlong = &timeout; } } else { timeout = TimerQueue::zeroTime(); howlong = &timeout; } } return howlong; } boolean Dispatcher::handleError() { switch (errno) { case EBADF: checkConnections(); break; case EINTR: if (_cqueue->isReady()) { return true; } break; default: perror("Dispatcher: select"); exit(1); /*NOTREACHED*/ } return false; // retry select; } void Dispatcher::checkConnections() { FdMask rmask; timeval poll = TimerQueue::zeroTime(); for (int fd = 0; fd < _nfds; fd++) { if (_rtable[fd] != nil) { rmask.setBit(fd); #if defined(hpux) if (select(fd+1, (int*)&rmask, nil, nil, &poll) < 0) { #else if (select(fd+1, &rmask, nil, nil, &poll) < 0) { #endif detach(fd); } rmask.clrBit(fd); } } } ivtools-1.2.11a1/src/Dispatch/iohandler.cc000066400000000000000000000032361214471147700203330ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include // Implement conceptually abstract virtual functions in the base class // so derived classes don't have to implement unused ones. IOHandler::IOHandler() {} IOHandler::~IOHandler() {} int IOHandler::inputReady(int) { return -1; } int IOHandler::outputReady(int) { return -1; } int IOHandler::exceptionRaised(int) { return -1; } void IOHandler::timerExpired(long, long) {} void IOHandler::childStatus(pid_t, int) {} ivtools-1.2.11a1/src/Dispatch/iostreamb.cc000066400000000000000000000277031214471147700203600ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include // Make sure that these assumptions about the sizes of integral types // hold for your machine. If your machine does not have 32-bit and // 16-bit integers, then you cannot use binary I/O because other // machines will expect the integers to be these sizes. If your // machine does not have 8-bit characters, then I don't know how // you're going to communicate with other machines! typedef long INT32; typedef short INT16; typedef unsigned long UINT32; typedef unsigned short UINT16; // Assume the peer machine has the same endian architecture but // disable binary I/O by default anyway. The two machines should // always negotiate these two options before enabling binary I/O. iosb::iosb() : _binary(false), _swapped(false) {} iosb::~iosb() {} // Get and set iosb's extra state information. Verify that the // assumptions about sizes of integral types hold before enabling // binary I/O; if they do not hold, then refuse to enable binary I/O. boolean iosb::binary() const { return _binary; } void iosb::binary(boolean binary) { if (binary) { // don't use consts; cfront has wrong idea of their values UINT32 max32 = ~0; UINT16 max16 = ~0; if (max32 != 0xffffffff || max16 != 0xffff) { binary = false; } } _binary = binary; } boolean iosb::swapped() const { return _swapped; } void iosb::swapped(boolean swapped) { _swapped = swapped; } // Provide a constructor for derived classes to use and a constructor // for public use. istreamb::istreamb() {} istreamb::istreamb(streambuf* b) { init(b); } istreamb::~istreamb() {} // Redefine these functions to extract binary data where possible for // faster I/O throughput and to discard delimiters automatically. // Binary integral values occupy the length implied by their type and // already fit this machine's endian architecture. Formatted integral // and floating point values end in a blank character that is // extracted. Strings end in a null character that is extracted. istreamb& istreamb::operator>>(char& c) { get(c); // assume c is 8 bits long on all machines return *this; } istreamb& istreamb::operator>>(unsigned char& uc) { get(uc); // assume uc is 8 bits long on all machines return *this; } istreamb& istreamb::operator>>(short& s) { if (_binary) { INT16 value; read((char*)&value, sizeof(value)); if (good()) { s = (short)value; if (s != value) { setstate(ios::failbit); // overflow: value won't fit in short } } } else { istream::operator>>(s); get(); } return *this; } istreamb& istreamb::operator>>(unsigned short& us) { if (_binary) { UINT16 value; read((char*)&value, sizeof(value)); if (good()) { us = (unsigned short)value; if (us != value) { setstate(ios::failbit); // overflow: value won't fit in ushort } } } else { istream::operator>>(us); get(); } return *this; } istreamb& istreamb::operator>>(int& i) { if (_binary) { INT32 value; read((char*)&value, sizeof(value)); if (good()) { i = (int)value; if (i != value) { setstate(ios::failbit); // overflow: value won't fit in int } } } else { istream::operator>>(i); get(); } return *this; } istreamb& istreamb::operator>>(unsigned int& ui) { if (_binary) { UINT32 value; read((char*)&value, sizeof(value)); if (good()) { ui = (unsigned int)value; if (ui != value) { setstate(ios::failbit); // overflow: value won't fit in uint } } } else { istream::operator>>(ui); get(); } return *this; } istreamb& istreamb::operator>>(long& l) { if (_binary) { INT32 value; read((char*)&value, sizeof(value)); if (good()) { l = (long)value; if (l != value) { setstate(ios::failbit); // overflow: value won't fit in long } } } else { istream::operator>>(l); get(); } return *this; } istreamb& istreamb::operator>>(unsigned long& ul) { if (_binary) { UINT32 value; read((char*)&value, sizeof(value)); if (good()) { ul = (unsigned long)value; if (ul != value) { setstate(ios::failbit); // overflow: value won't fit in ulong } } } else { istream::operator>>(ul); get(); } return *this; } istreamb& istreamb::operator>>(float& f) { istream::operator>>(f); get(); return *this; } istreamb& istreamb::operator>>(double& d) { istream::operator>>(d); get(); return *this; } istreamb& istreamb::operator>>(char* p) { const int MAXINT = (int)(((unsigned)-1) >> 1); const int w = width(0); getline(p, w ? w : MAXINT, '\0'); if (w && gcount() == w - 1) { setstate(ios::failbit); } return *this; } istreamb& istreamb::operator>>(unsigned char* up) { const int MAXINT = (int)(((unsigned)-1) >> 1); const int w = width(0); getline(up, w ? w : MAXINT, '\0'); if (w && gcount() == w - 1) { setstate(ios::failbit); } return *this; } // Redefine the rest of the overloaded operator>> functions that we // want to keep in the derived class. istreamb& istreamb::operator>>(istream& (*f)(istream&)) { istream::operator>>(f); return *this; } istreamb& istreamb::operator>>(ios& (*f)(ios&)) { istream::operator>>(f); return *this; } // Provide a constructor for derived classes to use and a constructor // for public use. ostreamb::ostreamb() {} ostreamb::ostreamb(streambuf* b) { init(b); } ostreamb::~ostreamb() {} // Decrement the width by one to take into account the delimiter // character that all the inserters insert after a formatted value. inline void ostreamb::fixwidth() { register int w = width(); if (w) { width(w - 1); } } // Redefine these functions to insert binary data where possible for // faster I/O throughput and to delimit formatted data automatically. // Binary integral values will occupy the length implied by their type // and fit the peer's endian architecture. Formatted integral and // floating point values will end in a blank character. Strings will // end in a null character. You need not, and should not, insert // explicit delimiters. ostreamb& ostreamb::operator<<(char c) { put(c); // assume c is 8 bits long on all machines return *this; } ostreamb& ostreamb::operator<<(unsigned char uc) { put(uc); // assume uc is 8 bits long on all machines return *this; } ostreamb& ostreamb::operator<<(short s) { if (_binary) { INT16 value = (INT16)s; if (value != s) { setstate(ios::failbit); // overflow: number won't fit in 16 bits } else if (_swapped) { INT16 copy = value; ((char*)&value)[0] = ((char*)©)[1]; ((char*)&value)[1] = ((char*)©)[0]; } width(0); write((char*)&value, sizeof(value)); } else { fixwidth(); ostream::operator<<(s); put(' '); } return *this; } ostreamb& ostreamb::operator<<(unsigned short us) { if (_binary) { UINT16 value = (UINT16)us; if (value != us) { setstate(ios::failbit); // number won't fit } else if (_swapped) { UINT16 copy = value; ((char*)&value)[0] = ((char*)©)[1]; ((char*)&value)[1] = ((char*)©)[0]; } width(0); write((char*)&value, sizeof(value)); } else { fixwidth(); ostream::operator<<(us); put(' '); } return *this; } ostreamb& ostreamb::operator<<(int i) { return *this << (long)i; } ostreamb& ostreamb::operator<<(unsigned int ui) { return *this << (unsigned long)ui; } ostreamb& ostreamb::operator<<(long l) { if (_binary) { INT32 value = (INT32)l; if (value != l) { setstate(ios::failbit); // overflow: number won't fit in 32 bits } else if (_swapped) { INT32 copy = value; ((char*)&value)[0] = ((char*)©)[3]; ((char*)&value)[1] = ((char*)©)[2]; ((char*)&value)[2] = ((char*)©)[1]; ((char*)&value)[3] = ((char*)©)[0]; } width(0); write((char*)&value, sizeof(value)); } else { fixwidth(); ostream::operator<<(l); put(' '); } return *this; } ostreamb& ostreamb::operator<<(unsigned long ul) { if (_binary) { UINT32 value = (UINT32)ul; if (value != ul) { setstate(ios::failbit); // overflow: number won't fit in 32 bits } else if (_swapped) { UINT32 copy = value; ((char*)&value)[0] = ((char*)©)[3]; ((char*)&value)[1] = ((char*)©)[2]; ((char*)&value)[2] = ((char*)©)[1]; ((char*)&value)[3] = ((char*)©)[0]; } width(0); write((char*)&value, sizeof(value)); } else { fixwidth(); ostream::operator<<(ul); put(' '); } return *this; } ostreamb& ostreamb::operator<<(float f) { fixwidth(); ostream::operator<<(f); put(' '); return *this; } ostreamb& ostreamb::operator<<(double d) { fixwidth(); ostream::operator<<(d); put(' '); return *this; } ostreamb& ostreamb::operator<<(const char* p) { fixwidth(); ostream::operator<<(p); put('\0'); return *this; } ostreamb& ostreamb::operator<<(const unsigned char* up) { fixwidth(); ostream::operator<<((const char*)up); // 2.0 ostream omitted unsigned char* put('\0'); return *this; } // Redefine the rest of the overloaded operator<< functions that we // want to keep in the derived class. ostreamb& ostreamb::operator<<(ostream& (*f)(ostream&)) { ostream::operator<<(f); return *this; } ostreamb& ostreamb::operator<<(ios& (*f)(ios&)) { ostream::operator<<(f); return *this; } // Provide a constructor for derived classes to use and a constructor // for public use. iostreamb::iostreamb() {} iostreamb::iostreamb(streambuf* b) { init(b); } iostreamb::~iostreamb() {} // Negotiate the option of binary I/O with the remote iostreamb. If // binary I/O is set, compare endians to enable swapping if necessary. // Ordinarily we don't need an explicit flush when we're switching // from insertion to extraction, but we do here because the first // underflow may read both format and remoteEndian, thus preventing // underflow from being called again and flushing localEndian. Tying // the stream to itself won't work either because 1) ipfx won't call // flush if remoteEndian is already available, and 2) opfx will make // the stream flush itself before every insertion because it doesn't // check for streams tied to themselves. Sigh.... void iostreamb::negotiate(boolean b) { if (!good()) { return; } iosb::binary(b); char format = iosb::binary() ? 'T' : 'F'; *this << format; flush(); *this >> format; if (format != 'T' && format != 'F') { setstate(ios::badbit); } else if (format == 'F') { iosb::binary(false); } if (iosb::binary()) { int indian = 1; char localEndian = (*(char*)&indian) ? 'l' : 'B'; char remoteEndian = localEndian; *this << localEndian; flush(); *this >> remoteEndian; if (remoteEndian != 'l' && remoteEndian != 'B') { setstate(ios::badbit); } else if (remoteEndian != localEndian) { swapped(true); } } } ivtools-1.2.11a1/src/Dispatch/netinet_in.h000066400000000000000000000036761214471147700203740ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * C++ interface to internet definitions. */ #ifndef netinet_in_h /* * Don't try to hide the ntohl prototypes because they may be * defined as macros, but don't define them as extern "C" either. */ #include #ifndef __lucid #ifndef __linux__ #ifndef ntohl /* * The operations are defined as functions, possibly without prototypes, * so we provide our own extern "C" declarations. */ extern "C" { unsigned long ntohl(unsigned long); unsigned long htonl(unsigned long); #if defined(__svr4__) unsigned short ntohs(unsigned int); unsigned short htons(unsigned int); #else unsigned short ntohs(unsigned short); unsigned short htons(unsigned short); #endif } #endif #endif /* __linux__ */ #endif #endif ivtools-1.2.11a1/src/Dispatch/rpcbuf.cc000066400000000000000000000362351214471147700176540ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include #include #include /* must come before on some systems */ extern "C" { #include } #include "netinet_in.h" #include #include #include #include #ifndef __DECCXX #include #endif #include #include #include #ifndef SOMAXCONN #define SOMAXCONN 5 #endif #if defined(__sun) && !defined(__svr4__) extern "C" { int accept(); int bind(); int connect(); int getsockname(); int listen(); int socket(); } #endif #if !defined(SOCKLEN_T_DEFINED) || !SOCKLEN_T_DEFINED typedef int socklen_t; #endif // I need a pointer to an iostreamb so I can insert and extract values // in the length field of RPC requests. If I don't have a stream, I // won't allow you to call start_request(). rpcbuf::rpcbuf(iostreamb* mystream) : streambuf(), _mystream(mystream), _rptr(nil), _actualWidth(0), _host(nil), _port(0), _fd(-1), _opened(false), _close(false), _nonblocking(false), _verbose(true) {} // Free the buffer used to store the put area. The streambuf // destructor will free the buffer used to store the get area. rpcbuf::~rpcbuf() { close(); delete pbase(); setp(nil, nil); } // Return information about the connection. const char* rpcbuf::host() { return _host; } int rpcbuf::port() { if (!_opened) { return 0; } if (_port) { return _port; } struct sockaddr_in name; socklen_t name_len = sizeof(name); if (getsockname(_fd, (struct sockaddr*)&name, &name_len) < 0) { sys_error("rpcbuf::port: getsockname"); return 0; } _port = ntohs(name.sin_port); return _port; } int rpcbuf::fd() { return _fd; } boolean rpcbuf::opened() { return _opened; } boolean rpcbuf::nonblocking() { return _nonblocking; } // Create a socket, bind the socket to a port address, and prepare to // accept incoming connections. rpcbuf* rpcbuf::listen(int port) { struct sockaddr_in name; Memory::zero(&name, sizeof(name)); name.sin_family = AF_INET; name.sin_port = htons(port); name.sin_addr.s_addr = htonl(INADDR_ANY); if (_opened) { error("rpcbuf::listen: already using a file number"); return nil; } int fd = socket(AF_INET, SOCK_STREAM, 0); if (fd < 0) { sys_error("rpcbuf::listen: socket"); return nil; } if (bind(fd, (struct sockaddr*)&name, sizeof(name)) < 0) { sys_error("rpcbuf::listen: bind"); ::close(fd); return nil; } if (::listen(fd, SOMAXCONN) < 0) { sys_error("rpcbuf::listen: listen"); ::close(fd); return nil; } _host = nil; _port = port; _fd = fd; _opened = true; _close = true; _nonblocking = false; return this; } // Create a socket and make a connection to another socket. Do // retries in case the peer has hit its backlog, but not too many // retries since the error is indistinguishable from there not being a // peer listening at all. rpcbuf* rpcbuf::connect(const char* host, int port) { struct sockaddr_in name; Memory::zero(&name, sizeof(name)); name.sin_family = AF_INET; name.sin_port = htons(port); if (_opened) { error("rpcbuf::connect: already using a file number"); return nil; } const unsigned long INVALIDADDR = (unsigned long) -1; unsigned long hostinetaddr = INVALIDADDR; if (isascii(host[0]) && isdigit(host[0])) { hostinetaddr = inet_addr(host); name.sin_addr.s_addr = hostinetaddr; } if (hostinetaddr == INVALIDADDR) { /* cast to workaround bug in prototype on some systems */ struct hostent* hp = gethostbyname((char*)host); if (hp == nil) { error("rpcbuf::connect: gethostbyname: no such host"); return nil; } if (hp->h_addrtype != AF_INET) { error("rpcbuf::connect: gethostbyname: not an Internet host"); return nil; } Memory::copy(hp->h_addr, &name.sin_addr, sizeof(name.sin_addr)); } int fd = -1; int retries = 2; do { fd = socket(AF_INET, SOCK_STREAM, 0); if (fd < 0) { sys_error("rpcbuf::connect: socket"); return nil; } if (::connect(fd, (struct sockaddr*)&name, sizeof(name)) < 0) { if (errno == ECONNREFUSED && retries > 0) { // try again since peer's backlog may just be full ::close(fd); sleep(1); continue; } else { sys_error("rpcbuf::connect: connect"); ::close(fd); return nil; } } break; // the connection succeeded } while (retries-- > 0); _host = host; _port = port; _fd = fd; _opened = true; _close = true; _nonblocking = false; return this; } // Accept an incoming connection, allocate a new file descriptor for // it, and return the new file descriptor. rpcbuf* rpcbuf::accept(int& fd) { struct sockaddr_in name; socklen_t name_len = sizeof(name); if (!_opened) { error("rpcbuf::accept: not using a file number yet"); return nil; } fd = ::accept(_fd, (struct sockaddr*)&name, &name_len); if (fd < 0) { sys_error("rpcbuf::accept: accept"); return nil; } return this; } // Attach the streambuf to a file descriptor. The streambuf cannot // close the file descriptor because something else might be using it. rpcbuf* rpcbuf::attach(int fd) { if (_opened) { error("rpcbuf::attach: already using a file number"); return nil; } if (fd < 0) { error("rpcbuf::attach: cannot use a negative file number"); return nil; } _host = nil; _port = 0; _fd = fd; _opened = true; _close = false; _nonblocking = false; return this; } // Empty the get/put areas, close the file descriptor if nothing else // might use it, and detach the streambuf from the file descriptor. rpcbuf* rpcbuf::close() { if (!_opened) { return nil; } sync(); int ok = 0; if (_close) { ok = ::close(_fd); if (ok < 0) { sys_error("rpcbuf::close: close"); } } _host = nil; _port = 0; _fd = -1; _opened = false; _close = false; _nonblocking = false; return (ok < 0) ? nil : this; } // Set or clear non-blocking I/O on the file descriptor. rpcbuf* rpcbuf::nonblocking(boolean nonblocking) { if (!_opened) { error("rpcbuf::nonblocking: not using a file number yet"); return nil; } if (_nonblocking != nonblocking) { int flags = fcntl(_fd, F_GETFL, 0); if (flags < 0) { sys_error("rpcbuf::nonblocking: F_GETFL fcntl"); return nil; } if (nonblocking) { flags |= O_NDELAY; } else { flags &= ~O_NDELAY; } if (fcntl(_fd, F_SETFL, flags) < 0) { sys_error("rpcbuf::nonblocking: F_SETFL fcntl"); return nil; } } _nonblocking = nonblocking; return this; } // Set or clear printing of system error messages. rpcbuf* rpcbuf::verbose(boolean verbose) { _verbose = verbose; return this; } int zapeof(int c) { return c == EOF ? 0 : c; } // Finish the current request, if any, and then start a new request. // The request begins with a length field, so insert a zero with // enough padding characters (if using formatted I/O) to overwrite the // zero later with 2**32 - 1, the largest possible length for a // request (the length must fit in an int). const int FIELDWIDTH = 11; // large enough to hold "2147483647 " int rpcbuf::start_request() { if (!_mystream || !_opened || allocate() == EOF) { return EOF; } finish_request(); setr(pptr()); const int length = 0; mystream().width(FIELDWIDTH); mystream() << length; _actualWidth = pptr() - rptr(); return 0; } // Finish the current request by inserting its final length in the // length field at the beginning of the request (overwriting the old // value). The length of the request includes its own length field. void rpcbuf::finish_request() { int length = pptr() - rptr(); if (rptr() && length > 0) { pbump(-length); mystream().width(FIELDWIDTH); mystream() << length; if (_actualWidth != pptr() - rptr()) { error("rpcbuf::finish_request: length field's width changed"); } pbump(length - (pptr() - rptr())); } setr(nil); } // Calculate the width of the length field (_actualWidth) and check // that all of the length field is in the buffer. If so, extract the // length, move the get pointer back to the beginning of the request, // and return 0 if all of the request is in the buffer. Otherwise, // return EOF. By checking for EOF, the caller avoids extracting a // request before it's completely buffered. The caller must call // select() to wait for new input and call rpcbuf::underflow() to // enqueue it until the complete request is buffered. int rpcbuf::read_request() { if (!_mystream) { return EOF; } if (!_actualWidth) { char* orig = pptr(); const int length = 0; mystream().width(FIELDWIDTH); mystream() << length; _actualWidth = pptr() - orig; pbump(orig - pptr()); } int navail = in_avail(); if (navail < _actualWidth) { return EOF; } char* orig = gptr(); int length = 0; mystream() >> length; gbump(orig - gptr()); if (length <= 0) { error("rpcbuf::read_request: zero or negative length"); return EOF; } if (length > ebuf() - eback() && !expand_g(length * 2)) { error("rpcbuf::read_request: out of memory"); return EOF; } if (navail < length) { return EOF; } else { return 0; } } // Finish the current RPC request if there's nothing to append to it, // thus allowing flush to send the current RPC request. Send any // outgoing data using a loop to safeguard against partial writes. // Shift any still incomplete RPC request to the beginning of the put // area to make room for more data. Append the overflow char if any. int rpcbuf::overflow(int c) { if (!_opened || allocate() == EOF) { return EOF; } if (c == EOF) { finish_request(); } if (rptr() == pbase() && pptr() >= epptr() && !expand_p()) { error("rpcbuf::overflow: out of memory"); return EOF; } int nwrite = (rptr() >= pbase()) ? rptr() - pbase() : out_waiting(); int count = 0; while (count < nwrite) { int nsent = write(_fd, pbase() + count, nwrite - count); if (nsent < 0) { sys_error("rpcbuf::overflow: write"); return EOF; } count += nsent; } if (rptr() > pbase()) { Memory::copy(rptr(), pbase(), pptr() - rptr()); rbump(-nwrite); } pbump(-nwrite); if (c != EOF) { sputc(c); } return zapeof(c); } // Empty the put area before filling the get area in case the input // depends on the output just flushed. Move any unread data between // gptr() and egptr() to the beginning of the get area. The get area // may contain unread data under nonblocking I/O because an incomplete // RPC request is not extracted until the rest of its data arrives. // Read as much data as available into the free space between egptr() // and ebuf() (the get area occupies the entire buffer). Move egptr() // to the end of the new data. Return the first unread character. int rpcbuf::underflow() { if (!_opened || allocate() == EOF) { return EOF; } if (overflow() == EOF) { return EOF; } int nunread = in_avail(); if (nunread) { Memory::copy(gptr(), eback(), nunread); } setg(eback(), eback(), eback() + nunread); int nread = read(_fd, egptr(), ebuf() - egptr()); if (nread < 0) { sys_error("rpcbuf::underflow: read"); return EOF; } if (nread == 0) { return EOF; } setg(eback(), gptr(), egptr() + nread); return zapeof(*gptr()); } // Probably called from ios's destructor. Can't do anything with // still unread data except discard it, but can flush any outgoing RPC // requests from the put area. int rpcbuf::sync() { gbump(in_avail()); return out_waiting() ? overflow() : 0; } // Can't seek on a socket, but can return the get pointer's current // position so that the caller can find out how many bytes he read // since the get pointer's last position (within the same request). #ifdef cplusplus_2_1 streampos rpcbuf::seekoff(streamoff offset, ios::seek_dir dir, int mode) { #else streampos rpcbuf::seekoff(streamoff offset, seek_dir dir, int mode) { #endif if (!_opened || !gptr()) { return EOF; } if (offset != 0 || dir != ios::cur || mode != ios::in) { return EOF; } return (streampos)gptr(); } // Refuse any attempt to set the buffers for storing incoming and // outgoing RPC requests because we need the ability to dynamically // expand the buffers' sizes. streambuf* rpcbuf::setbuf(char*, int) { return nil; } // Dynamically allocate two separate buffers for storing incoming and // outgoing RPC requests. Allocating separate buffers for the get and // put areas makes it easier to expand either area later if necessary. int rpcbuf::doallocate() { const int RPCBUFSIZE = 2032; char* get = new char[RPCBUFSIZE]; if (!get) { error("rpcbuf::doallocate: out of memory"); return EOF; } setb(get, get + RPCBUFSIZE, true); setg(get, get, get); char* put = new char[RPCBUFSIZE]; if (!put) { error("rpcbuf::doallocate: out of memory"); return EOF; } setp(put, put + RPCBUFSIZE); setr(nil); return 0; } // Expand the get area to make room for a large incoming request. boolean rpcbuf::expand_g(int newsize) { char* get = new char[newsize]; if (!get) { return false; } int navail = in_avail(); Memory::copy(gptr(), get, navail); delete eback(); setb(get, get + newsize, true); setg(get, get, get + navail); return true; } // Expand the put area to make room for additional data to be appended // to an outgoing request. boolean rpcbuf::expand_p() { int newsize = (epptr() - pbase()) * 2; char* put = new char[newsize]; if (!put) { return false; } int nwaiting = out_waiting(); Memory::copy(pbase(), put, nwaiting); delete pbase(); setp(put, put + newsize); pbump(nwaiting); setr(put); return true; } // Print a user error message. void rpcbuf::error(const char* msg) { if (_verbose) { cerr << msg << "\n"; cerr.flush(); } } // Print a system error message. void rpcbuf::sys_error(const char* msg) { if (_verbose) { perror(msg); } } ivtools-1.2.11a1/src/Dispatch/rpchdr.cc000066400000000000000000000064331214471147700176520ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include #include // Initialize the header for an outgoing RPC request. RpcHdr::RpcHdr(void* writer, int request) : _writer(writer), _request(request), _ndata(0) {} // Initialize the header for an incoming RPC request. RpcHdr::RpcHdr() : _reader(0), _request(0), _ndata(0) {} // If incomplete_request was set, explicitly call underflow in an // attempt to complete an incoming RPC request by reading additional // data and reset the flag. Set the stream in eof state if no // additional data was available or in fail state if it was already in // eof state. If the stream is still good, call read_request to check // if the incoming RPC request is complete yet. If it is, extract its // header, else set incomplete_request to note so. Decrement the // length (which counted the entire request) by the space that the // header occupied to count only the data following the header. rpcstream& operator>>(rpcstream& client, RpcHdr& hdr) { if (client.good() && client.incomplete_request()) { if (client.rdbuf()->underflow() != EOF) { client.incomplete_request(false); } else { client.clear(client.rdstate() | ios::eofbit); } } else if (client.eof()) { client.clear(client.rdstate() | ios::failbit); } if (client.good()) { if (client.rdbuf()->read_request() != EOF) { streampos beginning = client.tellg(); client >> hdr._ndata >> hdr._reader >> hdr._request; hdr._ndata -= (int)(client.tellg() - beginning); } else { client.incomplete_request(true); } } return client; } // Store the beginning of a new RPC request. The rpcbuf automatically // initializes the length field of the previous RPC request and skips // the put pointer past the length field of the new RPC request so // there's no need to examine hdr._ndata or insert its value. rpcstream& operator<<(rpcstream& server, const RpcHdr& hdr) { if (server && server.rdbuf()->start_request() != EOF) { server << hdr._reader << hdr._request; } else { server.clear(server.rdstate() | ios::failbit); } return server; } ivtools-1.2.11a1/src/Dispatch/rpcpeer.cc000066400000000000000000000077201214471147700200300ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include #include #include #include #include // Store our parameters for use later since we can't call a derived // class's virtual function from a base constructor. RpcPeer::RpcPeer( const char* lPath, int lPort ) : IOHandler(), _lPath(lPath), _lPort(lPort), _service(nil), _running(false), _remote(false), _rHost(nil) {} // Delete our RPC service if we created one. Free any storage // allocated by RpcRegistry::find for the remote service's host name. RpcPeer::~RpcPeer() { if (_service) { stopListening(); } delete _rHost; } // Find the host name and port number registered by the remote RPC // service and try to open a connection to it. Unregister the remote // RPC service to prevent another attempt if the connection could not // be opened. If necessary, start up our own RPC service and wait for // the remote RPC service to contact us. void RpcPeer::init(const char* rPath) { if (_service || _remote) { return; } int rPort; _remote = RpcRegistry::find(rPath, _rHost, rPort); if (_remote && !createReaderAndWriter(_rHost, rPort)) { RpcRegistry::erase(rPath); _remote = false; } if (!_remote) { startListening(); } } // Read RPC requests until something tells us to quit the run loop. // If you're using the InterViews event-reading code, you don't have // to use this code since that code will also read RPC requests. void RpcPeer::run() { _running = true; while (_running) { Dispatcher::instance().dispatch(); } } void RpcPeer::quitRunning() { _running = false; } // Open an RPC service at a port number (zero means any available port // number). Store our RPC service's assigned port number in a file to // allow clients to find our service. Start listening for connections // from clients. void RpcPeer::startListening() { _service = new rpcbuf; rpcbuf* ok = _service->listen(_lPort); _lPort = _service->port(); if (!ok) { abort(); } if (!RpcRegistry::record(_lPath, _lPort)) { abort(); } Dispatcher::instance().link(_service->fd(), Dispatcher::ReadMask, this); } // Stop listening for connections from clients, unregister our RPC // service, and delete it. void RpcPeer::stopListening() { Dispatcher::instance().unlink(_service->fd()); RpcRegistry::erase(_lPath); delete _service; _service = nil; } // Accept a connection from a client. Ask a derived class to attach a // reader and a writer which will read RPC requests and send RPC // requests over the same connection. int RpcPeer::inputReady(int) { int fd; rpcbuf* ok = _service->accept(fd); if (!ok) { abort(); } createReaderAndWriter(fd); return 0; } ivtools-1.2.11a1/src/Dispatch/rpcreader.cc000066400000000000000000000126341214471147700203370ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include #include #include #include // Prepare to read RPC requests from somebody else's connection or // prepare to handle RPC requests read by somebody else. Assume the // I/O format has already been negotiated. Start listening for RPC // requests on the connection, taking into account the special case // where RPC requests have already been buffered. Zero the function // array that a derived class will initialize with addresses of static // member functions to unmarshall RPC requests. RpcReader::RpcReader(rpcstream* _client, int nfcns) : IOHandler(), _nfcns(nfcns), _function(new PF[nfcns]), _client(_client), _delete(false), _fd(_client ? _client->rdbuf()->fd() : -1) { if (_client) { client().nonblocking(true); Dispatcher::instance().link(_fd, Dispatcher::ReadMask, this); if (client().rdbuf()->read_request() != EOF) { Dispatcher::instance().setReady(_fd, Dispatcher::ReadMask); client().incomplete_request(false); } } for (int i = 0; i < nfcns; i++) { _function[i] = nil; } } // Connect to a client through an already open file number. Negotiate // the I/O format. Start listening for RPC requests on the // connection, taking into account the special case where RPC requests // have already been buffered (when the I/O format was negotiated). // Zero the function array that a derived class will initialize with // addresses of static member functions to unmarshall RPC requests. RpcReader::RpcReader(int fd, int nfcns, boolean binary) : IOHandler(), _nfcns(nfcns), _function(new PF[nfcns]), _client(new rpcstream), _delete(true), _fd(fd) { client().attach(fd); client().negotiate(binary); client().nonblocking(true); Dispatcher::instance().link(fd, Dispatcher::ReadMask, this); if (client().rdbuf()->read_request() != EOF) { Dispatcher::instance().setReady(fd, Dispatcher::ReadMask); client().incomplete_request(false); } for (int i = 0; i < nfcns; i++) { _function[i] = nil; } } // Stop listening for RPC requests on the connection if we have one. // Delete the connection if we created it ourselves. Note that // deleting a connection attached to a file number will not close that // file number. RpcReader::~RpcReader() { if (_fd >= 0) { Dispatcher::instance().unlink(_fd); } if (_delete) { #if !defined(_IO_NEW_STREAMS) delete _client; #endif } delete[] _function; } // Read only one RPC request per call to allow the program to // interleave RPC requests from multiple clients. Look up the proper // reader to execute the request or skip over the request's data if it // could not be executed. Ask a derived class to take the appropriate // action (perhaps closing the file number or deleting ``this'') if no // more data is available or the data wasn't what we expected. int RpcReader::inputReady(int fd) { RpcHdr hdr; client() >> hdr; if (client().good() && !client().incomplete_request()) { RpcReader* reader = map(hdr.reader()); if (!execute(reader, hdr)) { client().ignore(hdr.ndata()); } } if (client().eof() || client().fail()) { connectionClosed(fd); return -1; // don't ever call me again (i.e., detach me) } else if (client().incomplete_request()) { return 0; // call me only when more input arrives } else { return 1; // call me again as soon as possible } } // Map the number to the reader that should unmarshall the RPC // request. Return this reader itself by default; derived classes // could return a different reader. RpcReader* RpcReader::map(unsigned long) { return this; } // Look up the static member function that will unmarshall the RPC // request's arguments and execute the request. Call that function // with the reader, RPC request header, and connection as arguments. // Return true if the function was called, false otherwise. boolean RpcReader::execute(RpcReader* reader, RpcHdr& hdr) { if (!reader) { return false; } if (hdr.request() < 0 || hdr.request() >= reader->_nfcns) { return false; } PF func = reader->_function[hdr.request()]; if (!func) { return false; } (*func)(reader, hdr, client()); return true; } ivtools-1.2.11a1/src/Dispatch/rpcregistry.cc000066400000000000000000000074151214471147700207460ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include #include #include #include #include #ifndef __DECCXX #include #endif #include #include #include #if defined(sun) && defined(__svr4__) #include #define MAXHOSTNAMELEN SYS_NMLN #endif #if defined(__linux__) || defined(__FreeBSD__) #include #endif // Print a short error message describing the last error encountered // during a call to a system function. static ostream& perror(ostream& s) { #if defined(sun) s << ": " << strerror(errno); #else if (errno > 0 && errno < sys_nerr) { s << ": " << sys_errlist[errno]; } #endif s << '\n'; return s; } // Record the RPC service's hostname and port number in the given // file. Remove the file before opening it in case it already exists // and the user has permission to delete it but not permission to // write data into it. boolean RpcRegistry::record(const char* path, int port) { if (!path) { return false; } unlink(path); ofstream registry(path); if (!registry) { cerr << "RpcRegistry::record: open(" << path << ")" << perror; return false; } registry << Host::name() << ends << port; if (!registry) { cerr << "RpcRegistry::record: write" << perror; return false; } return true; } // Remove the file which stores the RPC service's hostname and port // number so that no more clients will be able to contact the RPC // service. boolean RpcRegistry::erase(const char* path) { if (!path) { return false; } if (unlink(path) < 0) { cerr << "RpcRegistry::erase: unlink(" << path << ")" << perror; return false; } return true; } // Open the file which stores the RPC service's hostname and port // number. If the file does not exist, return failure silently. If // the file does exist, read the RPC service's hostname and port // number from it. If the RPC service and client are on the same // host, speed up I/O between them by returning "localhost" instead of // the host's true name. boolean RpcRegistry::find(const char* path, char*& hostname, int& port) { if (!path) { return false; } ifstream registry(path); if (!registry) { return false; } if (!hostname) { hostname = new char[MAXHOSTNAMELEN]; } registry.getline(hostname, MAXHOSTNAMELEN, '\0'); registry >> port; if (!registry) { cerr << "RpcRegistry::find: error reading " << path << '\n'; return false; } if (strcmp(hostname, Host::name()) == 0) { strcpy(hostname, "localhost"); } return true; } ivtools-1.2.11a1/src/Dispatch/rpcservice.cc000066400000000000000000000065761214471147700205450ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include #include #include #include #include // Start up an RPC service. If a filename is given, store our // service's assigned port number in it so clients can find us. RpcService::RpcService(int port) : IOHandler(), _path(nil), _port(port), _service(new rpcbuf), _running(false) { startListening(); } RpcService::RpcService(const char* path, int port) : IOHandler(), _path(path), _port(port), _service(new rpcbuf), _running(false) { startListening(); } // Close our RPC service if it was open. RpcService::~RpcService() { if (_service->opened()) { stopListening(); } delete _service; } // Read RPC requests until something tells us to quit the run loop. // If you're using the InterViews event-reading code, you don't have // to use this code since that code will also read RPC requests. void RpcService::run() { _running = true; while (_running) { Dispatcher::instance().dispatch(); } } void RpcService::quitRunning() { _running = false; } // Open an RPC service at a port number (zero means any available port // number). If a filename was given, store our service's assigned // port number in it to allow clients to find us. Start listening for // connections from clients. void RpcService::startListening() { rpcbuf* ok = _service->listen(_port); _port = _service->port(); if (!ok) { abort(); } if (_path && !RpcRegistry::record(_path, _port)) { abort(); } Dispatcher::instance().link(_service->fd(), Dispatcher::ReadMask, this); } // Stop listening for connections from clients, unregister our RPC // service if it was registered, and close it. void RpcService::stopListening() { Dispatcher::instance().unlink(_service->fd()); if (_path) { RpcRegistry::erase(_path); } _service->close(); } // Accept a connection from a client. Ask a derived class to attach a // reader which will read RPC requests from the connection. int RpcService::inputReady(int) { int fd; rpcbuf* ok = _service->accept(fd); if (!ok) { abort(); } createReader(fd); return 0; } ivtools-1.2.11a1/src/Dispatch/rpcstream.cc000066400000000000000000000051741214471147700203710ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include // Specialize this class to RPC requests by initializing an rpcbuf. // Set incomplete_request to ensure the first attempt to extract an RPC // request will call underflow. rpcstream::rpcstream() : _buf(this), _incomplete_request(true) { // init(&_buf); } #if !defined(_IO_NEW_STREAMS) rpcstream::~rpcstream() {} #endif // Provide operations on the rpcbuf. Most change the stream's state // so radically that it's either cleared or failed. void rpcstream::listen(int port) { verify(rdbuf()->listen(port) != nil); } void rpcstream::connect(const char* host, int port) { verify(rdbuf()->connect(host, port) != nil); } int rpcstream::accept() { // no effect on stream's state int fd; if (!rdbuf()->accept(fd)) { return -1; } return fd; } void rpcstream::attach(int fd) { verify(rdbuf()->attach(fd) != nil); } void rpcstream::close() { verify(rdbuf()->close() != nil); } void rpcstream::nonblocking(boolean nonblocking) { // can only fail, not clear if (!rdbuf()->nonblocking(nonblocking)) { setstate(ios::failbit); } } void rpcstream::verbose(boolean verbose) { // no effect on stream's state rdbuf()->verbose(verbose); } // For some of the functions above, success means starting over with a // clean slate while failure means setting failbit as usual. void rpcstream::verify(int ok) { if (ok) { clear(); } else { setstate(ios::failbit); } } ivtools-1.2.11a1/src/Dispatch/rpcwriter.cc000066400000000000000000000067111214471147700204100ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include #include #include #include /* for abort() */ // Open a connection to an RPC service at its registered host name and // port number, or give the host name and port number needed to open a // connection to the RPC service, or give the number of an already // open file descriptor, or give the address of an already open // rpcstream (connection). Negotiate the I/O format if opening a // connection. Terminate the program if errors should be fatal. RpcWriter::RpcWriter(const char* path, boolean fatal, boolean binary) : _server(new rpcstream), _delete(true), _host(nil) { open(path, fatal, binary); } RpcWriter::RpcWriter( const char* host, int port, boolean fatal, boolean binary ) : _server(new rpcstream), _delete(true), _host(nil) { server().verbose(fatal); server().connect(host, port); server().negotiate(binary); if (!server() && fatal) { abort(); } } RpcWriter::RpcWriter(int fd, boolean fatal, boolean binary) : _server(new rpcstream), _delete(true), _host(nil) { server().verbose(fatal); server().attach(fd); server().negotiate(binary); if (!server() && fatal) { abort(); } } RpcWriter::RpcWriter(rpcstream* server) : _server(server), _delete(false), _host(nil) {} // Close the connection to the server, although the file number won't // be closed if we attached the connection to it. Free any storage // allocated by RpcRegistry::find for the host name. RpcWriter::~RpcWriter() { if (_delete) { #if !defined(_IO_NEW_STREAMS) delete _server; #endif } delete _host; } // Use a member function to open a connection to an RPC service at its // registered host name and port number so that a derived class's // constructor can retry the attempt if necessary. void RpcWriter::open(const char* path, boolean fatal, boolean binary) { int port; if (RpcRegistry::find(path, _host, port)) { server().verbose(fatal); server().connect(_host, port); server().negotiate(binary); } else { server().clear(ios::failbit | ios::badbit); } if (!server() && fatal) { cerr << "RpcWriter::open: service " << path << " not found" << "\n"; cerr.flush(); abort(); } } ivtools-1.2.11a1/src/DrawServ/000077500000000000000000000000001214471147700160515ustar00rootroot00000000000000ivtools-1.2.11a1/src/DrawServ/ackback-handler.cc000066400000000000000000000115571214471147700213630ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifdef HAVE_ACE using namespace std; #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ // Default constructor. AckBackHandler::AckBackHandler () { _timer_started = false; _ackback_arrived = false; _eof_expected = false; } AckBackHandler::~AckBackHandler() { fprintf(stderr, "AckBackHandler deleted\n"); } // Called when input becomes available on fd. int AckBackHandler::handle_input (ACE_HANDLE fd) { if (drawlink() && drawlink()->socket()) { vector inv; char ch; int status; while((status = read(fd, &ch, 1))==1) inv.push_back(ch); inv.push_back('\0'); if (strcmp((char*)&inv[0], "ackback(cycle)\n")==0) { char buffer[BUFSIZ]; snprintf(buffer, BUFSIZ, "%s:%d", drawlink()->hostname(), drawlink()->portnum()); GAcknowledgeDialog::map(DrawKit::Instance()->GetEditor()->GetWindow(), "Redundant connection rejected", buffer, "Redundant connection rejected"); _eof_expected = true; } if (status == 0) { if (!_eof_expected) { char buffer[BUFSIZ]; snprintf(buffer, BUFSIZ, "%s:%d", drawlink()->hostname(), drawlink()->portnum()); GAcknowledgeDialog::map(DrawKit::Instance()->GetEditor()->GetWindow(), "Unexpected end-of-file on connection", buffer, "Unexpected end-of-file on connection"); } else _eof_expected = false; cerr << "AckBack (end of file): [" << (char*)&inv[0] << "]\n"; drawlink()->ackhandler(nil); ((DrawServ*)unidraw)->linkdown(drawlink()); return -1; } else if (errno != EAGAIN) warn(nil); else { cerr << "AckBack: [" << (char*)&inv[0] << "]\n"; _ackback_arrived = true; } return 0; } else { fprintf(stderr, "unexpected missing socket\n"); return -1; } } void AckBackHandler::start_timer() { if (!_timer_started) { _timerid = ComterpHandler::reactor_singleton()->schedule_timer (this, (const void *) this, ACE_Time_Value (5), ACE_Time_Value (5)); _timer_started = true; _ackback_arrived = false; } } int AckBackHandler::handle_timeout (const ACE_Time_Value &, const void *arg) { if(_timer_started && !ComterpHandler::reactor_singleton()->cancel_timer(_timerid, nil)) cerr << "unable to cancel timerid " << _timerid << "\n"; _timer_started = false; if (!_ackback_arrived) { fprintf(stderr, "ackback timeout\n"); drawlink()->ackhandler(nil); ((DrawServ*)unidraw)->linkdown(drawlink()); return -1; } return 0; } // Get the I/O handle. ACE_HANDLE AckBackHandler::get_handle (void) const { return _handle; } // Set the I/O handle. void AckBackHandler::set_handle (ACE_HANDLE handle) { _handle = handle; } // Called when the object is about to be removed from the Dispatcher // tables. int AckBackHandler::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask mask) { fprintf(stderr, "AckBackHandler::handle_close called with mask 0x%x\n", mask); if(_timer_started && !ComterpHandler::reactor_singleton()->cancel_timer(_timerid, nil)) cerr << "unable to cancel timerid " << _timerid << "\n"; else _timer_started = false; if (mask == ACE_Event_Handler::TIMER_MASK || mask == ACE_Event_Handler::READ_MASK) { if (mask == ACE_Event_Handler::TIMER_MASK) if (ComterpHandler::reactor_singleton()->remove_handler(this, ACE_Event_Handler::READ_MASK|ACE_Event_Handler::TIMER_MASK)==-1) cerr << "drawserv: error removing ackback handler\n"; delete this; } return 0; } #endif /* HAVE_ACE */ ivtools-1.2.11a1/src/DrawServ/ackback-handler.h000066400000000000000000000053241214471147700212200ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifdef HAVE_ACE #ifndef _ackback_handler_ #define _ackback_handler_ #include #include class DrawLink; //: specialized ACE_EventHandler for monitoring responses from outgoing connection class AckBackHandler : public ACE_Event_Handler { public: // = Initialization and termination methods. AckBackHandler (); virtual ~AckBackHandler (); DrawLink* drawlink() { return _drawlink; } // get DrawLink associated with this handler void drawlink(DrawLink* link) { _drawlink = link; } // set DrawLink associated with this handler virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE); // Called when input events occur (e.g., connection or data). virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); // called when timer goes off. virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask); // Called when a method returns -1 or when the // method is called on an . The // indicates which event has triggered the // method callback on a particular . virtual ACE_HANDLE get_handle (void) const; // Get the I/O handle. virtual void set_handle (ACE_HANDLE); // Set the I/O handle. void start_timer(); // Start timer waiting for ackback protected: DrawLink* _drawlink; int _timer_started; int _ackback_arrived; long _timerid; ACE_HANDLE _handle; int _eof_expected; }; #endif /* _ackback_handler_ */ #endif /* HAVE_ACE */ ivtools-1.2.11a1/src/DrawServ/drawcatalog.cc000066400000000000000000000124661214471147700206610ustar00rootroot00000000000000/* * Copyright (c) 1994-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * DrawCatalog implementation. */ #include #include #include #include #include #include #include #include #include #include #include #include #if __GNUC__>=3 #include #endif /*****************************************************************************/ DrawCatalog::DrawCatalog ( const char* name, Creator* creator ) : FrameCatalog(name, creator) { _startnode = _endnode = nil; _edges = nil; _nodes = nil; _comps = nil; } boolean DrawCatalog::Retrieve (const char* filename, Component*& comp) { FILE* fptr = nil; boolean compressed = false; char* name = strdup(filename); if (Valid(name, comp)) { _valid = true; } else { #if __GNUC__<3 filebuf fbuf; #else filebuf* pfbuf = nil; #endif if (strcmp(name, "-") == 0) { #if __GNUC__<3 _valid = fbuf.attach(fileno(stdin)) != 0; #else pfbuf = new fileptr_filebuf(stdin, input); _valid = 1; #endif name = nil; } else { fptr = fopen(name, "r"); fptr = OvImportCmd::CheckCompression(fptr, name, compressed); #if __GNUC__<3 _valid = fptr ? fbuf.attach(fileno(fptr)) != 0 : false; #else pfbuf = new fileptr_filebuf(fptr, input); _valid = fptr ? 1 : 0; #endif if (compressed) { int namelen = strlen(name); if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0'; else if (strcmp(name+namelen-2,".Z")==0) name[namelen-2] = '\0'; } } if (_valid) { #if __GNUC__<3 istream in(&fbuf); #else istream in(pfbuf); #endif const char* command = "drawserv"; int len = strlen(command)+1; char buf[len]; char ch; while (isspace(ch = in.get())); in.putback(ch); ParamList::parse_token(in, buf, len); if (strcmp(buf, "drawserv") == 0) { comp = new DrawIdrawComp(in, name, _parent); _valid = in.good() && ((OverlayComp*)comp)->valid(); } else _valid = false; if (_valid && name) { Forget(comp, name); Register(comp, name); } else if (!_valid) { delete comp; comp = nil; } } #if __GNUC__>=3 delete pfbuf; #endif } if (fptr) { if (compressed) fclose(fptr); else pclose(fptr); } delete name; return _valid; } OverlayComp* DrawCatalog::ReadComp(const char* name, istream& in, OverlayComp* parent) { OverlayComp* child = nil; if (strcmp(name, "edge") == 0) { child = new EdgeComp(in, parent); EdgeComp* comp = (EdgeComp*)child; _startnode[_edge_cnt] = comp->GetStartNode(); _endnode[_edge_cnt] = comp->GetEndNode(); _edges[_edge_cnt] = comp; _edge_cnt++; } else if (strcmp(name, "node") == 0) { child = new NodeComp(in, parent); _nodes[_node_cnt] = (NodeComp*)child; _node_cnt++; } else if (strcmp(name, "graph") == 0) child = new GraphComp(in, nil, parent); else child = OverlayCatalog::ReadComp(name, in, parent); return child; } void DrawCatalog::graph_init(DrawIdrawComp* comps, int num_edge, int num_node) { delete _startnode; delete _endnode; delete _edges; delete _nodes; _comps = comps; _startnode = new int[num_edge]; _endnode = new int[num_edge]; _edges = new EdgeComp*[num_edge]; _nodes = new NodeComp*[num_node]; _num_edge = num_edge; _num_node = num_node; _edge_cnt = 0; _node_cnt = 0; } void DrawCatalog::graph_finish() { for (int i=0; i<_num_edge; i++) { int start_id = _startnode[i]; int end_id = _endnode[i]; if (start_id < 0 || end_id < 0) _comps->AppendEdge(_edges[i]); _edges[i]->AttachNodes(start_id < 0 ? nil : _nodes[start_id], end_id < 0 ? nil : _nodes[end_id]); #if defined(GRAPH_OBSERVABLES) if (start_id >=0 && end_id >=0) _edges[i]->NodeStart()->attach(_edges[i]->NodeEnd()); #endif } delete _startnode; _startnode = nil; delete _endnode; _endnode = nil; delete _edges; _edges = nil; delete _nodes; _nodes = nil; _comps = nil; } ivtools-1.2.11a1/src/DrawServ/drawcatalog.h000066400000000000000000000037161214471147700205210ustar00rootroot00000000000000/* * Copyright (c) 1997,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * DrawCatalog - can read and write components in script or postscript */ #ifndef drawcatalog_h #define drawcatalog_h #include class DrawIdrawComp; class EdgeComp; class NodeComp; //: catalog for use with drawserv. class DrawCatalog : public FrameCatalog{ public: DrawCatalog(const char*, Creator*); boolean Retrieve (const char*, Component*&); virtual OverlayComp* ReadComp(const char*, istream&, OverlayComp* =nil); virtual void graph_init(DrawIdrawComp* comps, int num_edge, int num_node); virtual void graph_finish(); protected: int* _startnode; int* _endnode; EdgeComp** _edges; NodeComp** _nodes; int _edge_cnt; int _node_cnt; int _num_edge; int _num_node; DrawIdrawComp* _comps; }; #endif ivtools-1.2.11a1/src/DrawServ/drawclasses.h000066400000000000000000000032461214471147700205420ustar00rootroot00000000000000/* * Copyright (c) 1996 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef drawclasses_h #define drawclasses_h #include #include #define DRAW_IDRAW_COMP 9801 #define DRAW_IDRAW_VIEW Combine(DRAW_IDRAW_COMP,COMPONENT_VIEW) #define DRAW_IDRAW_PS Combine(DRAW_IDRAW_COMP,POSTSCRIPT_VIEW) #define DRAW_IDRAW_SCRIPT Combine(DRAW_IDRAW_COMP, SCRIPT_VIEW) #define DRAWLINK_COMP 9802 #define DRAWIMPORT_CMD 9803 #define DRAWIMPORTPASTE_CMD 9804 #define COPYMOVEGRAPHFRAME_CMD 9805 #endif ivtools-1.2.11a1/src/DrawServ/drawcmds.cc000066400000000000000000000050441214471147700201670ustar00rootroot00000000000000/* * Copyright (c) 2009 Scott E. Johnston * Copyright (c) 1997-2000 Vectaport Inc. * Copyright (c) 1994, 1995 Vectaport Inc., Cider Press * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ CopyMoveGraphFrameCmd::CopyMoveGraphFrameCmd(ControlInfo* i, boolean after) : CopyMoveFrameCmd(i, after) { } CopyMoveGraphFrameCmd::CopyMoveGraphFrameCmd(Editor* e, boolean after) : CopyMoveFrameCmd(e, after) { } ClassId CopyMoveGraphFrameCmd::GetClassId() { return COPYMOVEGRAPHFRAME_CMD; } boolean CopyMoveGraphFrameCmd::IsA(ClassId id) { return id == COPYMOVEGRAPHFRAME_CMD || CopyMoveFrameCmd::IsA(id); } Command* CopyMoveGraphFrameCmd::Copy() { Command* copy = new CopyMoveGraphFrameCmd(CopyControlInfo(), _after); InitCopy(copy); return copy; } void CopyMoveGraphFrameCmd::Execute() { FrameEditor* ed = (FrameEditor*)GetEditor(); Append(new OvSlctAllCmd(ed)); Append(new GraphCopyCmd(ed)); Append(new CreateFrameCmd(ed, _after)); Append(new MoveFrameCmd(ed, _after ? +1 : -1)); Append(new GraphPasteCmd(ed)); MacroCmd::Execute(); } ivtools-1.2.11a1/src/DrawServ/drawcmds.h000066400000000000000000000033311214471147700200260ustar00rootroot00000000000000/* * Copyright (c) 2009 Scott E. Johnston * Copyright (c) 1994, 1995, 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef drawcmds_h #define drawcmds_h #include //: command to copy contents of current frame to create a new frame and reconnect graph. class CopyMoveGraphFrameCmd : public CopyMoveFrameCmd { public: CopyMoveGraphFrameCmd(ControlInfo*, boolean after = true); CopyMoveGraphFrameCmd(Editor* = nil, boolean after = true); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual Command* Copy(); virtual void Execute(); protected: }; #endif ivtools-1.2.11a1/src/DrawServ/drawcomps.cc000066400000000000000000000175201214471147700203640ustar00rootroot00000000000000/* * Copyright (c) 1994-1996,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * DrawIdrawComp implementation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::cerr; /*****************************************************************************/ ParamList* DrawIdrawComp::_com_idraw_params = nil; DrawIdrawComp::DrawIdrawComp (const char* pathname, OverlayComp* parent) : FrameIdrawComp(false, pathname, parent) { _graphedges = new UList(); } DrawIdrawComp::DrawIdrawComp (istream& in, const char* pathname, OverlayComp* parent) : FrameIdrawComp(parent) { _pathname = _basedir = nil; _gslist = nil; _ptsbuf = nil; SetPathName(pathname); _graphedges = new UList(); _valid = GetParamList()->read_args(in, this); delete _gslist; if (_ptsbuf) { for (int i=0; i<_ptsnum; i++) Unref(_ptsbuf[i]); delete _ptsbuf; } } DrawIdrawComp::~DrawIdrawComp () { delete _graphedges; } ClassId DrawIdrawComp::GetClassId () { return DRAW_IDRAW_COMP; } Component* DrawIdrawComp::Copy () { DrawIdrawComp* comps = new DrawIdrawComp(GetPathName()); if (attrlist()) comps->SetAttributeList(new AttributeList(attrlist())); Iterator i; First(i); while (!Done(i)) { comps->Append((GraphicComp*)GetComp(i)->Copy()); Next(i); } for (UList* u = _graphedges->First(); u != _graphedges->End(); u = u->Next()) { EdgeComp* edgecomp = (EdgeComp*) (*u)(); comps->AppendEdge(edgecomp); } return comps; } boolean DrawIdrawComp::IsA (ClassId id) { return DRAW_IDRAW_COMP == id || FrameIdrawComp::IsA(id); } ParamList* DrawIdrawComp::GetParamList() { if (!_com_idraw_params) GrowParamList(_com_idraw_params = new ParamList()); return _com_idraw_params; } void DrawIdrawComp::GrowParamList(ParamList* pl) { pl->add_param("edges_nodes", ParamStruct::required, &ParamList::read_int, this, &_num_edge, &_num_node); pl->add_param("frames", ParamStruct::required, &DrawIdrawScript::ReadFrames, this, this); OverlayComp::GrowParamList(pl); return; } void DrawIdrawComp::AppendEdge(EdgeComp* comp) { _graphedges->Append(new UList(comp)); } /*****************************************************************************/ DrawIdrawScript::DrawIdrawScript (DrawIdrawComp* subj) : FrameIdrawScript(subj) { } DrawIdrawScript::~DrawIdrawScript() { } ClassId DrawIdrawScript::GetClassId () { return DRAW_IDRAW_SCRIPT; } boolean DrawIdrawScript::IsA (ClassId id) { return DRAW_IDRAW_SCRIPT == id || FrameIdrawScript::IsA(id); } boolean DrawIdrawScript::Emit (ostream& out) { out << script_name() << "("; GraphicComp* comps = GetGraphicComp(); Iterator i; int num_edge = 0; int num_node = 0; for (comps->First(i); !comps->Done(i); comps->Next(i)) { GraphicComp* comp = comps->GetComp(i); if (comp->IsA(FRAME_COMP)) { Iterator j; for(comp->First(j); !comp->Done(j); comp->Next(j)) { GraphicComp* subcomp = comp->GetComp(j); if (subcomp->IsA(NODE_COMP)) { ((NodeComp*)subcomp)->index(num_node); num_node++; } else if (subcomp->IsA(EDGE_COMP)) num_edge++; } } } out << num_edge << "," << num_node; /* make list and output unique point lists */ boolean prevout = false; if (_pts_compacted) { _ptslist = new Clipboard(); prevout = EmitPts(out, _ptslist, prevout); } /* make list and output unique graphic states */ if (_gs_compacted) { _gslist = new Clipboard(); prevout = EmitGS(out, _gslist, prevout); } /* make list and output unique picture graphics */ if (_pic_compacted) { _piclist1 = new Clipboard(); _piclist2 = new Clipboard(); prevout = EmitPic(out, _piclist1, _piclist2, prevout); } /* output graphic components */ boolean status = true; First(i); if (!Done(i) ) { if (prevout) out << ","; out << "\n"; } for (; status && !Done(i); ) { ExternView* ev = GetView(i); Indent(out); status = ev->Definition(out); Next(i); if (!Done(i)) out << ",\n"; } out << "\n"; FullGS(out); Annotation(out); Attributes(out); out << ")\n"; return status; } int DrawIdrawScript::ReadFrames (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { FrameComp* frame; FrameFileComp* framefile; OverlayComp* child; DrawIdrawComp* comps = (DrawIdrawComp*)addr1; char buf1[BUFSIZ]; char buf2[BUFSIZ]; char* buf = buf1; DrawCatalog* catalog = unidraw ? (DrawCatalog*) unidraw->GetCatalog() : (DrawCatalog*) DrawCatalog::Instance(); int num_edge = (comps)->GetNumEdge(); int num_node = (comps)->GetNumNode(); catalog->graph_init(comps, num_edge, num_node); FrameComp* bgframe = nil; while (in.good()) { frame = nil; framefile = nil; child = nil; if (read_name(in, buf, BUFSIZ)) break; int status; if (status = read_gsptspic(buf, in, comps)) { if (status==-1) break; } else if (strcmp(buf, "frame") == 0) { frame = new FrameComp(in, comps); if (!bgframe) bgframe = frame; } else if (strcmp(buf, "framefile") == 0) framefile = new FrameFileComp(in, comps); else { if (!bgframe) { bgframe = new FrameComp(comps); comps->Append(bgframe); } child = read_obj(buf, in, bgframe); if (!child) return -1; } if (frame != nil) { if (in.good() && frame->valid()) { comps->Append(frame); } else { /* report failure even if one child fails */ delete frame; return -1; } } if (framefile != nil) { Iterator j; framefile->First(j); FrameIdrawComp* frameidraw = (FrameIdrawComp*)framefile->GetComp(j); if (in.good() && frameidraw->valid()) { Iterator i; frameidraw->First(i); frameidraw->Next(i); while (!frameidraw->Done(i)) { comps->Append((GraphicComp*)frameidraw->GetComp(i)); frameidraw->Next(i); } } else { /* report failure even if one child fails */ delete framefile; return -1; } } if (child) { if (in.good() && child->valid()) { bgframe->Append(child); } else { /* report failure even if one child fails */ if (!*buf && (buf==buf1 ? *buf2 : *buf1)) cerr << "Error after reading " << (buf==buf1 ? buf2 : buf1) << "\n"; delete child; return -1; } } buf = buf==buf1 ? buf2 : buf1; } catalog->graph_finish(); return 0; } ivtools-1.2.11a1/src/DrawServ/drawcomps.h000066400000000000000000000053141214471147700202240ustar00rootroot00000000000000/* * Copyright (c) 1994-1996,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Draw components */ #ifndef drawcomps_h #define drawcomps_h #include #include class EdgeComp; //: top-level component for a drawserv document. class DrawIdrawComp : public FrameIdrawComp { public: DrawIdrawComp(const char* pathname = nil, OverlayComp* parent = nil); DrawIdrawComp(istream&, const char* pathname = nil, OverlayComp* parent = nil); virtual ~DrawIdrawComp(); virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); int GetNumEdge() { return _num_edge; } // number of edges in graph. int GetNumNode() { return _num_node; } // number of nodes in graph. void AppendEdge(EdgeComp*); // add edge component to the graph. UList* GraphEdges() { return _graphedges; } protected: UList* _graphedges; int _num_edge; int _num_node; ParamList* GetParamList(); void GrowParamList(ParamList* pl); static ParamList* _com_idraw_params; }; //: serialized view of a DrawIdrawComp. class DrawIdrawScript : public FrameIdrawScript { public: DrawIdrawScript(DrawIdrawComp* = nil); virtual ~DrawIdrawScript(); virtual boolean Emit(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); static int ReadFrames(istream& in, void* addr1, void* addr2, void* addr3, void* addr4); virtual const char* script_name() { return "drawserv"; } // for overriding in derived classes }; #endif ivtools-1.2.11a1/src/DrawServ/drawcreator.cc000066400000000000000000000043361214471147700207030ustar00rootroot00000000000000/* * Copyright (c) 1994-1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include DrawCreator::DrawCreator () { } void* DrawCreator::Create (ClassId id) { void* view = DrawCreator::create(id); if (!view) view = FrameCreator::create(id); if (!view) view = GraphCreator::create(id); return view ? view : OverlayCreator::Create(id); } void* DrawCreator::create (ClassId id) { if (id == DRAW_IDRAW_VIEW) return new DrawIdrawView; if (id == DRAW_IDRAW_PS) return new OverlayIdrawPS; if (id == DRAW_IDRAW_SCRIPT) return new DrawIdrawScript; return nil; } ivtools-1.2.11a1/src/DrawServ/drawcreator.h000066400000000000000000000027401214471147700205420ustar00rootroot00000000000000/* * Copyright (c) 1994-1996,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef drawcreator_h #define drawcreator_h #include //: creator for use with drawserv. class DrawCreator : public FrameCreator { public: DrawCreator(); virtual void* Create(ClassId); // for views static void* create(ClassId); }; #endif ivtools-1.2.11a1/src/DrawServ/draweditor.cc000066400000000000000000000057741214471147700205410ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include /*****************************************************************************/ DrawEditor::DrawEditor(OverlayComp* comp, OverlayKit* kit) : FrameEditor(false, kit) { Init(comp, "DrawEditor"); } DrawEditor::DrawEditor(const char* file, OverlayKit* kit) : FrameEditor(false, kit) { if (file == nil) { Init(); } else { Catalog* catalog = unidraw->GetCatalog(); OverlayComp* comp; if (catalog->Retrieve(file, (Component*&) comp)) { Init(comp); } else { Init(); fprintf(stderr, "drawserv: couldn't open %s\n", file); } } } DrawEditor::DrawEditor(boolean initflag, OverlayKit* kit) : FrameEditor(initflag, kit) { } void DrawEditor::Init (OverlayComp* comp, const char* name) { _curr_others = _prev_others = nil; _num_curr_others = _num_prev_others = 0; _texteditor = nil; _autonewframe = false; _autonewframe_tts = nil; if (!comp) comp = new DrawIdrawComp; _terp = new ComTerpServ(); ((OverlayUnidraw*)unidraw)->comterp(_terp); AddCommands(_terp); add_comterp("DrawServ", _terp); _overlay_kit->Init(comp, name); InitFrame(); _last_selection = new Selection; } void DrawEditor::InitCommands() { FrameEditor::InitCommands(); } void DrawEditor::AddCommands(ComTerp* comterp) { FrameEditor::AddCommands(comterp); #ifdef HAVE_ACE comterp->add_command("drawlink", new DrawLinkFunc(comterp, this)); comterp->add_command("sid", new SessionIdFunc(comterp, this)); comterp->add_command("grid", new GraphicIdFunc(comterp, this)); comterp->add_command("chgid", new ChangeIdFunc(comterp, this)); #endif comterp->add_command("points", new DrawPointsFunc(comterp, this)); } ivtools-1.2.11a1/src/DrawServ/draweditor.h000066400000000000000000000044011214471147700203650ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef draweditor_h #define draweditor_h #include class DrawKit; class Selection; //: editor for DrawServ application class DrawEditor : public FrameEditor { public: DrawEditor(OverlayComp*, OverlayKit* = OverlayKit::Instance()); // constructor for using existing component. DrawEditor(const char* file, OverlayKit* = OverlayKit::Instance()); // constructor for building top-level component from a file. DrawEditor(boolean initflag, OverlayKit* = OverlayKit::Instance()); // constructor for use of derived classes. void Init(OverlayComp* = nil, const char* name = "DrawEditor"); virtual void InitCommands(); // method for running Unidraw Command objects after OverlayEditor // is constructed. virtual void AddCommands(ComTerp*); // method for adding ComFunc objects to the ComTerp associated with // this DrawEditor. Selection* last_selection() { return _last_selection; } // return point to Selection that shadows the last setting. protected: Selection* _last_selection; friend class DrawKit; }; #endif ivtools-1.2.11a1/src/DrawServ/drawfunc.cc000066400000000000000000000253711214471147700202010ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define TITLE "DrawLinkFunc" /*****************************************************************************/ DrawLinkFunc::DrawLinkFunc(ComTerp* comterp, DrawEditor* ed) : UnidrawFunc(comterp, ed) { } void DrawLinkFunc::execute() { #ifndef HAVE_ACE reset_stack(); fprintf(stderr, "rebuild ivtools with ACE support to get full drawserv functionality\n"); push_stack(ComValue::nullval()); #else ComValue hostv(stack_arg(0, true)); static int port_sym = symbol_add("port"); ComValue default_port(20002); ComValue portv(stack_key(port_sym, false, default_port, true)); static int state_sym = symbol_add("state"); ComValue default_state(0); ComValue statev(stack_key(state_sym, false, default_state, true)); static int lid_sym = symbol_add("lid"); ComValue lidv(stack_key(lid_sym)); static int rid_sym = symbol_add("rid"); ComValue ridv(stack_key(rid_sym)); static int close_sym = symbol_add("close"); ComValue closev(stack_key(close_sym)); static int dump_sym = symbol_add("dump"); ComValue dumpv(stack_key(dump_sym)); static int pid_sym = symbol_add("pid"); ComValue pidv(stack_key(pid_sym)); static int sid_sym = symbol_add("sid"); ComValue sidv(stack_key(sid_sym)); static int user_sym = symbol_add("user"); ComValue userv(stack_key(user_sym)); reset_stack(); #if __GNUC__==3&&__GNUC_MINOR__<1 fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n"); push_stack(ComValue::nullval()); return; #endif DrawLink* link = nil; /* creating a new link to remote drawserv */ if (hostv.is_string() && portv.is_known() && statev.is_known()) { /* cast of this link if it is a duplicate or cycle */ if (statev.int_val()==DrawLink::one_way && ((DrawServ*)unidraw)->cycletest (sidv.uint_val(), hostv.string_ptr(), userv.string_ptr(), pidv.int_val())) { #if 1 #if __GNUC__<4 && !defined(__CYGWIN__) fileptr_filebuf obuf(comterp()->handler()->get_handle(), ios_base::out, false, static_cast(BUFSIZ)); #else fileptr_filebuf obuf(comterp()->handler()->get_handle(), ios_base::out, static_cast(BUFSIZ)); #endif ostream out(&obuf); out << "ackback(cycle)\n"; out.flush(); comterp()->quit(); #else comterp()->handler()->destroy(); #endif return; } const char* hoststr = hostv.string_ptr(); const char* portstr = portv.is_string() ? portv.string_ptr() : nil; u_short portnum = portstr ? atoi(portstr) : portv.ushort_val(); u_short statenum = statev.ushort_val(); int lidnum = lidv.is_known() ? lidv.int_val() : -1; int ridnum = ridv.is_known() ? ridv.int_val() : -1; link = ((DrawServ*)unidraw)->linkup(hoststr, portnum, statenum, lidnum, ridnum, this->comterp()); } /* return pointer to existing link */ else if (ridv.is_known() || lidv.is_known()) { link = ((DrawServ*)unidraw)->linkget (lidv.is_known() ? lidv.int_val() : -1, ridv.is_known() ? ridv.int_val() : -1); /* close if that flag is set. */ if (link && closev.is_true()) { ((DrawServ*)unidraw)->linkdown(link); link = nil; } else if (link && dumpv.is_true()) { link->dump(stderr); } } /* set state to complete linkup */ else if (statev.int_val()==DrawLink::two_way) { DrawServHandler* handler = comterp() ? (DrawServHandler*)comterp()->handler() : nil; DrawLink* link = handler ? (DrawLink*)handler->drawlink() : nil; link->state(DrawLink::two_way); } /* dump DrawLink table to stderr */ else ((DrawServ*)unidraw)->linkdump(stderr); if (link) { DrawLinkComp* linkcomp = new DrawLinkComp(link); ComValue result(new OverlayViewRef(linkcomp), DrawLinkComp::class_symid()); push_stack(result); } else push_stack(ComValue::nullval()); return; #endif } /*****************************************************************************/ SessionIdFunc::SessionIdFunc(ComTerp* comterp, DrawEditor* ed) : UnidrawFunc(comterp, ed) { } void SessionIdFunc::execute() { #ifndef HAVE_ACE reset_stack(); fprintf(stderr, "rebuild ivtools with ACE support to get full drawserv functionality\n"); push_stack(ComValue::nullval()); #else static int all_sym = symbol_add("all"); ComValue allv(stack_key(all_sym)); static int remap_sym = symbol_add("remap"); ComValue remapv(stack_key(remap_sym)); static int pid_sym = symbol_add("pid"); ComValue pidv(stack_key(pid_sym)); static int user_sym = symbol_add("user"); ComValue userv(stack_key(user_sym)); static int host_sym = symbol_add("host"); ComValue hostv(stack_key(host_sym)); static int hostid_sym = symbol_add("hostid"); ComValue hostidv(stack_key(hostid_sym)); ComValue sidv(stack_arg(0)); ComValue osidv(stack_arg(1)); reset_stack(); #if __GNUC__==3&&__GNUC_MINOR__<1 fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n"); push_stack(ComValue::nullval()); return; #endif DrawServHandler* handler = comterp() ? (DrawServHandler*)comterp()->handler() : nil; DrawLink* link = handler ? (DrawLink*)handler->drawlink() : nil; if (allv.is_true()) { ((DrawServ*)unidraw)->sessionid_register(link); return; } if (sidv.is_known() && osidv.is_known()) { if (remapv.is_false()) ((DrawServ*)unidraw)->sessionid_register_handle (link, sidv.uint_val(), osidv.uint_val(), pidv.int_val(), userv.string_ptr(), hostv.string_ptr(), hostidv.int_val()); else link->sid_insert(osidv.uint_val(), sidv.uint_val()); } else { ((DrawServ*)unidraw)->print_sidtable(); } #endif } /*****************************************************************************/ GraphicIdFunc::GraphicIdFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void GraphicIdFunc::execute() { static int request_sym = symbol_add("request"); ComValue requestv(stack_key(request_sym)); static int grant_sym = symbol_add("grant"); ComValue grantv(stack_key(grant_sym)); static int state_sym = symbol_add("state"); ComValue statev(stack_key(state_sym)); ComValue idv(stack_arg(0)); ComValue selectorv(stack_arg(1)); reset_stack(); DrawServHandler* handler = comterp() ? (DrawServHandler*)comterp()->handler() : nil; DrawLink* link = handler ? (DrawLink*)handler->drawlink() : nil; if (idv.is_known() && selectorv.is_known()) { if (grantv.is_unknown()) { if (requestv.is_unknown()) ((DrawServ*)unidraw)->grid_message_handle (link, idv.uint_val(), selectorv.uint_val(), statev.int_val()); else ((DrawServ*)unidraw)->grid_message_handle (link, idv.uint_val(), selectorv.uint_val(), statev.int_val(), requestv.uint_val()); } else ((DrawServ*)unidraw)->grid_message_callback (link, idv.uint_val(), selectorv.uint_val(), statev.int_val(), grantv.uint_val()); } else if (idv.is_unknown()) { ((DrawServ*)unidraw)->print_gridtable(); } } /*****************************************************************************/ ChangeIdFunc::ChangeIdFunc(ComTerp* comterp, DrawEditor* ed) : UnidrawFunc(comterp, ed) { } void ChangeIdFunc::execute() { ComValue idv(stack_arg(0)); reset_stack(); DrawServHandler* handler = comterp() ? (DrawServHandler*)comterp()->handler() : nil; DrawLink* link = handler ? (DrawLink*)handler->drawlink() : nil; if (idv.is_known()) { unsigned int id = idv.uint_val(); link->sid_change(id); ComValue result(id, ComValue::UIntType); result.state(AttributeValue::HexState); push_stack(result); } } /*****************************************************************************/ DrawPointsFunc::DrawPointsFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void DrawPointsFunc::execute() { Viewer* viewer = _ed->GetViewer(); ComValue obj(stack_arg(0)); reset_stack(); if (obj.object_compview()) { ComponentView* compview = (ComponentView*)obj.obj_val(); if (compview && compview->GetSubject()) { GraphicComp* comp = (GraphicComp*)compview->GetSubject(); Graphic* gr = comp ? comp->GetGraphic() : nil; AttributeValueList* avl = new AttributeValueList(); if (gr && comp->IsA(OVVERTICES_COMP)) { VerticesOvComp* vertcomp = (VerticesOvComp*)comp; Vertices* vertgr = vertcomp->GetVertices(); for(int i=0; icount(); i++) { ComValue* val = new ComValue(vertgr->x()[i]); avl->Append(val); val = new ComValue(vertgr->y()[i]); avl->Append(val); } } else if (gr && comp->IsA(OVLINE_COMP)) { LineOvComp* linecomp = (LineOvComp*)comp; Coord x0, y0, x1, y1; linecomp->GetLine()->GetOriginal(x0, y0, x1, y1); avl->Append(new ComValue(x0)); avl->Append(new ComValue(y0)); avl->Append(new ComValue(x1)); avl->Append(new ComValue(y1)); } else if (gr && comp->IsA(EDGE_COMP)) { EdgeComp* edgecomp = (EdgeComp*)comp; Coord x0, y0, x1, y1; edgecomp->GetArrowLine()->GetOriginal(x0, y0, x1, y1); avl->Append(new ComValue(x0)); avl->Append(new ComValue(y0)); avl->Append(new ComValue(x1)); avl->Append(new ComValue(y1)); } ComValue retval(avl); push_stack(retval); } } } ivtools-1.2.11a1/src/DrawServ/drawfunc.h000066400000000000000000000066301214471147700200400ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(_drawfunc_h) #define _drawfunc_h #include #include //: command to connect to another drawserv // drawlink([hoststr] :port portnum :state num :lid nu :rid num :close :dump) -- connect to remote drawserv class DrawLinkFunc : public UnidrawFunc { public: DrawLinkFunc(ComTerp*,DrawEditor*); virtual void execute(); virtual const char* docstring() { return "%s([hoststr] :port portnum :state num :lid num :rid num :close :dump) -- connect to remote drawserv"; } }; //: command to reserve unique session id // sid([sid osid :pid pid :user namestr :host hoststr :hostid hostid :remap] | :all) -- command to manage session id's class SessionIdFunc : public UnidrawFunc { public: SessionIdFunc(ComTerp*,DrawEditor*); virtual void execute(); virtual const char* docstring() { return "%s([sid osid :pid pid :user namestr :host hoststr :hostid hostid :remap] | :all) -- command to manage session id's"; } }; //: command to send message between remote selections // grid(id selector :state selected :request newselector :grant oldselector) -- command to send message between remote selections class GraphicIdFunc : public UnidrawFunc { public: GraphicIdFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(id selector :state selected :request newselector :grant oldselector) -- command to send message between remote selections"; } }; //: command to change session (or graphic id) to use local session id // chgid(id) -- command to change session (or graphic id) to use local session id class ChangeIdFunc : public UnidrawFunc { public: ChangeIdFunc(ComTerp*,DrawEditor*); virtual void execute(); virtual const char* docstring() { return "%s(id) -- command to change session (or graphic id) to use local session id"; } }; //: command to return point list associated with a graphic // ptlist=points(compview) -- return point list from compview graphic class DrawPointsFunc : public UnidrawFunc { public: DrawPointsFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "ptlist=%s(compview) -- return point list from compview graphic"; } }; #endif /* !defined(_drawfunc_h) */ ivtools-1.2.11a1/src/DrawServ/drawimport.cc000066400000000000000000000167301214471147700205570ustar00rootroot00000000000000/* * Copyright (c) 2009 Scott E. Johnston * Copyright (c) 1996 Vectaport Inc. * Copyright (c) 1994-1995 Vectaport Inc., Cartoactive Systems * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * DrawImportCmd implementation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ ClassId DrawImportCmd::GetClassId () { return GRAPHIMPORT_CMD; } boolean DrawImportCmd::IsA (ClassId id) { return DRAWIMPORT_CMD == id || FrameImportCmd::IsA(id); } DrawImportCmd::DrawImportCmd (ControlInfo* c, ImportChooser* f) : FrameImportCmd(c, f) { } DrawImportCmd::DrawImportCmd (Editor* ed, ImportChooser* f) : FrameImportCmd(ed, f) { } Command* DrawImportCmd::Copy () { DrawImportCmd* copy = new DrawImportCmd(CopyControlInfo(), chooser_); InitCopy(copy); return copy; } void DrawImportCmd::Execute () { GraphicComp* comps = PostDialog(); Clipboard* cb; if (comps != nil) { DrawImportPasteCmd* paste_cmd = new DrawImportPasteCmd(GetEditor(), new Clipboard(comps)); paste_cmd->Execute(); paste_cmd->Log(); if(!comps->IsA(FRAME_IDRAW_COMP) && !comps->IsA(DRAW_IDRAW_COMP)) { if (chooser_->centered()) GetEditor()->GetViewer()->Align(comps, /* Center */ 4); if (!chooser_->by_pathname()) { FrameUngroupCmd* ungroup_cmd = new FrameUngroupCmd(GetEditor()); ungroup_cmd->Execute(); MacroCmd* macro_cmd = new MacroCmd(GetEditor(), paste_cmd, ungroup_cmd); macro_cmd->Log(); } else { paste_cmd->Log(); } } else delete comps; } } GraphicComp* DrawImportCmd::Import (const char* pathname) { GraphicComp* comp = nil; const char* creator = ReadCreator(pathname); DrawCatalog* catalog = (DrawCatalog*)unidraw->GetCatalog(); if (strcmp(creator, "drawserv") == 0) { catalog->SetImport(true); if (catalog->DrawCatalog::Retrieve(pathname, (Component*&) comp)) { catalog->SetImport(false); catalog->Forget(comp); return comp; } catalog->SetImport(false); return nil; } else if (strcmp(creator, "graphdraw") == 0 || strcmp(creator, "netdraw") == 0 || strcmp(creator, "graph-idraw") == 0) { static GraphCatalog *graphcatalog = new GraphCatalog("GraphCatalog", new GraphCreator());; graphcatalog->SetImport(true); if (graphcatalog->Retrieve(pathname, (Component*&) comp)) { graphcatalog->SetImport(false); graphcatalog->Forget(comp); if (chooser_->by_pathname()) { return new NodeComp((GraphComp*)comp); } else return comp; } catalog->SetImport(false); return nil; } else return FrameImportCmd::Import(pathname); } /*****************************************************************************/ static NodeComp* node (Clipboard* cb, int index) { if (index == -1) return nil; Iterator i; int count = -1; for (cb->First(i); !cb->Done(i); cb->Next(i)) { GraphicComp* gcomp = cb->GetComp(i); if (gcomp->IsA(NODE_COMP)) { count++; if (count == index) return (NodeComp*)gcomp; } } return nil; } ClassId DrawImportPasteCmd::GetClassId () { return DRAWIMPORTPASTE_CMD; } boolean DrawImportPasteCmd::IsA (ClassId id) { return DRAWIMPORTPASTE_CMD==id || FrameImportPasteCmd::IsA(id); } DrawImportPasteCmd::DrawImportPasteCmd (ControlInfo* c, Clipboard* cb) : FrameImportPasteCmd(c, cb) { } DrawImportPasteCmd::DrawImportPasteCmd (Editor* ed, Clipboard* cb) : FrameImportPasteCmd(ed, cb) { } DrawImportPasteCmd::~DrawImportPasteCmd () { } Command* DrawImportPasteCmd::Copy () { Command* copy = new DrawImportPasteCmd(CopyControlInfo(), DeepCopyClipboard()); InitCopy(copy); return copy; } void DrawImportPasteCmd::Execute () { if(!_executed) { Clipboard* cb = GetClipboard(); Iterator it; cb->First(it); GraphicComp* gcomp = cb->GetComp(it); cb->Next(it); if(cb->Done(it) && gcomp->IsA(DRAW_IDRAW_COMP) || gcomp->IsA(FRAME_IDRAW_COMP)) { gcomp->First(it); /* move to background frame */ DrawEditor* ed = (DrawEditor*)GetEditor(); FrameNumberState* fnumstate = ed->framenumstate(); int origfnum = fnumstate->framenumber(); int currfnum = 0; Append(new MoveFrameCmd(ed, -origfnum, true /* allowbg */)); /* paste contents of background frame */ FrameComp* fcomp = (FrameComp*) (gcomp->GetComp(it)->IsA(FRAME_COMP) ? gcomp->GetComp(it) : nil); if (fcomp) { while(!gcomp->Done(it)) { gcomp->Remove(it); Clipboard* newcb = new Clipboard(); Iterator jt; fcomp->First(jt); while(!fcomp->Done(jt)) { newcb->Append(fcomp->GetComp(jt)); fcomp->Remove(jt); } Append(new PasteCmd(ed, newcb)); delete fcomp; /* while more frames move to next frame and paste (create new frame if necessary) */ if(!gcomp->Done(it)) { currfnum++; fcomp = (FrameComp*) (gcomp->GetComp(it)->IsA(FRAME_COMP) ? gcomp->GetComp(it) : nil); if(currfnum>=ed->NumFrames()) Append(new CreateMoveFrameCmd(ed)); else Append(new MoveFrameCmd(ed, 1, true /* allowbg */)); } } } /* move to original frame */ Append(new MoveFrameCmd(ed, origfnum-currfnum, true /* allowbg */)); } else { Append(new PasteCmd(GetEditor(), cb->Copy())); Iterator i; for (cb->First(i); !cb->Done(i); cb->Next(i)) { GraphicComp* gcomp = cb->GetComp(i); if (gcomp->IsA(EDGE_COMP)) { EdgeComp* comp = (EdgeComp*)gcomp; NodeComp* start = node(cb, comp->GetStartNode()); NodeComp* end = node(cb, comp->GetEndNode()); EdgeConnectCmd* cmd = new EdgeConnectCmd(GetEditor(), comp, start, end); Append(cmd); } } } } MacroCmd::Execute(); _executed = 1; } ivtools-1.2.11a1/src/DrawServ/drawimport.h000066400000000000000000000043611214471147700204160ustar00rootroot00000000000000/* * Copyright (c) 2009 Scott E. Johnston * Copyright (c) 1996,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * DrawImportCmd - a command for importing graphs in multi-frame situations */ #ifndef draw_import_h #define draw_import_h #include #include //: specialized FrameImportCmd for importing graphs in frames class DrawImportCmd : public FrameImportCmd { public: DrawImportCmd(ControlInfo*, ImportChooser* = nil); DrawImportCmd(Editor* = nil, ImportChooser* = nil); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual GraphicComp* Import(const char*); }; //: specialized ImportPasteCmd for DrawServ class DrawImportPasteCmd : public FrameImportPasteCmd { public: DrawImportPasteCmd(ControlInfo*, Clipboard* = nil); DrawImportPasteCmd(Editor* = nil, Clipboard* = nil); virtual ~DrawImportPasteCmd(); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: }; #endif ivtools-1.2.11a1/src/DrawServ/drawkit.cc000066400000000000000000000575241214471147700200420ustar00rootroot00000000000000/* * Copyright (c) 1997,1999 Vectaport Inc. * Copyright (c) 1994-1996 Vectaport Inc., Cartoactive Systems * Copyright (c) 1993 David B. Hollenbeck * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * DrawKit definitions */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include declareActionCallback(DrawKit) implementActionCallback(DrawKit) static const int unit = 15; static const int xradius = 35; static const int yradius = 20; static int xClosed[] = { unit/5, unit, unit, unit*3/5, 0 }; static int yClosed[] = { 0, unit/5, unit*3/5, unit, unit*2/5 }; static Coord fxClosed[] = { unit/5, unit, unit, unit*3/5, 0 }; static Coord fyClosed[] = { 0, unit/5, unit*3/5, unit, unit*2/5 }; static const int nClosed = 5; static int xOpen[] = { 0, unit/2, unit/2, unit }; static int yOpen[] = { 0, unit/4, unit*3/4, unit }; static Coord fxOpen[] = { 0, unit/2, unit/2, unit }; static Coord fyOpen[] = { 0, unit/4, unit*3/4, unit }; static const int nOpen = 4; static Coord xhead[] = { unit, unit-4, unit-7 }; static Coord yhead[] = { unit, unit-7, unit-4 }; /******************************************************************************/ DrawKit* DrawKit::_comkit = nil; DrawKit::DrawKit () { } void DrawKit::Init (OverlayComp* comp, const char* name) { FrameKit::Init(comp, name); } DrawKit* DrawKit::Instance() { if (!_comkit) _comkit = new DrawKit(); return _comkit; } MenuItem * DrawKit::MakeFileMenu() { LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); MenuItem *mbi = kit.menubar_item(kit.label("File")); mbi->menu(kit.pulldown()); MakeMenu(mbi, new OvAboutCmd(new ControlInfo("About drawserv", KLBL_ABOUT, CODE_ABOUT)), "About drawserv "); MakeMenu(mbi, new OvNewCompCmd(new ControlInfo("New", KLBL_NEWCOMP, CODE_NEWCOMP), new DrawIdrawComp), "New "); MakeMenu(mbi, new OvRevertCmd(new ControlInfo("Revert", KLBL_REVERT, CODE_REVERT)), "Revert "); MakeMenu(mbi, new OvOpenCmd(new ControlInfo("Open...", KLBL_VIEWCOMP, CODE_VIEWCOMP)), "Open... "); MakeMenu(mbi, new OvSaveCompCmd(new ControlInfo("Save", KLBL_SAVECOMP, CODE_SAVECOMP)), "Save "); MakeMenu(mbi, new OvSaveCompAsCmd(new ControlInfo("Save As...", KLBL_SAVECOMPAS, CODE_SAVECOMPAS)), "Save As... "); MakeMenu(mbi, new OvPrintCmd(new ControlInfo("Print...", KLBL_PRINT, CODE_PRINT)), "Print... "); MakeMenu(mbi, new DrawImportCmd(new ControlInfo("Import Graphic...", KLBL_IMPORT, CODE_IMPORT)), "Import Graphic... "); MakeMenu(mbi, new OvExportCmd(new ControlInfo("Export Graphic...", "^X", "\030")), "Export Graphic... "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new OvQuitCmd(new ControlInfo("Quit", KLBL_QUIT, CODE_QUIT)), "Quit "); return mbi; } MenuItem* DrawKit::MakeEditMenu() { LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); MenuItem *mbi = kit.menubar_item(kit.label("Edit")); mbi->menu(kit.pulldown()); MakeMenu(mbi, new UndoCmd(new ControlInfo("Undo", KLBL_UNDO, CODE_UNDO)), "Undo "); MakeMenu(mbi, new RedoCmd(new ControlInfo("Redo", KLBL_REDO, CODE_REDO)), "Redo "); MakeMenu(mbi, new GraphCutCmd(new ControlInfo("Cut", KLBL_CUT, CODE_CUT)), "Cut "); // overrides FrameCutCmd MakeMenu(mbi, new GraphCopyCmd(new ControlInfo("Copy", KLBL_COPY, CODE_COPY)), "Copy "); MakeMenu(mbi, new GraphPasteCmd(new ControlInfo("Paste", KLBL_PASTE, CODE_PASTE)), "Paste "); MakeMenu(mbi, new GraphDupCmd(new ControlInfo("Duplicate", KLBL_DUP, CODE_DUP)), "Duplicate "); MakeMenu(mbi, new GraphDeleteCmd(new ControlInfo("Delete", KLBL_DEL, CODE_DEL)), "Delete "); MakeMenu(mbi, new OvSlctAllCmd(new ControlInfo("Select All", KLBL_SLCTALL, CODE_SLCTALL)), "Select All "); MakeMenu(mbi, new SlctByAttrCmd(new ControlInfo("Select by Attribute", "$", "$")), "Select by Attribute "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new ScaleCmd(new ControlInfo("Flip Horizontal", KLBL_HFLIP, CODE_HFLIP), -1.0, 1.0), "Flip Horizontal "); MakeMenu(mbi, new ScaleCmd(new ControlInfo("Flip Vertical", KLBL_VFLIP, CODE_VFLIP), 1.0, -1.0), "Flip Vertical "); MakeMenu(mbi, new RotateCmd(new ControlInfo("90 Clockwise", KLBL_CW90, CODE_CW90), -90.0), "90 Clockwise "); MakeMenu(mbi, new RotateCmd(new ControlInfo("90 CounterCW", KLBL_CCW90, CODE_CCW90), 90.0), "90 CounterCW "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new OvPreciseMoveCmd(new ControlInfo("Precise Move", KLBL_PMOVE, CODE_PMOVE)), "Precise Move "); MakeMenu(mbi, new OvPreciseScaleCmd(new ControlInfo("Precise Scale", KLBL_PSCALE, CODE_PSCALE)), "Precise Scale "); MakeMenu(mbi, new OvPreciseRotateCmd(new ControlInfo("Precise Rotate", KLBL_PROTATE, CODE_PROTATE)), "Precise Rotate "); return mbi; } MenuItem* DrawKit::MakeFrameMenu() { LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); MenuItem *mbi = kit.menubar_item(kit.label("Frame")); mbi->menu(kit.pulldown()); MoveFrameCmd::default_instance (new MoveFrameCmd(new ControlInfo("Move Forward","^F",""), +1)); MakeMenu(mbi, MoveFrameCmd::default_instance(), "Move Forward "); MakeMenu(mbi, new MoveFrameCmd(new ControlInfo("Move Backward","^B",""), -1), "Move Backward "); MakeMenu(mbi, new FrameBeginCmd(new ControlInfo("Goto First Frame")), "Goto First Frame"); MakeMenu(mbi, new FrameEndCmd(new ControlInfo("Goto Last Frame")), "Goto Last Frame "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new CreateMoveFrameCmd(new ControlInfo("New Forward","F","F")), "New Forward "); MakeMenu(mbi, new CreateMoveFrameCmd(new ControlInfo("New Backward","B","B"), false), "New Backward "); MakeMenu(mbi, new CopyMoveGraphFrameCmd(new ControlInfo("Copy Forward","X","X")), "Copy Forward "); MakeMenu(mbi, new CopyMoveGraphFrameCmd(new ControlInfo("Copy Backward","Y","Y"), false), "Copy Backward "); MakeMenu(mbi, new DeleteFrameCmd(new ControlInfo("Delete","D","D")), "Delete "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new ShowOtherFrameCmd(new ControlInfo("Show Prev Frame","",""), -1), "Show Prev Frame"); MakeMenu(mbi, new ShowOtherFrameCmd(new ControlInfo("Hide Prev Frame","",""), 0), "Hide Prev Frame"); MenuItem* menu_item; menu_item = kit.menu_item(kit.label("Enable Looping")); menu_item->action (new ActionCallback(MoveFrameCmd) (MoveFrameCmd::default_instance(), &MoveFrameCmd::set_wraparound)); mbi->menu()->append_item(menu_item); menu_item = kit.menu_item(kit.label("Disable Looping")); menu_item->action (new ActionCallback(MoveFrameCmd) (MoveFrameCmd::default_instance(), &MoveFrameCmd::clr_wraparound)); mbi->menu()->append_item(menu_item); #if 0 MakeMenu(mbi, new AutoNewFrameCmd(new ControlInfo("Toggle Auto New Frame", "","")), "Toggle Auto New Frame"); #else menu_item = kit.check_menu_item(kit.label("Auto New Frame")); menu_item->state()->set(TelltaleState::is_chosen, ((FrameEditor*)GetEditor())->AutoNewFrame()); ((FrameEditor*)GetEditor())->_autonewframe_tts = menu_item->state(); AutoNewFrameCmd::default_instance(new AutoNewFrameCmd(GetEditor())); menu_item->action (new ActionCallback(AutoNewFrameCmd) (AutoNewFrameCmd::default_instance(), &AutoNewFrameCmd::Execute)); mbi->menu()->append_item(menu_item); #endif return mbi; } MenuItem * DrawKit::MakeToolsMenu() { LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); MenuItem *mbi = kit.menubar_item(kit.label("Tools")); mbi->menu(kit.pulldown()); MenuItem* menu_item = kit.menu_item(kit.label("Graph Tools")); menu_item->action(new ActionCallback(DrawKit)(this, &DrawKit::toolbar1)); mbi->menu()->append_item(menu_item); menu_item = kit.menu_item(kit.label("Idraw Tools")); menu_item->action(new ActionCallback(DrawKit)(this, &DrawKit::toolbar0)); mbi->menu()->append_item(menu_item); return mbi; } Glyph* DrawKit::MakeToolbar() { WidgetKit& kit = *WidgetKit::instance(); const LayoutKit& layout = *LayoutKit::instance(); Style* s = kit.style(); ToolButton* select; ToolButton* move; ToolButton* reshape; ToolButton* magnify; _toolbars = layout.deck(2); PolyGlyph* vb = layout.vbox(); _toolbar_vbox = new Glyph*[2]; _toolbar_vbox[0] = vb; _tg = new TelltaleGroup(); Glyph* sel = kit.label("Select"); Glyph* mov = kit.label("Move"); Glyph* scl = kit.label("Scale"); Glyph* str = kit.label("Stretch"); Glyph* rot = kit.label("Rotate"); Glyph* alt = kit.label("Alter"); Glyph* mag = kit.label("Magnify"); Glyph* txt = kit.label("Text"); Glyph* glin = new Fig31Line(new Brush(0), kit.foreground(), nil, 0, 0, unit, unit); Glyph* gmlin = new Fig31Polyline(new Brush(0), kit.foreground(), nil, fxOpen, fyOpen, nOpen); Glyph* gospl = new Fig31Open_BSpline(new Brush(0), kit.foreground(), nil, fxOpen, fyOpen, nOpen); Glyph* grect = new Fig31Rectangle(new Brush(0), kit.foreground(), nil, 0, 0, unit, unit*4/5); Glyph* gellp = new Fig31Ellipse(new Brush(0), kit.foreground(), nil, 0, 0, unit*2/3, unit*2/5); Glyph* gpoly = new Fig31Polygon(new Brush(0), kit.foreground(), nil, fxClosed, fyClosed, nClosed); Glyph* gcspl = new Fig31Closed_BSpline(new Brush(0), kit.foreground(), nil, fxClosed, fyClosed, nClosed); Glyph* anno = kit.label("Annotate"); Glyph* attr = kit.label("Attribute"); Glyph* gedge = layout.overlay( new Fig31Line(new Brush(0), kit.foreground(), nil, 0, 0, unit, unit), new Fig31Polygon(new Brush(0), kit.foreground(), kit.foreground(), xhead, yhead, 3) ); Glyph* gnod1 = layout.overlay( new Fig31Ellipse(new Brush(0), kit.foreground(), nil, 0, 0, unit, unit*3/5), layout.center(kit.label("___"))); Glyph* gnod2 = layout.overlay( new Fig31Ellipse(new Brush(0), kit.foreground(), nil, 0, 0, unit, unit*3/5), layout.center(kit.label("abc"))); Coord maxwidth = 0; Requisition req; maxwidth = Math::max((sel->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((mov->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((scl->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((str->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((rot->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((alt->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((mag->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((txt->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((glin->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((gmlin->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((gospl->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((grect->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((gellp->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((gpoly->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((gcspl->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((anno->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((gedge->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((gnod1->request(req), req.x_requirement().natural()), maxwidth); maxwidth = Math::max((gnod2->request(req), req.x_requirement().natural()), maxwidth); vb->append(select = MakeTool(new SelectTool(new ControlInfo("Select", KLBL_SELECT, CODE_SELECT)), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(sel)), _tg, _ed->MouseDocObservable(), mouse_sel)); vb->append(move = MakeTool(new MoveTool(new ControlInfo("Move", KLBL_MOVE, CODE_MOVE)), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(mov)), _tg, _ed->MouseDocObservable(), mouse_mov)); vb->append(MakeTool(new ScaleTool(new ControlInfo("Scale", KLBL_SCALE, CODE_SCALE)), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(scl)), _tg, _ed->MouseDocObservable(), mouse_scl)); vb->append(MakeTool(new StretchTool(new ControlInfo("Stretch", KLBL_STRETCH,CODE_STRETCH)), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(str)), _tg, _ed->MouseDocObservable(), mouse_str)); vb->append(MakeTool(new RotateTool(new ControlInfo("Rotate", KLBL_ROTATE, CODE_ROTATE)), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(rot)), _tg, _ed->MouseDocObservable(), mouse_rot)); vb->append(reshape = MakeTool(new ReshapeTool(new ControlInfo("Alter", KLBL_RESHAPE, CODE_RESHAPE)), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(alt)), _tg, _ed->MouseDocObservable(), mouse_alt)); vb->append(magnify = MakeTool(new MagnifyTool(new ControlInfo("Magnify", KLBL_MAGNIFY,CODE_MAGNIFY)), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(mag)), _tg, _ed->MouseDocObservable(), mouse_mag)); TextGraphic* text = new TextGraphic("Text", stdgraphic); TextOvComp* textComp = new TextOvComp(text); vb->append(MakeTool(new GraphicCompTool(new ControlInfo("Text", KLBL_TEXT, CODE_TEXT), textComp), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(txt)), _tg, _ed->MouseDocObservable(), mouse_txt)); ArrowLine* line = new ArrowLine( 0, 0, unit, unit, false, false, 1., stdgraphic ); ArrowLineOvComp* arrowLineComp = new ArrowLineOvComp(line); vb->append(MakeTool(new GraphicCompTool(new ControlInfo(arrowLineComp, KLBL_LINE, CODE_LINE), arrowLineComp), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(glin)), _tg, _ed->MouseDocObservable(), mouse_lin)); ArrowMultiLine* ml = new ArrowMultiLine( xOpen, yOpen, nOpen, false, false, 1., stdgraphic ); ml->SetPattern(psnonepat); ArrowMultiLineOvComp* mlComp = new ArrowMultiLineOvComp(ml); vb->append(MakeTool(new GraphicCompTool(new ControlInfo(mlComp, KLBL_MULTILINE, CODE_MULTILINE), mlComp), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(gmlin)), _tg, _ed->MouseDocObservable(), mouse_mlin)); ArrowOpenBSpline* spl = new ArrowOpenBSpline( xOpen, yOpen, nOpen, false, false, 1., stdgraphic ); spl->SetPattern(psnonepat); ArrowSplineOvComp* splComp = new ArrowSplineOvComp(spl); vb->append(MakeTool(new GraphicCompTool(new ControlInfo(splComp, KLBL_SPLINE, CODE_SPLINE), splComp), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(gospl)), _tg, _ed->MouseDocObservable(), mouse_ospl)); SF_Rect* rect = new SF_Rect(0, 0, unit, unit*4/5, stdgraphic); rect->SetPattern(psnonepat); RectOvComp* rectComp = new RectOvComp(rect); vb->append(MakeTool(new GraphicCompTool(new ControlInfo(rectComp, KLBL_RECT, CODE_RECT), rectComp), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(grect)), _tg, _ed->MouseDocObservable(), mouse_rect)); SF_Ellipse* ellipse = new SF_Ellipse(0, 0, unit*2/3, unit*2/5, stdgraphic); ellipse->SetPattern(psnonepat); EllipseOvComp* ellipseComp = new EllipseOvComp(ellipse); vb->append(MakeTool(new GraphicCompTool(new ControlInfo(ellipseComp, KLBL_ELLIPSE, CODE_ELLIPSE), ellipseComp), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(gellp)), _tg, _ed->MouseDocObservable(), mouse_ellp)); SF_Polygon* polygon = new SF_Polygon(xClosed, yClosed, nClosed,stdgraphic); polygon->SetPattern(psnonepat); PolygonOvComp* polygonComp = new PolygonOvComp(polygon); vb->append(MakeTool(new GraphicCompTool(new ControlInfo(polygonComp, KLBL_POLY, CODE_POLY), polygonComp), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(gpoly)), _tg, _ed->MouseDocObservable(), mouse_poly)); SFH_ClosedBSpline* cspline = new SFH_ClosedBSpline( xClosed, yClosed, nClosed, stdgraphic ); cspline->SetPattern(psnonepat); ClosedSplineOvComp* csplineComp = new ClosedSplineOvComp(cspline); vb->append(MakeTool(new GraphicCompTool(new ControlInfo(csplineComp, KLBL_CSPLINE,CODE_CSPLINE), csplineComp), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(gcspl)), _tg, _ed->MouseDocObservable(), mouse_cspl)); vb->append(MakeTool(new AnnotateTool(new ControlInfo("Annotate", "A", "A")), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(anno)), _tg, _ed->MouseDocObservable(), mouse_anno)); vb->append(MakeTool(new AttributeTool(new ControlInfo("Attribute", "T", "T")), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(attr)), _tg, _ed->MouseDocObservable(), mouse_attr)); _toolbars->append(vb); vb = layout.vbox(); _toolbar_vbox[1] = vb; vb->append(select); vb->append(move); vb->append(reshape); vb->append(magnify); ArrowLine* aline = new ArrowLine( 0, 0, unit, unit, true, false, 1., stdgraphic ); EdgeComp* protoedge = new EdgeComp(aline); vb->append(MakeTool(new GraphicCompTool(new ControlInfo(protoedge, "E","E"), protoedge), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(gedge)), _tg, _ed->MouseDocObservable(), GraphKit::mouse_edge)); SF_Ellipse* nellipse = new SF_Ellipse(0, 0, xradius, yradius, stdgraphic); nellipse->SetPattern(psnonepat); TextGraphic* ntext = new TextGraphic("___", stdgraphic); nellipse->Align(4, ntext, 4); // same as Center in IV-2_6/InterViews/alignment.h NodeComp* protonode = new NodeComp(nellipse, ntext); vb->append(MakeTool(new GraphicCompTool(new ControlInfo(protonode, "N","N"), protonode), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(gnod1)), _tg, _ed->MouseDocObservable(), GraphKit::mouse_node)); SF_Ellipse* nellipse2 = new SF_Ellipse(0, 0, xradius, yradius, stdgraphic); nellipse2->SetPattern(psnonepat); TextGraphic* ntext2 = new TextGraphic("abc", stdgraphic); nellipse2->Align(4, ntext2, 4); // same as Center in IV-2_6/InterViews/alignment.h NodeComp* protonode2 = new NodeComp(nellipse2, ntext2, true); vb->append(MakeTool(new GraphicCompTool(new ControlInfo(protonode2, "L","L"), protonode2), layout.overlay(layout.hcenter(layout.hspace(maxwidth)), layout.hcenter(gnod2)), _tg, _ed->MouseDocObservable(), GraphKit::mouse_lnode)); _toolbars->append(vb); _toolbars->flip_to(0); _toolbar = new Patch(_toolbars); return layout.hbox( layout.vflexible( layout.vnatural( new Background( layout.vcenter( _toolbar ), unidraw->GetCatalog()->FindColor("#aaaaaa") ), 550 ) ) ); } void DrawKit::toolbar0() { _toolbars->flip_to(0); _ed->GetKeyMap()->Execute(CODE_SELECT); _toolbar->redraw(); } void DrawKit::toolbar1() { _toolbars->flip_to(1); _ed->GetKeyMap()->Execute("L"); _toolbar->redraw(); } void DrawKit::launch_drawtool() { OverlayEditor* ed = new OverlayEditor((const char*)nil); unidraw->Open(ed); } void DrawKit::launch_flipbook() { FrameEditor* ed = new FrameEditor((const char*)nil); unidraw->Open(ed); } void DrawKit::launch_graphdraw() { GraphEditor* ed = new GraphEditor((const char*)nil); unidraw->Open(ed); } OverlaySelection* DrawKit::MakeSelection(Selection* sel) { #ifdef HAVE_ACE return new LinkSelection((DrawEditor*)GetEditor(), sel); #else return FrameKit::MakeSelection(sel); #endif } MenuItem * DrawKit::MakeViewersMenu() { #ifdef HAVE_ACE LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); MenuItem *mbi = kit.menubar_item(kit.label("Connections")); mbi->menu(kit.pulldown()); MenuItem* menu_item = kit.menu_item(kit.label("Connect")); menu_item->action(new RemoteConnectPopupAction(GetEditor())); mbi->menu()->append_item(menu_item); return mbi; #else return nil; #endif } ivtools-1.2.11a1/src/DrawServ/drawkit.h000066400000000000000000000042531214471147700176730ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * Copyright (c) 1994-1997,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * DrawKit - object to construct objects for an ComEditor */ #ifndef draw_kit_h #define draw_kit_h #include #include class FieldEditor; class NodeDialog; //: specialized FrameKit for use with drawserv. class DrawKit : public FrameKit { public: DrawKit(); virtual void Init(OverlayComp*, const char* name); virtual MenuItem *MakeFileMenu(); virtual MenuItem *MakeEditMenu(); virtual Glyph* MakeToolbar(); virtual MenuItem* MakeFrameMenu(); virtual MenuItem* MakeToolsMenu(); virtual MenuItem* MakeViewersMenu(); static DrawKit* Instance(); virtual OverlaySelection* MakeSelection(Selection* sel = nil); // make Selection of the proper derivation. protected: void toolbar0(); void toolbar1(); void launch_drawtool(); void launch_flipbook(); void launch_graphdraw(); protected: static DrawKit* _comkit; }; #include #endif ivtools-1.2.11a1/src/DrawServ/drawlink.cc000066400000000000000000000153061214471147700202000ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Implementation of Drawlink class. */ #include #include #include #include #include #include #include #include #include using std::cout; using std::cerr; int DrawLink::_linkcnt = 0; implementTable(IncomingSidTable,unsigned int,unsigned int) const char* DrawLink::_state_strings[] = { "new_link", "one_way", "two_way", "redundant" }; /*****************************************************************************/ DrawLink::DrawLink (const char* hostname, int portnum, int state) { _host = strnew(hostname); _althost = nil; _port = portnum; _ok = false; _local_linkid = _linkcnt++; _remote_linkid = -1; _state = state; _addr = nil; _socket = nil; _conn = nil; _comhandler = nil; _ackhandler = nil; _incomingsidtable = new IncomingSidTable(32); _incomingsidtable_size = 0; } DrawLink::~DrawLink () { #ifdef HAVE_ACE if (_socket->close () == -1) ACE_ERROR ((LM_ERROR, "%p\n", "close")); delete _conn; delete _socket; delete _addr; delete _host; delete _althost; #endif delete _incomingsidtable; } int DrawLink::open() { #if defined(HAVE_ACE) && (__GNUC__>3 || __GNUC__==3 && __GNUC_MINOR__>0) _addr = new ACE_INET_Addr(_port, _host); _socket = new ACE_SOCK_Stream; _conn = new ACE_SOCK_Connector; if (_conn->connect (*_socket, *_addr) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "open")); return -1; } else { _socket->enable(ACE_NONBLOCK); /* set up handler to monitor backtalk */ ackhandler(new AckBackHandler); ackhandler()->drawlink(this); ackhandler()->set_handle(_socket->get_handle()); if (ComterpHandler::reactor_singleton()->register_handler(ackhandler(), ACE_Event_Handler::READ_MASK|ACE_Event_Handler::TIMER_MASK)==-1) fprintf(stderr, "drawserv: error registering ackback handler (handle==%d)\n", _socket->get_handle()); #if __GNUC__<4 && !defined(__CYGWIN__) fileptr_filebuf obuf(_socket->get_handle(), ios_base::out, false, static_cast(BUFSIZ)); #else fileptr_filebuf obuf(_socket->get_handle(), ios_base::out, static_cast(BUFSIZ)); #endif ostream out(&obuf); out << "drawlink(\""; char buffer[HOST_NAME_MAX]; gethostname(buffer, HOST_NAME_MAX); unsigned int sid = ((DrawServ*)unidraw)->sessionid(); void* ptr = nil; ((DrawServ*)unidraw)->sessionidtable()->find(ptr, sid); SessionId* sessionid = (SessionId*)ptr; out << buffer << "\""; out << " :port " << ((DrawServ*)unidraw)->comdraw_port(); out << " :state " << _state+1; out << " :rid " << _local_linkid; out << " :lid " << _remote_linkid; out << " :sid 0x" << std::hex << sid << std::dec; if (sessionid) { out << " :pid " << sessionid->pid(); out << " :user \"" << sessionid->username() << "\""; } out << ")\n"; out.flush(); _ok = true; /* schedule timer on ackback link, to detect timeout */ ackhandler()->start_timer(); return 0; } #else fprintf(stderr, "drawserv requires ACE and >= gcc-3.1 for full functionality\n"); return -1; #endif } int DrawLink::close() { fprintf(stderr, "Closing link to %s (%s) port # %d (lid=%d, rid=%d)\n", hostname(), althostname(), portnum(), local_linkid(), remote_linkid()); if (comhandler()) comhandler()->drawlink(nil); if (_socket) { if (ackhandler()) { if (ackhandler()->get_handle() !=-1) if (ComterpHandler::reactor_singleton()->remove_handler(ackhandler(), ACE_Event_Handler::READ_MASK|ACE_Event_Handler::TIMER_MASK)==-1) cerr << "drawserv: error removing ackback handler\n"; delete ackhandler(); ackhandler(nil); } if (_socket->close () == -1) ACE_ERROR ((LM_ERROR, "%p\n", "close")); } } void DrawLink::hostname(const char* host) { delete _host; _host = nil; if (host) _host = strnew(host); notify(); } void DrawLink::althostname(const char* althost) { delete _althost; _althost = nil; if (althost) _althost = strnew(althost); notify(); } int DrawLink::handle() { if (_socket) return _socket->get_handle(); else return -1; } unsigned DrawLink::sid_lookup(unsigned int sid) { unsigned int local_sid = 0; if (_incomingsidtable_size==0) return sid; incomingsidtable()->find(local_sid, sid); return local_sid ? local_sid : sid; } void DrawLink::sid_change(unsigned int& id) { if (_incomingsidtable_size==0) return; id = sid_lookup(id & DrawServ::SessionIdMask) | (id & DrawServ::GraphicIdMask); return; } void DrawLink::sid_insert(unsigned int sid, unsigned int alt_sid) { if (sid!=alt_sid) { _incomingsidtable_size++; _incomingsidtable->insert(sid, alt_sid); } } void DrawLink::dump(FILE* fptr) { fprintf(fptr, "Host Alt. Port LID RID State\n"); fprintf(fptr, "------------------------------ ------------------------------ ------ --- --- -----\n"); fprintf(fptr, "%-30.30s %-30.30s %-6d %-3d %-3d %-3d\n", hostname(), althostname(), portnum(), local_linkid(), remote_linkid(), state()); dump_incomingsidtable(fptr); } void DrawLink::dump_incomingsidtable(FILE* fptr) { IncomingSidTable* table = incomingsidtable(); IncomingSidTable_Iterator it(*table); printf("sid osid\n"); printf("---------- ----------\n"); while(it.more()) { unsigned int osid = (unsigned int)it.cur_value(); unsigned int sid = (unsigned int)it.cur_key(); fprintf(fptr, "0x%08x 0x%08x\n", sid, osid); it.next(); } } ivtools-1.2.11a1/src/DrawServ/drawlink.h000066400000000000000000000116171214471147700200430ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * DrawLink - object to encapsulate 2-way link with remote drawserv */ #ifndef drawlink_h #define drawlink_h #include class AckBackHandler; class DrawServ; class DrawServHandler; #include declareTable(IncomingSidTable,unsigned int,unsigned int) #ifdef HAVE_ACE #include #include class ACE_INET_Addr; class ACE_SOCK_Stream; class ACE_SOCK_Stream; #endif #include //: object to encapsulate 2-way link with remote drawserv class DrawLink : public Observable { public: DrawLink(const char* hostname, int portnum, int state); virtual ~DrawLink(); enum { new_link=0, one_way, two_way, redundant }; static const char* state_string(int state) { return state>=0 && state<=redundant ? _state_strings[state] : nil; } const char* hostname() { return _host; } // return name of remote host void hostname(const char* host); // set name of remote host const char* althostname() { return _althost; } // return alternate name of remote host void althostname(const char* althost); // set alternate name of remote host int portnum() { return _port; } // return port on remote host int open(); // open link to remote DrawServ int close(); // close link to remote DrawServ int up() { state() == two_way; } // return 1 if link up, 0 if down int ok() { return _ok; } // return 1 if link ok (but not necessarily two-way yet), 0 if not int handle(); // return file descriptor associated with link int local_linkid() { return _local_linkid; } // get local DrawLink id int remote_linkid() { return _remote_linkid; } // get remote DrawLink id void local_linkid(int id) { _local_linkid = id; } // get local DrawLink id void remote_linkid(int id) { _remote_linkid = id; } // get remote DrawLink id void comhandler(DrawServHandler* handler) { _comhandler = handler; } // set DrawServHandler associated with incoming connection DrawServHandler* comhandler() { return _comhandler; } // get DrawServHandler associated with incoming connection void ackhandler(AckBackHandler* handler) { _ackhandler = handler; } // set AckBackHandler associated with incoming connection AckBackHandler* ackhandler() { return _ackhandler; } // get AckBackHandler associated with incoming connection IncomingSidTable* incomingsidtable() { return _incomingsidtable; } // return pointer to table mapping incoming sessionid's to locally unique sessionid's void state(int val) { _state = val; notify(); } // set state of DrawLink int state() { return _state; } // get state of DrawLink #ifdef HAVE_ACE ACE_SOCK_Stream* socket() { return _socket; } // return pointer to connected socket. #endif unsigned int sid_lookup(unsigned int sid); // map incoming sid to local sid. void sid_change(unsigned int& id); // change sid portion of an id to use local sid. void sid_insert(unsigned int sid, unsigned int alt_sid); // insert new sid pair into table void dump(FILE*); // dump complete information on this DrawLink void dump_incomingsidtable(FILE*); // dump complete information on this DrawLink's IncomingSidTable protected: const char* _host; const char* _althost; int _port; int _ok; static int _linkcnt; int _local_linkid; int _remote_linkid; int _state; IncomingSidTable* _incomingsidtable; int _incomingsidtable_size; #ifdef HAVE_ACE ACE_INET_Addr* _addr; ACE_SOCK_Connector* _conn; ACE_SOCK_Stream* _socket; #endif DrawServHandler* _comhandler; AckBackHandler* _ackhandler; static const char* _state_strings[]; }; #endif ivtools-1.2.11a1/src/DrawServ/drawlinkcomp.cc000066400000000000000000000033621214471147700210560ustar00rootroot00000000000000/* * Copyright 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include /****************************************************************************/ int DrawLinkComp::_symid = -1; DrawLinkComp::DrawLinkComp(DrawLink* link) : OverlayComp() { _drawlink = link; _gr = nil; } DrawLinkComp::~DrawLinkComp() { } Component* DrawLinkComp::Copy() { DrawLinkComp* comp = new DrawLinkComp(_drawlink); return comp; } ClassId DrawLinkComp::GetClassId () { return DRAWLINK_COMP; } boolean DrawLinkComp::IsA (ClassId id) { return DRAWLINK_COMP == id || OverlayComp::IsA(id); } ivtools-1.2.11a1/src/DrawServ/drawlinkcomp.h000066400000000000000000000032371214471147700207210ustar00rootroot00000000000000/* * Copyright 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef drawlinkcomp_h #define drawlinkcomp_h #include class DrawLink; class DrawLinkComp : public OverlayComp { public: DrawLinkComp(DrawLink* link = nil); ~DrawLinkComp(); virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); DrawLink* drawlink() { return _drawlink; } void drawlink(DrawLink* link) { _drawlink = link; } protected: CLASS_SYMID("DrawLinkComp"); DrawLink* _drawlink; }; #endif ivtools-1.2.11a1/src/DrawServ/drawlinklist.cc000066400000000000000000000076211214471147700210750ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Implementation of DrawLinkList class. */ #include #include #include #include #include #include #include /*****************************************************************************/ DrawLinkList::DrawLinkList() { _ulist = new UList; _count = 0; } DrawLinkList::~DrawLinkList () { if (_ulist) { Iterator i; for (First(i); !Done(i); Next(i)) { delete GetDrawLink(i); } delete _ulist; } } void DrawLinkList::add_drawlink(DrawLink* new_link) { Iterator i; First(i); InsertBefore(i, new_link); } DrawLink* DrawLinkList::find_drawlink(GraphicId* grid) { void* ptr = nil; ((DrawServ*)unidraw)->sessionidtable()->find(ptr, grid->selector()); SessionId* sessionid = (SessionId*)ptr; return (DrawLink*) (sessionid ? sessionid->drawlink() : nil); } DrawLink* DrawLinkList::Link (UList* r) { return (DrawLink*) (*r)(); } UList* DrawLinkList::Elem (Iterator i) { return (UList*) i.GetValue(); } void DrawLinkList::Append (DrawLink* v) { _ulist->Append(new UList(v)); ++_count; v->attach(this); notify(); } void DrawLinkList::Prepend (DrawLink* v) { _ulist->Prepend(new UList(v)); ++_count; v->attach(this); notify(); } void DrawLinkList::InsertAfter (Iterator i, DrawLink* v) { Elem(i)->Prepend(new UList(v)); ++_count; v->attach(this); notify(); } void DrawLinkList::InsertBefore (Iterator i, DrawLink* v) { Elem(i)->Append(new UList(v)); ++_count; v->attach(this); notify(); } void DrawLinkList::Remove (Iterator& i) { GetDrawLink(i)->detach(this); UList* doomed = Elem(i); Next(i); _ulist->Remove(doomed); delete doomed; --_count; notify(); } void DrawLinkList::Remove (DrawLink* p) { p->detach(this); UList* temp; if ((temp = _ulist->Find(p)) != nil) { _ulist->Remove(temp); delete temp; --_count; } notify(); } DrawLink* DrawLinkList::GetDrawLink (Iterator i) { return Link(Elem(i)); } void DrawLinkList::SetDrawLink (DrawLink* gv, Iterator& i) { i.SetValue(_ulist->Find(gv)); } void DrawLinkList::First (Iterator& i) { i.SetValue(_ulist->First()); } void DrawLinkList::Last (Iterator& i) { i.SetValue(_ulist->Last()); } void DrawLinkList::Next (Iterator& i) { i.SetValue(Elem(i)->Next()); } void DrawLinkList::Prev (Iterator& i) { i.SetValue(Elem(i)->Prev()); } boolean DrawLinkList::Done (Iterator i) { return Elem(i) == _ulist->End(); } int DrawLinkList::Number () { return _count; } boolean DrawLinkList::Includes (DrawLink* e) { return _ulist->Find(e) != nil; } boolean DrawLinkList::IsEmpty () { return _ulist->IsEmpty(); } ivtools-1.2.11a1/src/DrawServ/drawlinklist.h000066400000000000000000000071101214471147700207300ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * DrawLinkList - a UList based list of DrawLink's */ #ifndef drawlinklist_h #define drawlinklist_h //: UList based list of DrawLink's #include #include class DrawLink; class GraphicId; class Iterator; class UList; class DrawLinkList : public Observable, Observer { public: DrawLinkList(); virtual ~DrawLinkList(); void add_drawlink(DrawLink*); // add DrawLink to list DrawLink* find_drawlink(GraphicId*); // find DrawLink to the selector of this graphic void First(Iterator&); // set iterator to point to first DrawLink in list. void Last(Iterator&); // set iterator to point to last DrawLink in list. void Next(Iterator&); // set iterator to point to next DrawLink in list. void Prev(Iterator&); // set iterator to point to previous DrawLink in list. boolean Done(Iterator); // return true if iterator is pointing off the end of the list. // works for forward and backward traversals. boolean IsEmpty(); // true if no DrawLink objects in list. int Number(); // number of DrawLink objects in list. void Append(DrawLink*); // append DrawLink to end of list. void Prepend(DrawLink*); // append DrawLink to front of list. void InsertAfter(Iterator, DrawLink*); // insert DrawLink after position pointed to by iterator. void InsertBefore(Iterator, DrawLink*); // insert DrawLink before position pointed to by iterator. void Remove(DrawLink*); // remove DrawLink from list, returning responsibility for freeing the // associated memory. DrawLink* GetDrawLink(Iterator); // get DrawLink pointed to by iterator. void SetDrawLink(DrawLink*, Iterator&); // set DrawLink pointed to by iterator. boolean Includes(DrawLink*); // check if list includes DrawLink by pointer-comparison. UList* Elem(Iterator); // return UList (UList) pointed to by Iterator (Iterator). DrawLink* Link(UList*); // return DrawLink pointed to by UList (UList). virtual void update(Observable* obs) { notify(); } // invoked when DrawLink is updated protected: void Remove(Iterator&); // remove DrawLink pointed to by iterator from the list, // returning responsibility for freeing the associated memory. // This requires saving a pointer to the DrawLink before calling this method. UList* _ulist; unsigned int _count; }; #endif ivtools-1.2.11a1/src/DrawServ/drawserv-handler.cc000066400000000000000000000052201214471147700216270ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifdef HAVE_ACE #include #include int DrawServHandler::_sigpipe_handler_initialized = 0; /*****************************************************************************/ // Default constructor. DrawServHandler::DrawServHandler (ComTerpServ* serv) : UnidrawComterpHandler(serv) { _drawlink = nil; if (!_sigpipe_handler_initialized) { if (ComterpHandler::reactor_singleton()->register_handler (SIGPIPE, this) == -1) ACE_DEBUG ((LM_ERROR, "(%P|%t) can't register signal handler with reactor\n")); _sigpipe_handler_initialized = 1; _sigpipe_handler = 1; } else _sigpipe_handler = 0; } int DrawServHandler::open (void * ptr) { ComterpHandler::open(ptr); return 0; } void DrawServHandler::destroy (void) { if (_sigpipe_handler) { #if 0 if (ComterpHandler::reactor_singleton()->remove_handler (SIGPIPE, (ACE_Sig_Action*)nil) == -1) ACE_DEBUG ((LM_ERROR, "(%P|%t) can't remove signal handler from reactor\n")); #endif _sigpipe_handler = _sigpipe_handler_initialized = 0; } ComterpHandler::destroy(); if (drawlink()) { ((DrawServ*)unidraw)->linkdown(drawlink()); drawlink(nil); } } int DrawServHandler::handle_signal(int signum, siginfo_t* s, ucontext_t* u) { if (signum==SIGPIPE) { fprintf(stderr, "ignoring SIGPIPE because we don't know what handle it is on\n"); } else fprintf(stderr, "unknown signal handled %d\n", signum); return 0; } #endif /* HAVE_ACE */ ivtools-1.2.11a1/src/DrawServ/drawserv-handler.h000066400000000000000000000043301214471147700214720ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifdef HAVE_ACE #ifndef _drawserv_handler_ #define _drawserv_handler_ #include class AckBackHandler; class DrawLink; //: specialized UnidrawComterpHandler for integration into DrawServ class DrawServHandler : public UnidrawComterpHandler { public: // = Initialization and termination methods. DrawServHandler (ComTerpServ* serv = NULL); DrawLink* drawlink() { return _drawlink; } // get DrawLink associated with this handler void drawlink(DrawLink* link) { _drawlink = link; } // set DrawLink associated with this handler virtual void destroy (void); // traps disconnects virtual int open (void *); // open handler hook. virtual int handle_signal(int, siginfo_t*, ucontext_t*); // handle signals protected: DrawLink* _drawlink; static int _sigpipe_handler_initialized; int _sigpipe_handler; }; //: Acceptor specialized for use with DrawServ and ComTerp. typedef ACE_Acceptor DrawServAcceptor; #endif /* _drawserv_handler_ */ #endif /* HAVE_ACE */ ivtools-1.2.11a1/src/DrawServ/drawserv.cc000066400000000000000000000540211214471147700202170ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Implementation of DrawServ class. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::cout; using std::cerr; #ifdef HAVE_ACE implementTable(GraphicIdTable,int,void*) implementTable(SessionIdTable,int,void*) implementTable(CompIdTable,void*,void*) unsigned int DrawServ::GraphicIdMask = 0x000fffff; unsigned int DrawServ::SessionIdMask = 0xfff00000; static int seed=0; #endif /* HAVE_ACE */ /*****************************************************************************/ DrawServ::DrawServ (Catalog* c, int& argc, char** argv, OptionDesc* od, PropertyData* pd) : OverlayUnidraw(c, argc, argv, od, pd) { Init(); } DrawServ::DrawServ (Catalog* c, World* w) : OverlayUnidraw(c, w) { Init(); } void DrawServ::Init() { #ifdef HAVE_ACE _linklist = new DrawLinkList; _gridtable = new GraphicIdTable(1024); _sessionidtable = new SessionIdTable(256); _compidtable = new CompIdTable(1024); _sessionid = unique_sessionid(); #if 0 _sessionid = 0xfff00000; // for testing purposes #endif char hostbuf[HOST_NAME_MAX]; gethostname(hostbuf, HOST_NAME_MAX); char* username = getlogin(); int pid = getpid(); int hostid = gethostid(); SessionId* sid = new SessionId(_sessionid, _sessionid, pid, username, hostbuf, hostid); _sessionidtable->insert(_sessionid, sid); _comdraw_port = atoi(unidraw->GetCatalog()->GetAttribute("comdraw")); #endif /* HAVE_ACE */ } DrawServ::~DrawServ () { #ifdef HAVE_ACE Iterator it; _linklist->First(it); while(_linklist->GetDrawLink(it) && !_linklist->Done(it)) { DrawLink* link = _linklist->GetDrawLink(it); _linklist->Next(it); linkdown(link); } delete _linklist; delete _gridtable; delete _sessionidtable; delete _compidtable; #endif /* HAVE_ACE */ } #ifdef HAVE_ACE DrawLink* DrawServ::linkup(const char* hostname, int portnum, int state, int local_id, int remote_id, ComTerp* comterp) { if (state == DrawLink::new_link || state == DrawLink::one_way) { DrawLink* link = new DrawLink(hostname, portnum, state); link->remote_linkid(remote_id); if (state==DrawLink::one_way && comterp && comterp->handler()) { ((DrawServHandler*)comterp->handler())->drawlink(link); link->comhandler((DrawServHandler*)comterp->handler()); } if (link->open()==0 && link->ok()) { _linklist->add_drawlink(link); return link; } else { delete link; return nil; } } else { // search for existing link with matching local_id Iterator i; _linklist->First(i); while(!_linklist->Done(i) && _linklist->GetDrawLink(i)->local_linkid()!=local_id) _linklist->Next(i); /* if found, finalize linkup */ if (!_linklist->Done(i)) { DrawLink* curlink = _linklist->GetDrawLink(i); curlink->remote_linkid(remote_id); curlink->althostname(hostname); curlink->state(DrawLink::two_way); if (comterp && comterp->handler()) { ((DrawServHandler*)comterp->handler())->drawlink(curlink); curlink->comhandler((DrawServHandler*)comterp->handler()); } fprintf(stderr, "link up with %s(%s) via port %d\n", curlink->hostname(), curlink->althostname(), portnum); fprintf(stderr, "local id %d, remote id %d\n", curlink->local_linkid(), curlink->remote_linkid()); /* register all sessionid's with other DrawServ */ sessionid_register(curlink); SendCmdString(curlink, "sid(:all)"); SendCmdString(curlink, "drawlink(:state 2)"); return curlink; } else { fprintf(stderr, "unable to complete two-way link\n"); return nil; } } } int DrawServ::linkdown(DrawLink* link) { if (link && _linklist->Includes(link)) { _linklist->Remove(link); link->close(); remove_sids(link); delete link; return 0; } else return -1; } DrawLink* DrawServ::linkget(int local_id, int remote_id) { DrawLink* link = nil; if (_linklist) { Iterator(i); _linklist->First(i); while (!_linklist->Done(i) && !link) { DrawLink* l = _linklist->GetDrawLink(i); if (l->local_linkid()==local_id && remote_id==-1 || local_id==-1 && l->remote_linkid()==remote_id || l->local_linkid()==local_id && l->remote_linkid()==remote_id) link = l; _linklist->Next(i); } } return link; } DrawLink* DrawServ::linkget(const char* hostname, int portnum) { DrawLink* link = nil; if (_linklist) { Iterator(i); _linklist->First(i); while (!_linklist->Done(i) && !link) { DrawLink* l = _linklist->GetDrawLink(i); if (strcmp(l->hostname(),hostname)==0 && l->portnum()==portnum) link = l; _linklist->Next(i); } } return link; } DrawLink* DrawServ::linkget(unsigned int sessionid) { void* ptr = nil; if (sessionid>0) sessionidtable()->find(ptr, sessionid); return ptr ? ((SessionId*)ptr)->drawlink() : nil; } void DrawServ::linkdump(FILE* fptr) { fprintf(fptr, "Host Alt. Port LID RID State\n"); fprintf(fptr, "------------------------------ ------------------------------ ------ --- --- -----\n"); if (_linklist) { Iterator i; _linklist->First(i); while(!_linklist->Done(i)) { DrawLink* link = _linklist->GetDrawLink(i); fprintf(fptr, "%-30.30s %-30.30s %-6d %-3d %-3d %-3d\n", link->hostname(), link->althostname(), link->portnum(), link->local_linkid(), link->remote_linkid(), link->state()); _linklist->Next(i); } } } void DrawServ::ExecuteCmd(Command* cmd) { static int grid_sym = symbol_add("grid"); static int sid_sym = symbol_add("sid"); boolean original = false; unsigned int from_sid = 0; if(!_linklist || _linklist->Number()==0) /* normal Unidraw command execution */ Unidraw::ExecuteCmd(cmd); else { /* indirect command execution, all by script */ std::ostrstream sbuf; boolean oldflag = OverlayScript::ptlist_parens(); OverlayScript::ptlist_parens(false); switch (cmd->GetClassId()) { case PASTE_CMD: { boolean scripted = false; Clipboard* cb = cmd->GetClipboard(); if (cb) { Iterator it; for (cb->First(it); !cb->Done(it); cb->Next(it)) { OverlayComp* comp = (OverlayComp*)cb->GetComp(it); AttributeList* al = comp->GetAttributeList(); AttributeValue* idv = al->find(grid_sym); AttributeValue* sidv = al->find(sid_sym); from_sid = sidv ? sidv->uint_val() : 0; /* unique id already remotely assigned */ if (idv && idv->uint_val() !=0 && sidv && sidv->uint_val() !=0) { GraphicId* graphicid = new GraphicId(); graphicid->grcomp(comp); graphicid->id(idv->uint_val()); graphicid->selector(sidv->uint_val()); graphicid->selected(LinkSelection::RemotelySelected); } /* generate unique id and add as attribute */ /* also mark with selector id */ else { GraphicId* graphicid = new GraphicId(sessionid()); graphicid->grcomp(comp); graphicid->selector(((DrawServ*)unidraw)->sessionid()); AttributeValue* gridv = new AttributeValue(graphicid->id(), AttributeValue::UIntType); gridv->state(AttributeValue::HexState); al->add_attr(grid_sym, gridv); AttributeValue* sidv = new AttributeValue(graphicid->selector(), AttributeValue::UIntType); sidv->state(AttributeValue::HexState); al->add_attr(sid_sym, sidv); original = true; } if (comp && (original || linklist()->Number()>1)) { Creator* creator = unidraw->GetCatalog()->GetCreator(); OverlayScript* scripter = (OverlayScript*) creator->Create(Combine(comp->GetClassId(), SCRIPT_VIEW)); if (scripter) { scripter->SetSubject(comp); if (scripted) sbuf << ';'; else scripted = true; boolean status = scripter->Definition(sbuf); delete scripter; } } } } if (original || linklist()->Number()>1) { if (!scripted) sbuf << "print(\"Failed attempt to generate script for a PASTE_CMD\\n\" :err)"; sbuf.put('\0'); cout << sbuf.str() << "\n"; cout.flush(); } /* first execute here */ #if 0 ((ComEditor*)cmd->GetEditor())->GetComTerp()->run(sbuf.str()); ((PasteCmd*)cmd)->executed(true); #else cmd->Execute(); #endif /* then send everywhere else */ if (original || linklist()->Number()>1) DistributeCmdString(sbuf.str(), linkget(from_sid)); } break; default: sbuf << "print(\"Attempt to convert unknown command (id == %d) to interpretable script\\n\" " << cmd->GetClassId() << " :err)"; cmd->Execute(); break; } if (cmd->Reversible()) { cmd->Log(); } else { delete cmd; } OverlayScript::ptlist_parens(oldflag); } } void DrawServ::DistributeCmdString(const char* cmdstring, DrawLink* orglink) { Iterator i; _linklist->First(i); while (!_linklist->Done(i)) { DrawLink* link = _linklist->GetDrawLink(i); if (link && link != orglink && link->state()==DrawLink::two_way) { int fd = link->handle(); if (fd>=0) { #if __GNUC__<4 && !defined(__CYGWIN__) fileptr_filebuf fbuf(fd, ios_base::out, false, static_cast(BUFSIZ)); #else fileptr_filebuf fbuf(fd, ios_base::out, static_cast(BUFSIZ)); #endif ostream out(&fbuf); out << cmdstring; out << "\n"; out.flush(); link->ackhandler()->start_timer(); } } _linklist->Next(i); } } void DrawServ::SendCmdString(DrawLink* link, const char* cmdstring) { if (link) { int fd = link->handle(); if (fd>=0) { #if __GNUC__<4 && !defined(__CYGWIN__) fileptr_filebuf fbuf(fd, ios_base::out, false, static_cast(BUFSIZ)); #else fileptr_filebuf fbuf(fd, ios_base::out, static_cast(BUFSIZ)); #endif ostream out(&fbuf); out << cmdstring; out << "\n"; out.flush(); link->ackhandler()->start_timer(); } } } // generate request to register each locally unique session id void DrawServ::sessionid_register(DrawLink* link) { SessionIdTable* table = ((DrawServ*)unidraw)->sessionidtable(); SessionIdTable_Iterator it(*table); while(it.more()) { if(it.cur_value()) { SessionId* sessionid = (SessionId*)it.cur_value(); if (sessionid && sessionid->drawlink() != link) { char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "sid(0x%08x 0x%08x :pid %d :user \"%s\" :host \"%s\" :hostid 0x%08x)%c", sessionid->sid(), sessionid->osid(), sessionid->pid(), sessionid->username(), sessionid->hostname(), sessionid->hostid(), '\0'); SendCmdString(link, buf); } } it.next(); } } // handle request to register session id void DrawServ::sessionid_register_handle (DrawLink* link, unsigned int sid, unsigned osid, int pid, const char* username, const char* hostname, int hostid) { if (link) { SessionIdTable* sidtable = ((DrawServ*)unidraw)->sessionidtable(); unsigned int alt_id = sid; if (!DrawServ::test_sessionid(sid)) alt_id = DrawServ::unique_sessionid(); SessionId* session_id = new SessionId(alt_id, osid, pid, username, hostname, hostid, link); sidtable->insert(alt_id, session_id); link->sid_insert(sid, alt_id); if (sid != alt_id) { char buffer[BUFSIZ]; snprintf(buffer, BUFSIZ, "sid(0x%08x 0x%08x :remap)%c", sid, alt_id, '\0'); SendCmdString(link, buffer); } /* propagate */ sessionid_register_propagate(link, alt_id, osid, pid, username, hostname, hostid); } } // propagate request to register session id void DrawServ::sessionid_register_propagate (DrawLink* link, unsigned int sid, unsigned int osid, int pid, const char* username, const char* hostname, int hostid) { Iterator it; _linklist->First(it); while (!_linklist->Done(it)) { char buf[BUFSIZ]; DrawLink* otherlink = _linklist->GetDrawLink(it); if (otherlink != link) { snprintf(buf, BUFSIZ, "sid(0x%08x 0x%08x :pid %d :user \"%s\" :host \"%s\" :hostid 0x%08x)%c", sid, osid, pid, username, hostname, hostid, '\0'); SendCmdString(otherlink, buf); } _linklist->Next(it); } } unsigned int DrawServ::unique_grid() { if (!seed) { seed = time(nil) & (time(nil) << 16); srand(seed); } unsigned int retval; do { static int flip=0; while ((retval=rand()&GraphicIdMask)<=1); } while (!test_grid(retval)); return retval; } int DrawServ::test_grid(unsigned int id) { GraphicIdTable* table = ((DrawServ*)unidraw)->gridtable(); void* ptr = nil; table->find(ptr, id); if (ptr) return 0; else return 1; } unsigned int DrawServ::unique_sessionid() { if (!seed) { seed = time(nil) & (time(nil) << 16); srand(seed); } int retval; do { while ((retval=rand()&SessionIdMask)==0); } while (!test_sessionid(retval)); return retval; } int DrawServ::test_sessionid(unsigned int id) { SessionIdTable* table = ((DrawServ*)unidraw)->sessionidtable(); void* ptr = nil; table->find(ptr, id); if (ptr) return 0; else return 1; } void DrawServ::grid_message(GraphicId* grid) { char buf[BUFSIZ]; if (grid->selected()==LinkSelection::LocallySelected || (grid->selector()==sessionid() && grid->selected()==LinkSelection::NotSelected)) { snprintf(buf, BUFSIZ, "grid(chgid(0x%08x) chgid(0x%08x) :state %d )%c", grid->id(), grid->selector(), grid->selected()==LinkSelection::LocallySelected ? LinkSelection::RemotelySelected : LinkSelection::NotSelected, '\0'); DistributeCmdString(buf); } else { /* find link on which current selector lives */ DrawLink* link = _linklist->find_drawlink(grid); if (link) { snprintf(buf, BUFSIZ, "grid(chgid(0x%08x) chgid(0x%08x) :request chgid(0x%08x))%c", grid->id(), grid->selector(), sessionid(), '\0'); SendCmdString(link, buf); } } } // handle reserve request from remote DrawLink. void DrawServ::grid_message_handle(DrawLink* link, unsigned int id, unsigned int selector, int state, unsigned int newselector) { void* ptr = nil; gridtable()->find(ptr, id); if (ptr) { GraphicId* grid = (GraphicId*)ptr; /* if this request is aimed here */ if (selector==sessionid() && newselector!=0) { /* if graphic is still locally owned */ if (grid->selector()==sessionid()) { /* if graphic is not actually selected */ if ((grid->selected()==LinkSelection::NotSelected || grid->selected()==LinkSelection::WaitingToBeSelected)) { grid->selected(LinkSelection::NotSelected); grid->selector(newselector); char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "grid(chgid(0x%08x) chgid(0x%08x) :grant chgid(0x%08x))%c", grid->id(), newselector, sessionid(), '\0'); SendCmdString(link, buf); fprintf(stderr, "grid: request granted\n"); } /* else do nothing, because it is selected */ else { fprintf(stderr, "grid: request ignored, graphic locally selected\n"); } } /* else reformulate this request and pass it along */ else { fprintf(stderr, "grid: request passed along to current selector\n"); char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "grid(chgid(0x%08x) chgid(0x%08x) :request chgid(0x%08x))%c", grid->id(), grid->selector(), newselector, '\0'); SendCmdString(linkget(grid->selector()), buf); } } /* else this request and/or simple state update should be passed along */ else { /* if simple state, set the values here, and pass it on to everyone else */ if (newselector==0) { if (linklist()->Number()>1) fprintf(stderr, "grid: state change passed along to everyone else\n"); grid->selector(selector); grid->selected(state); char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "grid(chgid(0x%08x) chgid(0x%08x) :state %d)%c", grid->id(), grid->selector(), grid->selected(), '\0'); DistributeCmdString(buf, link); } /* else pass the request on to the target selector */ else { fprintf(stderr, "grid: request passed along to targeted selector"); char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "grid(chgid(0x%08x) chgid(0x%08x) :request chgid(0x%08x))%c", grid->id(), selector, newselector, '\0'); SendCmdString(linkget(grid->selector()), buf); } } } } // handle callback from remote DrawLink. void DrawServ::grid_message_callback(DrawLink* link, unsigned int id, unsigned int selector, int state, unsigned int oldselector) { void* ptr = nil; gridtable()->find(ptr, id); if (ptr) { GraphicId* grid = (GraphicId*)ptr; /* if request is granted, add to selection */ if (grid->selected()==LinkSelection::WaitingToBeSelected && selector==sessionid()) { grid->selector(selector); fprintf(stderr, "grid: request granted, add to selection now\n"); OverlayComp* comp = (OverlayComp*)grid->grcomp(); LinkSelection* sel = (LinkSelection*)DrawKit::Instance()->GetEditor()->GetSelection(); sel->AddComp(comp); } /* otherwise, pass the granting message along */ else { fprintf(stderr, "grid: pass grant request along\n"); char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "grid(chgid(0x%08x) chgid(0x%08x) :grant chgid(0x%08x))%c", grid->id(), selector, oldselector, '\0'); SendCmdString(linkget(selector), buf); } } } void DrawServ::print_gridtable() { GraphicIdTable* table = gridtable(); GraphicIdTable_Iterator it(*table); printf("id &grid &grcomp selector selected\n"); printf("---------- ---------- ---------- ---------- --------\n"); while(it.more()) { GraphicId* grid = (GraphicId*)it.cur_value(); printf("0x%08x 0x%08x 0x%08x 0x%08x %s\n", (unsigned int)it.cur_key(), grid, grid->grcomp(), grid->selector(), LinkSelection::selected_string(grid->selected())); it.next(); } } void DrawServ::print_sidtable() { SessionIdTable* table = sessionidtable(); SessionIdTable_Iterator it(*table); printf("sid osid &DrawLink lid rid pid hostid user host \n"); printf("---------- ---------- ---------- ---- ---- ------ ------ ---- ---- \n"); while(it.more()) { SessionId* sid = (SessionId*)it.cur_value(); DrawLink* link = sid->drawlink(); printf("0x%08x 0x%08x 0x%08x %4d %4d %6d %6d %16s %16s\n", sid->sid(), sid->osid(), link, link ? link->local_linkid() : 9999, link ? link->remote_linkid() : 9999, sid->pid(), sid->hostid(), sid->username(), sid->hostname()); it.next(); } } void DrawServ::remove_sids(DrawLink* link) { SessionIdTable* table = sessionidtable(); SessionIdTable_Iterator it(*table); while(it.more()) { SessionId* sid = (SessionId*)it.cur_value(); void* vsid = (void*)sid; DrawLink* testlink = sid->drawlink(); int altid = it.cur_key(); it.next(); if (testlink==link) if (!table->find_and_remove(vsid, altid)) fprintf(stderr, "unable to remove SessionId's associated with DrawLink\n"); } } boolean DrawServ::cycletest(unsigned int sid, const char* host, const char* user, int pid) { boolean found = false; SessionIdTable* table = sessionidtable(); SessionIdTable_Iterator it(*table); while(it.more() && !found) { SessionId* sessionid = (SessionId*)it.cur_value(); if (sessionid->osid()==sid) { if (strcmp(host, sessionid->hostname())==0 && strcmp(user, sessionid->username())==0 && pid==sessionid->pid()) found = true; } it.next(); } return found; } boolean DrawServ::selftest(const char* host, unsigned int portnum) { if (portnum==comdraw_port()) { if (strcmp(host, "localhost")==0 || strcmp(host, "127.0.0.1")==0) return 1; else { char hostbuf[HOST_NAME_MAX]; gethostname(hostbuf, HOST_NAME_MAX); if (strcmp(host, hostbuf)==0) return 1; } } return 0; } boolean DrawServ::PrintAttributeList(ostream& out, AttributeList* attrlist) { static int grid_sym = symbol_add("grid"); static int sid_sym = symbol_add("sid"); ALIterator i; for (attrlist->First(i); !attrlist->Done(i); attrlist->Next(i)) { Attribute* attr = attrlist->GetAttr(i); out << " :" << attr->Name() << " "; AttributeValue* attrval = attr->Value(); boolean special = attr->SymbolId()==grid_sym || attr->SymbolId()==sid_sym; if (special) out << "chgid("; out << *attrval; if (special) out << ")"; } return true; } #endif /* HAVE_ACE */ ivtools-1.2.11a1/src/DrawServ/drawserv.h000066400000000000000000000152701214471147700200640ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * DrawServ - Unidraw derived from OverlayUnidraw for DrawServ library */ #ifndef drawserv_h #define drawserv_h #include #include #include declareTable(GraphicIdTable,int,void*) declareTable(SessionIdTable,int,void*) declareTable(CompIdTable,void*,void*); //: Unidraw specialized for DrawServ // Unidraw (OverlayUnidraw) specialized for DrawServ application. // Networked application of the Unidraw framework. class AttributeValueList; class ComTerp; class DrawLink; class DrawLinkList; class GraphicId; class GraphicIdList; #if !defined (HOST_NAME_MAX) # define HOST_NAME_MAX 256 #endif /* !HOST_NAME_MAX */ class DrawServ : public OverlayUnidraw { public: DrawServ( Catalog*, int& argc, char** argv, OptionDesc* = nil, PropertyData* = nil ); DrawServ(Catalog*, World*); virtual ~DrawServ(); void Init(); #ifdef HAVE_ACE DrawLink* linkup(const char* hostname, int portnum, int state, int local_id=-1, int remote_id=-1, ComTerp* comterp=nil); // Create new link to remote drawserv, return -1 if error // state: 0==new_link, 1==one_way, 2==two_way. // Let DrawLink assign local_id by passing -1 for local_id. // The local_id argument is for verification purposes once // two-way link is established. int linkdown(DrawLink* link); // shut down existing link to remote drawserv DrawLink* linkget(int local_id, int remote_id=-1); // return pointer to existing DrawLink DrawLink* linkget(const char* hostname, int portnum); // return pointer to existing DrawLink DrawLink* linkget(unsigned int sessionid); // return pointer to existing DrawLink given a sessionid. void linkdump(FILE*); // dump text table of DrawLink's virtual void ExecuteCmd(Command*); // execute Command's locally, and on remote linked DrawServ's. virtual void DistributeCmdString(const char* cmdstring, DrawLink* orglink=nil); // send command string to every remote DrawServ (except where it came from). virtual void SendCmdString(DrawLink* link, const char* cmdstring); // execute command string on one remote DrawServ DrawLinkList* linklist() { return _linklist; } // return pointer to list of DrawLink's GraphicIdTable* gridtable() { return _gridtable; } // return pointer to table of GraphicId's. SessionIdTable* sessionidtable() { return _sessionidtable; } // return pointer to table of session id's that map to SessionId's CompIdTable* compidtable() { return _compidtable; } // return pointer to table that map from GraphicComp* to GraphicId* void sessionid_register(DrawLink* link); // register all sessionid's used by this DrawServ with remote DrawServ void sessionid_register_handle(DrawLink* link, unsigned int sid, unsigned int osid, int pid, const char* user, const char* host, int hostid); // handle request to register unique session id void sessionid_register_propagate(DrawLink* link, unsigned int sid, unsigned int osid, int pid, const char* user, const char *host, int hostid); // propagate a newly registered session id to all other DrawLink's unsigned int sessionid() { return _sessionid; } // current unique session id. void remove_sids(DrawLink*); // remove all SessionId's associated with this DrawLink void grid_message(GraphicId* grid); // generate graphic id selection message void grid_message_handle(DrawLink* link, unsigned int id, unsigned int selector, int state, unsigned int newselector=0); // handle graphic id selection message void grid_message_callback(DrawLink* link, unsigned int id, unsigned int selector, int state, unsigned int oldselector); // callback for graphic id selection message #if 0 void grid_message_propagate(DrawLink* link, unsigned int id, unsigned int selector, int state, unsigned int otherselector=0); // propagate graphic id selection message #endif static unsigned int unique_grid(); // generate unique graphic id. static int test_grid(unsigned int id); // test candidate graphic id for local uniqueness static unsigned int unique_sessionid(); // generate unique session id. static int test_sessionid(unsigned int id); // test candidate session id for local uniqueness static unsigned int GraphicIdMask; static unsigned int SessionIdMask; void print_gridtable(); // print contents of table of GraphicId's void print_sidtable(); // print contents of table of SessionId's int comdraw_port() { return _comdraw_port; } // return port used for comdraw command interpreter boolean cycletest(unsigned int sid, const char* host, const char* user, int pid); // test for new incoming link that would establish a cycle boolean selftest(const char* host, unsigned int portnum); // test if a new outgoing link is really to yourself virtual boolean PrintAttributeList(ostream& out, AttributeList* list); // alternate method for serializing an AttributeList // returns false if really not there. protected: DrawLinkList* _linklist; // DrawLink list GraphicIdTable* _gridtable; // table of all GraphicId's. // maps from id to GraphicId* SessionIdTable* _sessionidtable; // table of all session id's. // maps from session id to SessionId* CompIdTable* _compidtable; // table of all GraphicComp's associated with a GraphicId. // maps from GraphicComp* to GraphicId* int _sessionid; // unique session id. int _comdraw_port; // port used for comdraw command interpreter #endif /* HAVE_ACE */ }; #endif ivtools-1.2.11a1/src/DrawServ/drawviews.cc000066400000000000000000000032601214471147700203740ustar00rootroot00000000000000/* * Copyright (c) 1994-1996,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * DrawIdrawView */ #include #include #include /*****************************************************************************/ DrawIdrawView::DrawIdrawView (DrawIdrawComp* subj) : FrameIdrawView(subj) { } ClassId DrawIdrawView::GetClassId () { return DRAW_IDRAW_VIEW; } boolean DrawIdrawView::IsA (ClassId id) { return DRAW_IDRAW_VIEW == id || FrameIdrawView::IsA(id); } ivtools-1.2.11a1/src/DrawServ/drawviews.h000066400000000000000000000031011214471147700202300ustar00rootroot00000000000000/* * Copyright (c) 1994-1996,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * DrawIdrawView */ #ifndef draw_views_h #define draw_views_h #include class DrawIdrawComp; //: graphical view of DrawIdrawComp. class DrawIdrawView : public FrameIdrawView { public: DrawIdrawView(DrawIdrawComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/DrawServ/grid.cc000066400000000000000000000060471214471147700173140ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Implementation of GraphicId class. */ #include #include #include #include #include #include #include #include /*****************************************************************************/ GraphicId::GraphicId (unsigned int sessionid) { _comp = nil; if (sessionid != 0) { _id = DrawServ::unique_grid(); _sid = sessionid&DrawServ::SessionIdMask; GraphicIdTable* table = ((DrawServ*)unidraw)->gridtable(); table->insert(_id|_sid, this); } else { _id = _sid = 0; } } GraphicId::~GraphicId () { GraphicIdTable* table = ((DrawServ*)unidraw)->gridtable(); table->remove(_id&_sid); } void GraphicId::id(unsigned int id) { GraphicIdTable* table = ((DrawServ*)unidraw)->gridtable(); if (_id!=0 && _sid!=0) table->remove(_id&_sid); _id = id & DrawServ::GraphicIdMask; _sid = id & DrawServ::SessionIdMask; table->insert(id, this); } /*****************************************************************************/ GraphicIds::GraphicIds(unsigned int sessionid, GraphicId* subids, int nsubs) : GraphicId (sessionid) { if (nsubs>0) { _sublist = new GraphicIdList(); for(int i=0; iAppend(&subids[i]); } Resource::ref(_sublist); } GraphicIds::GraphicIds(unsigned int sessionid, GraphicIdList* sublist) : GraphicId (sessionid) { if (!sublist) sublist = new GraphicIdList; _sublist = sublist; _sublist->Reference(); } GraphicIds::~GraphicIds () { Unref(_sublist); _sublist = nil; } void GraphicId::grcomp(GraphicComp* comp) { if (comp==_comp) return; CompIdTable* table = ((DrawServ*)unidraw)->compidtable(); if (_comp) { void* ptr = nil; table->find_and_remove(ptr, comp); } _comp = comp; table->insert((void*)comp, (void*)this); } ivtools-1.2.11a1/src/DrawServ/grid.h000066400000000000000000000062131214471147700171510ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * GraphicId - object to encapsulate 2-way link with remote drawserv */ #ifndef grid_h #define grid_h #include class DrawLink; class GraphicComp; class GraphicIdList; //: object to encapsulate unique graphic id class GraphicId { public: GraphicId(unsigned int sessionid=0); virtual ~GraphicId(); unsigned int id() { return _id|_sid; } // get associated unique composite integer id void id(unsigned int id); // set associated unique composite integer id unsigned int grid() { return _id; } // return graphic id portion of composite id // unique only to this process unsigned int sessionid() { return _sid; } // return session id portion of composite id virtual int is_list() { return 0; } // return true if can be cast to GraphicIds virtual GraphicIdList* sublist() { return nil; } // returns pointer to sublist of GraphicId's, if any void grcomp(GraphicComp* comp); // set pointer to associated GraphicComp GraphicComp* grcomp() { return _comp; } // get pointer to associated GraphicComp void selector(unsigned int sid) { _selector = sid; } // set session id of current selector unsigned int selector() { return _selector; } // get session id of current selector void selected(int state) { _selected = state; } // set selected state int selected() { return _selected; } // get selected state protected: unsigned int _id; unsigned int _sid; unsigned int _selector; int _selected; GraphicComp* _comp; }; //: object to encapsulate a set of graphic ids class GraphicIds : public GraphicId { public: GraphicIds(unsigned int sessionid, GraphicId* subids, int nsubids); GraphicIds(unsigned int sessionid, GraphicIdList* sublist=nil); virtual ~GraphicIds(); virtual int is_list() { return 1; } // return true if can be cast to GraphicIds virtual GraphicIdList* sublist() { return _sublist; } // returns pointer to sublist of GraphicId's, if any protected: GraphicIdList* _sublist; }; #endif ivtools-1.2.11a1/src/DrawServ/gridlist.cc000066400000000000000000000065551214471147700202140ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Implementation of GraphicIdList class. */ #include #include #include #include /*****************************************************************************/ GraphicIdList::GraphicIdList() { _ulist = new UList; _count = 0; } GraphicIdList::~GraphicIdList () { if (_ulist) { Iterator i; for (First(i); !Done(i); Next(i)) { delete GetGraphicId(i); } delete _ulist; } } void GraphicIdList::add_grid(GraphicId* new_id) { Iterator i; First(i); InsertBefore(i, new_id); } GraphicId* GraphicIdList::Id (UList* r) { return (GraphicId*) (*r)(); } UList* GraphicIdList::Elem (Iterator i) { return (UList*) i.GetValue(); } void GraphicIdList::Append (GraphicId* v) { _ulist->Append(new UList(v)); ++_count; } void GraphicIdList::Prepend (GraphicId* v) { _ulist->Prepend(new UList(v)); ++_count; } void GraphicIdList::InsertAfter (Iterator i, GraphicId* v) { Elem(i)->Prepend(new UList(v)); ++_count; } void GraphicIdList::InsertBefore (Iterator i, GraphicId* v) { Elem(i)->Append(new UList(v)); ++_count; } void GraphicIdList::Remove (Iterator& i) { UList* doomed = Elem(i); Next(i); _ulist->Remove(doomed); delete doomed; --_count; } void GraphicIdList::Remove (GraphicId* p) { UList* temp; if ((temp = _ulist->Find(p)) != nil) { _ulist->Remove(temp); delete temp; --_count; } } GraphicId* GraphicIdList::GetGraphicId (Iterator i) { return Id(Elem(i)); } void GraphicIdList::SetGraphicId (GraphicId* gv, Iterator& i) { i.SetValue(_ulist->Find(gv)); } void GraphicIdList::First (Iterator& i) { i.SetValue(_ulist->First()); } void GraphicIdList::Last (Iterator& i) { i.SetValue(_ulist->Last()); } void GraphicIdList::Next (Iterator& i) { i.SetValue(Elem(i)->Next()); } void GraphicIdList::Prev (Iterator& i) { i.SetValue(Elem(i)->Prev()); } boolean GraphicIdList::Done (Iterator i) { return Elem(i) == _ulist->End(); } int GraphicIdList::Number () { return _count; } boolean GraphicIdList::Includes (GraphicId* e) { return _ulist->Find(e) != nil; } boolean GraphicIdList::IsEmpty () { return _ulist->IsEmpty(); } ivtools-1.2.11a1/src/DrawServ/gridlist.h000066400000000000000000000066711214471147700200550ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * GraphicIdList - a UList based list of GraphicId's */ #ifndef gridlist_h #define gridlist_h //: UList based list of GraphicId's #include #include class GraphicId; class Iterator; class UList; class GraphicIdList : public Resource { public: GraphicIdList(); virtual ~GraphicIdList(); void add_grid(GraphicId*); // add GraphicId to list void First(Iterator&); // set iterator to point to first GraphicId in list. void Last(Iterator&); // set iterator to point to last GraphicId in list. void Next(Iterator&); // set iterator to point to next GraphicId in list. void Prev(Iterator&); // set iterator to point to previous GraphicId in list. boolean Done(Iterator); // return true if iterator is pointing off the end of the list. // works for forward and backward traversals. boolean IsEmpty(); // true if no GraphicId objects in list. int Number(); // number of GraphicId objects in list. void Append(GraphicId*); // append GraphicId to end of list. void Prepend(GraphicId*); // append GraphicId to front of list. void InsertAfter(Iterator, GraphicId*); // insert GraphicId after position pointed to by iterator. void InsertBefore(Iterator, GraphicId*); // insert GraphicId before position pointed to by iterator. void Remove(GraphicId*); // remove GraphicId from list, returning responsibility for freeing the // associated memory. GraphicId* GetGraphicId(Iterator); // get GraphicId pointed to by iterator. void SetGraphicId(GraphicId*, Iterator&); // set GraphicId pointed to by iterator. boolean Includes(GraphicId*); // check if list includes GraphicId by pointer-comparison. UList* Elem(Iterator); // return UList (UList) pointed to by Iterator (Iterator). GraphicId* Id(UList*); // return GraphicId pointed to by UList (UList). protected: void Remove(Iterator&); // remove GraphicId pointed to by iterator from the list, // returning responsibility for freeing the associated memory. // This requires saving a pointer to the GraphicId before calling this method. UList* _ulist; unsigned int _count; friend class DrawServ; friend class LinkSelection; }; #endif ivtools-1.2.11a1/src/DrawServ/linkselection.cc000066400000000000000000000124761214471147700212350ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Implementation of LinkSelection class. */ #include #include #include #include #include #include #include #include #include #include #include #include GraphicIdList* LinkSelection::_locally_selected = nil; GraphicIdList* LinkSelection::_waiting_to_be_selected = nil; const char* LinkSelection::_selected_strings[] = { "NotSelected", "LocallySelected", "RemotelySelected", "WaitingToBeSelected"}; /*****************************************************************************/ LinkSelection::LinkSelection (DrawEditor* editor, LinkSelection* s) : OverlaySelection(s) { _editor = editor; if (!_locally_selected) { _locally_selected = new GraphicIdList; _waiting_to_be_selected = new GraphicIdList; } } LinkSelection::LinkSelection (DrawEditor* editor, Selection* s) : OverlaySelection(s) { _editor = editor; if (!_locally_selected) { _locally_selected = new GraphicIdList; _waiting_to_be_selected = new GraphicIdList; } } void LinkSelection::Update(Viewer* viewer) { #if 0 fprintf(stderr, "LinkSelection::Update\n"); #endif Reserve(); OverlaySelection::Update(viewer); } void LinkSelection::Clear(Viewer* viewer) { #if 0 fprintf(stderr, "LinkSelection::Clear\n"); #endif #if 0 CompIdTable* table = ((DrawServ*)unidraw)->compidtable(); Iterator it; First(it); while(!Done(it)) { OverlayView* view = GetView(it); OverlayComp* comp = view ? view->GetOverlayComp() : nil; void* ptr = nil; table->find(ptr, (void*)comp); if (ptr) { GraphicId* grid = (GraphicId*)ptr; if (grid->selected()==LocallySelected || grid->selected()==WaitingToBeSelected) grid->selected(NotSelected); char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "grid(chgid(0x%08x) chgid(0x%08x) :state %d)%c", grid->id(), grid->selector(), grid->selected(), '\0'); ((DrawServ*)unidraw)->DistributeCmdString(buf); } Next(it); } #endif OverlaySelection::Clear(viewer); Reserve(); } void LinkSelection::Reserve() { #if 0 fprintf(stderr, "LinkSelection::Reserve\n"); #endif CompIdTable* table = ((DrawServ*)unidraw)->compidtable(); /* clear anything that was in the previous selection, but not in this one */ Selection* lastsel = _editor->last_selection(); if (!lastsel) return; Iterator lt; lastsel->First(lt); Iterator it; while (!lastsel->Done(lt)) { First(it); boolean match = false; while (!Done(it) && !match) { if(GetView(it)==lastsel->GetView(lt)) match = true; else Next(it); } if (!match) { OverlayComp* comp = ((OverlayView*)lastsel->GetView(lt))->GetOverlayComp(); void* ptr = nil; table->find(ptr, (void*)comp); if (ptr) { GraphicId* grid = (GraphicId*)ptr; grid->selected(NotSelected); ((DrawServ*)unidraw)->grid_message(grid); } } lastsel->Remove(lt); } /* remove anything from selection that has a remote selector */ First(it); while (!Done(it)) { int removed = false; OverlayView* view = GetView(it); OverlayComp* comp = view ? view->GetOverlayComp() : nil; void* ptr = nil; table->find(ptr, (void*)comp); if (ptr) { GraphicId* grid = (GraphicId*)ptr; if (grid->selector() && ((DrawServ*)unidraw)->sessionid()!=grid->selector()) { Remove(it); removed = true; if (grid->selected()==NotSelected) { /* make a request to select this in the future */ grid->selected(WaitingToBeSelected); ((DrawServ*)unidraw)->grid_message(grid); } } else { if (grid->selected()!=LocallySelected) { grid->selected(LocallySelected); ((DrawServ*)unidraw)->grid_message(grid); } } } if (!removed) Next(it); } /* store copy of selection */ First(it); while (!Done(it)) { lastsel->Append(GetView(it)); Next(it); } } void LinkSelection::AddComp(OverlayComp* comp) { OverlayView* ov = comp->FindView(_editor->GetViewer()); Append(ov); Update(_editor->GetViewer()); } ivtools-1.2.11a1/src/DrawServ/linkselection.h000066400000000000000000000046231214471147700210720ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * LinkSelection - manages the selection of graphics between remotely linked drawing editors. */ #ifndef link_selection_h #define link_selection_h #ifdef HAVE_ACE #include class DrawLinkList; //: distributed Selection class // specialized Selection class with support for coordinating the selection of graphics // between two remote drawing editors that are linked together. class LinkSelection: public OverlaySelection { public: LinkSelection(DrawEditor* ed, LinkSelection* = nil); LinkSelection(DrawEditor* ed, Selection*); virtual void Update(Viewer* = nil); virtual void Clear(Viewer* = nil); virtual void Reserve(); // reserve newly created graphics in selection across the network void AddComp(OverlayComp*); // add this graphic to the Selection. enum { NotSelected, LocallySelected, RemotelySelected, WaitingToBeSelected }; static const char* selected_string(int state) { return state>=0 && state<=WaitingToBeSelected ? _selected_strings[state] : nil; } protected: DrawEditor* _editor; static GraphicIdList* _locally_selected; static GraphicIdList* _waiting_to_be_selected; static const char* _selected_strings[]; }; #endif /* HAVE_ACE */ #endif ivtools-1.2.11a1/src/DrawServ/rcdialog.cc000066400000000000000000000265601214471147700201550ustar00rootroot00000000000000/* * Copyright (c) 1997,1999 Vectaport Inc. * Copyright (c) 1994-1996 Vectaport Inc., Cartoactive Systems * Copyright (c) 1993 David B. Hollenbeck * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * RemoteConnectDialog related classes */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #include /*****************************************************************************/ RemoteConnectPopupAction::RemoteConnectPopupAction(Editor* editor) : Action() { _editor = editor; } void RemoteConnectPopupAction::execute() { #if 0 StrEditDialog::accept_custom("Connect"); StrEditDialog::cancel_custom("Close"); StrEditDialog* dialog = StrEditDialog::map (_editor->GetWindow(), "Enter host name to connect: ", "localhost", nil, nil, true); StrEditDialog::action_custom(new RemoteConnectAction(dialog), nil); #else WidgetKit& kit = *WidgetKit::instance(); ConnectionsDialog* dlog = new ConnectionsDialog(_editor, ((DrawServ*)unidraw)->linklist(), &kit, kit.style()); dlog->ref(); dlog->map_for(_editor->GetWindow()); #endif } /*****************************************************************************/ RemoteConnectAction::RemoteConnectAction(StrEditDialog* dialog) : Action() { _dialog = dialog; } void RemoteConnectAction::execute() { if (_dialog && _dialog->text()) ((DrawServ*)unidraw)->linkup(_dialog->text(), 20002, 0); } /*****************************************************************************/ declareActionCallback(ConnectionsDialogImpl) implementActionCallback(ConnectionsDialogImpl) declareFieldEditorCallback(ConnectionsDialogImpl) implementFieldEditorCallback(ConnectionsDialogImpl) class ConnectionsDialogImpl : public Observer { public: virtual void update(Observable* obs); private: friend class ConnectionsDialog; WidgetKit* kit_; Style* style_; ConnectionsDialog* dialog_; DrawLinkList* list_; Patch* patch_; EivTextEditor* ete_; FieldEditor* hostfe_; FieldEditor* portfe_; void init(DrawLinkList*, ConnectionsDialog*, Style*); void free(); void build(DrawLinkList*); void connect(); void disconnect(); void close(); const char* value(); void value(const char*, boolean update); void clear(); Patch* table_patch(DrawLinkList*); void fe_add(FieldEditor*); void fe_clr(FieldEditor*); void update_text(boolean); }; ConnectionsDialog::ConnectionsDialog(Editor* ed, DrawLinkList* list, WidgetKit* kit, Style* s) : Dialog(nil, s) { impl_ = new ConnectionsDialogImpl; ConnectionsDialogImpl& adi = *impl_; adi.kit_ = kit; adi.init(list, this, s); _ed = ed; } ConnectionsDialog::~ConnectionsDialog() { impl_->free(); delete impl_; } /** class ConnectionsDialogImpl **/ void ConnectionsDialogImpl::init(DrawLinkList* list, ConnectionsDialog* p, Style* s) { list->attach(this); dialog_ = p; style_ = s; list_ = list; DialogKit& dk = *DialogKit::instance(); WidgetKit& wk = *WidgetKit::instance(); hostfe_ = dk.field_editor("", wk.style(), new FieldEditorCallback(ConnectionsDialogImpl) (this, &ConnectionsDialogImpl::fe_add, &ConnectionsDialogImpl::fe_clr)); portfe_ = dk.field_editor("", wk.style(), new FieldEditorCallback(ConnectionsDialogImpl) (this, &ConnectionsDialogImpl::fe_add, &ConnectionsDialogImpl::fe_clr)); s->attribute("rows", "10"); s->attribute("columns", "30"); ete_ = new EivTextEditor(s, false); ete_->ref(); ete_->textview()->disable_caret(); build(list_); } void ConnectionsDialogImpl::free() { ete_->unref(); } void ConnectionsDialogImpl::build(DrawLinkList* list) { WidgetKit& kit = *kit_; const LayoutKit& layout = *LayoutKit::instance(); const DialogKit& dialog = *DialogKit::instance(); Style* s = style_; String caption("DrawLink Connections"); #if 0 String connect_str("Connect"); #endif String close_str("Close"); #if 0 Action* connect = new ActionCallback(ConnectionsDialogImpl)( this, &ConnectionsDialogImpl::connect ); #endif Action* close = new ActionCallback(ConnectionsDialogImpl)( this, &ConnectionsDialogImpl::close ); Glyph* g = layout.vbox( layout.hcenter(kit.fancy_label(caption)), layout.vspace(15.0), layout.hcenter(layout.hbox( layout.hglue(10.0), layout.vcenter(kit.push_button(close_str, close)), #if 0 layout.hglue(10.0, 0.0, 5.0), layout.vcenter(kit.push_button(connect_str, connect)), #endif layout.hglue(10.0) )), layout.vspace(15.0), layout.hcenter(table_patch(list)), layout.vglue(1) ); dialog_->body( kit.outset_frame(layout.margin(g, 5.0)) ); dialog_->append_input_handler(hostfe_); dialog_->append_input_handler(portfe_); dialog_->focus(hostfe_); } void ConnectionsDialogImpl::connect() { const String* hoststr = hostfe_->text(); const String* portstr = portfe_->text(); /* remove terminating spaces */ int hostlen = strlen(hoststr->string())+1; int portlen = strlen(portstr->string())+1; char hostbuf[hostlen]; char portbuf[portlen]; strcpy(hostbuf, hoststr->string()); strcpy(portbuf, portstr->string()); char *ptr; ptr = hostbuf + hostlen - 2; while (*ptr == ' ' && ptr >= (char*)hostbuf) *ptr-- = '\0'; ptr = portbuf + portlen - 2; while (*ptr == ' ' && ptr >= (char*)portbuf) *ptr-- = '\0'; if (strlen(hostbuf) > 0) { int portnum=20002; if (strlen(portbuf) > 0) portnum = atoi(portbuf); if(((DrawServ*)unidraw)->selftest(hostbuf, portnum)) { char buffer[BUFSIZ]; snprintf(buffer, BUFSIZ, "%s:%d", hostbuf, portnum); GAcknowledgeDialog::map(dialog_->GetEditor()->GetWindow(), "Can't connect to self", buffer, "Can't connect to self"); return; } if(((DrawServ*)unidraw)->linkup(hostbuf, portnum, 0)==nil) { char buffer[BUFSIZ]; snprintf(buffer, BUFSIZ, "%s:%d", hostbuf, portnum); GAcknowledgeDialog::map(dialog_->GetEditor()->GetWindow(), "Connection refused", buffer, "Connection refused"); } } } void ConnectionsDialogImpl::disconnect() { const String* hoststr = hostfe_->text(); const String* portstr = portfe_->text(); /* remove terminating spaces */ int hostlen = strlen(hoststr->string())+1; int portlen = strlen(portstr->string())+1; char hostbuf[hostlen]; char portbuf[portlen]; strcpy(hostbuf, hoststr->string()); strcpy(portbuf, portstr->string()); char *ptr; ptr = hostbuf + hostlen - 2; while (*ptr == ' ' && ptr >= (char*)hostbuf) *ptr-- = '\0'; ptr = portbuf + portlen - 2; while (*ptr == ' ' && ptr >= (char*)portbuf) *ptr-- = '\0'; if (strlen(hostbuf) > 0) { int portnum=20002; if (strlen(portbuf) > 0) portnum = atoi(portbuf); DrawLink* link = ((DrawServ*)unidraw)->linkget(hostbuf, portnum); if (link) ((DrawServ*)unidraw)->linkdown(link); } } void ConnectionsDialogImpl::close() { dialog_->dismiss(false); } Patch* ConnectionsDialogImpl::table_patch(DrawLinkList* list) { DialogKit& dk = *DialogKit::instance(); WidgetKit& wk = *WidgetKit::instance(); const LayoutKit& lk = *LayoutKit::instance(); PolyGlyph* mainglyph = lk.vbox(); Glyph* glu = lk.vspace(5); PolyGlyph* _namebox = lk.vbox(); PolyGlyph* _valbox = lk.vbox(); InputHandler* ih = new InputHandler(nil, wk.style()); Coord wid = wk.font()->width("MMMMMMMMMMMMMMM", 15); Action* conaction = new ActionCallback(ConnectionsDialogImpl) (this, &ConnectionsDialogImpl::connect); Button* conbutton = wk.push_button("Connect", conaction); Action* disaction = new ActionCallback(ConnectionsDialogImpl) (this, &ConnectionsDialogImpl::disconnect); Button* disbutton = wk.push_button("Disconnect", disaction); mainglyph->append (lk.hcenter (lk.hbox (lk.vcenter(conbutton), lk.hspace(10), lk.vcenter(disbutton) ) ) ); mainglyph->append(lk.vspace(10)); mainglyph->append (lk.hcenter (lk.hbox (lk.vcenter(lk.hfixed(wk.label("Host"), wid)), lk.hspace(10), lk.vcenter(lk.hfixed(wk.label("Port"), wid)) ) ) ); mainglyph->append(lk.vspace(2)); mainglyph->append (lk.hcenter (lk.hbox (lk.vcenter(lk.hfixed(hostfe_, wid)), lk.hspace(10), lk.vcenter(lk.hfixed(portfe_, wid)) ) ) ); mainglyph->append(lk.vspace(15)); update_text(false); mainglyph->append(lk.hcenter(lk.hspace(300))); mainglyph->append(lk.hcenter(ete_)); ih->body(wk.outset_frame(lk.margin(mainglyph, 10))); patch_ = new Patch(nil); patch_->body(ih); return patch_; } void ConnectionsDialogImpl::fe_add(FieldEditor* fe) { #if 0 const String* txt = _namefe->text(); if (txt->length() > 0) { char* buf = new char[strlen(_valfe->text()->string())+2]; sprintf(buf, "%s\n", _valfe->text()->string()); _list->add_attr(txt->string(), ParamList::lexscan()->get_attr(buf, strlen(buf))); update_text(true); } #endif } void ConnectionsDialogImpl::fe_clr(FieldEditor* fe) { fe->field(""); } void ConnectionsDialogImpl::update(Observable* obs) { fprintf(stderr, "DrawLinkList has been modified\n"); update_text(true); } void ConnectionsDialogImpl::update_text(boolean update) { if (!dialog_->mapped() && update) return; Iterator i; vector vbuf; char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "Host Port State\n"); for(int i=0; iFirst(i); !list_->Done(i); list_->Next(i)) { DrawLink* link = list_->GetDrawLink(i); snprintf(buf, BUFSIZ, "%-30.30s %-6d %s\n", link->hostname(), link->portnum(), DrawLink::state_string(link->state())); for(int i=0; itext(&vbuf[0] ? &vbuf[0] : "", update); } ivtools-1.2.11a1/src/DrawServ/rcdialog.h000066400000000000000000000045501214471147700200120ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * Copyright (c) 1994-1997,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * RemoteConnectDialog - classes related to the remote connect dialog box */ #ifndef rcdialog_h #define rcdialog_h #include #include class Editor; class RemoteConnectDialog; //: action to establish a dialog box for connecting with a remote DrawServ class RemoteConnectPopupAction : public Action { public: RemoteConnectPopupAction(Editor*); virtual void execute(); protected: Editor* _editor; }; class StrEditDialog; //: action for connecting with a remote DrawServ class RemoteConnectAction : public Action { public: RemoteConnectAction(StrEditDialog*); virtual void execute(); protected: StrEditDialog* _dialog; }; #include class ConnectionsDialogImpl; class DrawLinkList; class Editor; class Style; class WidgetKit; //: dialog for editing list of current connections class ConnectionsDialog : public Dialog { public: ConnectionsDialog(Editor*, DrawLinkList*, WidgetKit*, Style*); virtual ~ConnectionsDialog(); Editor* GetEditor() { return _ed; } protected: ConnectionsDialogImpl* impl_; Editor* _ed; }; #include #endif ivtools-1.2.11a1/src/DrawServ/sid.cc000066400000000000000000000033471214471147700171460ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Implementation of SessionId class. */ #include #include /*****************************************************************************/ SessionId::SessionId (unsigned int sid, unsigned int osid, int pid, const char* username, const char* hostname, int hostid, DrawLink* link) { _sid = sid; _osid = osid; _pid = pid; _username = strnew(username); _hostname = strnew(hostname); _hostid = hostid; _drawlink = link; } SessionId::~SessionId () { delete _username; delete _hostname; } ivtools-1.2.11a1/src/DrawServ/sid.h000066400000000000000000000044141214471147700170040ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * SessionId - object to encapsulate session member info */ #ifndef sid_h #define sid_h #include //: object to encapsulate session member info class SessionId { public: SessionId(unsigned int sid, unsigned int osid, int pid, const char* username, const char* hostname, int hostid, DrawLink* link = nil); virtual ~SessionId(); unsigned int sid() { return _sid; } // return session id unsigned int osid() { return _osid; } // return original session id unsigned int pid() { return _pid; } // return associated process id const char* username() { return _username; } // return associated user name const char* hostname() { return _hostname; } // return associated host name int hostid() { return _hostid; } // return associated host id. DrawLink* drawlink() { return _drawlink; } // return associated DrawLink void drawlink(DrawLink* link) {_drawlink = link; } // set associated DrawLink protected: unsigned int _sid; unsigned int _osid; int _pid; char* _username; char* _hostname; int _hostid; DrawLink* _drawlink; }; #endif ivtools-1.2.11a1/src/FrameUnidraw/000077500000000000000000000000001214471147700167005ustar00rootroot00000000000000ivtools-1.2.11a1/src/FrameUnidraw/framecatalog.cc000066400000000000000000000077361214471147700216510ustar00rootroot00000000000000/* * Copyright (c) 1994-1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * FrameCatalog implementation. */ #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ FrameCatalog::FrameCatalog ( const char* name, Creator* creator ) : OverlayCatalog(name, creator) { _import = false; } boolean FrameCatalog::Retrieve (const char* pathname, Component*& comp) { FILE* fptr = nil; boolean compressed = false; char* name = strdup(pathname); if (Valid(name, comp)) { _valid = true; } else { #if __GNUC__<3 filebuf fbuf; #else filebuf* pfbuf = nil; #endif if (strcmp(name, "-") == 0) { #if __GNUC__<3 _valid = fbuf.attach(fileno(stdin)) != 0; #else pfbuf = new fileptr_filebuf(stdin, input); _valid = 1; #endif name = nil; } else { fptr = fopen(name, "r"); fptr = OvImportCmd::CheckCompression(fptr, name, compressed); #if __GNUC__<3 _valid = fptr ? fbuf.attach(fileno(fptr)) != 0 : false; #else pfbuf = fptr ? new fileptr_filebuf(fptr, input) : nil; _valid = fptr ? 1 : 0; #endif if (compressed) { int namelen = strlen(name); if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0'; else if (strcmp(name+namelen-2,".Z")==0) name[namelen-2] = '\0'; } } if (_valid) { #if __GNUC__<3 istream in(&fbuf); #else istream in(pfbuf); #endif char ch; while (isspace(ch = in.get())); in.putback(ch); ParamList::parse_token(in, sbuf, SBUFSIZE); if (strcmp(sbuf, "flipbook") == 0 || strcmp(sbuf, "frame-idraw") == 0) { comp = new FrameIdrawComp(in, name, _parent); _valid = in.good() && ((OverlayComp*)comp)->valid(); } else if (strcmp(sbuf, "drawtool") == 0 || strcmp(sbuf, "ov-idraw") == 0) { comp = new OverlayIdrawComp(in, name, _parent); _valid = in.good() && ((OverlayComp*)comp)->valid(); } else _valid = false; if (_valid && name) { Forget(comp, name); Register(comp, name); } else if (!_valid) { delete comp; comp = nil; } } #if __GNUC__>=3 delete pfbuf; #endif } if (fptr) { if (compressed) fclose(fptr); else pclose(fptr); } delete name; return _valid; } OverlayComp* FrameCatalog::ReadComp(const char* name, istream& in, OverlayComp* parent) { OverlayComp* child = nil; if (strcmp(name, "picture") == 0 || strcmp(name, "grp") == 0) child = new FrameOverlaysComp(in, parent); else child = OverlayCatalog::ReadComp(name, in, parent); return child; } ivtools-1.2.11a1/src/FrameUnidraw/framecatalog.h000066400000000000000000000040341214471147700214770ustar00rootroot00000000000000/* * Copyright (c) 1994-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * FrameCatalog - can read and write components in script and postscript */ #ifndef frame_catalog_h #define frame_catalog_h #include //: catalog for retrieving flipbook documents class FrameCatalog : public OverlayCatalog{ public: FrameCatalog(const char*, Creator*); boolean Retrieve (const char* path, Component*&); // construct a FrameIdrawComp from 'path'. virtual OverlayComp* ReadComp(const char*, istream&, OverlayComp* =nil); // specialized method to ensure a FrameOverlaysComp gets constructed // whenever a composite-graphic is de-serialized (as opposed to // just a plain OverlaysComp). void SetImport(boolean); // set flag that indicates read is for import instead of an open. protected: boolean _import; }; inline void FrameCatalog::SetImport(boolean v) { _import = v; } #endif ivtools-1.2.11a1/src/FrameUnidraw/frameclasses.h000066400000000000000000000061031214471147700215210ustar00rootroot00000000000000/* * Copyright (c) 1994-1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef frameclasses_h #define frameclasses_h #include #define FRAME_OVERLAYS_COMP 8001 #define FRAME_COMP 8002 #define FRAMES_COMP 8003 #define FRAME_IDRAW_COMP 8004 #define FRAME_FILE_COMP 8005 #define CREATEFRAME_CMD 8055 #define DELETEFRAME_CMD 8056 #define MOVEFRAME_CMD 8057 #define FRAME_GROUP_CMD 8058 #define FRAME_UNGROUP_CMD 8059 #define FRAME_FRONT_CMD 8060 #define FRAME_BACK_CMD 8061 #define FRAME_COPY_CMD 8062 #define CREATEMOVEFRAME_CMD 8063 #define FRGRIDSPACING_CMD 8064 #define FRAMEBEGIN_CMD 8065 #define FRAMEEND_CMD 8066 #define FRAMEOPEN_CMD 8067 #define FRAMENEWVIEW_CMD 8068 #define COPYMOVEFRAME_CMD 8069 #define SHOWOTHERFRAME_CMD 8070 #define AUTONEWFRAME_CMD 8071 #define FRAMEIMPORT_CMD 8072 #define FRAMEIMPORTPASTE_CMD 8073 #define FRAME_OVERLAYS_VIEW Combine(FRAME_OVERLAYS_COMP, COMPONENT_VIEW) #define FRAME_VIEW Combine(FRAME_COMP, COMPONENT_VIEW) #define FRAMES_VIEW Combine(FRAMES_COMP, COMPONENT_VIEW) #define FRAME_IDRAW_VIEW Combine(FRAME_IDRAW_COMP, COMPONENT_VIEW) #define FRAME_FILE_VIEW Combine(FRAME_FILE_COMP, COMPONENT_VIEW) #define FRAME_OVERLAYS_PS Combine(FRAME_OVERLAYS_COMP, POSTSCRIPT_VIEW) #define FRAME_PS Combine(FRAME_COMP, POSTSCRIPT_VIEW) #define FRAMES_PS Combine(FRAMES_COMP, POSTSCRIPT_VIEW) #define FRAME_IDRAW_PS Combine(FRAME_IDRAW_COMP, POSTSCRIPT_VIEW) #define FRAME_FILE_PS Combine(FRAME_FILE_COMP, POSTSCRIPT_VIEW) #define FRAME_OVERLAYS_SCRIPT Combine(FRAME_OVERLAYS_COMP, SCRIPT_VIEW) #define FRAME_SCRIPT Combine(FRAME_COMP, SCRIPT_VIEW) #define FRAMES_SCRIPT Combine(FRAMES_COMP, SCRIPT_VIEW) #define FRAME_IDRAW_SCRIPT Combine(FRAME_IDRAW_COMP, SCRIPT_VIEW) #define FRAME_FILE_SCRIPT Combine(FRAME_FILE_COMP, SCRIPT_VIEW) #endif ivtools-1.2.11a1/src/FrameUnidraw/framecmds.cc000066400000000000000000000560101214471147700211520ustar00rootroot00000000000000/* * Copyright (c) 2009 Scott E. Johnston * Copyright (c) 1997-2000 Vectaport Inc. * Copyright (c) 1994, 1995 Vectaport Inc., Cider Press * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ CreateFrameCmd::CreateFrameCmd(ControlInfo* i, boolean after) : Command(i) { _after = after; } CreateFrameCmd::CreateFrameCmd(Editor* e, boolean after) : Command(e) { _after = after; } ClassId CreateFrameCmd::GetClassId() { return CREATEFRAME_CMD; } boolean CreateFrameCmd::IsA(ClassId id) { return id == CREATEFRAME_CMD || Command::IsA(id); } Command* CreateFrameCmd::Copy() { Command* copy = new CreateFrameCmd(CopyControlInfo(), _after); InitCopy(copy); return copy; } boolean CreateFrameCmd::Reversible() { return true; } void CreateFrameCmd::Execute() { GetEditor()->GetComponent()->Interpret(this); } void CreateFrameCmd::Unexecute() { GetEditor()->GetComponent()->Uninterpret(this); } /*****************************************************************************/ DeleteFrameData::DeleteFrameData (void* v, boolean restore_after) : VoidData(v) { _after = restore_after; } /*****************************************************************************/ DeleteFrameCmd::DeleteFrameCmd(ControlInfo* i) : Command(i) { } DeleteFrameCmd::DeleteFrameCmd(Editor* e) : Command(e) { } ClassId DeleteFrameCmd::GetClassId() { return DELETEFRAME_CMD; } boolean DeleteFrameCmd::IsA(ClassId id) { return id == DELETEFRAME_CMD || Command::IsA(id); } Command* DeleteFrameCmd::Copy() { Command* copy = new DeleteFrameCmd(CopyControlInfo()); InitCopy(copy); return copy; } boolean DeleteFrameCmd::Reversible() { return true; } void DeleteFrameCmd::Execute() { GetEditor()->GetComponent()->Interpret(this); } void DeleteFrameCmd::Unexecute() { GetEditor()->GetComponent()->Uninterpret(this); } /*****************************************************************************/ boolean MoveFrameCmd::_func_on= false; char* MoveFrameCmd::_move_func = nil; char* MoveFrameCmd::_absmove_func = nil; MoveFrameCmd* MoveFrameCmd::_default = nil; MoveFrameCmd::MoveFrameCmd(ControlInfo* i, int motion, boolean allowbg) : Command(i) { init(motion, allowbg); } MoveFrameCmd::MoveFrameCmd(Editor* e, int motion, boolean allowbg) : Command(e) { init(motion, allowbg); } void MoveFrameCmd::init(int motion, boolean allowbg) { _requestmotion = motion; _plannedmotion = _actualmotion = 0; _allowbg = allowbg; _wraparound = false; } ClassId MoveFrameCmd::GetClassId() { return MOVEFRAME_CMD; } boolean MoveFrameCmd::IsA(ClassId id) { return id == MOVEFRAME_CMD || Command::IsA(id); } Command* MoveFrameCmd::Copy() { MoveFrameCmd* copy = new MoveFrameCmd(CopyControlInfo(), _requestmotion, _allowbg); copy->wraparound(wraparound()); InitCopy(copy); return copy; } boolean MoveFrameCmd::Reversible() { return true; } void MoveFrameCmd::Log () { ((OverlayUnidraw*)unidraw)->Log(this, false); } const char* MoveFrameCmd::MoveFuncFormat() { return _func_on ? (_move_func ? _move_func : "timeframe(%d)" ) : nil; } const char* MoveFrameCmd::AbsMoveFuncFormat() { return _func_on ? (_absmove_func ? _absmove_func : "timeframe(%d :abs)" ) : nil; } void MoveFrameCmd::FuncEnable(const char* movefunc, const char* absmovefunc) { _func_on=true; if (movefunc) { delete _move_func; _move_func = strdup(movefunc); } if (absmovefunc) { delete _absmove_func; _absmove_func = strdup(absmovefunc); } } void MoveFrameCmd::Execute() { FrameEditor* ed = (FrameEditor*) GetEditor(); FrameIdrawComp *comp = ((FrameIdrawComp*)ed->GetComponent()); ed->GetViewer()->GetSelection()->Clear(); FramesView* fv = (FramesView*)ed->GetViewer()->GetGraphicView(); Iterator frameptr; fv->SetView(ed->GetFrame(), frameptr); OverlaysView* prev = ed->GetFrame(); _actualmotion = 0; FrameNumberState* fnumstate = ed->framenumstate(); int ofnum = fnumstate->framenumber(); if (!_allowbg && ofnum + _requestmotion <= 0) _plannedmotion = -ofnum + 1; else _plannedmotion = _requestmotion; for (int i = 0; i < Math::abs(_plannedmotion); i++) { if (!fv->Done(frameptr)) { if (_plannedmotion > 0) fv->Next(frameptr); else fv->Prev(frameptr); _actualmotion++; } } if (fv->Done(frameptr)) { if (plannedmotion() > 0) fv->Prev(frameptr); else fv->Next(frameptr); _actualmotion--; if (wraparound()) { if (requestmotion() > 0) { fv->First(frameptr); fv->Next(frameptr); } else fv->Last(frameptr); } } ed->SetFrame((FrameView*)fv->GetView(frameptr)); if (ed->GetFrame() && prev != ed->GetFrame()) { Damage* damage = ed->GetViewer()->GetDamage(); damage->Incur(prev->GetGraphic()); damage->Incur(ed->GetFrame()->GetGraphic()); } ed->UpdateFrame(true); int fnum = fv->Index(frameptr); fnumstate->framenumber(fnum); ComTerpServ* comterp = ed->GetComTerp(); const char* funcformat = MoveFuncFormat(); if (funcformat && comterp) { char buf[BUFSIZ]; sprintf(buf, funcformat, _requestmotion); ComValue retval(comterp->run(buf)); } unidraw->Update(); } void MoveFrameCmd::Unexecute() { FrameEditor* ed = (FrameEditor*) GetEditor(); FrameIdrawComp* comp = ((FrameIdrawComp*)ed->GetComponent()); FramesView* fv = (FramesView*)ed->GetViewer()->GetGraphicView(); OverlaysView* prev = ed->GetFrame(); Iterator frameptr; fv->SetView(ed->GetFrame(), frameptr); Damage* damage = ed->GetViewer()->GetDamage(); damage->Incur(ed->GetFrame()->GetGraphic()); for (int i = 0; i < _actualmotion; i++) { if (_plannedmotion > 0) fv->Prev(frameptr); else fv->Next(frameptr); } ed->SetFrame((FrameView*)fv->GetView(frameptr)); damage->Incur(ed->GetFrame()->GetGraphic()); ed->UpdateFrame(true); FrameNumberState* fnumstate = ed->framenumstate(); fnumstate->framenumber(fv->Index(frameptr)); ComTerpServ* comterp = ed->GetComTerp(); const char* funcformat = MoveFuncFormat(); if (funcformat && comterp) { char buf[BUFSIZ]; sprintf(buf, funcformat, -_requestmotion); ComValue retval(comterp->run(buf)); } unidraw->Update(); } void MoveFrameCmd::clr_wraparound() { wraparound(false); } void MoveFrameCmd::set_wraparound() { wraparound(true); } implementActionCallback(MoveFrameCmd) /*****************************************************************************/ FrameBeginCmd::FrameBeginCmd(ControlInfo* i) : MoveFrameCmd(i, 0) { } FrameBeginCmd::FrameBeginCmd(Editor* e) : MoveFrameCmd(e, 0) { } ClassId FrameBeginCmd::GetClassId() { return FRAMEBEGIN_CMD; } boolean FrameBeginCmd::IsA(ClassId id) { return id == FRAMEBEGIN_CMD || MoveFrameCmd::IsA(id); } Command* FrameBeginCmd::Copy() { Command* copy = new FrameBeginCmd(CopyControlInfo()); InitCopy(copy); return copy; } void FrameBeginCmd::Execute() { FrameEditor* ed = (FrameEditor*) GetEditor(); FrameIdrawComp *comp = ((FrameIdrawComp*)ed->GetComponent()); ed->GetViewer()->GetSelection()->Clear(); FramesView* fv = (FramesView*)ed->GetViewer()->GetGraphicView(); Iterator frameptr; fv->SetView( ed->GetFrame(), frameptr ); Damage* damage = ed->GetViewer()->GetDamage(); damage->Incur(ed->GetFrame()->GetGraphic()); int before = fv->Index(frameptr); fv->First(frameptr); fv->Next(frameptr); if (fv->Done(frameptr)) fv->First(frameptr); int after = fv->Index(frameptr); ed->SetFrame((FrameView*)fv->GetView(frameptr)); damage->Incur(ed->GetFrame()->GetGraphic()); ed->UpdateFrame(true); FrameNumberState* fnumstate = ed->framenumstate(); int fnum = fv->Index(frameptr); fnumstate->framenumber(fnum); _requestmotion = before-after; _actualmotion = Math::abs(_requestmotion); const char* funcformat = AbsMoveFuncFormat(); ComTerpServ* comterp = ed->GetComTerp(); if (funcformat && comterp) { char buf[BUFSIZ]; sprintf(buf, funcformat, _allowbg ? 0 : 1); ComValue retval (comterp->run(buf)); } unidraw->Update(); } /*****************************************************************************/ FrameEndCmd::FrameEndCmd(ControlInfo* i) : MoveFrameCmd(i, 0) { } FrameEndCmd::FrameEndCmd(Editor* e) : MoveFrameCmd(e, 0) { } ClassId FrameEndCmd::GetClassId() { return FRAMEEND_CMD; } boolean FrameEndCmd::IsA(ClassId id) { return id == FRAMEEND_CMD || MoveFrameCmd::IsA(id); } Command* FrameEndCmd::Copy() { Command* copy = new FrameEndCmd(CopyControlInfo()); InitCopy(copy); return copy; } void FrameEndCmd::Execute() { FrameEditor* ed = (FrameEditor*) GetEditor(); FrameIdrawComp *comp = ((FrameIdrawComp*)ed->GetComponent()); ed->GetViewer()->GetSelection()->Clear(); FramesView* fv = (FramesView*)ed->GetViewer()->GetGraphicView(); Iterator frameptr; fv->SetView(ed->GetFrame(), frameptr); Damage* damage = ed->GetViewer()->GetDamage(); damage->Incur(fv->GetView(frameptr)->GetGraphic()); int before = fv->Index(frameptr); fv->Last(frameptr); int after = fv->Index(frameptr); ed->SetFrame((FrameView*)fv->GetView(frameptr)); damage->Incur(ed->GetFrame()->GetGraphic()); ed->UpdateFrame(true); FrameNumberState* fnumstate = ed->framenumstate(); int fnum = fv->Index(frameptr); fnumstate->framenumber(fnum); _requestmotion = after-before; _actualmotion = Math::abs(_requestmotion); const char* funcformat = AbsMoveFuncFormat(); ComTerpServ* comterp = ed->GetComTerp(); if (funcformat && comterp) { char buf[BUFSIZ]; sprintf(buf, funcformat, fnum); ComValue retval(comterp->run(buf)); } unidraw->Update(); } /*****************************************************************************/ CreateMoveFrameCmd::CreateMoveFrameCmd(ControlInfo* i, boolean after) : MacroCmd(i) { _after = after; Append(new CreateFrameCmd(i->Copy(), _after)); Append(new MoveFrameCmd(i->Copy(), _after ? +1 : -1)); } CreateMoveFrameCmd::CreateMoveFrameCmd(Editor* e, boolean after) : MacroCmd(e) { _after = after; Append(new CreateFrameCmd(e, _after)); Append(new MoveFrameCmd(e, _after ? +1 : -1)); } ClassId CreateMoveFrameCmd::GetClassId() { return CREATEMOVEFRAME_CMD; } boolean CreateMoveFrameCmd::IsA(ClassId id) { return id == CREATEMOVEFRAME_CMD || MacroCmd::IsA(id); } Command* CreateMoveFrameCmd::Copy() { Command* copy = new CreateMoveFrameCmd(CopyControlInfo(), _after); InitCopy(copy); return copy; } CreateFrameCmd* CreateMoveFrameCmd::createframecmd() { Iterator i; First(i); return (CreateFrameCmd*)GetCommand(i); } MoveFrameCmd* CreateMoveFrameCmd::moveframecmd() { Iterator i; First(i); Next(i); return (MoveFrameCmd*)GetCommand(i); } /*****************************************************************************/ CopyMoveFrameCmd::CopyMoveFrameCmd(ControlInfo* i, boolean after) : MacroCmd(i) { _after = after; } CopyMoveFrameCmd::CopyMoveFrameCmd(Editor* e, boolean after) : MacroCmd(e) { _after = after; } ClassId CopyMoveFrameCmd::GetClassId() { return COPYMOVEFRAME_CMD; } boolean CopyMoveFrameCmd::IsA(ClassId id) { return id == COPYMOVEFRAME_CMD || MacroCmd::IsA(id); } Command* CopyMoveFrameCmd::Copy() { Command* copy = new CopyMoveFrameCmd(CopyControlInfo(), _after); InitCopy(copy); return copy; } void CopyMoveFrameCmd::Execute() { FrameEditor* ed = (FrameEditor*)GetEditor(); Append(new OvSlctAllCmd(ed)); Append(new FrameCopyCmd(ed)); Append(new CreateFrameCmd(ed, _after)); Append(new MoveFrameCmd(ed, _after ? +1 : -1)); Append(new PasteCmd(ed)); MacroCmd::Execute(); } /*****************************************************************************/ ClassId FrameGroupCmd::GetClassId () { return FRAME_GROUP_CMD; } boolean FrameGroupCmd::IsA (ClassId id) { return FRAME_GROUP_CMD == id || OvGroupCmd::IsA(id); } FrameGroupCmd::FrameGroupCmd (ControlInfo* c, OverlayComp* d) : OvGroupCmd(c, d) { } FrameGroupCmd::FrameGroupCmd (Editor* ed, OverlayComp* d) : OvGroupCmd(ed, d) { } Command* FrameGroupCmd::Copy () { OverlayComp* dest = (_group == nil) ? nil : (OverlayComp*) _group->Copy(); Command* copy = new FrameGroupCmd(CopyControlInfo(), dest); InitCopy(copy); return copy; } void FrameGroupCmd::Execute () { Clipboard* cb = GetClipboard(); FrameEditor* ed = (FrameEditor*)GetEditor(); FrameIdrawView* top = (FrameIdrawView*)ed->GetViewer()->GetGraphicView(); GraphicView* views = ((FrameEditor*)ed)->GetFrame(); if (cb == nil) { SetClipboard(cb = new Clipboard); Selection* s = ed->GetSelection(); if (s->Number() > 1) { Iterator i; s->Sort(views); for (s->First(i); !s->Done(i); s->Next(i)) { s->GetView(i)->Interpret(this); } } } else { Clipboard* oldcb = cb; SetClipboard(cb = new Clipboard); Iterator i; for (oldcb->First(i); !oldcb->Done(i); oldcb->Next(i)) { oldcb->GetComp(i)->Interpret(this); } delete oldcb; } if (!cb->IsEmpty()) { if (_group == nil) { SetGroup(MakeOverlaysComp()); } ed->GetComponent()->Interpret(this); _executed = true; } } OverlaysComp* FrameGroupCmd::MakeOverlaysComp() { return new FrameOverlaysComp(); } /*****************************************************************************/ ClassId FrameUngroupCmd::GetClassId () { return FRAME_UNGROUP_CMD; } boolean FrameUngroupCmd::IsA (ClassId id) { return FRAME_UNGROUP_CMD == id || UngroupCmd::IsA(id); } FrameUngroupCmd::FrameUngroupCmd (ControlInfo* c) : UngroupCmd(c) { Init(); } FrameUngroupCmd::FrameUngroupCmd (Editor* ed) : UngroupCmd(ed) { Init(); } FrameUngroupCmd::~FrameUngroupCmd () { } Command* FrameUngroupCmd::Copy () { Command* copy = new FrameUngroupCmd(CopyControlInfo()); InitCopy(copy); return copy; } void FrameUngroupCmd::Execute () { Clipboard* cb = GetClipboard(); FrameEditor* ed = (FrameEditor*)GetEditor(); FrameIdrawView* top = (FrameIdrawView*)ed->GetViewer()->GetGraphicView(); GraphicView* views = ((FrameEditor*)ed)->GetFrame(); if (cb == nil) { Selection* s = ed->GetSelection(); if (s->IsEmpty()) { return; } SetClipboard(cb = new Clipboard); s->Sort(views); Iterator i; for (s->First(i); !s->Done(i); s->Next(i)) { s->GetView(i)->Interpret(this); } } else { Clipboard* oldcb = cb; SetClipboard(cb = new Clipboard); Iterator i; for (oldcb->First(i); !oldcb->Done(i); oldcb->Next(i)) { oldcb->GetComp(i)->Interpret(this); } delete oldcb; } if (!cb->IsEmpty()) { ed->GetComponent()->Interpret(this); _executed = true; } } /*****************************************************************************/ ClassId FrameFrontCmd::GetClassId () { return FRAME_FRONT_CMD; } boolean FrameFrontCmd::IsA (ClassId id) { return FRAME_FRONT_CMD==id || FrontCmd::IsA(id);} FrameFrontCmd::FrameFrontCmd (ControlInfo* c) : FrontCmd(c) { } FrameFrontCmd::FrameFrontCmd (Editor* ed) : FrontCmd(ed) { } Command* FrameFrontCmd::Copy () { Command* copy = new FrameFrontCmd(CopyControlInfo()); InitCopy(copy); return copy; } void FrameFrontCmd::Execute () { Clipboard* cb = GetClipboard(); Editor* ed = GetEditor(); if (cb == nil) { Selection* s = ed->GetSelection(); if (s->IsEmpty()) { return; } SetClipboard(cb = new Clipboard); FrameIdrawView* top = (FrameIdrawView*)ed->GetViewer()->GetGraphicView(); GraphicView* views = ((FrameEditor*)ed)->GetFrame(); s->Sort(views); Iterator i; for (s->First(i); !s->Done(i); s->Next(i)) { s->GetView(i)->Interpret(this); } } else { Clipboard* oldcb = cb; SetClipboard(cb = new Clipboard); Iterator i; for (oldcb->First(i); !oldcb->Done(i); oldcb->Next(i)) { oldcb->GetComp(i)->Interpret(this); } delete oldcb; } if (!cb->IsEmpty()) { ed->GetComponent()->Interpret(this); } } /*****************************************************************************/ ClassId FrameBackCmd::GetClassId () { return FRAME_BACK_CMD; } boolean FrameBackCmd::IsA (ClassId id) { return FRAME_BACK_CMD == id || BackCmd::IsA(id);} FrameBackCmd::FrameBackCmd (ControlInfo* c) : BackCmd(c) { } FrameBackCmd::FrameBackCmd (Editor* ed) : BackCmd(ed) { } Command* FrameBackCmd::Copy () { Command* copy = new FrameBackCmd(CopyControlInfo()); InitCopy(copy); return copy; } void FrameBackCmd::Execute () { Clipboard* cb = GetClipboard(); Editor* ed = GetEditor(); if (cb == nil) { Selection* s = ed->GetSelection(); if (s->IsEmpty()) { return; } SetClipboard(cb = new Clipboard); FrameIdrawView* top = (FrameIdrawView*)ed->GetViewer()->GetGraphicView(); GraphicView* views = ((FrameEditor*)ed)->GetFrame(); s->Sort(views); Iterator i; for (s->First(i); !s->Done(i); s->Next(i)) { s->GetView(i)->Interpret(this); } } else { Clipboard* oldcb = cb; SetClipboard(cb = new Clipboard); Iterator i; for (oldcb->First(i); !oldcb->Done(i); oldcb->Next(i)) { oldcb->GetComp(i)->Interpret(this); } delete oldcb; } if (!cb->IsEmpty()) { ed->GetComponent()->Interpret(this); } } /*****************************************************************************/ ClassId FrameCopyCmd::GetClassId () { return FRAME_COPY_CMD; } boolean FrameCopyCmd::IsA (ClassId id) { return FRAME_COPY_CMD == id || CopyCmd::IsA(id); } FrameCopyCmd::FrameCopyCmd (ControlInfo* c, Clipboard* cb) : CopyCmd(c, cb) { } FrameCopyCmd::FrameCopyCmd (Editor* ed, Clipboard* cb) : CopyCmd(ed, cb) { } Command* FrameCopyCmd::Copy () { Command* copy = new FrameCopyCmd(CopyControlInfo()); InitCopy(copy); return copy; } void FrameCopyCmd::Execute () { Editor* editor = GetEditor(); Selection* s = editor->GetSelection(); if (!s->IsEmpty()) { Clipboard* cb = GetClipboard(); cb = (cb == nil) ? unidraw->GetCatalog()->GetClipboard() : cb; GraphicView* top = editor->GetViewer()->GetGraphicView(); GraphicView* views = ((FrameEditor*)editor)->GetFrame(); s->Sort(views); cb->DeleteComps(); cb->CopyInit(s); } } /*****************************************************************************/ ClassId FrameNewViewCmd::GetClassId () { return OVNEWVIEW_CMD; } boolean FrameNewViewCmd::IsA (ClassId id) { return FRAMENEWVIEW_CMD == id || OvNewViewCmd::IsA(id); } FrameNewViewCmd::FrameNewViewCmd (ControlInfo* c) : OvNewViewCmd(c) { } FrameNewViewCmd::FrameNewViewCmd (Editor* ed) : OvNewViewCmd(ed) { } Command* FrameNewViewCmd::Copy () { Command* copy = new FrameNewViewCmd(CopyControlInfo()); InitCopy(copy); return copy; } void FrameNewViewCmd::Execute () { Editor* ed = GetEditor(); Editor* newEd = new FrameEditor((OverlayComp*)GetGraphicComp()); *newEd->GetState("ModifStatusVar") = *ed->GetState("ModifStatusVar"); unidraw->Open(newEd); } /*****************************************************************************/ ShowOtherFrameCmd::ShowOtherFrameCmd(ControlInfo* i, int offset) : Command(i) { _offset = offset; _old_offset = 0; } ShowOtherFrameCmd::ShowOtherFrameCmd(Editor* e, int offset) : Command(e) { _offset = offset; _old_offset = 0; } ClassId ShowOtherFrameCmd::GetClassId() { return SHOWOTHERFRAME_CMD; } boolean ShowOtherFrameCmd::IsA(ClassId id) { return id == SHOWOTHERFRAME_CMD || Command::IsA(id); } Command* ShowOtherFrameCmd::Copy() { Command* copy = new ShowOtherFrameCmd(CopyControlInfo(), _offset); InitCopy(copy); return copy; } boolean ShowOtherFrameCmd::Reversible() { return true; } void ShowOtherFrameCmd::Log () { ((OverlayUnidraw*)unidraw)->Log(this, false); } void ShowOtherFrameCmd::Execute() { FrameEditor* ed = (FrameEditor*) GetEditor(); _old_offset = ed->OtherFrame(); ed->OtherFrame(_offset); ed->UpdateFrame(); unidraw->Update(); } void ShowOtherFrameCmd::Unexecute() { FrameEditor* ed = (FrameEditor*) GetEditor(); ed->OtherFrame(_old_offset); ed->UpdateFrame(); unidraw->Update(); } /*****************************************************************************/ AutoNewFrameCmd* AutoNewFrameCmd::_default = nil; AutoNewFrameCmd::AutoNewFrameCmd(ControlInfo* i) : MacroCmd(i) { } AutoNewFrameCmd::AutoNewFrameCmd(Editor* e) : MacroCmd(e) { } ClassId AutoNewFrameCmd::GetClassId() { return AUTONEWFRAME_CMD; } boolean AutoNewFrameCmd::IsA(ClassId id) { return id == AUTONEWFRAME_CMD || MacroCmd::IsA(id); } Command* AutoNewFrameCmd::Copy() { Command* copy = new AutoNewFrameCmd(CopyControlInfo()); InitCopy(copy); return copy; } boolean AutoNewFrameCmd::Reversible() { return true; } void AutoNewFrameCmd::Log () { boolean document_changed = false; ((OverlayUnidraw*)unidraw)->Log(this, document_changed); } void AutoNewFrameCmd::Execute() { FrameEditor* ed = (FrameEditor*) GetEditor(); ed->ToggleAutoNewFrame(); } void AutoNewFrameCmd::Unexecute() { FrameEditor* ed = (FrameEditor*) GetEditor(); ed->ToggleAutoNewFrame(); } implementActionCallback(AutoNewFrameCmd) ivtools-1.2.11a1/src/FrameUnidraw/framecmds.h000066400000000000000000000226331214471147700210200ustar00rootroot00000000000000/* * Copyright (c) 2009 Scott E. Johnston * Copyright (c) 1994, 1995, 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef framecmds_h #define framecmds_h #include #include #include #include #include #include #include //: command to create a frame. // commmand to create a frame, before or after the current frame. class CreateFrameCmd : public Command { public: CreateFrameCmd(ControlInfo*, boolean after = true); CreateFrameCmd(Editor* =nil, boolean after = true); boolean After() { return _after; } virtual void Execute(); virtual void Unexecute(); virtual boolean Reversible(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual Command* Copy(); protected: boolean _after; }; //: data object for DeleteFrameCmd. class DeleteFrameData : public VoidData { public: DeleteFrameData(void*, boolean restore_after); boolean RestoreAfter() { return _after; } protected: boolean _after; }; //: command to delete a frame. class DeleteFrameCmd : public Command { public: DeleteFrameCmd(ControlInfo*); DeleteFrameCmd(Editor* = nil); virtual void Execute(); virtual void Unexecute(); virtual boolean Reversible(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual Command* Copy(); }; //: command to change current frame. class MoveFrameCmd : public Command { public: MoveFrameCmd(ControlInfo*, int motion = +1, boolean allowbg = true); MoveFrameCmd(Editor* =nil, int motion = +1, boolean allowbg = true); void init(int motion, boolean allowbg); void wraparound(boolean flag) { _wraparound = flag; } // set flag to indicate forward wraparound during replay. boolean wraparound() { return _wraparound; } // get flag to indicate forward wraparound during replay. virtual void Execute(); virtual void Unexecute(); virtual boolean Reversible(); virtual void Log(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual Command* Copy(); boolean AllowBg() { return _allowbg; } // get flag that indicates whether to allow a background frame. void AllowBg(boolean abg) { _allowbg = abg; } // set flag that indicates whether to allow a background frame. static const char* MoveFuncFormat(); // return format string for generating interpreted move command. static const char* AbsMoveFuncFormat(); // return format string for generating interpreted move command with // absolute frame arguments. static void FuncEnable(const char* movefunc=nil, const char* absmovefunc=nil); // enable execution of an interpreter command on each move. static void FuncDisable() { _func_on=false; } // disable execution of an interpreter command on each move. int requestmotion() { return _requestmotion; } // requested motion in frames, negative means backward. int plannedmotion() { return _plannedmotion; } // planned motion in frames, negative means backward. int actualmotion() { return _actualmotion; } // actual motion in frames, negative means backward. void set_wraparound(); // set forward wraparound flag. void clr_wraparound(); // clear forward wraparound flag. static MoveFrameCmd* default_instance() { return _default; } // return a default instance of the MoveFrameCmd. static void default_instance(MoveFrameCmd* cmd) { _default = cmd; } // set a default instance of the MoveFrameCmd. protected: int _requestmotion, _actualmotion, _plannedmotion; boolean _allowbg; boolean _wraparound; static boolean _func_on; static char* _move_func; static char* _absmove_func; static MoveFrameCmd* _default; friend class MoveFrameFunc; }; declareActionCallback(MoveFrameCmd) //: command to move to the first frame. class FrameBeginCmd : public MoveFrameCmd { public: FrameBeginCmd(ControlInfo*); FrameBeginCmd(Editor* =nil); virtual void Execute(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual Command* Copy(); }; //: command to move to the last frame. class FrameEndCmd : public MoveFrameCmd { public: FrameEndCmd(ControlInfo*); FrameEndCmd(Editor* =nil); virtual void Execute(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual Command* Copy(); }; //: command to create a frame and move to it. class CreateMoveFrameCmd : public MacroCmd { public: CreateMoveFrameCmd(ControlInfo*, boolean after = true); CreateMoveFrameCmd(Editor* = nil, boolean after = true); boolean After() { return _after; } virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual Command* Copy(); CreateFrameCmd* createframecmd(); MoveFrameCmd* moveframecmd(); protected: boolean _after; }; //: command to copy contents of current frame to create a new frame. class CopyMoveFrameCmd : public MacroCmd { public: CopyMoveFrameCmd(ControlInfo*, boolean after = true); CopyMoveFrameCmd(Editor* = nil, boolean after = true); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual Command* Copy(); virtual void Execute(); protected: boolean _after; }; //: OvGroupCmd specialized for FrameUnidraw use. class FrameGroupCmd : public OvGroupCmd { public: FrameGroupCmd(ControlInfo*, OverlayComp* dest = nil); FrameGroupCmd(Editor* = nil, OverlayComp* dest = nil); virtual void Execute (); virtual OverlaysComp* MakeOverlaysComp(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: UngroupCmd specialized for FrameUnidraw use. class FrameUngroupCmd : public UngroupCmd { public: FrameUngroupCmd(ControlInfo*); FrameUngroupCmd(Editor* = nil); virtual ~FrameUngroupCmd(); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: FrontCmd specialized for FrameUnidraw use. class FrameFrontCmd : public FrontCmd { public: FrameFrontCmd(ControlInfo*); FrameFrontCmd(Editor* = nil); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: BackCmd specialized for FrameUnidraw use. class FrameBackCmd : public BackCmd { public: FrameBackCmd(ControlInfo*); FrameBackCmd(Editor* = nil); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: CopyCmd specialized for FrameUnidraw use. class FrameCopyCmd : public CopyCmd { public: FrameCopyCmd(ControlInfo*, Clipboard* = nil); FrameCopyCmd(Editor* = nil, Clipboard* = nil); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: OvNewViewCmd specialized for FrameUnidraw use. class FrameNewViewCmd : public OvNewViewCmd { public: FrameNewViewCmd(ControlInfo*); FrameNewViewCmd(Editor* = nil); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: command to enable/disable display of previous frame class ShowOtherFrameCmd : public Command { public: ShowOtherFrameCmd(ControlInfo*, int offset = -1); ShowOtherFrameCmd(Editor* =nil, int offset = -1); virtual void Execute(); virtual void Unexecute(); virtual boolean Reversible(); virtual void Log(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual Command* Copy(); protected: int _offset; int _old_offset; }; //: command to enable/disable auto-new-frame on import. class AutoNewFrameCmd : public MacroCmd { public: AutoNewFrameCmd(ControlInfo*); AutoNewFrameCmd(Editor* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual Command* Copy(); virtual void Execute(); virtual void Unexecute(); virtual void Log(); virtual boolean Reversible(); static AutoNewFrameCmd* default_instance() { return _default; } static void default_instance(AutoNewFrameCmd* cmd) { _default = cmd; } protected: static AutoNewFrameCmd* _default; }; declareActionCallback(AutoNewFrameCmd) #endif ivtools-1.2.11a1/src/FrameUnidraw/framecomps.cc000066400000000000000000000552621214471147700213550ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1994, 1995 Vectaport Inc., Cider Press * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ static void NullGS (Graphic* g) { FullGraphic null; *g = null; } /*****************************************************************************/ ParamList* FrameOverlaysComp::_frame_ovcomps_params = nil; int FrameOverlaysComp::_symid = -1; FrameOverlaysComp::FrameOverlaysComp(OverlayComp* parent) : OverlaysComp(parent) {} FrameOverlaysComp::FrameOverlaysComp(Graphic* g, OverlayComp* parent) : OverlaysComp(g, parent) {} FrameOverlaysComp::FrameOverlaysComp (istream& in, OverlayComp* parent) : OverlaysComp(parent) { _valid = GetParamList()->read_args(in, this); } ParamList* FrameOverlaysComp::GetParamList() { if (!_frame_ovcomps_params) GrowParamList(_frame_ovcomps_params = new ParamList()); return _frame_ovcomps_params; } void FrameOverlaysComp::GrowParamList(ParamList* pl) { pl->add_param("kids", ParamStruct::optional, &FrameScript::ReadChildren, this, this); OverlaysComp::GrowParamList(pl); return; } ClassId FrameOverlaysComp::GetClassId() { return FRAME_OVERLAYS_COMP; } boolean FrameOverlaysComp::IsA(ClassId id) { return id == FRAME_OVERLAYS_COMP || OverlaysComp::IsA(id); } Component* FrameOverlaysComp::Copy () { FrameOverlaysComp* comps = new FrameOverlaysComp(new Picture(GetGraphic())); if (attrlist()) comps->SetAttributeList(new AttributeList(attrlist())); Iterator i; First(i); while (!Done(i)) { comps->Append((GraphicComp*)GetComp(i)->Copy()); Next(i); } return comps; } void FrameOverlaysComp::Interpret (Command* cmd) { if (cmd->IsA(GROUP_CMD) || cmd->IsA(FRONT_CMD) || cmd->IsA(BACK_CMD)) { cmd->GetClipboard()->Append(this); } else OverlaysComp::Interpret(cmd); } void FrameOverlaysComp::Uninterpret (Command* cmd) { FrameEditor* ed = (FrameEditor*)cmd->GetEditor(); FramesView *views = (FramesView*)ed->GetViewer()->GetGraphicView(); if (cmd->IsA(GROUP_CMD)) { FrameComp* framecomp = (FrameComp*)ed->GetFrame()->GetGraphicComp(); framecomp->Uninterpret(cmd); } else OverlaysComp::Uninterpret(cmd); } /*****************************************************************************/ ParamList* FrameComp::_frame_comp_params = nil; int FrameComp::_symid = -1; FrameComp::FrameComp(OverlayComp* parent) : OverlaysComp(parent) {} FrameComp::FrameComp(Graphic* g, OverlayComp* parent) : OverlaysComp(g, parent) {} FrameComp::FrameComp (istream& in, OverlayComp* parent) : OverlaysComp(parent) { _valid = GetParamList()->read_args(in, this); } ParamList* FrameComp::GetParamList() { if (!_frame_comp_params) GrowParamList(_frame_comp_params = new ParamList()); return _frame_comp_params; } void FrameComp::GrowParamList(ParamList* pl) { pl->add_param("kids", ParamStruct::required, &FrameScript::ReadChildren, this, this); OverlayComp::GrowParamList(pl); return; } ClassId FrameComp::GetClassId() { return FRAME_COMP; } boolean FrameComp::IsA(ClassId id) { return id == FRAME_COMP || OverlaysComp::IsA(id); } Component* FrameComp::Copy () { FrameComp* comp = new FrameComp(new Picture(GetGraphic())); if (attrlist()) comp->SetAttributeList(new AttributeList(attrlist())); Iterator i; First(i); while (!Done(i)) { comp->Append((GraphicComp*)GetComp(i)->Copy()); Next(i); } return comp; } void FrameComp::Interpret (Command* cmd) { FrameEditor* ed = (FrameEditor*)cmd->GetEditor(); if (cmd->IsA(DELETE_CMD)) { Clipboard* cb = cmd->GetClipboard(); Selection* s = ed->GetSelection(); if (cb == nil) { if (s->IsEmpty()) { return; } cmd->SetClipboard(cb = new Clipboard); cb->Init(s); } s->Clear(); Iterator i; for (cb->First(i); !cb->Done(i); cb->Next(i)) { OverlayComp* comp = (OverlayComp*) cb->GetComp(i); unidraw->CloseDependents(comp); comp->Interpret(cmd); StorePosition(comp, cmd); Remove(comp); } Notify(); unidraw->Update(); } else if (cmd->IsA(CUT_CMD)) { Clipboard* cb = cmd->GetClipboard(); Selection* s = ed->GetSelection(); if (cb == nil) { if (s->IsEmpty()) { return; } GraphicView* views = ed->GetFrame(); s->Sort(views); cmd->SetClipboard(cb = new Clipboard); cb->Init(s); Clipboard* globalcb = unidraw->GetCatalog()->GetClipboard(); globalcb->DeleteComps(); globalcb->CopyInit(s); } s->Clear(); Iterator i; for (cb->First(i); !cb->Done(i); cb->Next(i)) { OverlayComp* comp = (OverlayComp*)cb->GetComp(i); unidraw->CloseDependents(comp); comp->Interpret(cmd); StorePosition(comp, cmd); Remove(comp); } Notify(); unidraw->Update(); } else if (cmd->IsA(DUP_CMD)) { GraphicView* views = ed->GetFrame(); GraphicComp* prev, *dup1; Iterator i, pos; Clipboard* cb = cmd->GetClipboard(); const float offset = 8; MoveCmd move(ed, offset, offset); if (cb == nil) { Selection* s = ed->GetSelection(); if (s->IsEmpty()) { return; } cmd->SetClipboard(cb = new Clipboard); s->Sort(views); for (s->First(i); !s->Done(i); s->Next(i)) { dup1 = (GraphicComp*) s->GetView(i)->GetGraphicComp()->Copy(); dup1->Interpret(&move); cb->Append(dup1); } cb->First(i); dup1 = cb->GetComp(i); Last(pos); prev = GetComp(pos); cmd->Store(dup1, new VoidData(prev)); } else { cb->First(i); dup1 = cb->GetComp(i); VoidData* vd = (VoidData*) cmd->Recall(dup1); prev = (GraphicComp*) vd->_void; SetComp(prev, pos); } for (cb->Last(i); !cb->Done(i); cb->Prev(i)) { InsertAfter(pos, cb->GetComp(i)); } Notify(); SelectClipboard(cb, ed); unidraw->Update(); } else if (cmd->IsA(GROUP_CMD)) { GroupCmd* gcmd = (GroupCmd*) cmd; FrameOverlaysComp* group = (FrameOverlaysComp*)gcmd->GetGroup(); Clipboard* cb = cmd->GetClipboard(); NullGS(group->GetGraphic()); Group(cb, group, cmd); Notify(); SelectViewsOf(group, ed); unidraw->Update(); } else if (cmd->IsA(UNGROUP_CMD)) { UngroupCmd* ucmd = (UngroupCmd*) cmd; Clipboard* cb = cmd->GetClipboard(); Clipboard* kids = new Clipboard; ucmd->SetKids(kids); Iterator i; for (cb->First(i); !cb->Done(i); cb->Next(i)) { OverlayComp* parent = (OverlayComp*)cb->GetComp(i); unidraw->CloseDependents(parent); Ungroup(parent, kids, cmd); } Notify(); SelectClipboard(kids, ed); unidraw->Update(); } else if (cmd->IsA(FRONT_CMD) || cmd->IsA(BACK_CMD)) { Clipboard* cb = cmd->GetClipboard(); Iterator i; if (cmd->IsA(FRONT_CMD)) { for (cb->First(i); !cb->Done(i); cb->Next(i)) { OverlayComp* comp = (OverlayComp*) cb->GetComp(i); StorePosition(comp, cmd); Remove(comp); Append(comp); } } else { for (cb->Last(i); !cb->Done(i); cb->Prev(i)) { OverlayComp* comp = (OverlayComp*) cb->GetComp(i); StorePosition(comp, cmd); Remove(comp); Prepend(comp); } } Notify(); unidraw->Update(); } else { OverlaysComp::Interpret(cmd); } } void FrameComp::Uninterpret (Command* cmd) { Editor* ed = cmd->GetEditor(); if (cmd->IsA(DELETE_CMD)) { Clipboard* cb = cmd->GetClipboard(); if (cb != nil) { Iterator i; for (cb->Last(i); !cb->Done(i); cb->Prev(i)) { OverlayComp* comp = (OverlayComp*) cb->GetComp(i); RestorePosition(comp, cmd); comp->Uninterpret(cmd); } Notify(); SelectClipboard(cb, ed); unidraw->Update(); } } else if (cmd->IsA(CUT_CMD)) { Clipboard* cb = cmd->GetClipboard(); if (cb != nil) { Iterator i; for (cb->Last(i); !cb->Done(i); cb->Prev(i)) { OverlayComp* comp = (OverlayComp*) cb->GetComp(i); RestorePosition(comp, cmd); comp->Uninterpret(cmd); } Notify(); SelectClipboard(cb, ed); unidraw->Update(); } } else if (cmd->IsA(GROUP_CMD)) { Clipboard* cb = cmd->GetClipboard(); Iterator i; cb->First(i); GraphicComp* group = (GraphicComp*) cb->GetComp(i)->GetParent(); unidraw->CloseDependents(group); for (cb->Last(i); !cb->Done(i); cb->Prev(i)) { RestorePosition((OverlayComp*) cb->GetComp(i), cmd); } Remove(group); Notify(); SelectClipboard(cb, ed); unidraw->Update(); } else if (cmd->IsA(UNGROUP_CMD)) { UngroupCmd* ucmd = (UngroupCmd*) cmd; Clipboard* cb = ucmd->GetClipboard(); Clipboard* kids = ucmd->GetKids(); Clipboard insertedParents; Iterator k; for (kids->First(k); !kids->Done(k); kids->Next(k)) { GraphicComp* kid = kids->GetComp(k); UngroupData* ud = (UngroupData*) cmd->Recall(kid); GraphicComp* parent = ud->_parent; *kid->GetGraphic() = *ud->_gs; if (!insertedParents.Includes(parent)) { GSData* gd = (GSData*) cmd->Recall(parent); *parent->GetGraphic() = *gd->_gs; Iterator insertPt; SetComp(kid, insertPt); InsertBefore(insertPt, parent); insertedParents.Append(parent); } Remove(kid); parent->Append(kid); } Notify(); SelectClipboard(cb, ed); unidraw->Update(); delete kids; ucmd->SetKids(nil); } else if (cmd->IsA(FRONT_CMD)) { Clipboard* cb = cmd->GetClipboard(); Iterator i; for (cb->Last(i); !cb->Done(i); cb->Prev(i)) { RestorePosition((OverlayComp*) cb->GetComp(i), cmd); } Notify(); SelectClipboard(cb, ed); unidraw->Update(); } else if (cmd->IsA(BACK_CMD)) { Clipboard* cb = cmd->GetClipboard(); Iterator i; for (cb->First(i); !cb->Done(i); cb->Next(i)) { RestorePosition((OverlayComp*) cb->GetComp(i), cmd); } Notify(); SelectClipboard(cb, ed); unidraw->Update(); } else { OverlaysComp::Uninterpret(cmd); } } /*****************************************************************************/ ParamList* FramesComp::_frame_comps_params = nil; int FramesComp::_symid = -1; FramesComp::FramesComp(OverlayComp* parent) : FrameComp(parent) {} FramesComp::FramesComp(Graphic* g, OverlayComp* parent) : FrameComp(g, parent) {} FramesComp::FramesComp (istream& in, OverlayComp* parent) : FrameComp(parent) { _valid = GetParamList()->read_args(in, this); } ParamList* FramesComp::GetParamList() { if (!_frame_comps_params) GrowParamList(_frame_comps_params = new ParamList()); return _frame_comps_params; } void FramesComp::GrowParamList(ParamList* pl) { pl->add_param("frames", ParamStruct::optional, &FramesScript::ReadFrames, this, this); OverlayComp::GrowParamList(pl); return; } Component* FramesComp::Copy () { FramesComp* comps = new FramesComp(new Picture(GetGraphic())); if (attrlist()) comps->SetAttributeList(new AttributeList(attrlist())); Iterator i; First(i); while (!Done(i)) { comps->Append((GraphicComp*)GetComp(i)->Copy()); Next(i); } return comps; } ClassId FramesComp::GetClassId() { return FRAMES_COMP; } boolean FramesComp::IsA(ClassId id) { return id == FRAMES_COMP || FrameComp::IsA(id); } void FramesComp::Interpret (Command* cmd) { if (cmd->IsA(DELETE_CMD) || cmd->IsA(CUT_CMD) || cmd->IsA(DUP_CMD) || cmd->IsA(GROUP_CMD) || cmd->IsA(UNGROUP_CMD) || cmd->IsA(FRONT_CMD) || cmd->IsA(BACK_CMD)) OverlaysComp::Interpret(cmd); else FrameComp::Interpret(cmd); } void FramesComp::Uninterpret (Command* cmd) { if (cmd->IsA(DELETE_CMD) || cmd->IsA(CUT_CMD) || cmd->IsA(DUP_CMD) || cmd->IsA(GROUP_CMD) || cmd->IsA(UNGROUP_CMD) || cmd->IsA(FRONT_CMD) || cmd->IsA(BACK_CMD)) OverlaysComp::Uninterpret(cmd); else FrameComp::Uninterpret(cmd); } /*****************************************************************************/ ParamList* FrameIdrawComp::_frame_idraw_params = nil; int FrameIdrawComp::_symid = -1; FrameIdrawComp::FrameIdrawComp(boolean add_bg, const char* pathname, OverlayComp* parent) : FramesComp(parent) { _pathname = _basedir = nil; _gslist = nil; _ptsbuf = nil; SetPathName(pathname); if (add_bg || !pathname) Append(new FrameComp()); } FrameIdrawComp::FrameIdrawComp (istream& in, const char* pathname, OverlayComp* parent) : FramesComp(parent) { _pathname = _basedir = nil; _gslist = nil; _ptsbuf = nil; SetPathName(pathname); _valid = GetParamList()->read_args(in, this); delete _gslist; if (_ptsbuf) { for (int i=0; i<_ptsnum; i++) Unref(_ptsbuf[i]); delete _ptsbuf; } } FrameIdrawComp::FrameIdrawComp(OverlayComp* parent) : FramesComp(parent) { } FrameIdrawComp::~FrameIdrawComp () { delete _pathname; delete _basedir; } ParamList* FrameIdrawComp::GetParamList() { if (!_frame_idraw_params) GrowParamList(_frame_idraw_params = new ParamList()); return _frame_idraw_params; } void FrameIdrawComp::GrowParamList(ParamList* pl) { pl->add_param("grid", ParamStruct::keyword, &ParamList::read_float, this, &_xincr, &_yincr); FramesComp::GrowParamList(pl); return; } Component* FrameIdrawComp::Copy () { FrameIdrawComp* comps = new FrameIdrawComp(false, GetPathName()); if (attrlist()) comps->SetAttributeList(new AttributeList(attrlist())); Iterator i; First(i); while (!Done(i)) { comps->Append((GraphicComp*)GetComp(i)->Copy()); Next(i); } return comps; } ClassId FrameIdrawComp::GetClassId() { return FRAME_IDRAW_COMP; } boolean FrameIdrawComp::IsA(ClassId id) { return id == FRAME_IDRAW_COMP || FramesComp::IsA(id); } void FrameIdrawComp::Interpret (Command* cmd) { FrameEditor* ed = (FrameEditor*)cmd->GetEditor(); FrameIdrawView *views = (FrameIdrawView*)ed->GetViewer()->GetGraphicView(); if (cmd->IsA(PASTE_CMD) || cmd->IsA(DELETE_CMD) || cmd->IsA(CUT_CMD) || cmd->IsA(DUP_CMD) || cmd->IsA(GROUP_CMD) || cmd->IsA(UNGROUP_CMD) || cmd->IsA(FRONT_CMD) || cmd->IsA(BACK_CMD)) { if (OverlaysView* frameview = ed->GetFrame()) frameview->GetGraphicComp()->Interpret(cmd); else OverlaysComp::Interpret(cmd); } else if (cmd->IsA(CREATEFRAME_CMD)) { boolean after = ((CreateFrameCmd*)cmd)->After(); Iterator frame; views->SetView(ed->GetFrame(), frame); int framenum = views->Index(frame); if (framenum >= 0) { for (int i = 0; i <= framenum; i++) { if (i == 0) First(frame); else Next(frame); } if (after) InsertAfter(frame, new FrameComp()); else InsertBefore(frame, new FrameComp()); Notify(); unidraw->Update(); FrameListState* fliststate = ed->frameliststate(); Iterator last; views->Last(last); fliststate->framenumber(views->Index(last)+1); } } else if (cmd->IsA(DELETEFRAME_CMD)) { FrameListState* fls = ed->frameliststate(); Iterator frame; views->SetView(ed->GetFrame(), frame); int framenum = views->Index(frame); int lastframe = fls->framenumber()-1; if (framenum > 0 && framenum != lastframe) { FrameNumberState* fns = ed->framenumstate(); int framestatenum = fns->framenumber(); Command *movecmd = new MoveFrameCmd(ed); movecmd->Execute(); GraphicComp* comp = ed->GetViewer()->GetGraphicView()->GetView(frame)->GetGraphicComp(); cmd->Store(this, new DeleteFrameData(comp, false)); Remove(comp); fns->framenumber(framestatenum); Notify(); unidraw->Update(); Iterator last; views->Last(last); fls->framenumber(views->Index(last)+1); } else if (framenum > 0 && framenum == lastframe) { FrameNumberState* fns = ed->framenumstate(); int framestatenum = fns->framenumber(); Command *movecmd = new MoveFrameCmd(ed, -1); movecmd->Execute(); GraphicComp* comp = ed->GetViewer()->GetGraphicView()->GetView(frame)->GetGraphicComp(); cmd->Store(this, new DeleteFrameData(comp, true)); Remove(comp); fns->framenumber(framestatenum-1); Notify(); unidraw->Update(); Iterator last; views->Last(last); fls->framenumber(views->Index(last)+1); } else if (framenum == 0) { unidraw->GetWorld()->RingBell(1); } } else FramesComp::Interpret(cmd); } void FrameIdrawComp::Uninterpret (Command* cmd) { FrameEditor* ed = (FrameEditor*)cmd->GetEditor(); FrameListState* fls = ed->frameliststate(); FrameIdrawView *views = (FrameIdrawView*)ed->GetViewer()->GetGraphicView(); if (cmd->IsA(PASTE_CMD) || cmd->IsA(DELETE_CMD) || cmd->IsA(CUT_CMD) || cmd->IsA(DUP_CMD) || cmd->IsA(GROUP_CMD) || cmd->IsA(UNGROUP_CMD) || cmd->IsA(FRONT_CMD) || cmd->IsA(BACK_CMD)) if (OverlaysView* frameview = ed->GetFrame()) frameview->GetGraphicComp()->Uninterpret(cmd); else OverlaysComp::Uninterpret(cmd); else if (cmd->IsA(CREATEFRAME_CMD)) { boolean after = ((CreateFrameCmd*)cmd)->After(); Iterator frame; views->SetView(ed->GetFrame(), frame); int framenum = views->Index(frame); if (framenum >= 0) { if (after) Next(frame); else Prev(frame); GraphicComp* comp = ed->GetViewer()->GetGraphicView()->GetView(frame)->GetGraphicComp(); Remove(comp); Notify(); unidraw->Update(); Iterator last; views->Last(last); fls->framenumber(views->Index(last)+1); } } else if (cmd->IsA(DELETEFRAME_CMD)) { Iterator frame; views->SetView(ed->GetFrame(), frame); DeleteFrameData* data = (DeleteFrameData*)cmd->Recall(this); int framenum = views->Index(frame); int lastframe = fls->framenumber()-1; if (data != nil) { GraphicComp* comp = (GraphicComp*)data->_void; for (int i = 0; i <= framenum; i++) { if (i == 0) First(frame); else Next(frame); } if (framenum == 0 || data->RestoreAfter()) { InsertAfter(frame, comp); Notify(); Command *movecmd = new MoveFrameCmd(ed, +1); movecmd->Execute(); } else { InsertBefore(frame, comp); Notify(); Command *movecmd = new MoveFrameCmd(ed, -1); movecmd->Execute(); } unidraw->Update(); Iterator last; views->Last(last); fls->framenumber(views->Index(last)+1); } } else FramesComp::Uninterpret(cmd); } void FrameIdrawComp::SetPathName(const char* pathname) { delete _pathname; _pathname = pathname ? strdup(pathname) : nil; char * old_basedir = _basedir; _basedir = pathname ? strdup(pathname) : nil; if (_basedir) { char* last_slash = strrchr(_basedir, '/'); if (last_slash) *(last_slash+1) = '\0'; else _basedir[0] = '\0'; } if (old_basedir && _basedir && strcmp(old_basedir, _basedir) != 0) { AdjustBaseDir(old_basedir, _basedir); delete old_basedir; } } const char* FrameIdrawComp::GetPathName() { return _pathname; } const char* FrameIdrawComp::GetBaseDir() { return _basedir; } void FrameIdrawComp::GrowIndexedGS(Graphic* gs) { if (!_gslist) _gslist = new Picture(); _gslist->Append(gs); } Graphic* FrameIdrawComp::GetIndexedGS(int index) { if (_gslist) { Iterator i; for (_gslist->First(i); !_gslist->Done(i); _gslist->Next(i)) { if (index==0) return _gslist->GetGraphic(i); index--; } } return nil; } void FrameIdrawComp::GrowIndexedPts(MultiLineObj* mlo) { if (!_ptsbuf) { _ptslen = 64; _ptsbuf = new MultiLineObj*[_ptslen]; _ptsnum = 0; for (int i=0; i<_ptslen; i++) _ptsbuf[i] = nil; } if (_ptsnum==_ptslen) { MultiLineObj** newbuf = new MultiLineObj*[_ptslen*2]; int i; for (i=0; i<_ptslen; i++) newbuf[i] = _ptsbuf[i]; for (;i<_ptslen*2; i++) newbuf[i] = nil; _ptslen *= 2; delete _ptsbuf; _ptsbuf = newbuf; } Resource::ref(mlo); _ptsbuf[_ptsnum++] = mlo; } MultiLineObj* FrameIdrawComp::GetIndexedPts(int index) { if (index >= 0 && index < _ptsnum) return _ptsbuf[index]; else return nil; } void FrameIdrawComp::GrowIndexedPic(OverlaysComp* pic) { if (!_picbuf) { _piclen = 64; _picbuf = new OverlaysComp*[_piclen]; _picnum = 0; for (int i=0; i<_piclen; i++) _picbuf[i] = nil; } if (_picnum==_piclen) { OverlaysComp** newbuf = new OverlaysComp*[_piclen*2]; int i; for (i=0; i<_piclen; i++) newbuf[i] = _picbuf[i]; for (;i<_piclen*2; i++) newbuf[i] = nil; _piclen *= 2; delete _picbuf; _picbuf = newbuf; } _picbuf[_picnum++] = pic; } OverlaysComp* FrameIdrawComp::GetIndexedPic(int index) { if (index >= 0 && index < _picnum) return _picbuf[index]; else return nil; } void FrameIdrawComp::ResetIndexedGS() { delete _gslist; _gslist = nil; } ivtools-1.2.11a1/src/FrameUnidraw/framecomps.h000066400000000000000000000107561214471147700212160ustar00rootroot00000000000000/* * Copyright (c) 1994, 1995, 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef framecomps_h #define framecomps_h #include class FrameCatalog; class FrameKit; class FrameScript; class FramesScript; class FrameIdrawScript; //: OverlaysComp specialized for use within a FrameIdrawComp. class FrameOverlaysComp : public OverlaysComp { public: FrameOverlaysComp(OverlayComp* parent = nil); FrameOverlaysComp(Graphic*, OverlayComp* parent = nil); FrameOverlaysComp(istream&, OverlayComp* parent = nil); virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _frame_ovcomps_params; CLASS_SYMID("FrameOverlaysComp"); }; //: single frame component. class FrameComp : public OverlaysComp { public: FrameComp(OverlayComp* parent = nil); FrameComp(Graphic* g, OverlayComp* parent = nil); FrameComp(istream&, OverlayComp* parent = nil); virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _frame_comp_params; CLASS_SYMID("FrameComp"); }; //: composite frame component. class FramesComp : public FrameComp { public: FramesComp(OverlayComp* parent = nil); FramesComp(Graphic* g, OverlayComp* parent = nil); FramesComp(istream&, OverlayComp* parent = nil); virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _frame_comps_params; CLASS_SYMID("FramesComp"); }; //: top-level component for flipbook document. // FrameIdrawComp is a clone of OverlayIdrawComp derived from FramesComp. class FrameIdrawComp : public FramesComp { public: FrameIdrawComp(boolean add_bg = true, const char* pathname = nil, OverlayComp* parent = nil); FrameIdrawComp(istream&, const char* pathname = nil, OverlayComp* parent = nil); FrameIdrawComp(OverlayComp* parent); virtual ~FrameIdrawComp(); virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual void SetPathName(const char*); virtual const char* GetPathName(); virtual void GrowIndexedGS(Graphic*); virtual Graphic* GetIndexedGS(int); virtual void GrowIndexedPts(MultiLineObj*); virtual MultiLineObj* GetIndexedPts(int); virtual void GrowIndexedPic(OverlaysComp*); virtual OverlaysComp* GetIndexedPic(int); virtual void ResetIndexedGS(); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); virtual const char* GetBaseDir(); protected: static ParamList* _frame_idraw_params; float _xincr, _yincr; Picture* _gslist; MultiLineObj** _ptsbuf; int _ptsnum; int _ptslen; OverlaysComp** _picbuf; int _picnum; int _piclen; char* _pathname; char* _basedir; CLASS_SYMID("FrameIdrawComp"); }; #endif ivtools-1.2.11a1/src/FrameUnidraw/framecreator.cc000066400000000000000000000067231214471147700216710ustar00rootroot00000000000000/* * Copyright (c) 1994, 1995 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ FrameCreator::FrameCreator () { } /* for commands */ void* FrameCreator::Create ( ClassId id, istream& in, ObjectMap* objmap, int objid ) { switch (id) { case CREATEFRAME_CMD: CREATE(CreateFrameCmd,in,objmap,objid); case DELETEFRAME_CMD: CREATE(DeleteFrameCmd,in,objmap,objid); case MOVEFRAME_CMD: CREATE(MoveFrameCmd,in,objmap,objid); case FRAME_COPY_CMD: CREATE(FrameCopyCmd,in,objmap,objid); case CREATEMOVEFRAME_CMD: CREATE(CreateMoveFrameCmd,in,objmap,objid); case FRAMEBEGIN_CMD: CREATE(FrameBeginCmd,in,objmap,objid); case FRAMEEND_CMD: CREATE(FrameEndCmd,in,objmap,objid); default: return OverlayCreator::Create(id, in,objmap,objid); } } /* for views */ void* FrameCreator::Create (ClassId id) { void* ptr = create(id); return ptr ? ptr : OverlayCreator::Create(id); } void* FrameCreator::create(ClassId id) { if (id == FRAME_OVERLAYS_VIEW) return new FrameOverlaysView; if (id == FRAME_VIEW) return new FrameView; if (id == FRAMES_VIEW) return new FramesView; if (id == FRAME_IDRAW_VIEW) return new FrameIdrawView; if (id == FRAME_FILE_VIEW) return new FrameFileView; if (id == FRAME_OVERLAYS_PS) return new OverlaysPS; if (id == FRAME_PS) return new OverlaysPS; if (id == FRAMES_PS) return new OverlaysPS; if (id == FRAME_IDRAW_PS) return new FrameIdrawPS; if (id == FRAME_FILE_PS) return new OverlaysPS; if (id == FRAME_OVERLAYS_SCRIPT) return new FrameOverlaysScript; if (id == FRAME_SCRIPT) return new FrameScript; if (id == FRAMES_SCRIPT) return new FramesScript; if (id == FRAME_IDRAW_SCRIPT) return new FrameIdrawScript; if (id == FRAME_FILE_SCRIPT) return new FrameFileScript; return nil; } ivtools-1.2.11a1/src/FrameUnidraw/framecreator.h000066400000000000000000000031551214471147700215270ustar00rootroot00000000000000/* * Copyright (c) 1994, 1995, 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef framecreator_h #define framecreator_h #include //: creator for use with FrameCatalog. class FrameCreator : public OverlayCreator { public: FrameCreator(); virtual void* Create( // for subjects ClassId, istream&, ObjectMap* = nil, int = 0 ); virtual void* Create(ClassId); // for views static void* create(ClassId); }; #endif ivtools-1.2.11a1/src/FrameUnidraw/frameeditor.cc000066400000000000000000000174671214471147700215270ustar00rootroot00000000000000/* * Copyright (c) 2000 Vectaport Inc, IET Inc. * Copyright (c) 1994-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include implementActionCallback(FrameEditor) /*****************************************************************************/ FrameEditor::FrameEditor(OverlayComp* gc, OverlayKit* ok) : ComEditor(false, ok) { Init(gc, ok->appname()); } FrameEditor::FrameEditor(const char* file, OverlayKit* ok) : ComEditor(false, ok) { if (file == nil) { Init(); } else { Catalog* catalog = unidraw->GetCatalog(); OverlayComp* comp; if (catalog->Retrieve(file, (Component*&) comp)) { Init(comp); } else { FrameIdrawComp* comp = new FrameIdrawComp; comp->SetPathName(file); catalog->Register(comp, file); Init(comp, file); fprintf(stderr, "flipbook: couldn't open %s\n", file); } } } FrameEditor::FrameEditor(boolean initflag, OverlayKit* ok) : ComEditor(initflag, ok) { _curr_others = _prev_others = nil; _num_curr_others = _num_prev_others = 0; _texteditor = nil; _autonewframe = false; _autonewframe_tts = nil; } FrameEditor::~FrameEditor() { delete _curr_others; delete _prev_others; } void FrameEditor::Init (OverlayComp* comp, const char* name) { _curr_others = _prev_others = nil; _num_curr_others = _num_prev_others = 0; _texteditor = nil; _autonewframe = false; _autonewframe_tts = nil; if (!comp) comp = new FrameIdrawComp; _terp = new ComTerpServ(); ((OverlayUnidraw*)unidraw)->comterp(_terp); AddCommands(_terp); add_comterp("Flipbook", _terp); _overlay_kit->Init(comp, name); InitFrame(); } void FrameEditor::InitCommands() { ComEditor::InitCommands(); int secs = 0; Catalog* catalog = unidraw->GetCatalog(); const char* slideshow_str = catalog->GetAttribute("slideshow"); if (slideshow_str) secs = atoi(slideshow_str); if (!secs) { FrameIdrawComp* comp = (FrameIdrawComp*)GetGraphicComp(); const char* attrname = "slideshow"; AttributeValue* av = comp->FindValue(attrname); if (av) secs = av->int_val(); } if (secs && _terp) { MoveFrameCmd::default_instance()->set_wraparound(); char buffer[BUFSIZ]; sprintf(buffer, "timeexpr(\"moveframe(1)\" :sec %d)", secs); _terp->run(buffer); } } void FrameEditor::InitFrame() { _currframe = nil; _prevframe = nil; FrameIdrawView* view = (FrameIdrawView*)GetViewer()->GetGraphicView(); Iterator it; view->First(it); OverlayView* subview = ((OverlayView*)view->GetView(it)); if (subview && subview->IsA(FRAME_VIEW)) { subview->Desensitize(); view->Next(it); if (view->Done(it)) { view->First(it); if (framenumstate()) framenumstate()->framenumber(0, true); } else { if (framenumstate()) framenumstate()->framenumber(1, true); Iterator i(it); view->Next(i); while (!view->Done(i)) { OverlayView* v = (OverlayView*)view->GetView(i); v->Hide(); view->Next(i); } } } SetFrame((FrameView*)view->GetView(it)); UpdateFrame(false); } void FrameEditor::Update() { ComEditor::Update(); } void FrameEditor::UpdateFrame(boolean txtupdate) { FrameIdrawView *views = (FrameIdrawView*)GetViewer()->GetGraphicView(); views->UpdateFrame(_currframe, _prevframe, _curr_others, _num_curr_others, _prev_others, _num_prev_others); delete _prev_others; _num_prev_others = _num_curr_others; _prev_others = new int[_num_prev_others]; for(int i=0; i<_num_prev_others; i++) _prev_others[i]=_curr_others[i]; if (GetFrame()) UpdateText((OverlayComp*)GetFrame()->GetGraphicComp(), txtupdate); Iterator last; views->Last(last); if (frameliststate()) frameliststate()->framenumber(views->Index(last)+1); } OverlaysView* FrameEditor::GetFrame(int index) { if (index<0) return _currframe; else if (_frameliststate && index<_frameliststate->framenumber()) { FrameIdrawView* views = (FrameIdrawView*)GetViewer()->GetGraphicView(); Iterator i; int count = 0; views->First(i); while (count++Done(i)) views->Next(i); return (OverlaysView*)views->GetView(i); } else return nil; } void FrameEditor::AddCommands(ComTerp* comterp) { ComEditor::AddCommands(comterp); comterp->add_command("moveframe", new MoveFrameFunc(comterp, this)); comterp->add_command("createframe", new CreateFrameFunc(comterp, this)); comterp->add_command("autoframe", new AutoNewFrameFunc(comterp, this)); comterp->add_command("numframes", new NumFramesFunc(comterp, this)); comterp->add_command("showframes", new ShowFramesFunc(comterp, this)); } void FrameEditor::DoAutoNewFrame() { if (_autonewframe) { CreateMoveFrameCmd* cmd = new CreateMoveFrameCmd(this, true); cmd->Execute(); cmd->Log(); } } void FrameEditor::ToggleAutoNewFrame() { _autonewframe = !_autonewframe; if (_autonewframe_tts) _autonewframe_tts->set(TelltaleState::is_chosen, _autonewframe); } int FrameEditor::NumFrames() { if (_frameliststate) return _frameliststate->framenumber(); else { FrameIdrawView* views = (FrameIdrawView*)GetViewer()->GetGraphicView(); Iterator i; int count = 0; for (views->First(i); !views->Done(i); views->Next(i)) { if (views->IsA(FRAME_VIEW)) count++; } return count; } } void FrameEditor::OtherFrame(int other_frame) { delete _prev_others; _prev_others = _curr_others; _num_prev_others = _num_curr_others; _curr_others = new int[1]; _curr_others[0] = other_frame; _num_curr_others = 1; } void FrameEditor::OtherFrames(int* other_frames, int num_other_frames) { delete _prev_others; _prev_others = _curr_others; _num_prev_others = _num_curr_others; _curr_others = new int[num_other_frames]; for (int i=0; i #include #include class FrameNumberState; class FrameListState; class FrameView; class TelltaleState; //: ComEditor specialized for multi-frame use. class FrameEditor : public ComEditor { public: FrameEditor(OverlayComp*, OverlayKit* = FrameKit::Instance()); // construct based on pre-existing FrameIdrawComp. FrameEditor(const char*, OverlayKit* = FrameKit::Instance()); // construct from pathname of a flipbook document. FrameEditor(boolean initflag, OverlayKit* = FrameKit::Instance()); // constructor for use of derived classes. virtual ~FrameEditor(); void Init (OverlayComp* = nil, const char* = "FrameEditor"); virtual void UpdateFrame(boolean txtupdate =true); // update state variables and text-editor display for current frame. virtual void InitFrame(); // initialize multi-frame display mechanism. virtual void Update(); // pass to ComEditor. virtual void AddCommands(ComTerp*); // add interpreter commands to ComTerp associated with this ComEditor. virtual void InitCommands(); // execute Unidraw commands as needed after FrameEditor is constructed. void SetFrame(FrameView* f) { _prevframe = _currframe;_currframe = f; } // set current frame. virtual OverlaysView* GetFrame(int index=-1); // return current frame. int OtherFrame(){ return _curr_others ? _curr_others[0] : nil; } // return index of previous (or secondary) frame. void OtherFrame(int other_frame); // set index of previous (or secondary) frame. int* OtherFrames(){ return _curr_others; } // return index of previous (or secondary) frames. void OtherFrames(int* other_frames, int num_others); // set index of previous (or secondary) frames. FrameNumberState*& framenumstate() { return _framenumstate; } // return reference to pointer to current-frame-number state variable FrameListState*& frameliststate() { return _frameliststate; } // return reference to pointer to current-frame-count state variable void ToggleAutoNewFrame(); // toggle flag which indicates a new frame should be automatically // created whenever anything is imported. boolean AutoNewFrame() { return _autonewframe; } // return flag which indicates a new frame should be automatically // created whenever anything is imported. virtual void DoAutoNewFrame(); // virtual method which does the work of creating a new frame // if flag is set. int NumFrames(); // number of frames not counting background frame protected: FrameView* _currframe; FrameView* _prevframe; FrameNumberState* _framenumstate; FrameListState* _frameliststate; int* _curr_others; int* _prev_others; int _num_curr_others; int _num_prev_others; boolean _autonewframe; public: TelltaleState* _autonewframe_tts; friend class FrameKit; }; declareActionCallback(FrameEditor) #endif ivtools-1.2.11a1/src/FrameUnidraw/framefile.cc000066400000000000000000000133051214471147700211430ustar00rootroot00000000000000/* * Copyright (c) 1994,1995,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::cerr; /*****************************************************************************/ ParamList* FrameFileComp::_frame_file_params = nil; FrameFileComp::FrameFileComp(OverlayComp* parent) : FramesComp(parent) { _pathname = nil; } FrameFileComp::FrameFileComp(Graphic* g, OverlayComp* parent) : FramesComp(g, parent) { _pathname = nil; } FrameFileComp::FrameFileComp (istream& in, OverlayComp* parent) : FramesComp(parent) { _pathname = nil; _valid = GetParamList()->read_args(in, this); } FrameFileComp::~FrameFileComp() { delete _pathname; } ParamList* FrameFileComp::GetParamList() { if (!_frame_file_params) GrowParamList(_frame_file_params = new ParamList()); return _frame_file_params; } void FrameFileComp::GrowParamList(ParamList* pl) { pl->add_param("pathname", ParamStruct::required, &FrameFileScript::ReadPathName, this, this); FramesComp::GrowParamList(pl); } Component* FrameFileComp::Copy () { FrameFileComp* ovfile = new FrameFileComp(new Picture(GetGraphic())); if (attrlist()) ovfile->SetAttributeList(new AttributeList(attrlist())); Iterator i; First(i); if (!Done(i)) ovfile->Append((GraphicComp*)GetComp(i)->Copy()); return ovfile; } ClassId FrameFileComp::GetClassId() { return FRAME_FILE_COMP; } boolean FrameFileComp::IsA(ClassId id) { return id == FRAME_FILE_COMP || FramesComp::IsA(id); } void FrameFileComp::Interpret (Command* cmd) { if (cmd->IsA(UNGROUP_CMD)) { } else FramesComp::Interpret(cmd); } void FrameFileComp::Uninterpret (Command* cmd) { if (cmd->IsA(UNGROUP_CMD)) { } else FramesComp::Uninterpret(cmd); } void FrameFileComp::SetPathName(const char* pathname) { _pathname = strdup(pathname); if (GetIdrawComp()) GetIdrawComp()->SetPathName(pathname); } const char* FrameFileComp::GetPathName() { return _pathname; } FrameIdrawComp* FrameFileComp::GetIdrawComp() { Iterator i; First(i); return ((FrameIdrawComp*) GetComp(i)); } /*****************************************************************************/ FrameFileView::FrameFileView() : FramesView() {} ClassId FrameFileView::GetClassId() { return FRAME_FILE_VIEW; } boolean FrameFileView::IsA(ClassId id) { return id == FRAME_FILE_VIEW || FramesView::IsA(id); } /*****************************************************************************/ FrameFileScript::FrameFileScript (FrameFileComp* subj) : FramesScript(subj) {} ClassId FrameFileScript::GetClassId () { return FRAME_FILE_SCRIPT; } boolean FrameFileScript::IsA (ClassId id) { return FRAME_FILE_SCRIPT == id || FramesScript::IsA(id); } boolean FrameFileScript::Definition (ostream& out) { FrameFileComp* comp = (FrameFileComp*) GetSubject(); out << "framefile(\"" << comp->GetPathName() << "\""; FullGS(out); Annotation(out); out << ")"; return true; } int FrameFileScript::ReadPathName (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { FrameFileComp* filecomp = (FrameFileComp*)addr1; char pathname[BUFSIZ]; if (ParamList::parse_pathname(in, pathname, BUFSIZ, filecomp->GetBaseDir()) != 0) return -1; /* check pathname for recursion */ OverlayComp* parent = (OverlayComp*) filecomp->GetParent(); while (parent != nil) { if (parent->GetPathName() && strcmp(parent->GetPathName(), pathname) == 0) { cerr << "framefile recursion not allowed (" << pathname << ")\n"; return -1; } parent = (OverlayComp*) parent->GetParent(); } filecomp->SetPathName(pathname); FrameIdrawComp* child = nil; FrameCatalog* catalog = (FrameCatalog*)unidraw->GetCatalog(); catalog->SetParent(filecomp); if( catalog->FrameCatalog::Retrieve(pathname, (Component*&)child)) { catalog->SetParent(nil); catalog->Forget(child); filecomp->Append(child); return 0; } else { catalog->SetParent(nil); return -1; } } boolean FrameFileScript::EmitGS(ostream& out, Clipboard* cb, boolean prevout) { return OverlayScript::EmitGS(out, cb, prevout); } boolean FrameFileScript::EmitPts(ostream& out, Clipboard* cb, boolean prevout) { return OverlayScript::EmitPts(out, cb, prevout); } ivtools-1.2.11a1/src/FrameUnidraw/framefile.h000066400000000000000000000053101214471147700210020ustar00rootroot00000000000000/* * Copyright (c) 1994, 1995, 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef framefile_h #define framefile_h #include #include #include //: component to indirectly refer to a flipbook document by a pathname. // similar to OverlayFileComp. class FrameFileComp : public FramesComp { public: FrameFileComp(OverlayComp* parent = nil); FrameFileComp(Graphic*, OverlayComp* parent = nil); FrameFileComp(istream&, OverlayComp* parent = nil); virtual ~FrameFileComp(); virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); void SetPathName(const char*); const char* GetPathName(); FrameIdrawComp* GetIdrawComp(); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _frame_file_params; char* _pathname; }; //: graphical view of FrameFileComp. class FrameFileView : public FramesView { public: FrameFileView(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: serialized view of FrameFileComp. class FrameFileScript : public FramesScript { public: virtual ClassId GetClassId(); virtual boolean IsA(ClassId); FrameFileScript(FrameFileComp* = nil); virtual boolean Definition (ostream&); virtual boolean EmitGS(ostream&, Clipboard*, boolean); virtual boolean EmitPts(ostream&, Clipboard*, boolean); static int ReadPathName(istream&, void*, void*, void*, void*); }; #endif ivtools-1.2.11a1/src/FrameUnidraw/framefunc.cc000066400000000000000000000132301214471147700211540ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1998-2000 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include #include #include using std::cerr; static int on_symid = symbol_add("on"); static int off_symid = symbol_add("off"); /*****************************************************************************/ MoveFrameFunc::MoveFrameFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void MoveFrameFunc::execute() { ComValue deltav(stack_arg(0, false, ComValue::oneval())); static int abs_symid = symbol_add("abs"); ComValue absflag(stack_key(abs_symid)); reset_stack(); if (editor() && deltav.is_num()) { int deltaframes = 0; if (absflag.is_true()) { FramesView* fv = (FramesView*)GetEditor()->GetViewer()->GetGraphicView(); Iterator it; fv->SetView(((FrameEditor*)GetEditor())->GetFrame(), it); int currframe = fv->Index(it); deltaframes = deltav.int_val() - currframe; } else deltaframes = deltav.int_val(); MoveFrameCmd* cmd = new MoveFrameCmd(GetEditor(), deltaframes); cmd->wraparound(MoveFrameCmd::default_instance()->wraparound()); execute_log(cmd); ComValue retval(cmd->actualmotion(), ComValue::IntType); push_stack(retval); } } /*****************************************************************************/ CreateFrameFunc::CreateFrameFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void CreateFrameFunc::execute() { static int before_symval = symbol_add("before"); ComValue beforev(stack_key(before_symval)); reset_stack(); if (editor()) { CreateMoveFrameCmd* cmd = new CreateMoveFrameCmd(editor(), beforev.is_false()); execute_log(cmd); ComValue retval(cmd->moveframecmd()->actualmotion(), ComValue::IntType); push_stack(retval); } } /*****************************************************************************/ AutoNewFrameFunc::AutoNewFrameFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void AutoNewFrameFunc::execute() { ComValue onflagv(stack_key(on_symid)); ComValue offflagv(stack_key(off_symid)); reset_stack(); FrameEditor* ed = (FrameEditor*)GetEditor(); if (ed) { if (onflagv.is_false() && offflagv.is_false()) { ed->ToggleAutoNewFrame(); } else if (onflagv.is_true()) { if (!ed->AutoNewFrame()) ed->ToggleAutoNewFrame(); } else if (offflagv.is_true()) { if (ed->AutoNewFrame()) ed->ToggleAutoNewFrame(); } } } /*****************************************************************************/ NumFramesFunc::NumFramesFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void NumFramesFunc::execute() { reset_stack(); FrameEditor* ed = (FrameEditor*)GetEditor(); ComValue retval(ed->NumFrames()); push_stack(retval); } /*****************************************************************************/ ShowFramesFunc::ShowFramesFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) { } void ShowFramesFunc::execute() { FrameEditor* ed = (FrameEditor*)GetEditor(); ComValue flistv(stack_arg(0)); reset_stack(); AttributeValueList* avl = nil; if (flistv.is_array() && (avl = flistv.array_val()) && avl->Number()>1 ) { int topframe = 0; int num_others=0; Iterator it; for (avl->First(it); !avl->Done(it); avl->Next(it)) { topframe = Math::max(topframe, avl->GetAttrVal(it)->int_val()); } ComValue topval(topframe, ComValue::IntType); static int abs_symid = symbol_add("abs"); ComValue abskey(abs_symid, 0, ComValue::KeywordType); push_stack(topval); push_stack(abskey); MoveFrameFunc moveframefunc(comterp(), ed); moveframefunc.exec(1, 1, pedepth()); pop_stack(); const int otherslen=avl->Number()-1; int others[otherslen]; int otherscnt=0; for (avl->First(it); !avl->Done(it); avl->Next(it)) { int currframe = avl->GetAttrVal(it)->int_val(); if (currframe != topframe) { int offset = currframe-topframe; boolean takenflag=false; for(int i=0; !takenflag && iOtherFrames(others, otherscnt); ed->UpdateFrame(true); } else cerr << "showframes: need at least two frames for this command.\n"; } ivtools-1.2.11a1/src/FrameUnidraw/framefunc.h000066400000000000000000000057051214471147700210260ustar00rootroot00000000000000/* * Copyright (c) 1998-2000 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #if !defined(framefunc_h) #define _framefunc_h #include //: interpreter command to move current frame. // moveframe([num] :abs) -- move frame by num or to num if :abs class MoveFrameFunc : public UnidrawFunc { public: MoveFrameFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s([num] :abs) -- move frame by num or to num if :abs"; } }; //: interpreter command to create new frame. // createframe(:before) -- create and move to new frame class CreateFrameFunc : public UnidrawFunc { public: CreateFrameFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(:before) -- create and move to new frame"; } }; //: interpreter command to toggle the autonewframe flag // autonewframe(:on :off) -- command to toggle the autonewframe flag class AutoNewFrameFunc : public UnidrawFunc { public: AutoNewFrameFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(:on :off) -- command to toggle autonewframe"; } }; //: interpreter command to return number of frames in viewer // numframes() -- return number of frames in viewer class NumFramesFunc : public UnidrawFunc { public: NumFramesFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s() -- return number of frames in viewer"; } }; //: interpreter command to show a set of frames at once // showframes(fnum[,fnum[...,fnum]]) -- show list of frames class ShowFramesFunc : public UnidrawFunc { public: ShowFramesFunc(ComTerp*,Editor*); virtual void execute(); virtual const char* docstring() { return "%s(fnum[,fnum[...,fnum]]) -- show list of frames"; } }; #endif /* !defined(_framefunc_h) */ ivtools-1.2.11a1/src/FrameUnidraw/frameimport.cc000066400000000000000000000137121214471147700215400ustar00rootroot00000000000000/* * Copyright (c) 2009 Scott E. Johnston * Copyright (c) 1996 Vectaport Inc. * Copyright (c) 1994-1995 Vectaport Inc., Cartoactive Systems * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * FrameImportCmd implementation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ ClassId FrameImportCmd::GetClassId () { return FRAMEIMPORT_CMD; } boolean FrameImportCmd::IsA (ClassId id) { return FRAMEIMPORT_CMD == id || OvImportCmd::IsA(id); } FrameImportCmd::FrameImportCmd (ControlInfo* c, ImportChooser* f) : OvImportCmd(c, f) { } FrameImportCmd::FrameImportCmd (Editor* ed, ImportChooser* f) : OvImportCmd(ed, f) { } Command* FrameImportCmd::Copy () { FrameImportCmd* copy = new FrameImportCmd(CopyControlInfo(), chooser_); InitCopy(copy); return copy; } void FrameImportCmd::Execute () { GraphicComp* comps = PostDialog(); Clipboard* cb; if (comps != nil) { FrameImportPasteCmd* paste_cmd = new FrameImportPasteCmd(GetEditor(), new Clipboard(comps)); paste_cmd->Execute(); paste_cmd->Log(); if (!comps->IsA(FRAME_IDRAW_COMP)) { if(chooser_->centered()) GetEditor()->GetViewer()->Align(comps, /* Center */ 4); if (!chooser_->by_pathname()) { FrameUngroupCmd* ungroup_cmd = new FrameUngroupCmd(GetEditor()); ungroup_cmd->Execute(); MacroCmd* macro_cmd = new MacroCmd(GetEditor(), paste_cmd, ungroup_cmd); macro_cmd->Log(); } else { paste_cmd->Log(); } } else delete comps; } } GraphicComp* FrameImportCmd::Import (const char* pathname) { GraphicComp* comp = nil; const char* creator = ReadCreator(pathname); if(!creator) return nil; FrameCatalog* catalog = (FrameCatalog*)unidraw->GetCatalog(); if (strcmp(creator, "flipbook") == 0 || strcmp(creator, "frame-idraw") == 0) { catalog->SetImport(true); if (catalog->FrameCatalog::Retrieve(pathname, (Component*&) comp)) { catalog->SetImport(false); catalog->Forget(comp); return comp; } catalog->SetImport(false); return nil; } else return OvImportCmd::Import(pathname); } /*****************************************************************************/ ClassId FrameImportPasteCmd::GetClassId () { return FRAMEIMPORTPASTE_CMD; } boolean FrameImportPasteCmd::IsA (ClassId id) { return FRAMEIMPORTPASTE_CMD==id || MacroCmd::IsA(id); } FrameImportPasteCmd::FrameImportPasteCmd (ControlInfo* c, Clipboard* cb) : MacroCmd(c) { SetClipboard(cb); _executed = 0; } FrameImportPasteCmd::FrameImportPasteCmd (Editor* ed, Clipboard* cb) : MacroCmd(ed) { SetClipboard(cb); _executed = 0; } FrameImportPasteCmd::~FrameImportPasteCmd () { } Command* FrameImportPasteCmd::Copy () { Command* copy = new FrameImportPasteCmd(CopyControlInfo(), DeepCopyClipboard()); InitCopy(copy); return copy; } void FrameImportPasteCmd::Execute () { if(!_executed) { Clipboard* cb = GetClipboard(); Iterator it; cb->First(it); GraphicComp* gcomp = cb->GetComp(it); cb->Next(it); if(cb->Done(it) && gcomp->IsA(FRAME_IDRAW_COMP)) { gcomp->First(it); /* move to background frame */ FrameEditor* ed = (FrameEditor*)GetEditor(); FrameNumberState* fnumstate = ed->framenumstate(); int origfnum = fnumstate->framenumber(); int currfnum = 0; Append(new MoveFrameCmd(ed, -origfnum, true /* allowbg */)); /* paste contents of background frame */ FrameComp* fcomp = (FrameComp*) (gcomp->GetComp(it)->IsA(FRAME_COMP) ? gcomp->GetComp(it) : nil); if (fcomp) { while(!gcomp->Done(it)) { gcomp->Remove(it); Clipboard* newcb = new Clipboard(); Iterator jt; fcomp->First(jt); while(!fcomp->Done(jt)) { newcb->Append(fcomp->GetComp(jt)); fcomp->Remove(jt); } Append(new PasteCmd(ed, newcb)); delete fcomp; /* while more frames move to next frame and paste (create new frame if necessary) */ if(!gcomp->Done(it)) { currfnum++; fcomp = (FrameComp*) (gcomp->GetComp(it)->IsA(FRAME_COMP) ? gcomp->GetComp(it) : nil); if(currfnum>=ed->NumFrames()) Append(new CreateMoveFrameCmd(ed)); else Append(new MoveFrameCmd(ed, 1, true /* allowbg */)); } } } /* move to original frame */ Append(new MoveFrameCmd(ed, origfnum-currfnum, true /* allowbg */)); } else Append(new PasteCmd(GetEditor(), cb->Copy())); } MacroCmd::Execute(); _executed = 1; } ivtools-1.2.11a1/src/FrameUnidraw/frameimport.h000066400000000000000000000043721214471147700214040ustar00rootroot00000000000000/* * * Copyright (c) 2009 Scott E. Johnston * Copyright (c) 1996,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * FrameImportCmd - a command for importing frames */ #ifndef frame_import_h #define frame_import_h #include #include #include //: specialized OvImportCmd for importing frames class FrameImportCmd : public OvImportCmd { public: FrameImportCmd(ControlInfo*, ImportChooser* = nil); FrameImportCmd(Editor* = nil, ImportChooser* = nil); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual GraphicComp* Import(const char*); }; //: specialized PasteCmd for flipbook class FrameImportPasteCmd : public MacroCmd { public: FrameImportPasteCmd(ControlInfo*, Clipboard* = nil); FrameImportPasteCmd(Editor* = nil, Clipboard* = nil); virtual ~FrameImportPasteCmd(); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: int _executed; }; #endif ivtools-1.2.11a1/src/FrameUnidraw/framekit.cc000066400000000000000000000640551214471147700210230ustar00rootroot00000000000000/* * Copyright (c) 1996-1998 Vectaport Inc. * Copyright (c) 1994, 1995 Vectaport Inc., Cartoactive Systems * Copyright (c) 1993 David B. Hollenbeck * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * FrameKit definitions */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #undef None /******************************************************************************/ static const char* page_width_attrib = "pagewidth"; static const char* page_height_attrib = "pageheight"; static const char* page_cols_attrib = "pagecols"; static const char* page_rows_attrib = "pagerows"; static const char* grid_x_incr = "gridxincr"; static const char* grid_y_incr = "gridyincr"; /******************************************************************************/ FrameKit* FrameKit::_framekit = nil; FrameKit::FrameKit () { } FrameKit* FrameKit::Instance() { if (!_framekit) _framekit = new FrameKit(); return _framekit; } void FrameKit::InitViewer () { Catalog* catalog = unidraw->GetCatalog(); const char* page_w = catalog->GetAttribute(page_width_attrib); const char* page_h = catalog->GetAttribute(page_height_attrib); const char* page_cols = catalog->GetAttribute(page_cols_attrib); const char* page_rows = catalog->GetAttribute(page_rows_attrib); const char* x_incr = catalog->GetAttribute(grid_x_incr); const char* y_incr = catalog->GetAttribute(grid_y_incr); GraphicView* view = (GraphicView*)((FrameEditor*)_ed)->_comp->Create(COMPONENT_VIEW); ((FrameEditor*)_ed)->_comp->Attach(view); view->Update(); Style* style = Session::instance()->style(); boolean bookgeom = style->value_is_on("bookgeom"); float w = bookgeom ? 700 : Math::round(atof(page_w) * ivinches); float h = bookgeom ? 906 : Math::round(atof(page_h) * ivinches); if (page_cols && page_rows) { int ncols = atoi(page_cols); int nrows = atoi(page_rows); if (ncols>0 && nrows>0) { w = ncols; h = nrows; } } OverlayPage* page = new OverlayPage(w, h); Grid* grid = new Grid(w, h, atof(x_incr), atof(y_incr)); grid->Visibility(false); if (!bookgeom) ((FrameEditor*)_ed)->_viewer = new FrameViewer(_ed, view, page, grid); else ((FrameEditor*)_ed)->_viewer = new FrameViewer(_ed, view, page, grid, (int) h+1, (int) w+1, Rotated); } void FrameKit::InitLayout(const char* name) { InitLayout(this, name); } void FrameKit::InitLayout(OverlayKit* kit, const char* name) { FrameEditor* ed = (FrameEditor*) kit->GetEditor(); Catalog* catalog = unidraw->GetCatalog(); const char* stripped_string = catalog->GetAttribute("stripped"); boolean stripped_flag = stripped_string ? strcmp(stripped_string, "true")==0 : false; if (ed->GetWindow() == nil) { TextObserver* mousedoc_observer = new TextObserver(ed->MouseDocObservable(), ""); WidgetKit& wk = *WidgetKit::instance(); const LayoutKit& layout = *LayoutKit::instance(); PolyGlyph* topbox = layout.vbox(); Glyph* menus = kit->MakeMenus(); Glyph* states = kit->MakeStates(); Glyph* toolbar = kit->MakeToolbar(); if (stripped_flag) { Target* viewer = new Target(new Frame(ed->Interior()), TargetPrimitiveHit); ed->body(viewer); topbox->append(ed); } else { if (states) menus->append(states); Target* viewer = new Target(new Frame(kit->Interior()), TargetPrimitiveHit); Catalog* catalog = unidraw->GetCatalog(); if (const char* toolbarloca = catalog->GetAttribute("toolbarloc")) { if (strcmp(toolbarloca, "r") == 0) toolbar->prepend(layout.vcenter(viewer)); else /* if (strcmp(toolbarloca, "l") == 0) */ toolbar->append(layout.vcenter(viewer)); } else toolbar->append(layout.vcenter(viewer)); menus->append(toolbar); Style* style = Session::instance()->style(); boolean bookgeom = style->value_is_on("bookgeom"); ed->body(menus); ed->GetKeyMap()->Execute(CODE_SELECT); topbox->append(ed); if (!bookgeom) { boolean set_flag = kit->set_button_flag(); boolean clr_flag = kit->clr_button_flag(); EivTextEditor* texteditor = nil; if(!set_flag && !clr_flag) { texteditor = new ComTextEditor(wk.style(), ed->comterp()); } else texteditor = new EivTextEditor(wk.style()); ((FrameEditor*)ed)->_texteditor = texteditor; Button* set = set_flag ? wk.push_button("Set", new ActionCallback(FrameEditor) ((FrameEditor*)ed, &FrameEditor::SetText)) : nil; Button* clear = clr_flag ? wk.push_button("Clear", new ActionCallback(FrameEditor) ((FrameEditor*)ed, &FrameEditor::ClearText)) : nil; Glyph* buttonbox = nil; if (set && !clear) { buttonbox = layout.vbox(layout.hcenter(set)); } else if (!set && clear) { buttonbox = layout.vbox(layout.hcenter(clear)); } else if (set && clear) { buttonbox = layout.vbox( layout.hcenter(set), layout.vspace(10), layout.hcenter(clear) ); } if (buttonbox) { topbox->append( wk.outset_frame( layout.hbox( layout.vcenter( layout.margin( buttonbox, 10 ) ), layout.vcenter(texteditor) ) ) ); } else { topbox->append( wk.outset_frame( layout.hbox( layout.vcenter( layout.margin( layout.vbox( #if 0 wk.label("type help"), layout.vspace(10), wk.label("to print"), layout.vspace(10), wk.label("info to stdout") #else kit->appicon() #endif ), 10 ) ), layout.vcenter(texteditor) ) ) ); } } } ManagedWindow* w = new ApplicationWindow(topbox); ed->SetWindow(w); Style* s = new Style(Session::instance()->style()); s->alias(name); w->style(s); } } MenuItem * FrameKit::MakeFileMenu() { LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); MenuItem *mbi = kit.menubar_item(kit.label("File")); mbi->menu(kit.pulldown()); MakeMenu(mbi, new OvAboutCmd(new ControlInfo("About flipbook", "", "")), "About flipbook "); MakeMenu(mbi, new OvNewCompCmd(new ControlInfo("New", KLBL_NEWCOMP, CODE_NEWCOMP), new FrameIdrawComp), "New "); MakeMenu(mbi, new OvRevertCmd(new ControlInfo("Revert", KLBL_REVERT, CODE_REVERT)), "Revert "); MakeMenu(mbi, new OvOpenCmd(new ControlInfo("Open...", KLBL_VIEWCOMP, CODE_VIEWCOMP)), "Open... "); MakeMenu(mbi, new OvSaveCompCmd(new ControlInfo("Save", KLBL_SAVECOMP, CODE_SAVECOMP), new SaveAsChooser(".", &kit, kit.style())), "Save "); MakeMenu(mbi, new OvSaveCompAsCmd(new ControlInfo("Save As...", KLBL_SAVECOMPAS, CODE_SAVECOMPAS), new SaveAsChooser(".", &kit, kit.style())), "Save As... "); MakeMenu(mbi, new OvPrintCmd(new ControlInfo("Print...", KLBL_PRINT, CODE_PRINT)), "Print... "); MakeMenu(mbi, new FrameImportCmd(new ControlInfo("Import Graphic...", KLBL_IMPORT, CODE_IMPORT)), "Import Graphic... "); MakeMenu(mbi, new OvExportCmd(new ControlInfo("Export Graphic...", "^X", "\030")), "Export Graphic... "); MakeMenu(mbi, new OvWindowDumpAsCmd(new ControlInfo("Dump Window As..." )), "Dump Window As... "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new OvQuitCmd(new ControlInfo("Quit", KLBL_QUIT, CODE_QUIT)), "Quit "); return mbi; } MenuItem* FrameKit::MakeFrameMenu() { LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); MenuItem *mbi = kit.menubar_item(kit.label("Frame")); mbi->menu(kit.pulldown()); MoveFrameCmd::default_instance (new MoveFrameCmd(new ControlInfo("Move Forward","^F",""), +1)); MakeMenu(mbi, MoveFrameCmd::default_instance(), "Move Forward "); MakeMenu(mbi, new MoveFrameCmd(new ControlInfo("Move Backward","^B",""), -1), "Move Backward "); MakeMenu(mbi, new FrameBeginCmd(new ControlInfo("Goto First Frame")), "Goto First Frame"); MakeMenu(mbi, new FrameEndCmd(new ControlInfo("Goto Last Frame")), "Goto Last Frame "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new CreateMoveFrameCmd(new ControlInfo("New Forward","F","F")), "New Forward "); MakeMenu(mbi, new CreateMoveFrameCmd(new ControlInfo("New Backward","B","B"), false), "New Backward "); MakeMenu(mbi, new CopyMoveFrameCmd(new ControlInfo("Copy Forward","X","X")), "Copy Forward "); MakeMenu(mbi, new CopyMoveFrameCmd(new ControlInfo("Copy Backward","Y","Y"), false), "Copy Backward "); MakeMenu(mbi, new DeleteFrameCmd(new ControlInfo("Delete","D","D")), "Delete "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new ShowOtherFrameCmd(new ControlInfo("Show Prev Frame","",""), -1), "Show Prev Frame"); MakeMenu(mbi, new ShowOtherFrameCmd(new ControlInfo("Hide Prev Frame","",""), 0), "Hide Prev Frame"); MenuItem* menu_item; menu_item = kit.menu_item(kit.label("Enable Looping")); menu_item->action (new ActionCallback(MoveFrameCmd) (MoveFrameCmd::default_instance(), &MoveFrameCmd::set_wraparound)); mbi->menu()->append_item(menu_item); menu_item = kit.menu_item(kit.label("Disable Looping")); menu_item->action (new ActionCallback(MoveFrameCmd) (MoveFrameCmd::default_instance(), &MoveFrameCmd::clr_wraparound)); mbi->menu()->append_item(menu_item); #if 0 MakeMenu(mbi, new AutoNewFrameCmd(new ControlInfo("Toggle Auto New Frame", "","")), "Toggle Auto New Frame"); #else menu_item = kit.check_menu_item(kit.label("Auto New Frame")); menu_item->state()->set(TelltaleState::is_chosen, ((FrameEditor*)GetEditor())->AutoNewFrame()); ((FrameEditor*)GetEditor())->_autonewframe_tts = menu_item->state(); AutoNewFrameCmd::default_instance(new AutoNewFrameCmd(GetEditor())); menu_item->action (new ActionCallback(AutoNewFrameCmd) (AutoNewFrameCmd::default_instance(), &AutoNewFrameCmd::Execute)); mbi->menu()->append_item(menu_item); #endif return mbi; } MenuItem* FrameKit::MakeStructureMenu() { LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); MenuItem *mbi = kit.menubar_item(kit.label("Structure")); mbi->menu(kit.pulldown()); MakeMenu(mbi, new FrameGroupCmd(new ControlInfo("Group", KLBL_GROUP, CODE_GROUP)), "Group "); MakeMenu(mbi, new FrameUngroupCmd(new ControlInfo("Ungroup", KLBL_UNGROUP, CODE_UNGROUP)), "Ungroup "); MakeMenu(mbi, new FrameFrontCmd(new ControlInfo("Bring to Front", KLBL_FRONT, CODE_FRONT)), "Bring to Front "); MakeMenu(mbi, new FrameBackCmd(new ControlInfo("Send to Back", KLBL_BACK, CODE_BACK)), "Send to Back "); return mbi; } MenuItem* FrameKit::MakeEditMenu() { LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); MenuItem *mbi = kit.menubar_item(kit.label("Edit")); mbi->menu(kit.pulldown()); MakeMenu(mbi, new UndoCmd(new ControlInfo("Undo", KLBL_UNDO, CODE_UNDO)), "Undo "); MakeMenu(mbi, new RedoCmd(new ControlInfo("Redo", KLBL_REDO, CODE_REDO)), "Redo "); MakeMenu(mbi, new CutCmd(new ControlInfo("Cut", KLBL_CUT, CODE_CUT)), "Cut "); MakeMenu(mbi, new FrameCopyCmd(new ControlInfo("Copy", KLBL_COPY, CODE_COPY)), "Copy "); MakeMenu(mbi, new PasteCmd(new ControlInfo("Paste", KLBL_PASTE, CODE_PASTE)), "Paste "); MakeMenu(mbi, new DupCmd(new ControlInfo("Duplicate", KLBL_DUP, CODE_DUP)), "Duplicate "); MakeMenu(mbi, new OvDeleteCmd(new ControlInfo("Delete", KLBL_DEL, CODE_DEL)), "Delete "); MakeMenu(mbi, new OvSlctAllCmd(new ControlInfo("Select All", KLBL_SLCTALL, CODE_SLCTALL)), "Select All "); MakeMenu(mbi, new SlctByAttrCmd(new ControlInfo("Select by Attribute", "$", "$")), "Select by Attribute "); MakeMenu(mbi, new SetAttrByExprCmd(new ControlInfo("Compute Attributes ", "#", "#")), "Compute Attributes "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new ScaleCmd(new ControlInfo("Flip Horizontal", KLBL_HFLIP, CODE_HFLIP), -1.0, 1.0), "Flip Horizontal "); MakeMenu(mbi, new ScaleCmd(new ControlInfo("Flip Vertical", KLBL_VFLIP, CODE_VFLIP), 1.0, -1.0), "Flip Vertical "); MakeMenu(mbi, new RotateCmd(new ControlInfo("90 Clockwise", KLBL_CW90, CODE_CW90), -90.0), "90 Clockwise "); MakeMenu(mbi, new RotateCmd(new ControlInfo("90 CounterCW", KLBL_CCW90, CODE_CCW90), 90.0), "90 CounterCW "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new OvPreciseMoveCmd(new ControlInfo("Precise Move", KLBL_PMOVE, CODE_PMOVE)), "Precise Move "); MakeMenu(mbi, new OvPreciseScaleCmd(new ControlInfo("Precise Scale", KLBL_PSCALE, CODE_PSCALE)), "Precise Scale "); MakeMenu(mbi, new OvPreciseRotateCmd(new ControlInfo("Precise Rotate", KLBL_PROTATE, CODE_PROTATE)), "Precise Rotate "); return mbi; } // upgrade to copy of OverlayKit::MakeViewMenu 3/24/99 #if 0 MenuItem* FrameKit::MakeViewMenu() { LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); MenuItem* mbi = kit.menubar_item(kit.label("View")); mbi->menu(kit.pulldown()); #if 0 MakeMenu(mbi, new FrameNewViewCmd(new ControlInfo("New View", KLBL_NEWVIEW, CODE_NEWVIEW)), "New View "); MakeMenu(mbi, new OvCloseEditorCmd(new ControlInfo("Close View", KLBL_CLOSEEDITOR, CODE_CLOSEEDITOR)), "Close View "); mbi->menu()->append_item(kit.menu_item_separator()); #endif MakeMenu(mbi, new PageCmd(new ControlInfo("Page on/off", "p", "p")), "Page on/off "); MakeMenu(mbi, new NormSizeCmd(new ControlInfo("Normal Size", KLBL_NORMSIZE, CODE_NORMSIZE)), "Normal Size "); MakeMenu(mbi, new RedToFitCmd(new ControlInfo("Reduce to Fit", KLBL_REDTOFIT, CODE_REDTOFIT)), "Reduce to Fit "); MakeMenu(mbi, new CenterCmd(new ControlInfo("Center Page", KLBL_CENTER, CODE_CENTER)), "Center Page "); MakeMenu(mbi, new OrientationCmd(new ControlInfo("Orientation", KLBL_ORIENTATION, CODE_ORIENTATION)), "Orientation "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new GridCmd(new ControlInfo("Grid on/off", KLBL_GRID, CODE_GRID)), "Grid on/off "); MakeMenu(mbi, new GridSpacingCmd(new ControlInfo("Grid Spacing...", KLBL_GRIDSPC, CODE_GRIDSPC)), "Grid Spacing... "); MakeMenu(mbi, new GravityCmd(new ControlInfo("Gravity on/off", KLBL_GRAVITY, CODE_GRAVITY)), "Gravity on/off "); mbi->menu()->append_item(kit.menu_item_separator()); MenuItem* zoomi = kit.menu_item(kit.label("Zoom ")); Menu* zoom = kit.pullright(); zoomi->menu(zoom); MakeMenu(zoomi, new ZoomCmd(new ControlInfo("Zoom In", "Z", "Z"), 2.0), "Zoom In "); MakeMenu(zoomi, new ZoomCmd(new ControlInfo("Zoom Out", "^Z", "\032"), 0.5), "Zoom Out "); MakeMenu(zoomi, new PreciseZoomCmd(new ControlInfo("Precise Zoom")), "Precise Zoom "); mbi->menu()->append_item(zoomi); MenuItem* spani = kit.menu_item(kit.label("Small Pan ")); Menu* span = kit.pullright(); spani->menu(span); MakeMenu(spani, new FixedPanCmd(new ControlInfo("Small Pan Up"), NO_PAN, PLUS_SMALL_PAN), "Small Pan Up "); MakeMenu(spani, new FixedPanCmd(new ControlInfo("Small Pan Down"), NO_PAN, MINUS_SMALL_PAN), "Small Pan Down "); MakeMenu(spani, new FixedPanCmd(new ControlInfo("Small Pan Left"), MINUS_SMALL_PAN, NO_PAN), "Small Pan Left "); MakeMenu(spani, new FixedPanCmd(new ControlInfo("Small Pan Right"), PLUS_SMALL_PAN, NO_PAN), "Small Pan Right "); mbi->menu()->append_item(spani); MenuItem* lpani = kit.menu_item(kit.label("Large Pan ")); Menu* lpan = kit.pullright(); lpani->menu(lpan); MakeMenu(lpani, new FixedPanCmd(new ControlInfo("Large Pan Up"), NO_PAN, PLUS_LARGE_PAN), "Large Pan Up "); MakeMenu(lpani, new FixedPanCmd(new ControlInfo("Large Pan Down"), NO_PAN, MINUS_LARGE_PAN), "Large Pan Down "); MakeMenu(lpani, new FixedPanCmd(new ControlInfo("Large Pan Left"), MINUS_LARGE_PAN, NO_PAN), "Large Pan Left "); MakeMenu(lpani, new FixedPanCmd(new ControlInfo("Large Pan Right"), PLUS_LARGE_PAN, NO_PAN), "Large Pan Right "); mbi->menu()->append_item(lpani); MakeMenu(mbi, new PrecisePanCmd(new ControlInfo("Precise Pan")), "Precise Pan "); return mbi; } #else MenuItem* FrameKit::MakeViewMenu() { LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); MenuItem* mbi = kit.menubar_item(kit.label("View")); mbi->menu(kit.pulldown()); #if 0 OvNewViewCmd::default_instance (new OvNewViewCmd (new ControlInfo("New View", KLBL_NEWVIEW, CODE_NEWVIEW), "localhost:0.0")); MakeMenu(mbi, OvNewViewCmd::default_instance(), "New View "); MakeMenu(mbi, new OvCloseEditorCmd(new ControlInfo("Close View", KLBL_CLOSEEDITOR, CODE_CLOSEEDITOR)), "Close View "); #endif #if 0 MenuItem* menu_item; menu_item = kit.menu_item(kit.label("New Display")); menu_item->action (new ActionCallback(OvNewViewCmd) (OvNewViewCmd::default_instance(), &OvNewViewCmd::set_display)); mbi->menu()->append_item(menu_item); mbi->menu()->append_item(kit.menu_item_separator()); #endif MakeMenu(mbi, new PageCmd(new ControlInfo("Page on/off", "p", "p")), "Page on/off "); MakeMenu(mbi, new OvPrecisePageCmd(new ControlInfo("Precise Page", "^P", "\020")), "Precise Page "); MakeMenu(mbi, new NormSizeCmd(new ControlInfo("Normal Size", KLBL_NORMSIZE, CODE_NORMSIZE)), "Normal Size "); MakeMenu(mbi, new RedToFitCmd(new ControlInfo("Reduce to Fit", KLBL_REDTOFIT, CODE_REDTOFIT)), "Reduce to Fit "); MakeMenu(mbi, new CenterCmd(new ControlInfo("Center Page", KLBL_CENTER, CODE_CENTER)), "Center Page "); MakeMenu(mbi, new OrientationCmd(new ControlInfo("Orientation", KLBL_ORIENTATION, CODE_ORIENTATION)), "Orientation "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new GridCmd(new ControlInfo("Grid on/off", KLBL_GRID, CODE_GRID)), "Grid on/off "); MakeMenu(mbi, new GridSpacingCmd(new ControlInfo("Grid Spacing...", KLBL_GRIDSPC, CODE_GRIDSPC)), "Grid Spacing... "); MakeMenu(mbi, new GravityCmd(new ControlInfo("Gravity on/off", KLBL_GRAVITY, CODE_GRAVITY)), "Gravity on/off "); MakeMenu(mbi, new ScribblePointerCmd(new ControlInfo("Scribble pointer on/off", "", "")), "Scribble pointer on/off "); mbi->menu()->append_item(kit.menu_item_separator()); MenuItem* zoomi = kit.menu_item(kit.label("Zoom ")); Menu* zoom = kit.pullright(); zoomi->menu(zoom); MakeMenu(zoomi, new ZoomCmd(new ControlInfo("Zoom In", "Z", "Z"), 2.0), "Zoom In "); MakeMenu(zoomi, new ZoomCmd(new ControlInfo("Zoom Out", "^Z", ""), 0.5), "Zoom Out "); MakeMenu(zoomi, new PreciseZoomCmd(new ControlInfo("Precise Zoom")), "Precise Zoom "); mbi->menu()->append_item(zoomi); MenuItem* spani = kit.menu_item(kit.label("Small Pan ")); Menu* span = kit.pullright(); spani->menu(span); MakeMenu(spani, new FixedPanCmd(new ControlInfo("Small Pan Up"), NO_PAN, PLUS_SMALL_PAN), "Small Pan Up "); MakeMenu(spani, new FixedPanCmd(new ControlInfo("Small Pan Down"), NO_PAN, MINUS_SMALL_PAN), "Small Pan Down "); MakeMenu(spani, new FixedPanCmd(new ControlInfo("Small Pan Left"), MINUS_SMALL_PAN, NO_PAN), "Small Pan Left "); MakeMenu(spani, new FixedPanCmd(new ControlInfo("Small Pan Right"), PLUS_SMALL_PAN, NO_PAN), "Small Pan Right "); mbi->menu()->append_item(spani); MenuItem* lpani = kit.menu_item(kit.label("Large Pan ")); Menu* lpan = kit.pullright(); lpani->menu(lpan); MakeMenu(lpani, new FixedPanCmd(new ControlInfo("Large Pan Up"), NO_PAN, PLUS_LARGE_PAN), "Large Pan Up "); MakeMenu(lpani, new FixedPanCmd(new ControlInfo("Large Pan Down"), NO_PAN, MINUS_LARGE_PAN), "Large Pan Down "); MakeMenu(lpani, new FixedPanCmd(new ControlInfo("Large Pan Left"), MINUS_LARGE_PAN, NO_PAN), "Large Pan Left "); MakeMenu(lpani, new FixedPanCmd(new ControlInfo("Large Pan Right"), PLUS_LARGE_PAN, NO_PAN), "Large Pan Right "); mbi->menu()->append_item(lpani); MakeMenu(mbi, new PrecisePanCmd(new ControlInfo("Precise Pan")), "Precise Pan "); mbi->menu()->append_item(kit.menu_item_separator()); #if 0 MenuItem* grmenu = kit.menu_item(kit.label("Hide/Show Graphics ")); grmenu->menu(kit.pullright()); mbi->menu()->append_item(grmenu); MakeMenu(grmenu, new HideViewCmd(_ed->GetViewer(), new ControlInfo("Hide Graphic Here", "H", "H")), "Hide Graphic Here"); MakeMenu(grmenu, new UnhideViewsCmd(new ControlInfo("Unhide Graphics There", "^H", "\010")), "Unhide Graphics There"); MakeMenu(grmenu, new DesensitizeViewCmd(_ed->GetViewer(), new ControlInfo("Desensitize Graphic Here", "", "")), "Desensitize Graphic Here"); MakeMenu(grmenu, new SensitizeViewsCmd(new ControlInfo("Sensitize Graphics There", "", "")), "Sensitize Graphics There"); #endif MenuItem* fixmenu = kit.menu_item(kit.label("Fix/Unfix Graphics ")); fixmenu->menu(kit.pullright()); mbi->menu()->append_item(fixmenu); MakeMenu(fixmenu, new FixViewCmd(new ControlInfo("Fix Size", " ", " "), true, false), "Fix Size"); MakeMenu(fixmenu, new UnfixViewCmd(new ControlInfo("Unfix Size", " ", " "), true, false), "Unfix Size"); MakeMenu(fixmenu, new FixViewCmd(new ControlInfo("Fix Location", " ", " "), false, true), "Fix Location"); MakeMenu(fixmenu, new UnfixViewCmd(new ControlInfo("Unfix Location", " ", " "), false, true), "Unfix Location"); #if 0 MenuItem* chainmenu = kit.menu_item(kit.label("Chain/Unchain Viewers ")); chainmenu->menu(kit.pullright()); mbi->menu()->append_item(chainmenu); MakeMenu(chainmenu, new ChainViewersCmd(_ed->GetViewer(), new ControlInfo("Chain Panning", " ", " "), true, false), "Chain Panning"); MakeMenu(chainmenu, new UnchainViewersCmd(_ed->GetViewer(), new ControlInfo("Unchain Panning", " ", " "), true, false), "Unchain Panning"); MakeMenu(chainmenu, new ChainViewersCmd(_ed->GetViewer(), new ControlInfo("Chain Zooming", " ", " "), false, true), "Chain Zooming"); MakeMenu(chainmenu, new UnchainViewersCmd(_ed->GetViewer(), new ControlInfo("Unchain Zooming", " ", " "), false, true), "Unchain Zooming"); #endif return mbi; } #endif Glyph* FrameKit::MakeStates() { ((FrameEditor*)_ed)->_framenumstate = new FrameNumberState(); ((FrameEditor*)_ed)->_frameliststate = new FrameListState(); NameView* fnumview = new NameView(((FrameEditor*)_ed)->framenumstate()); NameView* flistview = new NameView(((FrameEditor*)_ed)->frameliststate()); LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); return kit.inset_frame( lk.margin( lk.hbox(fnumview, lk.hspace(40), flistview, lk.hglue()), 4, 2 ) ); } ivtools-1.2.11a1/src/FrameUnidraw/framekit.h000066400000000000000000000041061214471147700206540ustar00rootroot00000000000000/* * Copyright (c) 1996-1999 Vectaport Inc. * Copyright (c) 1994, 1995 Vectaport Inc., Cartoactive Systems * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * FrameKit - object to construct objects for an FrameEditor */ #ifndef frame_kit_h #define frame_kit_h #include #include class EivTextEditor; class FrameEditor; //: derived OverlayKit for use with FrameEditor. class FrameKit : public OverlayKit { public: FrameKit(); virtual void InitViewer(); virtual void InitLayout(const char* name); static void InitLayout(OverlayKit* kit, const char* name); virtual MenuItem* MakeFileMenu(); virtual MenuItem* MakeEditMenu(); virtual MenuItem* MakeStructureMenu(); virtual MenuItem* MakeViewMenu(); virtual MenuItem* MakeFrameMenu(); virtual Glyph* MakeStates(); static FrameKit* Instance(); protected: static FrameKit* _framekit; }; #include #include #endif ivtools-1.2.11a1/src/FrameUnidraw/frameps.cc000066400000000000000000000072071214471147700206520ustar00rootroot00000000000000/* * Copyright (c) 1994, 1995 Vectaport Inc., Cartoactive Systems * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * FrameIdrawPS definition */ #include #include #include #include #include #include #include /*****************************************************************************/ static Transformer* SaveTransformer (Graphic* g) { Transformer* orig = g->GetTransformer(); Ref(orig); g->SetTransformer(new Transformer(orig)); return orig; } static void RestoreTransformer (Graphic* g, Transformer* orig) { g->SetTransformer(orig); Unref(orig); } // ScaleToPostscriptCoords scales the picture to Postscript // coordinates if screen and Postscript inches are different. static void ScaleToPostScriptCoords (Graphic* g) { const double ps_inch = 72.; if (ivinch != ps_inch) { double factor = ps_inch / ivinch; g->Scale(factor, factor); } } /*****************************************************************************/ FrameIdrawPS::FrameIdrawPS (FrameIdrawComp* subj) : OverlayIdrawPS(subj) { } ClassId FrameIdrawPS::GetClassId () { return FRAME_IDRAW_PS; } boolean FrameIdrawPS::IsA (ClassId id) { return FRAME_IDRAW_PS == id || OverlayIdrawPS::IsA(id); } boolean FrameIdrawPS::Emit (ostream& out) { SetPSFonts(); Graphic* g = GetGraphicComp()->GetGraphic(); Transformer* t = SaveTransformer(g); ScaleToPostScriptCoords(g); Comments(out); Prologue(out); Version(out); GridSpacing(out); /* count up number of pages (not counting the zeroth) */ Iterator i; int npage = -1; for (First(i); !Done(i); Next(i)) npage++; /* loop through the first through nth page */ First(i); Next(i); Iterator j; First(j); boolean status = true; int pagenum = 1; while (status && !Done(i)) { out << "\n\n%%Page: " << pagenum << " " << npage << "\n\n"; out << "Begin\n"; FullGS(out); out << "/originalCTM matrix currentmatrix def\n\n"; status = ((PostScriptView*)GetView(j))->PreorderView::Definition(out); if (!status) break; out << "\n"; status = ((PostScriptView*)GetView(i))->PreorderView::Definition(out); if (!status) break; out << "End " << MARK << " eop\n\n"; out << "showpage\n\n"; Next(i); pagenum++; } /* done looping through the first through nth page */ Trailer(out); RestoreTransformer(g, t); return status; } ivtools-1.2.11a1/src/FrameUnidraw/frameps.h000066400000000000000000000035231214471147700205110ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1994, 1995 Vectaport Inc., Cartoactive Systems * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * FrameIdrawPS and related classes */ #ifndef framepsview_h #define framepsview_h #include #include class FrameIdrawComp; //: "PostScript" view of FrameIdrawComp. // this generates a multi-page "PostScript" document that is // not necessarily in idraw format. class FrameIdrawPS : public OverlayIdrawPS { public: FrameIdrawPS(FrameIdrawComp* = nil); virtual boolean Emit(ostream&); protected: virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #include #endif ivtools-1.2.11a1/src/FrameUnidraw/framescripts.cc000066400000000000000000000251321214471147700217140ustar00rootroot00000000000000/* * Copyright (c) 1994, 1995 Vectaport * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representation about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * FrameScript* and FrameIdrawScript implementation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::cerr; /*****************************************************************************/ FrameOverlaysScript::FrameOverlaysScript (FrameOverlaysComp* subj) : OverlaysScript(subj) {} ClassId FrameOverlaysScript::GetClassId () { return FRAME_OVERLAYS_SCRIPT; } boolean FrameOverlaysScript::IsA (ClassId id) { return FRAME_OVERLAYS_SCRIPT == id || OverlaysScript::IsA(id); } /*****************************************************************************/ FrameScript::FrameScript (FrameComp* subj) : OverlaysScript(subj) { _suppress_frame = false; } ClassId FrameScript::GetClassId () { return FRAME_SCRIPT; } boolean FrameScript::IsA (ClassId id) { return FRAME_SCRIPT == id || OverlaysScript::IsA(id); } boolean FrameScript::Definition (ostream& out) { Iterator i; boolean status = true; if (!_suppress_frame) out << "frame(\n"; static int readonly_symval = symbol_add("readonly"); boolean outflag = false; for (First(i); status && !Done(i); ) { OverlayScript* sv = (OverlayScript*)GetView(i); boolean readonly = false; AttributeList* al; if (al = sv->GetOverlayComp()->attrlist()) { AttributeValue* av = al->find(readonly_symval); if (av) readonly = av->is_true(); } if (!readonly) { if (outflag) out << ",\n"; Indent(out); status = sv->Definition(out); outflag = true; } Next(i); } out << "\n"; Indent(out); Attributes(out); if (!_suppress_frame) out << ")"; return status; } int FrameScript::ReadChildren (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { OverlayComp* child = nil; OverlaysComp* comps = (OverlaysComp*)addr1; char buf1[BUFSIZ]; char buf2[BUFSIZ]; char* buf = buf1; while (in.good()) { if (read_name(in, buf, BUFSIZ)) break; int status; if (status = read_gsptspic(buf, in, comps)) { if (status==-1) break; } else { child = read_obj(buf, in, comps); if (!child) return -1; } if (child) { if (in.good() && child->valid()) { comps->Append(child); } else { /* report failure even if one child fails */ if (!*buf && (buf==buf1 ? *buf2 : *buf1)) cerr << "Error after reading " << (buf==buf1 ? buf2 : buf1) << "\n"; delete child; return -1; } } buf = buf==buf1 ? buf2 : buf1; } return 0; } boolean FrameScript::EmitPic(ostream& out, Clipboard* cb1, Clipboard* cb2, boolean prevout) { Iterator i; for (First(i); !Done(i); Next(i)) { prevout = GetScript(i)->EmitPic(out, cb1, cb2, prevout); } return prevout; } /*****************************************************************************/ ClassId FramesScript::GetClassId () { return FRAMES_SCRIPT; } boolean FramesScript::IsA (ClassId id) { return FRAMES_SCRIPT == id || FrameScript::IsA(id); } FramesScript::FramesScript (FramesComp* subj) : FrameScript(subj) {} boolean FramesScript::Definition (ostream& out) { Iterator i; boolean status = true; Clipboard* cb = GetPicList(); if (cb) { out << "frames( :pic " << MatchedPic(cb); } else { out << "frames(\n"; static int readonly_symval = symbol_add("readonly"); boolean outflag = false; for (First(i); status && !Done(i); ) { OverlayScript* sv = (OverlayScript*)GetView(i); boolean readonly = false; AttributeList* al; if (al = sv->GetOverlayComp()->attrlist()) { AttributeValue* av = al->find(readonly_symval); if (av) readonly = av->is_true(); } if (!readonly) { if (outflag) out << ",\n"; Indent(out); status = sv->Definition(out); outflag = true; } Next(i); } } if (!cb) { out << "\n"; Indent(out); Attributes(out); } else { Transformation(out); } out << ")"; return status; } int FramesScript::ReadFrames (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { FrameComp* frame; FrameFileComp* framefile; OverlayComp* child; FramesComp* comps = (FramesComp*)addr1; char buf1[BUFSIZ]; char buf2[BUFSIZ]; char* buf = buf1; FrameComp* bgframe = nil; Iterator it; comps->First(it); if (!comps->Done(it)) { OverlayComp* comp = (OverlayComp*) comps->GetComp(it); if (comp->IsA(FRAME_COMP)) bgframe = (FrameComp*) comp; } while (in.good()) { frame = nil; framefile = nil; child = nil; if (read_name(in, buf, BUFSIZ)) break; int status; if (status = read_gsptspic(buf, in, comps)) { if (status==-1) break; } else if (strcmp(buf, "frame") == 0) { frame = new FrameComp(in, comps); if (!bgframe) bgframe = frame; } else if (strcmp(buf, "framefile") == 0) framefile = new FrameFileComp(in, comps); else { if (!bgframe) { bgframe = new FrameComp(comps); comps->Append(bgframe); } child = read_obj(buf, in, bgframe); if (!child) return -1; } if (frame != nil) { if (in.good() && frame->valid()) { comps->Append(frame); } else { /* report failure even if one child fails */ delete frame; return -1; } } if (framefile != nil) { Iterator j; framefile->First(j); FrameIdrawComp* frameidraw = (FrameIdrawComp*)framefile->GetComp(j); if (in.good() && frameidraw->valid()) { Iterator i; frameidraw->First(i); frameidraw->Next(i); while (!frameidraw->Done(i)) { comps->Append((GraphicComp*)frameidraw->GetComp(i)); frameidraw->Next(i); } } else { /* report failure even if one child fails */ delete framefile; return -1; } } if (child) { if (in.good() && child->valid()) { bgframe->Append(child); } else { /* report failure even if one child fails */ if (!*buf && (buf==buf1 ? *buf2 : *buf1)) cerr << "Error after reading " << (buf==buf1 ? buf2 : buf1) << "\n"; delete child; return -1; } } buf = buf==buf1 ? buf2 : buf1; } return 0; } /*****************************************************************************/ FrameIdrawScript::FrameIdrawScript (FrameIdrawComp* subj) : FramesScript(subj) { _gslist = nil; _ptslist = nil; _piclist1 = _piclist2 = nil; _gs_compacted = _pts_compacted = _pic_compacted = false; _by_pathname = true; } FrameIdrawScript::~FrameIdrawScript() { delete _gslist; delete _ptslist; delete _piclist1; delete _piclist2; } ClassId FrameIdrawScript::GetClassId () { return FRAME_IDRAW_SCRIPT; } boolean FrameIdrawScript::IsA (ClassId id) { return FRAME_IDRAW_SCRIPT == id || FramesScript::IsA(id); } boolean FrameIdrawScript::EmitPic(ostream& out, Clipboard* cb1, Clipboard* cb2, boolean prevout) { Iterator i; for (First(i); !Done(i); Next(i)) { prevout = GetScript(i)->EmitPic(out, cb1, cb2, prevout); } return prevout; } boolean FrameIdrawScript::Emit (ostream& out) { out << "flipbook("; /* make list and output unique point lists */ boolean prevout = false; if (_pts_compacted) { _ptslist = new Clipboard(); prevout = EmitPts(out, _ptslist, prevout); } /* make list and output unique graphic states */ if (_gs_compacted) { _gslist = new Clipboard(); prevout = EmitGS(out, _gslist, prevout); } /* make list and output unique picture graphics */ if (_pic_compacted) { _piclist1 = new Clipboard(); _piclist2 = new Clipboard(); prevout = EmitPic(out, _piclist1, _piclist2, prevout); } /* output graphic components */ boolean status = true; Iterator i; First(i); if (!Done(i) ) { if (prevout) out << ","; out << "\n"; } static int readonly_symval = symbol_add("readonly"); boolean outflag = false; for (; status && !Done(i); ) { OverlayScript* ev = (OverlayScript*)GetView(i); boolean readonly = false; AttributeList* al; if (al = ev->GetOverlayComp()->attrlist()) { AttributeValue* av = al->find(readonly_symval); if (av) readonly = av->is_true(); } if (!readonly) { if (outflag) out << ",\n"; Indent(out); status = ev->Definition(out); outflag = true; } Next(i); } out << "\n"; FullGS(out); Annotation(out); Attributes(out); out << ")\n"; return status; } Clipboard* FrameIdrawScript::GetGSList() { return _gslist; } Clipboard* FrameIdrawScript::GetPtsList() { return _ptslist; } Clipboard* FrameIdrawScript::GetPicList() { return _piclist1; } void FrameIdrawScript::SetCompactions(boolean gs, boolean pts, boolean pic) { _gs_compacted = gs; _pts_compacted = pts; _pic_compacted = pic; } void FrameIdrawScript::SetByPathnameFlag(boolean flag) { _by_pathname = flag; } boolean FrameIdrawScript::GetByPathnameFlag() { return _by_pathname; } ivtools-1.2.11a1/src/FrameUnidraw/framescripts.h000066400000000000000000000066231214471147700215620ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1994, 1995, 1999 Vectaport * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representation about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * FrameScript* and FrameIdrawScript - command-oriented external * representation of frame components */ #ifndef frame_scripts_h #define frame_scripts_h #include #include class Clipboard; class FrameOverlaysComp; class FrameComp; class FramesComp; class FrameIdrawComp; #include //: serialized view of FrameOverlaysComp. class FrameOverlaysScript : OverlaysScript { public: virtual ClassId GetClassId(); virtual boolean IsA(ClassId); FrameOverlaysScript(FrameOverlaysComp* = nil); }; //: serialized view of FrameComp. class FrameScript : public OverlaysScript { public: virtual ClassId GetClassId(); virtual boolean IsA(ClassId); FrameScript(FrameComp* = nil); virtual boolean Definition(ostream&); static int ReadChildren(istream&, void*, void*, void*, void*); virtual boolean EmitPic(ostream&, Clipboard*, Clipboard*, boolean); void suppress_frame() { _suppress_frame = true; } protected: boolean _suppress_frame; }; //: serialized view of FramesComp. class FramesScript : public FrameScript { public: virtual ClassId GetClassId(); virtual boolean IsA(ClassId); FramesScript(FramesComp* = nil); virtual boolean Definition(ostream&); static int ReadFrames(istream& in, void* addr1, void* addr2, void* addr3, void* addr4); }; //: serialized view of FrameIdrawComp. class FrameIdrawScript : public FramesScript { public: virtual ClassId GetClassId(); virtual boolean IsA(ClassId); FrameIdrawScript(FrameIdrawComp* = nil); virtual ~FrameIdrawScript(); virtual void SetCompactions (boolean gs = false, boolean pts = false, boolean pic=false); virtual boolean EmitPic(ostream&, Clipboard*, Clipboard*, boolean); virtual boolean Emit(ostream&); virtual Clipboard* GetGSList(); virtual Clipboard* GetPtsList(); virtual Clipboard* GetPicList(); virtual void SetByPathnameFlag(boolean); virtual boolean GetByPathnameFlag(); protected: Clipboard* _gslist; Clipboard* _ptslist; Clipboard* _piclist1; Clipboard* _piclist2; boolean _gs_compacted; boolean _pts_compacted; boolean _pic_compacted; boolean _by_pathname; }; #endif ivtools-1.2.11a1/src/FrameUnidraw/framestates.cc000066400000000000000000000055511214471147700215330ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc * Copyright (c) 1994, 1995 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include

// In this way other classes can be derived from OverlayKit with different // virtual methods for initializing the pull-down menus and toolbars, and can // completely change the appearance and functionality of essentially the same // OverlayEditor. //

// Another feature of the OverlayKit idea is it solves the problem of what to // do when a particular vertical application wants to use the features of two // different derivations of an OverlayEditor. Prior to OverlayKit you would need // to use multiple-inheritance, which can have problems, or permanently decide // on the ordering of one derived editor relative to the other, which may be // undesirable in future circumstances. With an OverlayKit it is easier to mix // and match the desirable features of one lineage of derived OverlayEditor classes // with the features of another lineage, pushing capability as needed from the // editor to the kit. //

// There is support for a default OverlayKit for use when constructing an // OverlayEditor. In general any editor-specific state should reside in // the editor, not the kit, but this is not a hard-and-fast rule. class OverlayKit { public: OverlayKit(); virtual ~OverlayKit(); void SetEditor(OverlayEditor*); // set editor currently associated with this kit. OverlayEditor* GetEditor(); // return pointer to editor currently associated with this kit. Interactor* Interior(); // construct the Interactor based interior of an editor. virtual void Init(OverlayComp* comp, const char* name); // initialize the editor, then the associated viewer, using an optional 'comp'. virtual void InitMembers(OverlayComp*); // initialize member variables of the editor. virtual void InitViewer(); // initialize viewer to go with the editor. virtual void InitLayout(const char* name); // initialize chrome that goes around the viewer. static void InitLayout(OverlayKit* kit, const char* name); // static method that implements virtual method. virtual Glyph* MakeMenus(); // make all the pull-down menus and their menu bar. virtual MenuItem* MakeFileMenu(); virtual MenuItem* MakeEditMenu(); virtual MenuItem* MakeStructureMenu(); virtual MenuItem* MakeFontMenu(); virtual MenuItem* MakeBrushMenu(); virtual MenuItem* MakePatternMenu(); virtual MenuItem* MakeFgColorMenu(); virtual MenuItem* MakeBgColorMenu(); virtual MenuItem* MakeAlignMenu(); virtual MenuItem* MakeFrameMenu(); virtual MenuItem* MakeViewMenu(); virtual MenuItem* MakeToolsMenu(); virtual MenuItem* MakeViewersMenu(); virtual Glyph* MakeStates(); // make state views in the chrome. virtual Glyph* MakeToolbar(); // make tool pallette. static OverlayKit* Instance(); // default instance of OverlayKit. virtual void Annotate(OverlayComp*); // utility method for popping an annotation dialog box. virtual void AttrEdit(OverlayComp*); // utility method for popping an attribute editing dialog box. static int bintest(const char* name); // static method for testing for URL prefix on pathname. 0 if found, otherwise -1. static boolean bincheck(const char* name); // static method for testing for URL prefix on pathname. Returns true if found. virtual Glyph* appicon(); // glyph to use for application icon. virtual const char* appname() { return _appname; } // get name of application. virtual void appname(const char* name) { _appname=name; } // set name of application. void MouseDoc(const char*); // set current mouse documentation string on the editor. static const char* mouse_sel; static const char* mouse_mov; static const char* mouse_scl; static const char* mouse_str; static const char* mouse_rot; static const char* mouse_alt; static const char* mouse_mag; static const char* mouse_txt; static const char* mouse_lin; static const char* mouse_mlin; static const char* mouse_ospl; static const char* mouse_rect; static const char* mouse_ellp; static const char* mouse_poly; static const char* mouse_cspl; static const char* mouse_anno; static const char* mouse_attr; static const char* mouse_tack; #ifdef CLIPPOLY static const char* mouse_clipr; #else static const char* mouse_clipr; #endif #ifdef CLIPPOLY static const char* mouse_clipp; #else static const char* mouse_clipp; #endif static const char* mouse_convexhull; static const char* mouse_imgscale; static const char* mouse_logscale; static const char* mouse_pseudocolor; static const char* mouse_grloc; static const char* mouse_custom; void otherdisplay(const char* display); // set possible alternate X display string for constructing viewer. // Not yet working. boolean& set_button_flag() { return _set_button_flag; } // flag to add setr button to text editor boolean& clr_button_flag() { return _clr_button_flag; } // flag to add clear button to text editor OverlayComp* add_tool_button(const char* path, OverlayComp* comp=nil); // low-level routine used by ::add_custom_tool and others virtual OverlaySelection* MakeSelection(Selection* sel = nil); // make Selection of the proper derivation. protected: Glyph* MenuLine(PSBrush*); // create line to put in a pulldown menu. Glyph* MenuArrowLine(boolean tail, boolean head); // create arrow line to put in a pulldown menu. Glyph* MenuRect(PSColor*); // create color rectangle to put in a pulldown menu. Glyph* MenuPatRect(PSPattern*); // create patterned rectangle to put in a pulldown menu. void MakeMenu(MenuItem*, Command*, const char*); // helper method for making a pull-down menu entry. void MakeMenu(MenuItem*, Command*, Glyph*); // helper method for making a pull-down menu entry. ToolButton* MakeTool(Tool*, Glyph*, TelltaleGroup*, ObservableText* mousedoc = nil, const char* doc = ""); // helper method for making a tool for the toolbar. const char* otherdisplay(); // returns string that might specify an alternate X display. public: void toolbar0(); // switch to default toolbar void toolbar1(); // switch to alternate toolbar void add_custom_tool(); // import idraw-format tool button protected: OverlayEditor* _ed; Deck* _toolbars; Patch* _toolbar; Glyph** _toolbar_vbox; TelltaleGroup* _tg; FloatCoord _maxwidth; char* _otherdisplay; boolean _set_button_flag; boolean _clr_button_flag; const char* _appname; protected: static OverlayKit* _overlaykit; }; #include #include declareActionCallback(Command) declareActionCallback(CommandDoer) declareActionCallback(CommandPusher) declareActionCallback(ToolSelector) declareActionCallback(OverlayKit) #include #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovline.cc000066400000000000000000000455641214471147700211100ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Line and MultiLine component definitions. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::cerr; /*****************************************************************************/ ParamList* LineOvComp::_ovline_params = nil; ParamList* MultiLineOvComp::_ovmultiline_params = nil; int LineOvComp::_symid = -1; ClassId LineOvComp::GetClassId () { return OVLINE_COMP; } boolean LineOvComp::IsA (ClassId id) { return OVLINE_COMP == id || OverlayComp::IsA(id); } Component* LineOvComp::Copy () { LineOvComp* comp = new LineOvComp((Line*) GetGraphic()->Copy()); if (attrlist()) comp->SetAttributeList(new AttributeList(attrlist())); return comp; } LineOvComp::LineOvComp (Line* graphic, OverlayComp* parent) : OverlayComp(graphic, parent) { } LineOvComp::LineOvComp(istream& in, OverlayComp* parent) : OverlayComp(nil, parent) { _valid = GetParamList()->read_args(in, this); } ParamList* LineOvComp::GetParamList() { if (!_ovline_params) GrowParamList(_ovline_params = new ParamList()); return _ovline_params; } void LineOvComp::GrowParamList(ParamList* pl) { pl->add_param("original", ParamStruct::required, &LineScript::ReadOriginal, this, &_gr); OverlayComp::GrowParamList(pl); return; } Line* LineOvComp::GetLine () { return (Line*) GetGraphic(); } void LineOvComp::Interpret (Command* cmd) { if (!cmd->IsA(PATTERN_CMD)) { OverlayComp::Interpret(cmd); } } boolean LineOvComp::operator == (OverlayComp& comp) { if (GetClassId() != comp.GetClassId()) return false; Line* linea = GetLine(); Line* lineb = ((LineOvComp&)comp).GetLine(); IntCoord ax0, ay0, ax1, ay1; IntCoord bx0, by0, bx1, by1; linea->GetOriginal(ax0, ay0, ax1, ay1); lineb->GetOriginal(bx0, by0, bx1, by1); return ax0 = bx0 && ay0 == by0 && ax1 == bx1 && ay1 == by1 && OverlayComp::operator==(comp); } /****************************************************************************/ LineOvComp* LineOvView::GetLineOvComp () { return (LineOvComp*) GetSubject(); } ClassId LineOvView::GetClassId () { return OVLINE_VIEW; } boolean LineOvView::IsA (ClassId id) { return OVLINE_VIEW == id || OverlayView::IsA(id); } LineOvView::LineOvView (LineOvComp* subj) : OverlayView(subj) { } void LineOvView::Interpret (Command* cmd) { if (cmd->IsA(ALIGNTOGRID_CMD)) { Line* line = (Line*) GetGraphic(); Transformer total; line->TotalTransformation(total); Coord x0, y0, x1, y1; float tx0, ty0; line->GetOriginal(x0, y0, x1, y1); total.Transform(float(x0), float(y0), tx0, ty0); ((AlignToGridCmd*) cmd)->Align(this, tx0, ty0); } else { OverlayView::Interpret(cmd); } } void LineOvView::Update () { Graphic* line = GetGraphic(); IncurDamage(line); *line = *GetLineOvComp()->GetGraphic(); IncurDamage(line); EraseHandles(); } void LineOvView::CreateHandles () { Coord x[2], y[2]; Viewer* v = GetViewer(); if (v != nil) { GetEndpoints(x[0], y[0], x[1], y[1]); _handles = new RubberHandles(nil, nil, x, y, 2, 0, HANDLE_SIZE); v->InitRubberband(_handles); } } Manipulator* LineOvView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Coord x0, y0, x1, y1; Rubberband* rub = nil; Manipulator* m = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { v->Constrain(e.x, e.y); rub = new RubberLine(nil, nil, e.x, e.y, e.x, e.y); m = new DragManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else if (tool->IsA(MOVE_TOOL)) { v->Constrain(e.x, e.y); GetEndpoints(x0, y0, x1, y1); rub = new SlidingLine(nil, nil, x0, y0, x1, y1, e.x, e.y); m = new OpaqueDragManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity), GetGraphic() ); } else if (tool->IsA(SCALE_TOOL)) { v->Constrain(e.x, e.y); GetEndpoints(x0, y0, x1, y1); rub = new ScalingLine(nil, nil, x0, y0, x1, y1, (x0+x1)/2, (y0+y1)/2); m = new OpaqueDragManip(v, rub, rel, tool, Gravity, GetGraphic()); } else if (tool->IsA(ROTATE_TOOL)) { v->Constrain(e.x, e.y); GetEndpoints(x0, y0, x1, y1); rub = new RotatingLine( nil, nil, x0, y0, x1, y1, (x0+x1)/2, (y0+y1)/2, e.x, e.y ); m = new OpaqueDragManip(v, rub, rel, tool, Gravity, GetGraphic()); } else if (tool->IsA(RESHAPE_TOOL)) { v->Constrain(e.x, e.y); GetEndpoints(x0, y0, x1, y1); PointObj p1(x0, y0), p2(x1, y1), cp(e.x, e.y); if (p1.Distance(cp) < p2.Distance(cp)) { rub = new RubberLine(nil, nil, x1, y1, e.x, e.y); } else { rub = new RubberLine(nil, nil, x0, y0, e.x, e.y); } m = new DragManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else { m = OverlayView::CreateManipulator(v, e, rel, tool); } return m; } Command* LineOvView::InterpretManipulator (Manipulator* m) { DragManip* dm = (DragManip*) m; Editor* ed = dm->GetViewer()->GetEditor(); Tool* tool = dm->GetTool(); Transformer* rel = dm->GetTransformer(); Command* cmd = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { RubberLine* rl = (RubberLine*) dm->GetRubberband(); Coord x0, y0, x1, y1; rl->GetCurrent(x0, y0, x1, y1); if (x0 != x1 || y0 != y1) { BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar"); ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar"); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } Graphic* pg = GetGraphicComp()->GetGraphic(); Line* line = new Line(x0, y0, x1, y1, pg); if (brVar != nil) line->SetBrush(brVar->GetBrush()); if (colVar != nil) { line->FillBg(!colVar->GetBgColor()->None()); line->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } line->SetTransformer(rel); Unref(rel); cmd = new PasteCmd(ed, new Clipboard(new LineOvComp(line))); } } else if (tool->IsA(MOVE_TOOL)) { Coord x0, y0, x1, y1, dummy1, dummy2; float fx0, fy0, fx1, fy1; SlidingLine* sl = (SlidingLine*) dm->GetRubberband(); sl->GetOriginal(x0, y0, dummy1, dummy2); sl->GetCurrent(x1, y1, dummy1, dummy2); if (rel != nil) { rel->InvTransform(float(x0), float(y0), fx0, fy0); rel->InvTransform(float(x1), float(y1), fx1, fy1); } cmd = new MoveCmd(ed, fx1 - fx0, fy1 - fy0); } else if (tool->IsA(SCALE_TOOL)) { ScalingLine* sl = (ScalingLine*) dm->GetRubberband(); float sxy = sl->CurrentScaling(); cmd = new ScaleCmd(ed, sxy, sxy); } else if (tool->IsA(ROTATE_TOOL)) { RotatingLine* rl = (RotatingLine*) dm->GetRubberband(); float angle = rl->CurrentAngle() - rl->OriginalAngle(); cmd = new RotateCmd(ed, angle); } else if (tool->IsA(RESHAPE_TOOL)) { RubberLine* rl = (RubberLine*) dm->GetRubberband(); Coord x0, y0, x1, y1; rl->GetCurrent(x0, y0, x1, y1); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } Line* line = new Line(x0, y0, x1, y1, GetGraphic()); line->SetTransformer(rel); Unref(rel); cmd = new ReplaceCmd(ed, new LineOvComp(line)); } else { cmd = OverlayView::InterpretManipulator(m); } return cmd; } void LineOvView::GetEndpoints (Coord& x0, Coord& y0, Coord& x1, Coord& y1) { Line* line = (Line*) GetGraphic(); Transformer t; line->GetOriginal(x0, y0, x1, y1); line->TotalTransformation(t); t.Transform(x0, y0); t.Transform(x1, y1); } Graphic* LineOvView::GetGraphic () { Graphic* graphic = GraphicView::GetGraphic(); if (graphic == nil) { LineOvComp* lineComp = GetLineOvComp(); graphic = lineComp->GetGraphic()->Copy(); SetGraphic(graphic); } return graphic; } /****************************************************************************/ ClassId LinePS::GetClassId () { return LINE_PS; } boolean LinePS::IsA (ClassId id) { return LINE_PS == id || OverlayPS::IsA(id); } LinePS::LinePS (OverlayComp* subj) : OverlayPS(subj) { } boolean LinePS::Definition (ostream& out) { Coord x0, y0, x1, y1; Line* line = (Line*) GetGraphicComp()->GetGraphic(); line->GetOriginal(x0, y0, x1, y1); out << "Begin " << MARK << " Line\n"; MinGS(out); out << MARK << "\n"; out << x0 << " " << y0 << " " << x1 << " " << y1 << " Line\n"; out << "End\n\n"; return out.good(); } /****************************************************************************/ ClassId LineScript::GetClassId () { return LINE_SCRIPT; } boolean LineScript::IsA (ClassId id) { return LINE_SCRIPT == id || OverlayScript::IsA(id); } LineScript::LineScript (LineOvComp* subj) : OverlayScript(subj) { } boolean LineScript::Definition (ostream& out) { Coord x0, y0, x1, y1; LineOvComp* comp = (LineOvComp*) GetSubject(); comp->GetLine()->GetOriginal(x0, y0, x1, y1); out << "line("; out << x0 << "," << y0 << "," << x1 << "," << y1; MinGS(out); Annotation(out); Attributes(out); out << ")"; return out.good(); } int LineScript::ReadOriginal (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { Coord x0, y0, x1, y1; char delim; char ch = in.peek(); if (ch != ')' && ch != ':') in >> x0 >> delim >> y0 >> delim >> x1 >> delim >> y1; else x0 = y0 = x1 = y1 = 0; if (!in.good()) { return -1; } else { *(Line**)addr1 = new Line(x0, y0, x1, y1); return 0; } } /****************************************************************************/ int MultiLineOvComp::_symid = -1; ClassId MultiLineOvComp::GetClassId () { return OVMULTILINE_COMP; } boolean MultiLineOvComp::IsA (ClassId id) { return OVMULTILINE_COMP == id || VerticesOvComp::IsA(id); } Component* MultiLineOvComp::Copy () { MultiLineOvComp* comp = new MultiLineOvComp((SF_MultiLine*) GetGraphic()->Copy()); if (attrlist()) comp->SetAttributeList(new AttributeList(attrlist())); return comp; } MultiLineOvComp::MultiLineOvComp (SF_MultiLine* graphic, OverlayComp* parent) : VerticesOvComp(graphic, parent) {} MultiLineOvComp::MultiLineOvComp(istream& in, OverlayComp* parent) : VerticesOvComp(nil, parent) { _valid = GetParamList()->read_args(in, this); } ParamList* MultiLineOvComp::GetParamList() { if (!_ovmultiline_params) GrowParamList(_ovmultiline_params = new ParamList()); return _ovmultiline_params; } void MultiLineOvComp::GrowParamList(ParamList* pl) { pl->add_param("points", ParamStruct::required, &MultiLineScript::ReadPoints, this, &_gr); VerticesOvComp::GrowParamList(pl); return; } SF_MultiLine* MultiLineOvComp::GetOvMultiLine () { return (SF_MultiLine*) GetGraphic(); } /****************************************************************************/ MultiLineOvView::MultiLineOvView (MultiLineOvComp* subj) : VerticesOvView(subj) { } MultiLineOvComp* MultiLineOvView::GetMultiLineOvComp () { return (MultiLineOvComp*) GetSubject(); } ClassId MultiLineOvView::GetClassId () { return OVMULTILINE_VIEW; } boolean MultiLineOvView::IsA (ClassId id) { return OVMULTILINE_VIEW == id || VerticesOvView::IsA(id); } boolean MultiLineOvView::VertexChanged () { SF_MultiLine* gview = (SF_MultiLine*) GetGraphic(); SF_MultiLine* gsubj = (SF_MultiLine*) GetMultiLineOvComp()->GetGraphic(); return *gview != *gsubj; } Manipulator* MultiLineOvView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Manipulator* m = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { ((OverlayEditor*)v->GetEditor())->MouseDocObservable()->textvalue(OverlayKit::mouse_tack); v->Constrain(e.x, e.y); Coord x[1], y[1]; x[0] = e.x; y[0] = e.y; GrowingVertices* rub = new GrowingMultiLine( nil, nil, x, y, 1, -1, HANDLE_SIZE ); if (((OverlayViewer*)v)->scribble_pointer()) m = new ScribbleVertexManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); else m = new VertexManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else if (tool->IsA(RESHAPE_TOOL)) { ((OverlayEditor*)v->GetEditor())->MouseDocObservable()->textvalue(OverlayKit::mouse_tack); Coord* x, *y; int n; v->Constrain(e.x, e.y); GetVertices(x, y, n); GrowingMultiLine* rub = new GrowingMultiLine( nil, nil, x, y, n, ClosestPoint(x, y, n, e.x, e.y), HANDLE_SIZE ); delete x; delete y; m = new VertexManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else { m = VerticesOvView::CreateManipulator(v, e, rel, tool); } return m; } Command* MultiLineOvView::InterpretManipulator (Manipulator* m) { DragManip* dm = (DragManip*) m; Editor* ed = dm->GetViewer()->GetEditor(); Tool* tool = dm->GetTool(); Transformer* rel = dm->GetTransformer(); Command* cmd = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { GrowingVertices* gv = (GrowingVertices*) dm->GetRubberband(); Coord* x, *y; int n, pt; gv->GetCurrent(x, y, n, pt); if (n > 2 || x[0] != x[1] || y[0] != y[1]) { BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar"); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } Graphic* pg = GetGraphicComp()->GetGraphic(); SF_MultiLine* polygon = new SF_MultiLine(x, y, n, pg); if (brVar != nil) polygon->SetBrush(brVar->GetBrush()); if (patVar != nil) polygon->SetPattern(patVar->GetPattern()); if (colVar != nil) { polygon->FillBg(!colVar->GetBgColor()->None()); polygon->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } polygon->SetTransformer(rel); Unref(rel); cmd = new PasteCmd(ed, new Clipboard(new MultiLineOvComp(polygon))); } delete x; delete y; } else if (tool->IsA(RESHAPE_TOOL)) { GrowingVertices* gv = (GrowingVertices*) dm->GetRubberband(); Coord* x, *y; int n, pt; gv->RemoveVertex(); gv->GetCurrent(x, y, n, pt); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } SF_MultiLine* polygon = new SF_MultiLine(x, y, n, GetGraphic()); delete x; delete y; polygon->SetTransformer(rel); Unref(rel); cmd = new ReplaceCmd(ed, new MultiLineOvComp(polygon)); } else { cmd = VerticesOvView::InterpretManipulator(m); } return cmd; } /*****************************************************************************/ ClassId MultiLinePS::GetClassId () { return MULTILINE_PS; } boolean MultiLinePS::IsA (ClassId id) { return MULTILINE_PS == id || VerticesPS::IsA(id); } MultiLinePS::MultiLinePS (OverlayComp* subj) : VerticesPS(subj) { } const char* MultiLinePS::Name () { return "MLine"; } /*****************************************************************************/ ClassId MultiLineScript::GetClassId () { return MULTILINE_SCRIPT; } boolean MultiLineScript::IsA (ClassId id) { return MULTILINE_SCRIPT == id || VerticesScript::IsA(id); } MultiLineScript::MultiLineScript (MultiLineOvComp* subj) : VerticesScript(subj) { } const char* MultiLineScript::Name () { return "multiline"; } boolean MultiLineScript::Definition (ostream& out) { const Coord* x; const Coord* y; int n; MultiLineOvComp* comp = (MultiLineOvComp*)GetSubject(); n = comp->GetVertices()->GetOriginal(x, y); out << Name() << "("; Clipboard* cb = GetPtsList(); if (cb) { out << " :pts " << MatchedPts(cb); } else { for (int i = 0; i < n; i++) { out << "(" << x[i] << "," << y[i] << ")"; if (i+1 < n ) out << ","; } } MinGS(out); Annotation(out); Attributes(out); out << ")"; return out.good(); } int MultiLineScript::ReadPoints (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { Coord* x, *y; int n, bad; char ch = in.peek(); if (ch != ')' && ch != ':') bad = ParamList::parse_points(in, x, y, n); else { x = y = nil; n = 0; bad = 0; } if (!in.good() || bad) { delete x; delete y; cerr << "abnormal exit from MultiLineScript::ReadPoints\n"; return -1; } else { *(SF_MultiLine**)addr1 = new SF_MultiLine(x, y, n); delete x; delete y; return 0; } } ivtools-1.2.11a1/src/OverlayUnidraw/ovline.h000066400000000000000000000133101214471147700207320ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OvLine and OvMultiLine component declarations. */ #ifndef overlay_line_h #define overlay_line_h #include #include #include class Line; class ParamList; class SF_MultiLine; //: clone of LineComp derived from OverlayComp. class LineOvComp : public OverlayComp { public: LineOvComp(Line* = nil, OverlayComp* parent = nil); LineOvComp(istream&, OverlayComp* parent = nil); virtual void Interpret(Command*); // interpret pattern command, otherwise pass to base class. Line* GetLine(); // return pointer to graphic. virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual boolean operator == (OverlayComp&); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _ovline_params; CLASS_SYMID2("LineComp", OVLINE_COMP); }; //: graphical view of LineOvComp. class LineOvView : public OverlayView { public: LineOvView(LineOvComp* = nil); virtual void Interpret(Command*); // interpret align-to-grid command, otherwise pass to base class. virtual void Update(); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); // create manipulators for tools that create, move, scale, rotate, or reshape. virtual Command* InterpretManipulator(Manipulator*); // intepret manipulators for tools that create, move, scale, rotate, or reshape. virtual void GetEndpoints(Coord&, Coord&, Coord&, Coord&); LineOvComp* GetLineOvComp(); // return pointer to associated ocmponent. virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual void CreateHandles(); }; //: "PostScript" view of LineOvComp. class LinePS : public OverlayPS { public: LinePS(OverlayComp* = nil); virtual boolean Definition(ostream&); // output PostScript fragment for Line. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: serialized view of LineOvComp. class LineScript : public OverlayScript { public: LineScript(LineOvComp* = nil); virtual boolean Definition(ostream&); // output variable-length ASCII record that defines the component. static int ReadOriginal(istream&, void*, void*, void*, void*); // read x0,y0,x1,y1 and construct Line graphic. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: clone of MultiLineComp derived from OverlayComp. class MultiLineOvComp : public VerticesOvComp { public: MultiLineOvComp(SF_MultiLine* = nil, OverlayComp* parent = nil); MultiLineOvComp(istream&, OverlayComp* parent = nil); SF_MultiLine* GetOvMultiLine(); // return pointer to graphic. virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _ovmultiline_params; CLASS_SYMID2("MultiLineComp", OVMULTILINE_COMP); }; //: graphical view of MultiLineOvComp. class MultiLineOvView : public VerticesOvView { public: MultiLineOvView(MultiLineOvComp* = nil); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); // create manipulators for tools that create or reshape. virtual Command* InterpretManipulator(Manipulator*); // intepret manipulators for tools that create or reshape. MultiLineOvComp* GetMultiLineOvComp(); // return pointer to associated ocmponent. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual boolean VertexChanged(); }; //: "PostScript" view of MultiLineOvComp. class MultiLinePS : public VerticesPS { public: MultiLinePS(OverlayComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual const char* Name(); // return name to differentiate from other VerticesPS. }; //: serialized view of LineOvComp. class MultiLineScript : public VerticesScript { public: MultiLineScript(MultiLineOvComp* = nil); virtual boolean Definition(ostream&); // output variable-length ASCII record that defines the component. static int ReadPoints(istream&, void*, void*, void*, void*); // read set of points and construct SF_MultiLine graphic. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual const char* Name(); // return name to differentiate from other VerticesScript. }; #include #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovmanips.cc000066400000000000000000000166221214471147700214410ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include #include #include #include #include /****************************************************************************/ OpaqueDragManip::OpaqueDragManip ( Viewer* v, Rubberband* rub, Transformer* rel, Tool* t, DragConstraint c, Graphic* graphic ) : DragManip(v, nil, rel, t, c) { Init(graphic, rub); } OpaqueDragManip::OpaqueDragManip ( Viewer* v, Rubberband* rub, Transformer* rel, Tool* t, DragConstraint c, Coord x, Coord y, Graphic* graphic ) : DragManip(v, nil, rel, t, c, x, y) { Init(graphic, rub); } void OpaqueDragManip::Init(Graphic* graphic, Rubberband* rub) { _notrans = false; _graphic = graphic; if (_graphic && OverlayEditor::opaque_flag() && opaqueable_rubband(rub) ) { _r = nil; _r2 = rub; Ref(_r2); if (!_graphic->GetTransformer()) { _notrans = true; _graphic->SetTransformer(new Transformer()); // cerr << "OpaqueDragManip::Init -- nil transformer set to identity\n"; // cerr << "_graphic pointer " << _graphic << "\n"; _origtrans = new Transformer(); } else _origtrans = new Transformer(*_graphic->GetTransformer()); _totaltrans = new Transformer(); _graphic->Parent()->TotalTransformation(*_totaltrans); } else { _graphic = nil; _r = rub; Ref(_r); if (_r != nil) _viewer->InitRubberband(_r); _totaltrans = _origtrans = nil; } } OpaqueDragManip::~OpaqueDragManip() { delete _totaltrans; delete _origtrans; } void OpaqueDragManip::Grasp (Event& e) { if (!_graphic) { DragManip::Grasp(e); return; } _grasp_e = e; Constrain(e); if (!_origPreset) { _origx = e.x; _origy = e.y; ClassId id = _r2->GetClassId(); if (id == SCALINGLINE || id == SCALINGLINELIST || id == SCALINGRECT) { _viewer->GetDamage()->Incur(_graphic); Track(e.x, e.y); _viewer->GetDamage()->Incur(_graphic); _viewer->Update(); } else _r2->SetTrack(e.x, e.y); } } boolean OpaqueDragManip::Manipulating (Event& e) { if (!_graphic) return DragManip::Manipulating(e); if (e.eventType == MotionEvent) { Constrain(e); IntCoord trackx, tracky; _r2->GetTrack(trackx, tracky); if (e.x!=trackx || e.y!=tracky) { _viewer->GetDamage()->Incur(_graphic); Track(e.x, e.y); _viewer->GetDamage()->Incur(_graphic); _viewer->Update(); } } else if (e.eventType == UpEvent) { /* restore original position and restore default rubberband */ _viewer->GetDamage()->Incur(_graphic); if (_notrans) _graphic->SetTransformer(nil); else *_graphic->GetTransformer() = *_origtrans; _graphic->uncacheParents(); _r = _r2; return false; } return true; } void OpaqueDragManip::Track (IntCoord x, IntCoord y) { IntCoord oldx, oldy; Rubberband* rub = _r2; ClassId id = rub->GetClassId(); // cerr << "OpaqueDragManip::Track -- _graphic and GetTransformer() " << // _graphic << "," << _graphic->GetTransformer() << "\n"; if (id == SLIDINGLINE || id == SLIDINGLINELIST || id == SLIDINGRECT) { *_graphic->GetTransformer() = *_origtrans; rub->SetTrack(x, y); float f_origx = _origx, f_origy = _origy; _totaltrans->InvTransform(f_origx, f_origy, f_origx, f_origy); float f_x = x, f_y = y; _totaltrans->InvTransform(f_x, f_y, f_x, f_y); _graphic->Translate(f_x-f_origx, f_y-f_origy); } else if (id == SCALINGLINE || id == SCALINGLINELIST || id == SCALINGRECT) { *_graphic->GetTransformer() = *_origtrans; rub->SetTrack(x, y); float cx, cy; _graphic->GetCenter(cx, cy); float curscale = current_scaling(rub); _graphic->Scale(curscale, curscale, cx, cy); } else if (id == RUBBERRECT) { *_graphic->GetTransformer() = *_origtrans; rub->SetTrack(x, y); Coord l0, b0, r0, t0, l1, b1, r1, t1; float sx, sy; Alignment a; Viewer* v = _viewer; RubberRect* rr = (RubberRect*) rub; rr->GetOriginal(l0, b0, r0, t0); if (v->GetOrientation() == Landscape) { if (l0 > r0) { a = (b0 > t0) ? TopLeft : TopRight; } else { a = (b0 > t0) ? BottomLeft : BottomRight; } } else { if (l0 > r0) { a = (b0 > t0) ? TopRight : BottomRight; } else { a = (b0 > t0) ? TopLeft : BottomLeft; } } rr->GetCurrent(l1, b1, r1, t1); sx = float(r1 - l1) / float(r0 - l0); sy = float(t1 - b1) / float(t0 - b0); if (v->GetOrientation() == Landscape) { float tmp = sx; sx = sy; sy = tmp; } float ax, ay; GetAlignmentPoint(_graphic, a, ax, ay); _graphic->Scale(sx, sy, ax, ay); } else if (id == ROTATINGLINE || id == ROTATINGLINELIST || id == ROTATINGRECT) { float angle_before = current_angle(rub); rub->SetTrack(x, y); float angle_after = current_angle(rub); float cx, cy; _graphic->GetCenter(cx, cy); _graphic->Rotate(angle_after-angle_before, cx, cy); } } boolean OpaqueDragManip::opaqueable_rubband(Rubberband* rub) { ClassId id = rub->GetClassId(); return id == SLIDINGLINE || id == SLIDINGLINELIST || id == SLIDINGRECT || id == SCALINGLINE || id == SCALINGLINELIST || id == SCALINGRECT || id == RUBBERRECT || id == ROTATINGLINE || id == ROTATINGLINELIST || id == ROTATINGRECT; ; } float OpaqueDragManip::current_angle(Rubberband* rub) { ClassId id = rub->GetClassId(); return id == ROTATINGLINE ? ((RotatingLine*)rub)->CurrentAngle() : (id == ROTATINGLINELIST ? ((RotatingLineList*)rub)->CurrentAngle() : (id == ROTATINGRECT ? ((RotatingRect*)rub)->CurrentAngle() : 0.0)); } float OpaqueDragManip::current_scaling(Rubberband* rub) { ClassId id = rub->GetClassId(); return id == SCALINGLINE ? ((ScalingLine*)rub)->CurrentScaling() : (id == SCALINGLINELIST ? ((ScalingLineList*)rub)->CurrentScaling() : (id == SCALINGRECT ? ((ScalingRect*)rub)->CurrentScaling() : 1.0)); } ivtools-1.2.11a1/src/OverlayUnidraw/ovmanips.h000066400000000000000000000053661214471147700213060ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef ov_manips_h #define ov_manips_h #include #include class Graphic; class Transformer; //: manipulator for opaque move. class OpaqueDragManip : public DragManip { public: OpaqueDragManip( Viewer*, Rubberband*, Transformer* = nil, Tool* = nil, DragConstraint = None, Graphic* = nil ); OpaqueDragManip( Viewer*, Rubberband*, Transformer*, Tool*, DragConstraint, IntCoord, IntCoord, Graphic* = nil ); virtual ~OpaqueDragManip(); void Init(Graphic*, Rubberband*); // constructor initialization method. virtual void Grasp(Event&); // down-event method. virtual boolean Manipulating(Event&); // until up-event method. void Track(IntCoord x, IntCoord y); // track method implemented here instead of in a rubberband. protected: boolean opaqueable_rubband(Rubberband*); // test to see if this kind of rubberband can be directly visualized instead. float current_angle(Rubberband*); // utility method for computing current angle of a rotating rubberband. float current_scaling(Rubberband*); // utility method for computing current factor of a scaling rubberband. Graphic* _graphic; // graphic for opaque move. Rubberband* _r2; // save pointer to _r member variable, which gets set to nil. boolean _notrans; // flag to say whether graphic had Transformer to start with Transformer* _totaltrans; // total transformation for parent graphic. Transformer* _origtrans; // original transformation of graphic. }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovpage.cc000066400000000000000000000036641214471147700210700ustar00rootroot00000000000000/* * Copyright (c) 1994 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlayPage implementation. */ #include #include #include #include /*****************************************************************************/ OverlayPage::OverlayPage (float width, float height, boolean visible) : UPage (width, height) { Catalog* catalog = unidraw->GetCatalog(); if (!visible) _graphic->SetBrush(catalog->FindNoneBrush()); } void OverlayPage::Visibility (boolean visible) { if (visible != IsVisible()) { PSBrush* br = visible ? pssingle : psnonebr; _graphic->SetBrush(br); } } boolean OverlayPage::IsVisible () { return !_graphic->GetBrush()->None(); } ivtools-1.2.11a1/src/OverlayUnidraw/ovpage.h000066400000000000000000000033131214471147700207210ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlayPage - defines the overlay viewer's page boundary. */ #ifndef ov_page_h #define ov_page_h #include //: drawing page object. class OverlayPage : public UPage { public: OverlayPage(float w, float h, boolean visible = false); // construct page object of a given pixel width and height. virtual void Visibility(boolean); // set visibility of page graphic. virtual boolean IsVisible(); // return visibility of page graphic. }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovpainter.cc000066400000000000000000001116771214471147700216220ustar00rootroot00000000000000/* * Copyright (c) 1994-1995 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * Copyright (c) 1996, 1999 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #define NDEBUG #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #undef RasterRect static inline int pround(float x) { return (x > 0. ? int(x + 0.5) : -int(-x + 0.499)); } // --------------------------------------------------------------------------- class Mapper { public: Mapper( IntCoord coff_x, IntCoord coff_y, IntCoord goff_x, IntCoord goff_y ); void Transform( const Transformer&, IntCoord x, IntCoord y, IntCoord& tx, IntCoord& ty ) const; void Transform( const Transformer&, float x, float y, float& tx, float& ty ) const; void Transform( const Transformer&, float& x, float& y ) const; void InverseTransform( const Transformer&, IntCoord x, IntCoord y, IntCoord& tx, IntCoord& ty ) const; void InverseTransform( const Transformer&, float x, float y, float& tx, float& ty ) const; void InverseTransform( const Transformer&, float& x, float& y ) const; protected: float _coff_x; float _coff_y; float _goff_x; float _goff_y; }; Mapper::Mapper( IntCoord coff_x, IntCoord coff_y, IntCoord goff_x, IntCoord goff_y ) : _coff_x(float(coff_x)), _coff_y(float(coff_y)), _goff_x(float(goff_x)), _goff_y(float(goff_y)) { } inline void Mapper::Transform( const Transformer& t, float x, float y, float& tx, float& ty ) const { x += _goff_x; y += _goff_y; t.transform(x, y, tx, ty); tx += _coff_x; ty += _coff_y; } inline void Mapper::Transform( const Transformer& t, IntCoord x, IntCoord y, IntCoord& tx, IntCoord& ty ) const { float ftx, fty; Transform(t, float(x), float(y), ftx, fty); tx = pround(ftx); ty = pround(fty); } inline void Mapper::Transform( const Transformer& t, float& x, float& y ) const { Transform(t, x, y, x, y); } inline void Mapper::InverseTransform( const Transformer& t, float x, float y, float& tx, float& ty ) const { x -= _coff_x; y -= _coff_y; t.inverse_transform(x, y, tx, ty); tx -= _goff_x; ty -= _goff_y; } inline void Mapper::InverseTransform( const Transformer& t, IntCoord x, IntCoord y, IntCoord& tx, IntCoord& ty ) const { float ftx, fty; InverseTransform(t, float(x), float(y), ftx, fty); tx = pround(ftx); ty = pround(fty); } inline void Mapper::InverseTransform( const Transformer& t, float& x, float& y ) const { InverseTransform(t, x, y, x, y); } // -------------------------------------------------------------------------- static void TransformedInfo( const Mapper* mpr, IntCoord swidth, IntCoord sheight, const Transformer& t, IntCoord* dxmin, IntCoord* dxmax = nil, IntCoord* dymin = nil, IntCoord* dymax = nil, IntCoord* pwidth = nil, IntCoord* pheight = nil, boolean* rotated = nil ) { float x1 = 0; float y1 = 0; float x2 = 0; float y2 = sheight; float x3 = swidth; float y3 = sheight; float x4 = swidth; float y4 = 0; if (mpr) { mpr->Transform(t, x1, y1); mpr->Transform(t, x2, y2); mpr->Transform(t, x3, y3); mpr->Transform(t, x4, y4); } else { t.transform(x1, y1); t.transform(x2, y2); t.transform(x3, y3); t.transform(x4, y4); } IntCoord xmin, ymin, xmax, ymax; xmin = pround(Math::min(x1, x2, x3, x4)); xmax = pround(Math::max(x1, x2, x3, x4)) - 1; ymin = pround(Math::min(y1, y2, y3, y4)); ymax = pround(Math::max(y1, y2, y3, y4)) - 1; if (dxmin) { *dxmin = xmin; } if (dxmax) { *dxmax = xmax; } if (dymin) { *dymin = ymin; } if (dymax) { *dymax = ymax; } if (pwidth) { *pwidth = xmax - xmin + 1; } if (pheight) { *pheight = ymax - ymin + 1; } if (rotated) { *rotated = !( (pround(x1)==pround(x2) || pround(y1)==pround(y2)) && (pround(x1)==pround(x4) || pround(y1)==pround(y4)) ); } } static void DrawSourceTransformedImage ( XImage* s, int sx0, int sy0, XImage* m, int mx0, int my0, XDrawable d, unsigned int height, int dx0, int dy0, boolean stencil, unsigned long fg, unsigned long bg, XDisplay* display, GC gc, const Transformer* matrix, int xmin, int ymin, int xmax, int ymax ) { unsigned long lastdrawnpixel = fg; for (int xx = xmin; xx <= xmax; ++xx) { float lx, ly; float rx, ry; float tx, ty; matrix->Transform(float(xx), float(ymin), lx, ly); matrix->Transform(float(xx + 1), float(ymin), rx, ry); matrix->Transform(float(xx), float(ymax+1), tx, ty); float dx = (tx - lx) / float(ymax - ymin + 1); float dy = (ty - ly) / float(ymax - ymin + 1); int ilx = 0, ily = 0; int irx = 0, iry = 0; boolean lastmask = false, mask; unsigned long lastpixel = fg, pixel, source; for (int yy = ymin; yy <= ymax+1; ++yy) { mask = ( yy <= ymax && (m == nil || XGetPixel(m, xx-mx0, m->height-1-(yy-my0))) ); if ( yy=sy0+s->height || xx=sx0+s->width ) { source = bg; } else { source = XGetPixel(s, xx-sx0, s->height-1-(yy-sy0)); } if (stencil) { pixel = (source != 0) ? fg : bg; } else { pixel = source; } if (mask != lastmask || lastmask && pixel != lastpixel) { int iilx = pround(lx), iily = pround(ly); int iirx = pround(rx), iiry = pround(ry); if (lastmask) { if (lastpixel != lastdrawnpixel) { XSetForeground(display, gc, lastpixel); lastdrawnpixel = lastpixel; } if ( (ilx==iilx || ily==iily) && (irx==ilx || iry==ily) ) { XFillRectangle( display, d, gc, Math::min(ilx, iirx) - dx0, height - (Math::max(ily, iiry) - dy0), Math::abs(ilx - iirx), Math::abs(ily - iiry) ); } else { XPoint v[4]; v[0].x = ilx-dx0; v[0].y = height - (ily-dy0); v[1].x = iilx-dx0; v[1].y = height - (iily-dy0); v[2].x = iirx-dx0; v[2].y = height - (iiry-dy0); v[3].x = irx-dx0; v[3].y = height - (iry-dy0); XFillPolygon( display, d, gc, v, 4, Convex, CoordModeOrigin ); } } ilx = iilx; ily = iily; irx = iirx; iry = iiry; lastpixel = pixel; lastmask = mask; } lx += dx; ly += dy; rx += dx; ry += dy; } } XSetForeground(display, gc, fg); } // --------------------------------------------------------------------------- class ImageHolder { public: ImageHolder(); ~ImageHolder(); XImage* _image; boolean _shared_memory; #ifdef XSHM XShmSegmentInfo _shminfo; #endif }; ImageHolder::ImageHolder() : _image(nil), _shared_memory(false) { } ImageHolder::~ImageHolder() { XDestroyImage(_image); #ifdef XSHM if (_shared_memory) { Display& d = *Session::instance()->default_display(); RasterRep::free_shared_memory(d, _shminfo); } #endif } declareTable(ImageTable,Pixmap,ImageHolder*) implementTable(ImageTable,Pixmap,ImageHolder*) class ImageCache { public: ImageCache(); ~ImageCache(); XImage* get(const Raster* r); XImage* get( Display&, Pixmap, int width, int height, const Raster* r = nil ); void remove(Pixmap); protected: ImageTable _table; }; static ImageCache* icache_; ImageCache::ImageCache() : _table(100) { } ImageCache::~ImageCache() { TableIterator(ImageTable) i(_table); for (; i.more(); i.next()) { delete i.cur_value(); } } XImage* ImageCache::get( Display& d, Pixmap pix, int width, int height, const Raster* ras ) { XImage* ret = nil; if (ras && (pix == ras->rep()->pixmap_)) { ret = ras->rep()->image_; } else { ImageHolder* ih = nil; if (!_table.find(ih, pix)) { XDisplay* dpy = d.rep()->display_; ih = new ImageHolder; #ifdef XSHM RasterRep::init_shared_memory( ih->_shared_memory, d, ih->_shminfo, width, height, ih->_image, pix ); #endif if (!ih->_shared_memory) { ih->_image = XGetImage( dpy, pix, 0, 0, width, height, AllPlanes, ZPixmap ); } _table.insert(pix, ih); } ret = ih->_image; } return ret; } XImage* ImageCache::get(const Raster* r) { RasterRep* srep = r->rep(); return get( *srep->display_, srep->pixmap_, srep->pwidth_, srep->pheight_, r ); } void ImageCache::remove(Pixmap p) { ImageHolder* doomed; if (_table.find(doomed, p)) { _table.remove(p); delete doomed; } } // --------------------------------------------------------------------------- // return the bounding box of the intersection of an axis aligned rectangle // and a polygon region static void BoundingRectIntersect( const XRectangle& r1, const Region& r2, XRectangle& ins ) { Region tmp = XCreateRegion(); XUnionRectWithRegion((XRectangle*)&r1, tmp, tmp); XIntersectRegion(r2, tmp, tmp); XClipBox(tmp, &ins); XDestroyRegion(tmp); } static inline void check_dim(IntCoord& w, IntCoord& h) { if (w <= 0) { w = 1; } if (h <= 0) { h = 1; } } static Pixmap CreateSourceClippedRaster( const Mapper& mpr, unsigned long fg, unsigned long bg, Display& d, const Raster* r, Pixmap smap, IntCoord swidth, IntCoord sheight, const Transformer& tx, XRectangle* bb, IntCoord& dwidth, IntCoord& dheight ) { float llx, lux, rlx, rux; float lly, luy, rly, ruy; mpr.InverseTransform(tx, float(bb->x), float(bb->y), llx, lly); mpr.InverseTransform( tx, float(bb->x), float(bb->y + bb->height), lux, luy ); mpr.InverseTransform( tx, float(bb->x + bb->width), float(bb->y), rlx, rly ); mpr.InverseTransform( tx, float(bb->x + bb->width), float(bb->y + bb->height), rux, ruy ); IntCoord xmin, ymin, xmax, ymax; xmin = pround(Math::min(llx, lux, rlx, rux)); xmax = pround(Math::max(llx, lux, rlx, rux)) - 1; ymin = pround(Math::min(lly, luy, rly, ruy)); ymax = pround(Math::max(lly, luy, rly, ruy)) - 1; DisplayRep& dr = *d.rep(); XDisplay* dpy = dr.display_; XImage* source = icache_->get(d, smap, swidth, sheight, r); dwidth = bb->width; dheight = bb->height; check_dim(dwidth, dheight); Pixmap dmap = XCreatePixmap( dpy, dr.root_, dwidth, dheight, dr.default_visual_->depth() ); GC xgc = XCreateGC(dpy, dmap, 0, nil); DrawSourceTransformedImage( source, 0, 0, nil, 0, 0, dmap, dheight, bb->x, bb->y, false, fg, bg, dpy, xgc, &tx, xmin - 1, ymin - 1, xmax + 1, ymax + 1 // out of range is ok ); XFreeGC(dpy, xgc); return dmap; } static Pixmap CreateSourceRaster( const Mapper& mpr, unsigned long fg, unsigned long bg, Display& d, const Raster* r, Pixmap smap, IntCoord swidth, IntCoord sheight, const Transformer& tx, IntCoord& xmin, IntCoord& ymin, IntCoord& dwidth, IntCoord& dheight ) { Transformer v(tx); IntCoord dxmin, dymin; TransformedInfo( &mpr, swidth, sheight, tx, &dxmin, nil, &dymin, nil, &dwidth, &dheight ); xmin = dxmin; ymin = dymin; check_dim(dwidth, dheight); DisplayRep& dr = *d.rep(); XDisplay* dpy = dr.display_; XImage* source = icache_->get(d, smap, swidth, sheight, r); Pixmap dmap = XCreatePixmap( dpy, dr.root_, dwidth, dheight, dr.default_visual_->depth() ); GC xgc = XCreateGC(dpy, dmap, 0, nil); DrawSourceTransformedImage( source, 0, 0, nil, 0, 0, dmap, dheight, dxmin, dymin, false, fg, bg, dpy, xgc, &v, 0, 0, swidth - 1, sheight - 1 ); XFreeGC(dpy, xgc); return dmap; } static Pixmap DrawDestTransformedImage( Display& d, OvRestrictedImage& img, const Transformer& tx, IntCoord dwidth, IntCoord dheight, IntCoord dx0, IntCoord dy0 ) { DisplayRep& dr = *d.rep(); XDisplay* dpy = d.rep()->display_; Pixmap map = XCreatePixmap( dpy, dr.root_, dwidth, dheight, dr.default_visual_->depth() ); GC xgc = XCreateGC(dpy, map, 0, nil); XImage* dest = nil; boolean shared_mem = false; #ifdef XSHM XShmSegmentInfo shminfo; RasterRep::init_shared_memory( shared_mem, d, shminfo, dwidth, dheight, dest, map ); #endif if (!shared_mem) { dest = XGetImage( dpy, map, 0, 0, dwidth, dheight, AllPlanes, ZPixmap ); } int sx0 = 0; int sy0 = 0; for (int dy = dheight - 1; dy >= 0; --dy) { float tx1, ty1, tx2, ty2; tx.inverse_transform(- dx0, dy - dy0, tx1, ty1); tx.inverse_transform(dwidth - dx0, dy - dy0, tx2, ty2); float delta_x = (tx2 - tx1) / dwidth; float delta_y = (ty2 - ty1) / dwidth; int sx, sy; for (int dx = 0; dx < dwidth; ++dx) { sx = int(tx1) + sx0; sy = int(ty1) + sy0; if ( sx >= 0 && sx < img.Width() && sy >= 0 && sy < img.Height() ) { XPutPixel( dest, dx, dheight - 1 - dy, img.Peek(sx, img.Height() - 1 - sy) ); } tx1 = tx1 + delta_x; ty1 = ty1 + delta_y; } } XPutImage(dpy, map, xgc, dest, 0, 0, 0, 0, dwidth, dheight); XFreeGC(dpy, xgc); XDestroyImage(dest); #ifdef XSHM if (shared_mem) { RasterRep::free_shared_memory(d, shminfo); } #endif return map; } static Pixmap CreateDestClippedRaster( const Mapper& mpr, Display& dis, OvRestrictedImage& img, const Transformer& tx, XRectangle* bb, IntCoord& dwidth, IntCoord& dheight ) { Transformer v(tx); float xt, yt; mpr.InverseTransform(v, (float)bb->x, (float)bb->y, xt, yt); float x0, y0; v.transform(0, 0, x0, y0); v.translate(-x0, -y0); v.transform(xt, yt, xt, yt); int xorig = -pround(xt); int yorig = -pround(yt); dwidth = bb->width; dheight = bb->height; check_dim(dwidth, dheight); return DrawDestTransformedImage( dis, img, v, dwidth, dheight, xorig, yorig ); } static Pixmap CreateDestRaster( const Mapper& mpr, Display& dis, OvRestrictedImage& img, const Transformer& tx, IntCoord& xmin, IntCoord& ymin, IntCoord& dwidth, IntCoord& dheight ) { TransformedInfo( &mpr, img.Width(), img.Height(), tx, &xmin, nil, &ymin, nil, nil, nil ); Transformer v(tx); float x0, y0; v.transform(0, 0, x0, y0); v.translate(-x0, -y0); IntCoord dxmin, dymin; TransformedInfo( &mpr, img.Width(), img.Height(), v, &dxmin, nil, &dymin, nil, &dwidth, &dheight ); check_dim(dwidth, dheight); int dx0 = -dxmin; int dy0 = -dymin; return DrawDestTransformedImage(dis, img, v, dwidth, dheight, dx0, dy0); } static void TransformFromSource( IntCoord swidth, IntCoord sheight, const Transformer& tx, boolean& fromsource, boolean& overlimit ) { boolean rotated; IntCoord dwidth, dheight; TransformedInfo( nil, swidth, sheight, tx, nil, nil, nil, nil, &dwidth, &dheight, &rotated ); // this doesn't consider non-uniform scaling boolean zoomed_out = dwidth * dheight < swidth * sheight; fromsource = !(rotated || zoomed_out); overlimit = (dwidth * dheight) > 1000000; } static inline signed char _ovtxkey (int i) { if (i >= 0) { return ( i<32 ? i : i<160 ? 24 + (i>>2) : i<672 ? 54 + (i>>4) : 127 ); } else { return ( i>-32 ? i : i>-160 ? -24 - (i>>2) : i>-672 ? -54 - (i>>4) : -127 ); } } static int ovtx_key(const Transformer& tx, float x, float y) { float x1, y1, x2, y2, x3, y3; tx.transform(0, 0, x1, y1); tx.transform(0, y, x2, y2); tx.transform(x, 0, x3, y3); int k1 = _ovtxkey(int(x2 - x1)) & 0xff; int k2 = _ovtxkey(int(y2 - y1 - y)) & 0xff; int k3 = _ovtxkey(int(x3 - x1 - x)) & 0xff; int k4 = _ovtxkey(int(y3 - y1)) & 0xff; return (k1 << 24) + (k2 << 16) + (k3 << 8) + k4; } // ------------------------------------------------------------------------- class RasterKey { public: RasterKey(); RasterKey(const Transformer&, float width, float height); operator long() const; // hash boolean operator ==(const RasterKey&) const; protected: Transformer _tx; float _width; float _height; }; RasterKey::RasterKey(const Transformer& t, float w, float h) : _tx(t), _width(w), _height(h) { float x, y; _tx.transform(0., 0., x, y); _tx.translate(-x, -y); } RasterKey::RasterKey() { } RasterKey::operator long() const { // hash return (long)ovtx_key(_tx, _width, _height); } static inline boolean eq_tol(float a, float b) { static float tol = 1e-6; float diff = a - b; return ((diff >= -tol) && (diff <= tol)); } boolean RasterKey::operator ==(const RasterKey& r) const { float m00, m01, m10, m11, m20, m21; _tx.GetEntries(m00, m01, m10, m11, m20, m21); Transformer ct(r._tx); float x, y; ct.transform(0., 0., x, y); ct.translate(-x, -y); float tm00, tm01, tm10, tm11, tm20, tm21; ct.GetEntries(tm00, tm01, tm10, tm11, tm20, tm21); return( eq_tol(m00, tm00) && eq_tol(m01, tm01) && eq_tol(m10, tm10) && eq_tol(m11, tm11) && eq_tol(m20, tm20) && eq_tol(m21, tm21) ); } // ------------------------------------------------------------------------- declareTable2(OvPixmapTableBase,const Raster*,RasterKey,Pixmap) implementTable2(OvPixmapTableBase,const Raster*,RasterKey,Pixmap) class OvPixmapTable : public OvPixmapTableBase { public: OvPixmapTable(int size); void remove(const Raster*); }; OvPixmapTable::OvPixmapTable(int size) : OvPixmapTableBase(size) { } // having only one key we are forced to delete by iterating through the entire // table void OvPixmapTable::remove(const Raster* r) { Display& d = *Session::instance()->default_display(); XDisplay* dpy = d.rep()->display_; OvPixmapTableBase_Entry** a; register OvPixmapTableBase_Entry* e; for (a = first_; a <= last_; a++) { e = *a; while (e != nil) { if (e->key1_ == r) { *a = e->chain_; XFreePixmap(dpy, e->value_); delete e; e = *a; } else { register OvPixmapTableBase_Entry* prev; do { prev = e; e = e->chain_; } while (e != nil && (e->key1_ != r)); if (e != nil) { prev->chain_ = e->chain_; XFreePixmap(dpy, e->value_); delete e; e = prev->chain_; } } } } } static OvPixmapTable* tx_pixmaps_; // ------------------------------------------------------------------------- class SourceRep { public: SourceRep(Pixmap, float hs, float vs, IntCoord w, IntCoord h); ~SourceRep(); Pixmap map_; float hscale_; float vscale_; IntCoord pwidth_; IntCoord pheight_; }; SourceRep::SourceRep(Pixmap pm, float hs, float vs, IntCoord w, IntCoord h) : map_(pm), hscale_(hs), vscale_(vs), pwidth_(w), pheight_(h) { } SourceRep::~SourceRep() { } declareTable(OvSourceTable,const Raster*,SourceRep*) implementTable(OvSourceTable,const Raster*,SourceRep*) static OvSourceTable* source_table_; // swidth, sheight and key are always set // if dpm is set then use that else either sri or spm will be set // if spm or sri is set then hscale, vscale will be set static void ImageSetup( const OverlayRaster* o_r, OverlayRasterRect* r_r, const Transformer& tx, OvFileImage*& sri, Pixmap& spm, IntCoord& swidth, IntCoord& sheight, float& hscale, float& vscale, int& key, Pixmap& dpm ) { const OverlayRaster* r = o_r ? o_r : r_r->GetOriginal(); Display* d = r->rep()->display_; sri = nil; spm = dpm = nil; key = ovtx_key(tx, r->width(), r->height()); #if 0 if (key == 0) { // no scale or rotation #else if (!(tx.Rotated() || tx.Scaled())) { #endif if (!r->rep()->pixmap_) { r_r->load_image(); } dpm = r->rep()->pixmap_; swidth = r->rep()->pwidth_; sheight = r->rep()->pheight_; } else { // rotated or scaled RasterKey rkey(tx, r->width(), r->height()); if (!tx_pixmaps_->find(dpm, r, rkey)) { if (r->rep()->pixmap_) { spm = r->rep()->pixmap_; swidth = r->rep()->pwidth_; sheight = r->rep()->pheight_; hscale = vscale = 1.; } else { if (tx.Rotated()) { r_r->load_image(); spm = r->rep()->pixmap_; swidth = r->rep()->pwidth_; sheight = r->rep()->pheight_; hscale = vscale = 1.; } else { // -- scaled only float m00, m01, m10, m11, m20, m21; tx.GetEntries(hscale, m01, m10, vscale, m20, m21); SourceRep* srep; if (!source_table_->find(srep, r)) { if ((hscale < 1.) && (vscale < 1.)) { // need to store this later in source_table sri = OvFileImage::create(d, r_r); assert(sri); swidth = sri->Width(); sheight = sri->Height(); } else { r_r->load_image(); spm = r->rep()->pixmap_; swidth = r->rep()->pwidth_; sheight = r->rep()->pheight_; hscale = vscale = 1.; } } else { assert( srep->hscale_ < 1. ); // -- ensure that the cached image has more detail if ( (srep->hscale_ > hscale) && (srep->vscale_ > vscale) ) { spm = srep->map_; swidth = srep->pwidth_; sheight = srep->pheight_; hscale = srep->hscale_; vscale = srep->vscale_; } else if ((hscale < 1.) && (vscale < 1.)) { // we need some sort of hueristic, we may just want // to read the 1x res // need to store this later in source_table sri = OvFileImage::create(d, r_r); assert(sri); swidth = sri->Width(); sheight = sri->Height(); } else { // normal or zoomed in scale r_r->load_image(); spm = r->rep()->pixmap_; swidth = r->rep()->pwidth_; sheight = r->rep()->pheight_; hscale = vscale = 1.; } } } } } else { swidth = r->rep()->pwidth_; sheight = r->rep()->pheight_; } } } static Pixmap DetermineImage( const Mapper& mpr, unsigned long fg, unsigned long bg, const OverlayRaster* o_r, OverlayRasterRect* r_r, const Transformer& tx, XRectangle* bb, boolean& free_pixmap, IntCoord& xmin, IntCoord& ymin, IntCoord& dwidth, IntCoord& dheight ) { Pixmap map; const OverlayRaster* r = o_r ? o_r : r_r->GetOriginal(); Display& dis = *r->rep()->display_; Pixmap spm = nil; Pixmap dpm = nil; IntCoord swidth, sheight; float hscale, vscale; OvFileImage* sri = nil; int key; ImageSetup( r, r_r, tx, sri, spm, swidth, sheight, hscale, vscale, key, dpm ); boolean from_source, over_maxpixels; TransformFromSource(swidth, sheight, tx, from_source, over_maxpixels); if (dpm) { map = dpm; free_pixmap = false; TransformedInfo( &mpr, swidth, sheight, tx, &xmin, nil, &ymin, nil, &dwidth, &dheight ); } else if (sri) { // not rotated, hscale && vscale < 1 if (over_maxpixels) { // just do visable area free_pixmap = true; map = CreateDestClippedRaster( mpr, dis, *sri, tx, bb, dwidth, dheight ); xmin = bb->x; ymin = bb->y; } else { free_pixmap = false; map = CreateDestRaster( mpr, dis, *sri, tx, xmin, ymin, dwidth, dheight ); SourceRep* srep; if (source_table_->find(srep, r)) { source_table_->remove(r); delete srep; } srep = new SourceRep( map, hscale, vscale, dwidth, dheight ); source_table_->insert(r,srep); RasterKey rkey(tx, r->width(), r->height()); tx_pixmaps_->insert(r, rkey, map); } delete sri; } else { // spm is set if (r->rep()->pixmap_) { // this raster has no need for source_table SourceRep* srep; if (source_table_->find(srep, r)) { source_table_->remove(r); delete srep; } } float m00, m01, m10, m11, m20, m21; tx.GetEntries(m00, m01, m10, m11, m20, m21); Transformer stx(m00/hscale, m01, m10, m11/vscale, m20, m21); if (over_maxpixels) { // just do visable area free_pixmap = true; if (from_source) { map = CreateSourceClippedRaster( mpr, fg, bg, dis, r, spm, swidth, sheight, stx, bb, dwidth, dheight ); } else { OvMemoryImage mem(icache_->get(dis, spm, swidth, sheight, r)); map = CreateDestClippedRaster( mpr, dis, mem, stx, bb, dwidth, dheight ); } xmin = bb->x; ymin = bb->y; } else { // full image free_pixmap = false; if (from_source) { map = CreateSourceRaster( mpr, fg, bg, dis, r, spm, swidth, sheight, stx, xmin, ymin, dwidth, dheight ); } else { // from destination OvMemoryImage mem(icache_->get(dis, spm, swidth, sheight,r)); map = CreateDestRaster( mpr, dis, mem, stx, xmin, ymin, dwidth, dheight ); } RasterKey rkey(tx, r->width(), r->height()); tx_pixmaps_->insert(r, rkey, map); } } return map; } void OverlayPainter::RasterRect( Canvas* c, IntCoord x, IntCoord y, Raster* r ) { DoRasterRect(c, x, y, (OverlayRaster*)r, nil); } void OverlayPainter::RasterRect( Canvas* c, IntCoord x, IntCoord y, OverlayRasterRect* r_r ) { DoRasterRect(c, x, y, nil, r_r); } void OverlayPainter::DoRasterRect( Canvas* c, IntCoord x, IntCoord y, OverlayRaster* o_r, OverlayRasterRect* r_r ) { if (c == nil || r_r == nil) { return; } r_r->load_image(); const OverlayRaster* r = o_r ? o_r : r_r->GetOriginal(); r_r->damage_flush(); // was r->flush() if (!icache_) { icache_ = new ImageCache(); } if (!source_table_) { source_table_ = new OvSourceTable(1024); } if (!tx_pixmaps_) { tx_pixmaps_ = new OvPixmapTable(1024); } // -- transform the corners of the image IntCoord rw = (unsigned int)r->pwidth(); IntCoord rh = (unsigned int)r->pheight(); IntCoord x1, y1, x2, y2, x3, y3, x4, y4; MapRoundUp(c, x, y, x1, y1); MapRoundUp(c, x, y + rh, x2, y2); MapRoundUp(c, x + rw, y + rh, x3, y3); MapRoundUp(c, x + rw, y, x4, y4); XPoint rast_area[4]; rast_area[0].x = x1; rast_area[0].y = y1; rast_area[1].x = x2; rast_area[1].y = y2; rast_area[2].x = x3; rast_area[2].y = y3; rast_area[3].x = x4; rast_area[3].y = y4; Region rg = XPolygonRegion(rast_area, 4, EvenOddRule); static const Transformer tt; const Transformer* tmatrix = GetTransformer() ? GetTransformer() : &tt; XRectangle bb; if (Rep()->clipped) { BoundingRectIntersect(Rep()->xclip[0], rg, bb); // cerr << "used clipbox of " // << Rep()->xclip[0].x << "," << Rep()->xclip[0].y << "," // << Rep()->xclip[0].width << "," << Rep()->xclip[0].height << "\n"; } else { XRectangle canvas_rect; canvas_rect.x = 0; canvas_rect.y = 0; canvas_rect.height = c->pheight(); canvas_rect.width = c->pwidth(); BoundingRectIntersect(canvas_rect, rg, bb); } Region tmp = XCreateRegion(); XUnionRectWithRegion(&bb, tmp, tmp); XIntersectRegion(rg, tmp, rg); XDestroyRegion(tmp); if (r_r && r_r->clippts()) { MultiLineObj* mlo = r_r->clippts(); XPoint polypts[mlo->count()]; for (int i=0; icount(); i++) { IntCoord x, y; MapRoundUp(c, mlo->x()[i], mlo->y()[i], x, y); polypts[i].x = x; polypts[i].y = y; } Region poly = XPolygonRegion(polypts, mlo->count(), EvenOddRule); XIntersectRegion(rg, poly, rg); XDestroyRegion(poly); } boolean free_pmap; IntCoord xmin, ymin; // map from ul to ll and the X origin to IV origin XRectangle iv_bb(bb); iv_bb.y = bb.y + bb.height; iv_bb.y = c->pheight() - 1 - iv_bb.y; IntCoord pwidth, pheight; IntCoord cx, cy; GetOrigin(cx, cy); Mapper mapper(cx, cy, x, y); Pixmap dest = DetermineImage( mapper, GetFgColor()->PixelValue(), GetBgColor()->PixelValue(), o_r, r_r, *tmatrix, &iv_bb, free_pmap, xmin, ymin, pwidth, pheight ); Display& d = *r->rep()->display_; XDisplay* dpy = d.rep()->display_; XDrawable xid = c->rep()->xdrawable_; if (xid != CanvasRep::unbound) { XSetRegion(dpy, Rep()->fillgc, rg); XSetGraphicsExposures(dpy, Rep()->fillgc, False); int _ymin = c->pheight() - 1 - (ymin + pheight); boolean transparent_val = 0; if (r_r->alphaval()<1.0 /* || transparent_val */ ) { /* WITH alpha-tranparency */ unsigned long alpha = (unsigned long)(r_r->alphaval() * 65535); unsigned long beta = 65535 - alpha; /* adjust pwidth and pheight, because they might be in error */ XWindow win_ret; int x_ret, y_ret; unsigned int w_ret, h_ret, borderw_ret, depth_ret; XGetGeometry(dpy, dest, &win_ret, &x_ret, &y_ret, &w_ret, &h_ret, &borderw_ret, &depth_ret); pwidth = Math::min((unsigned)pwidth, w_ret); pheight = Math::min((unsigned)pheight, h_ret); XImage* im1 = XGetImage(dpy, dest, 0, 0, pwidth, pheight, AllPlanes, ZPixmap); int xbclip = xmin < 0 ? -xmin : 0; int ybclip = _ymin < 0 ? -_ymin : 0; int xeclip = xmin + pwidth > c->pwidth() ? (pwidth + xmin) - c->pwidth() : 0; int yeclip = _ymin + pheight > c->pheight() ? (pheight + _ymin) - c->pheight() : 0; XImage* im2 = XGetImage(dpy, xid, xmin+xbclip, _ymin+ybclip, pwidth-xeclip-xbclip, pheight-yeclip-ybclip, AllPlanes, ZPixmap); if (im1 && im2) { for (int j=ybclip; jdefault_visual_->find_color(val1, xc1); d.rep()->default_visual_->find_color(val2, xc2); #if 0 if (!(transparent_val && xc1.red==0xffff && xc1.green==0xffff && xc1.blue==0xffff)) { #endif unsigned short newred = (unsigned short)((xc1.red*alpha+xc2.red*beta)>>16); unsigned short newgreen = (unsigned short)((xc1.green*alpha+xc2.green*beta)>>16); unsigned short newblue = (unsigned short)((xc1.blue*alpha+xc2.blue*beta)>>16); XColor newcolor; d.rep()->default_visual_->find_color((short unsigned int)newred, (short unsigned int)newgreen, (short unsigned int)newblue, newcolor); XPutPixel(im1, i, j, newcolor.pixel); #if 0 } else { XPutPixel(im1, i, j, xc2.pixel); } #endif } } XPutImage(dpy, xid, Rep()->fillgc, im1, xbclip, ybclip, xmin+xbclip, _ymin+ybclip, pwidth-xbclip-xeclip, pheight-ybclip-yeclip); XDestroyImage(im1); XDestroyImage(im2); } } else { /* WITHOUT alpha-tranparency */ XCopyArea( dpy, dest, xid, Rep()->fillgc, 0, 0, pwidth, pheight, xmin, _ymin); } XSetGraphicsExposures(dpy, Rep()->fillgc, True); XDestroyRegion(rg); if (Rep()->clipped) { XSetClipRectangles( dpy, Rep()->fillgc, 0, 0, Rep()->xclip, 1, Unsorted ); } else { NoClip(); } } if (free_pmap) { XFreePixmap(dpy, dest); icache_->remove(dest); } } void OverlayPainter::MapRoundUp( Canvas* c, IntCoord x, IntCoord y, IntCoord& mx, IntCoord& my ) { Transformer* matrix = GetTransformer(); int xoff, yoff; if (matrix == nil) { mx = x; my = y; } else { float fx, fy; matrix->Transform(float(x), float(y), fx, fy); mx = pround(fx); my = pround(fy); } GetOrigin(xoff, yoff); mx += xoff; my = c->pheight() - 1 - (my + yoff); } // --------------------------------------------------------------------------- /* static */ void OverlayPainter::Uncache(Raster* r) { Display& d = *r->rep()->display_; XDisplay* dpy = d.rep()->display_; if (icache_) { icache_->remove(r->rep()->pixmap_); // deletes ximage } // tx_pixmaps_ is a superset of source_table_ if (tx_pixmaps_) { tx_pixmaps_->remove(r); // frees pixmap } if (source_table_) { SourceRep* dum; while(source_table_->find_and_remove(dum, r)); } } /* static */ void OverlayPainter::FreeCache() { Display& d = *Session::instance()->default_display(); XDisplay* dpy = d.rep()->display_; if (icache_) { delete icache_; // will free up ximages icache_ = nil; } // tx_pixmaps_ is a superset of source_table_ if (tx_pixmaps_) { Table2Iterator(OvPixmapTableBase) i(*tx_pixmaps_); for (; i.more(); i.next()) { XFreePixmap(dpy, i.cur_value()); } delete tx_pixmaps_; tx_pixmaps_ = nil; } delete source_table_; source_table_ = nil; } ivtools-1.2.11a1/src/OverlayUnidraw/ovpainter.h000066400000000000000000000060361214471147700214540ustar00rootroot00000000000000/* * Copyright (c) 1994-1995,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlayPainter -- painter extended to support OverlayUnidraw * */ #ifndef ovpainter_h #define ovpainter_h #include class OverlayRaster; class OverlayRasterRect; //: specialized Painter for use with OverlayUnidraw. class OverlayPainter : public Painter { public: #ifdef RasterRect #undef RasterRect virtual void RasterRect(Canvas*, Coord x, Coord y, Raster*); virtual void RasterRect(Canvas*, Coord x, Coord y, OverlayRasterRect*); #define RasterRect _lib_iv(RasterRect) #else virtual void RasterRect(Canvas*, Coord x, Coord y, Raster*); virtual void RasterRect(Canvas*, Coord x, Coord y, OverlayRasterRect*); #endif /* RasterRect */ void MapRoundUp(Canvas*c, IntCoord x, IntCoord y, IntCoord& mx, IntCoord& my); static void Uncache(Raster*); static void FreeCache(); protected: virtual void DoRasterRect( Canvas*, Coord x, Coord y, OverlayRaster*, OverlayRasterRect* ); }; /* * Per-display shared painter information. */ #include #include #include class Bitmap; class RasterRep; declareTable2(BitmapTable,XFont,int,Bitmap*) declareTable2(RasterTable,const Raster*,int,RasterRep*) class PainterDpyInfoList; class PainterDpyInfo { public: Display* display_; BitmapTable* btable_; BitmapTable* txtable_; RasterTable* tx_rasters_; static PainterDpyInfoList* info_list_; enum { TxFontsDefault, TxFontsOff, TxFontsOn, TxFontsCache } txfonts; enum { TxImagesDefault, TxImagesAuto, TxImagesDest, TxImagesSource } tximages; static PainterDpyInfo* find(Display*); int tx_key(const Transformer&, Coord x, Coord y); Bitmap* get_char_bitmap(const Font*, int c, int k, const Transformer&); RasterRep* tx_raster(const Raster*, const Transformer&); }; declarePtrList(PainterDpyInfoList,PainterDpyInfo); #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovpanner.cc000066400000000000000000000273761214471147700214450ustar00rootroot00000000000000/* * Copyright (c) 1995 Vectaport Inc. * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlayPanner implementation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ OverlayPanner::OverlayPanner (Interactor* i, int size, boolean panner, boolean zoomer, boolean slider) { Init(i, size, panner, zoomer, slider); } OverlayPanner::OverlayPanner (const char* name, Interactor* i, int size, boolean panner, boolean zoomer, boolean slider) { SetInstance(name); Init(i, size, panner, zoomer, slider); } OverlayPanner::~OverlayPanner() { } /* 0.3 second delay for auto-repeat */ static int DELAY = 3; void OverlayPanner::Init (Interactor* i, int n, boolean panner, boolean zoomer, boolean slider) { panner_on() = panner; zoomer_on() = zoomer; slider_on() = slider; SetClassName("OverlayPanner"); size = n; VBox* panner_vbox = nil; if (panner_on()) panner_vbox = new VBox( new VGlue, new OvUpMover(i, DELAY), new HBox( new HGlue, new OvLeftMover(i, DELAY), new HGlue, new OvRightMover(i, DELAY), new HGlue ), new OvDownMover(i, DELAY), new VGlue ); VBox* zoomer_vbox = nil; if (zoomer_on()) zoomer_vbox = new VBox( new VGlue(2), new Enlarger(i), new VGlue(4), new Reducer(i), new VGlue(2) ); if (panner_vbox || zoomer_vbox) { adjusters = new HBox(); adjusters->Insert(new HGlue()); if (panner_vbox) { adjusters->Insert(panner_vbox); adjusters->Insert(new HGlue); } if (zoomer_vbox) { adjusters->Insert(zoomer_vbox); adjusters->Insert(new HGlue); } if (slider_on()) { islider = new OverlaySlider(i); Insert(new VBox(adjusters, new HBorder, islider)); } else Insert(adjusters); } } void OverlayPanner::Reconfig () { MonoScene::Reconfig(); Shape a = *adjusters->GetShape(); if (a.vstretch != 0 || a.vshrink != a.height / 3) { if (size != 0) { a.width = size; a.hshrink = a.hstretch = 0; } a.vstretch = 0; a.vshrink = a.height/3; adjusters->Reshape(a); } if (slider_on()) { Shape* s = islider->GetShape(); if (s->width != a.width) islider->Reshape(a); } } static const int MIN_SLIDER_HT = 20; enum MoveType { MOVE_HORIZ, MOVE_VERT, MOVE_UNDEF }; OverlaySlider::OverlaySlider (Interactor* i) { Init(i); } OverlaySlider::OverlaySlider (const char* name, Interactor* i) { SetInstance(name); Init(i); } void OverlaySlider::Init (Interactor* i) { SetClassName("OverlaySlider"); interactor = i; view = i->GetPerspective(); view->Attach(this); shown = new Perspective; constrained = false; moveType = MOVE_UNDEF; *shown = *view; shape->vstretch = shape->vshrink = 0; prevl = prevb = prevr = prevt = 0; input = new Sensor(updownEvents); } void OverlaySlider::Reconfig () { Painter* p = new Painter(output); p->Reference(); Unref(output); output = p; const char* attrib = GetAttribute("syncScroll"); syncScroll = attrib != nil && (strcmp(attrib, "true") == 0 || strcmp(attrib, "on") == 0); } void OverlaySlider::Reshape (Shape& ns) { if (shown->width == 0) { *shape = ns; } else { shape->width = (canvas == nil) ? ns.width : xmax + 1; float aspect = float(shown->height) / float(shown->width); int h = Math::round(aspect * float(shape->width)); if (h != shape->height) { shape->height = h; Scene* p = Parent(); if (p != nil) { p->Change(this); } } } } void OverlaySlider::Draw () { if (canvas != nil) { output->SetPattern(new Pattern(Pattern::lightgray)); output->FillRect(canvas, 0, 0, xmax, ymax); output->SetPattern(new Pattern(Pattern::clear)); output->FillRect(canvas, left, bottom, right, top); output->SetPattern(new Pattern(Pattern::solid)); output->Rect(canvas, left, bottom, right, top); #ifdef Line #undef Line output->Line(canvas, left+1, bottom-1, right+1, bottom-1); output->Line(canvas, right+1, bottom-1, right+1, top-1); #define Line _lib_iv(Line) #else output->Line(canvas, left+1, bottom-1, right+1, bottom-1); output->Line(canvas, right+1, bottom-1, right+1, top-1); #endif prevl = left; prevb = bottom; prevr = right; prevt = top; } } void OverlaySlider::Redraw ( IntCoord left, IntCoord bottom, IntCoord right, IntCoord top ) { output->Clip(canvas, left, bottom, right, top); Draw(); output->NoClip(); } inline IntCoord OverlaySlider::ViewX (IntCoord x) { return Math::round(float(x) * float(shown->width) / float(xmax)); } inline IntCoord OverlaySlider::ViewY (IntCoord y) { return Math::round(float(y) * float(shown->height) / float(ymax)); } inline IntCoord OverlaySlider::SliderX (IntCoord x) { return Math::round(float(x) * float(xmax) / float(shown->width)); } inline IntCoord OverlaySlider::SliderY (IntCoord y) { return Math::round(float(y) * float(ymax) / float(shown->height)); } void OverlaySlider::Move (IntCoord dx, IntCoord dy) { shown->curx += dx; shown->cury += dy; } boolean OverlaySlider::Inside (Event& e) { return e.x > left && e.x < right && e.y > bottom && e.y < top; } void OverlaySlider::CalcLimits (Event& e) { llim = e.x - Math::max(0, left); blim = e.y - Math::max(0, bottom); rlim = e.x + Math::max(0, xmax - right); tlim = e.y + Math::max(0, ymax - top); constrained = e.shift; moveType = MOVE_UNDEF; origx = e.x; origy = e.y; } static int CONSTRAIN_THRESH = 2; // difference between x and y movement needed to decide which direction // is constrained void OverlaySlider::Constrain (Event& e) { IntCoord dx, dy; if (constrained && moveType == MOVE_UNDEF) { dx = Math::abs(e.x - origx); dy = Math::abs(e.y - origy); if (Math::abs(dx - dy) < CONSTRAIN_THRESH) { e.x = origx; e.y = origy; } else if (dx > dy) { moveType = MOVE_HORIZ; } else { moveType = MOVE_VERT; } } if (!constrained) { e.x = Math::min(Math::max(e.x, llim), rlim); e.y = Math::min(Math::max(e.y, blim), tlim); } else if (moveType == MOVE_HORIZ) { e.x = Math::min(Math::max(e.x, llim), rlim); e.y = origy; } else if (moveType == MOVE_VERT) { e.x = origx; e.y = Math::min(Math::max(e.y, blim), tlim); } } void OverlaySlider::Slide (Event& e) { IntCoord newleft, newbot, dummy; boolean control = e.control; Listen(allEvents); SlidingRect r(output, canvas, left, bottom, right, top, e.x, e.y); CalcLimits(e); do { switch (e.eventType) { case MotionEvent: e.target->GetRelative(e.x, e.y, this); Constrain(e); r.Track(e.x, e.y); if ((syncScroll && !control) || (!syncScroll && control)) { r.Erase(); r.GetCurrent(newleft, newbot, dummy, dummy); Move(ViewX(newleft - left), ViewY(newbot - bottom)); interactor->Adjust(*shown); } break; default: break; } Read(e); } while (e.eventType != UpEvent); r.GetCurrent(newleft, newbot, dummy, dummy); Move(ViewX(newleft - left), ViewY(newbot - bottom)); Listen(input); } void OverlaySlider::Jump (Event& e) { register Perspective* s = shown; IntCoord dx, dy; if (e.button == RIGHTMOUSE) { dx = ViewX(e.x) - s->curx - s->curwidth/2; dy = ViewY(e.y) - s->cury - s->curheight/2; } else { if (e.button == LEFTMOUSE) { dx = s->sx; dy = s->sy; } else { dx = s->lx; dy = s->ly; } if (e.x < left) { dx = -dx; } else if (e.x < right) { dx = 0; } if (e.y < bottom) { dy = -dy; } else if (e.y < top) { dy = 0; } } dx = Math::min( Math::max(s->x0 - s->curx, dx), s->x0 + s->width - s->curx - s->curwidth ); dy = Math::min( Math::max(s->y0 - s->cury, dy), s->y0 + s->height - s->cury - s->curheight ); Move(dx, dy); } void OverlaySlider::Handle (Event& e) { Perspective oldp = *shown; if (e.eventType == DownEvent) { if (Inside(e)) { Slide(e); } else { Jump(e); } interactor->Adjust(*shown); if (((OverlayViewer*)interactor)->Chained()) { IntCoord dx = shown->curx - oldp.curx; IntCoord dy = shown->cury - oldp.cury; Iterator i; for (unidraw->First(i); !unidraw->Done(i); unidraw->Next(i)) { OverlayViewer* v = (OverlayViewer*)unidraw->GetEditor(i)->GetViewer(); Perspective p = *v->GetPerspective(); if (interactor != v && v->Chained()) { p.curx += dx * p.width / oldp.width; p.cury += dy * p.height / oldp.height; v->Adjust(p); } } } } } static const int MIN_SIZE = 2; void OverlaySlider::SizeKnob () { register Perspective* s = shown; if (canvas != nil) { left = SliderX(s->curx - s->x0); bottom = SliderY(s->cury - s->y0); right = left + Math::max(SliderX(s->curwidth), MIN_SIZE); top = bottom + Math::max(SliderY(s->curheight), MIN_SIZE); } } #include void OverlaySlider::Update () { register Perspective* p = shown; int h, oldwidth, oldheight; float aspect; Scene* s; Shape ns; oldwidth = p->width; oldheight = p->height; *p = *view; aspect = float(p->height) / float(p->width); SizeKnob(); if (p->width != oldwidth || p->height != oldheight) { h = Math::round(aspect * float(shape->width)); #if 0 printf("pw=%d, ph=%d, ow=%d, oh=%d, sw=%d, sh=%d, aspect=%f, h=%d\n", p->width, p->height, oldwidth, oldheight, shape->width, shape->height, aspect, h); #endif if (h == shape->height || h+1 == shape->height || h-1==shape->height) { Draw(); } else { shape->height = h; if ((s = Parent()) != nil) { s->Change(this); } } } else if ( prevl != left || prevb != bottom || prevr != right || prevt != top ) { Draw(); } } void OverlaySlider::Resize () { int w = xmax + 1; if (shape->width != w) { Shape ns = *shape; ns.width = w; Reshape(ns); } SizeKnob(); } OverlaySlider::~OverlaySlider () { view->Detach(this); Unref(shown); } ivtools-1.2.11a1/src/OverlayUnidraw/ovpanner.h000066400000000000000000000073241214471147700212760ustar00rootroot00000000000000/* * Copyright (c) 1995,1999 Vectaport Inc. * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * OverlayPanner - an interactor for two-dimensional scrolling and zooming. */ #ifndef ovpanner_h #define ovpanner_h #include #include //: flexible panner/zoomer/slider window. class OverlayPanner : public MonoScene { public: OverlayPanner(Interactor*, int size = 0, boolean panner = true, boolean zoomer = true, boolean slider = true); OverlayPanner(const char*, Interactor*, int size = 0, boolean panner = true, boolean zoomer = true, boolean slider = true); virtual ~OverlayPanner(); boolean& panner_on() { return _panner_on; } // set/get flag to enable/disable panner. boolean& zoomer_on() { return _zoomer_on; } // set/get flag to enable/disable zoomer. boolean& slider_on() { return _slider_on; } // set/get flag to enable/disable slider. protected: int size; boolean _panner_on; boolean _zoomer_on; boolean _slider_on; virtual void Reconfig(); private: Scene* adjusters; Interactor* islider; void Init(Interactor*, int, boolean, boolean, boolean); }; //: slider window within an OverlayPanner. class OverlaySlider : public Interactor { public: OverlaySlider(Interactor*); OverlaySlider(const char*, Interactor*); virtual ~OverlaySlider(); virtual void Draw(); virtual void Handle(Event&); virtual void Update(); virtual void Reshape(Shape&); virtual void Resize(); protected: virtual void Reconfig(); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); private: Interactor* interactor; Perspective* view; Perspective* shown; IntCoord left, bottom, right, top; IntCoord prevl, prevb, prevr, prevt; // for smart update IntCoord llim, blim, rlim, tlim; // sliding limits boolean constrained, syncScroll; int moveType; IntCoord origx, origy; void Init(Interactor*); IntCoord ViewX(IntCoord); IntCoord ViewY(IntCoord); IntCoord SliderX(IntCoord); IntCoord SliderY(IntCoord); void CalcLimits(Event&); // calculate sliding limits void SizeKnob(); // calculate size of slider knob boolean Inside(Event&); // true if inside slider knob void Constrain(Event&); // constrain slider knob motion void Move(IntCoord dx, IntCoord dy);// move view to reflect slider position void Slide(Event&); // rubberband rect while mousing void Jump(Event&); // for click outside knob }; #include #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovpolygon.cc000066400000000000000000000212331214471147700216330ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Polygon component definitions. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::cerr; /****************************************************************************/ ParamList* PolygonOvComp::_ovpolygon_params = nil; int PolygonOvComp::_symid = -1; ClassId PolygonOvComp::GetClassId () { return OVPOLYGON_COMP; } boolean PolygonOvComp::IsA (ClassId id) { return OVPOLYGON_COMP == id || VerticesOvComp::IsA(id); } Component* PolygonOvComp::Copy () { PolygonOvComp* comp = new PolygonOvComp((SF_Polygon*) GetGraphic()->Copy()); if (attrlist()) comp->SetAttributeList(new AttributeList(attrlist())); return comp; } PolygonOvComp::PolygonOvComp (SF_Polygon* graphic, OverlayComp* parent) : VerticesOvComp(graphic, parent) { } PolygonOvComp::PolygonOvComp(istream& in, OverlayComp* parent) : VerticesOvComp(nil, parent) { _valid = GetParamList()->read_args(in, this); } ParamList* PolygonOvComp::GetParamList() { if (!_ovpolygon_params) GrowParamList(_ovpolygon_params = new ParamList()); return _ovpolygon_params; } void PolygonOvComp::GrowParamList(ParamList* pl) { pl->add_param("points", ParamStruct::required, (param_callback)&PolygonScript::ReadPoints, this, &_gr); VerticesOvComp::GrowParamList(pl); return; } SF_Polygon* PolygonOvComp::GetPolygon () { return (SF_Polygon*) GetGraphic(); } /****************************************************************************/ PolygonOvView::PolygonOvView (PolygonOvComp* subj) : VerticesOvView(subj) { } PolygonOvComp* PolygonOvView::GetPolygonOvComp () { return (PolygonOvComp*) GetSubject(); } ClassId PolygonOvView::GetClassId () { return OVPOLYGON_VIEW; } boolean PolygonOvView::IsA (ClassId id) { return OVPOLYGON_VIEW == id || VerticesOvView::IsA(id); } boolean PolygonOvView::VertexChanged () { SF_Polygon* gview = (SF_Polygon*) GetGraphic(); SF_Polygon* gsubj = (SF_Polygon*) GetPolygonOvComp()->GetGraphic(); return *gview != *gsubj; } Manipulator* PolygonOvView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Manipulator* m = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { ((OverlayEditor*)v->GetEditor())->MouseDocObservable()->textvalue(OverlayKit::mouse_tack); v->Constrain(e.x, e.y); Coord x[1], y[1]; x[0] = e.x; y[0] = e.y; GrowingVertices* rub = new GrowingPolygon( nil, nil, x, y, 1, -1, HANDLE_SIZE ); if (((OverlayViewer*)v)->scribble_pointer()) m = new ScribbleVertexManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); else m = new VertexManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else if (tool->IsA(RESHAPE_TOOL)) { ((OverlayEditor*)v->GetEditor())->MouseDocObservable()->textvalue(OverlayKit::mouse_tack); Coord* x, *y; int n; v->Constrain(e.x, e.y); GetVertices(x, y, n); GrowingPolygon* rub = new GrowingPolygon( nil, nil, x, y, n, ClosestPoint(x, y, n, e.x, e.y), HANDLE_SIZE ); delete x; delete y; m = new VertexManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else { m = VerticesOvView::CreateManipulator(v, e, rel, tool); } return m; } Command* PolygonOvView::InterpretManipulator (Manipulator* m) { DragManip* dm = (DragManip*) m; Editor* ed = dm->GetViewer()->GetEditor(); Tool* tool = dm->GetTool(); Transformer* rel = dm->GetTransformer(); Command* cmd = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { GrowingVertices* gv = (GrowingVertices*) dm->GetRubberband(); ((OverlayEditor*)ed)->MouseDocObservable()->textvalue(OverlayKit::mouse_poly); Coord* x, *y; int n, pt; gv->GetCurrent(x, y, n, pt); if (n > 2 || x[0] != x[1] || y[0] != y[1]) { BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar"); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } Graphic* pg = GetGraphicComp()->GetGraphic(); SF_Polygon* polygon = new SF_Polygon(x, y, n, pg); if (brVar != nil) polygon->SetBrush(brVar->GetBrush()); if (patVar != nil) polygon->SetPattern(patVar->GetPattern()); if (colVar != nil) { polygon->FillBg(!colVar->GetBgColor()->None()); polygon->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } polygon->SetTransformer(rel); Unref(rel); cmd = new PasteCmd(ed, new Clipboard(new PolygonOvComp(polygon))); } delete x; delete y; } else if (tool->IsA(RESHAPE_TOOL)) { GrowingVertices* gv = (GrowingVertices*) dm->GetRubberband(); ((OverlayEditor*)ed)->MouseDocObservable()->textvalue(OverlayKit::mouse_poly); Coord* x, *y; int n, pt; gv->RemoveVertex(); gv->GetCurrent(x, y, n, pt); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } SF_Polygon* polygon = new SF_Polygon(x, y, n, GetGraphic()); delete x; delete y; polygon->SetTransformer(rel); Unref(rel); cmd = new ReplaceCmd(ed, new PolygonOvComp(polygon)); } else { cmd = VerticesOvView::InterpretManipulator(m); } return cmd; } /*****************************************************************************/ ClassId PolygonPS::GetClassId () { return POLYGON_PS; } boolean PolygonPS::IsA (ClassId id) { return POLYGON_PS == id || VerticesPS::IsA(id); } PolygonPS::PolygonPS (OverlayComp* subj) : VerticesPS(subj) { } const char* PolygonPS::Name () { return "Poly"; } /*****************************************************************************/ ClassId PolygonScript::GetClassId () { return POLYGON_SCRIPT; } boolean PolygonScript::IsA (ClassId id) { return POLYGON_SCRIPT == id || VerticesScript::IsA(id); } PolygonScript::PolygonScript (PolygonOvComp* subj) : VerticesScript(subj) { } const char* PolygonScript::Name () { return "polygon"; } int PolygonScript::ReadPoints (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { Coord* x, *y; int n, bad; char ch = in.peek(); if (ch != ')' && ch != ':') bad = ParamList::parse_points(in, x, y, n); else { x = y = nil; n =0; bad = 0; } if (!in.good() || bad) { delete x; delete y; cerr << "abnormal exit from PolygonScript::ReadPoints\n"; return -1; } else { *(SF_Polygon**)addr1 = new SF_Polygon(x, y, n); delete x; delete y; return 0; } } ivtools-1.2.11a1/src/OverlayUnidraw/ovpolygon.h000066400000000000000000000064661214471147700215100ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Polygon component declarations. */ #ifndef overlay_polygon_h #define overlay_polygon_h #include #include class SF_Polygon; //: clone of PolygonComp derived from OverlayComp. class PolygonOvComp : public VerticesOvComp { public: PolygonOvComp(SF_Polygon* = nil, OverlayComp* parent = nil); PolygonOvComp(istream&, OverlayComp* parent = nil); SF_Polygon* GetPolygon(); // return pointer to graphic. virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _ovpolygon_params; friend class OverlaysScript; CLASS_SYMID2("PolygonComp", OVPOLYGON_COMP); }; //: graphical view of PolygonOvComp. class PolygonOvView : public VerticesOvView { public: PolygonOvView(PolygonOvComp* = nil); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); // create manipulators for tools that create or reshape. virtual Command* InterpretManipulator(Manipulator*); // interpret manipulators for tools that create or reshape. PolygonOvComp* GetPolygonOvComp(); // return pointer to associated component. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual boolean VertexChanged(); }; //: "PostScript" view of PolygonOvComp. class PolygonPS : public VerticesPS { public: PolygonPS(OverlayComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual const char* Name(); // return name to differentiate from other VerticesPS. }; //: serialized view of PolygonOvComp. class PolygonScript : public VerticesScript { public: PolygonScript(PolygonOvComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); static int ReadPoints(istream&, void*, void*, void*, void*); // read point list and construct an SF_Polygon. protected: virtual const char* Name(); // return name to differentiate from other VerticesScript. }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovprecise.cc000066400000000000000000000211271214471147700216000ustar00rootroot00000000000000/* * Copyright (c) 2001 Scott Johnston * Copyright (c) 1998-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * precise commands */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ char* OvPreciseMoveCmd::_default_movestr = nil; int OvPreciseMoveCmd::_default_enumval = 0; ClassId OvPreciseMoveCmd::GetClassId () { return OVPRECISEMOVE_CMD; } boolean OvPreciseMoveCmd::IsA (ClassId id) { return OVPRECISEMOVE_CMD == id || PreciseMoveCmd::IsA(id); } OvPreciseMoveCmd::OvPreciseMoveCmd (ControlInfo* c) : PreciseMoveCmd(c) {} OvPreciseMoveCmd::OvPreciseMoveCmd (Editor* ed) : PreciseMoveCmd(ed) {} OvPreciseMoveCmd::~OvPreciseMoveCmd () {} Command* OvPreciseMoveCmd::Copy () { Command* copy = new OvPreciseMoveCmd(CopyControlInfo()); InitCopy(copy); return copy; } Glyph* OvPreciseMoveCmd::unit_buttons() { StringList* list = new StringList; String* str_i; str_i = new String("Pixels"); list->append(*str_i); str_i = new String("Points"); list->append(*str_i); str_i = new String("Centimeters"); list->append(*str_i); str_i = new String("Inches"); list->append(*str_i); _unit_enum = new ObservableEnum(list); _unit_enum->setvalue(_default_enumval); return new RadioEnumEditor(_unit_enum, "Units", true, true); } void OvPreciseMoveCmd::Execute () { if (!_default_movestr) _default_movestr = strdup("1.0 1.0"); char* movestr = StrEditDialog::post(GetEditor()->GetWindow(), "Enter X and Y movement:", _default_movestr, "Precise Move", unit_buttons()); int cur_unit = _unit_enum->intvalue(); _default_enumval = cur_unit; if (movestr) { std::istrstream in(movestr); float xmove = 0, ymove = 0; in >> xmove >> ymove; switch (cur_unit) { case 1: xmove *= ivpoints; ymove *= ivpoints; break; case 2: xmove *= ivcm; ymove *= ivcm; break; case 3: xmove *= ivinches; ymove *= ivinches; break; } if (xmove!=0.0 || ymove!=0.0) { MoveCmd* moveCmd = new MoveCmd(GetEditor(), xmove, ymove); moveCmd->Execute(); moveCmd->Log(); } delete _default_movestr; _default_movestr = movestr; } } /*****************************************************************************/ ClassId OvPreciseScaleCmd::GetClassId () { return OVPRECISESCALE_CMD; } boolean OvPreciseScaleCmd::IsA (ClassId id) { return OVPRECISESCALE_CMD == id || PreciseScaleCmd::IsA(id); } OvPreciseScaleCmd::OvPreciseScaleCmd (ControlInfo* c) : PreciseScaleCmd(c) {} OvPreciseScaleCmd::OvPreciseScaleCmd (Editor* ed) : PreciseScaleCmd(ed) {} OvPreciseScaleCmd::~OvPreciseScaleCmd () {} Command* OvPreciseScaleCmd::Copy () { Command* copy = new OvPreciseScaleCmd(CopyControlInfo()); InitCopy(copy); return copy; } void OvPreciseScaleCmd::Execute () { static char* default_scalestr = strdup("1.0 1.0"); char* scalestr = StrEditDialog::post(GetEditor()->GetWindow(), "Enter X and Y scaling:", default_scalestr, "Precise Scale"); if (scalestr) { std::istrstream in(scalestr); float xscale = 0.0, yscale = 0.0; in >> xscale >> yscale; if (xscale !=0.0 && yscale != 0.0) { ScaleCmd* scaleCmd = new ScaleCmd(GetEditor(), xscale, yscale); scaleCmd->Execute(); scaleCmd->Log(); } delete default_scalestr; default_scalestr = scalestr; } } /*****************************************************************************/ ClassId OvPreciseRotateCmd::GetClassId () { return OVPRECISEROTATE_CMD; } boolean OvPreciseRotateCmd::IsA (ClassId id) { return OVPRECISEROTATE_CMD == id || PreciseRotateCmd::IsA(id); } OvPreciseRotateCmd::OvPreciseRotateCmd (ControlInfo* c) : PreciseRotateCmd(c) {} OvPreciseRotateCmd::OvPreciseRotateCmd (Editor* ed) : PreciseRotateCmd(ed) {} OvPreciseRotateCmd::~OvPreciseRotateCmd () {} Command* OvPreciseRotateCmd::Copy () { Command* copy = new OvPreciseRotateCmd(CopyControlInfo()); InitCopy(copy); return copy; } void OvPreciseRotateCmd::Execute () { static char* default_rotatestr = strdup("45.0"); char* rotatestr = StrEditDialog::post(GetEditor()->GetWindow(), "Enter rotation in degrees:", default_rotatestr, "Precise Rotate"); if (rotatestr) { std::istrstream in(rotatestr); float angle = 0.0; in >> angle; if (angle!=0.0) { RotateCmd* rotateCmd = new RotateCmd(GetEditor(), angle); rotateCmd->Execute(); rotateCmd->Log(); } delete default_rotatestr; default_rotatestr = rotatestr; } } /*****************************************************************************/ ClassId OvPrecisePageCmd::GetClassId () { return OVPRECISEPAGE_CMD; } boolean OvPrecisePageCmd::IsA (ClassId id) { return OVPRECISEPAGE_CMD == id || PrecisePageCmd::IsA(id); } OvPrecisePageCmd::OvPrecisePageCmd (ControlInfo* c) : PrecisePageCmd(c) {} OvPrecisePageCmd::OvPrecisePageCmd (Editor* ed) : PrecisePageCmd(ed) {} OvPrecisePageCmd::~OvPrecisePageCmd () {} Command* OvPrecisePageCmd::Copy () { Command* copy = new OvPrecisePageCmd(CopyControlInfo()); InitCopy(copy); return copy; } void OvPrecisePageCmd::Execute () { static char* default_pagestr = nil; if (!default_pagestr) { OverlayPage* page = (OverlayPage*) GetEditor()->GetViewer()->GetPage(); char buffer[BUFSIZ]; sprintf( buffer, "%d %d\0", (int) ((PageGraphic*)page->GetGraphic())->Width(), (int) ((PageGraphic*)page->GetGraphic())->Height()); default_pagestr = strdup(buffer); } char* pagestr = StrEditDialog::post(GetEditor()->GetWindow(), "Enter width and height of page:", default_pagestr); if (pagestr) { std::istrstream in(pagestr); int xpage = 0, ypage = 0; in >> xpage >> ypage; if (xpage !=0 && ypage != 0) { Viewer* viewer = GetEditor()->GetViewer(); viewer->SetPage(new OverlayPage(xpage, ypage, true)); viewer->Update(); } delete default_pagestr; default_pagestr = pagestr; } } /*****************************************************************************/ ClassId OvPreciseBrushCmd::GetClassId () { return OVPRECISEBRUSH_CMD; } boolean OvPreciseBrushCmd::IsA (ClassId id) { return OVPRECISEBRUSH_CMD == id || Command::IsA(id); } OvPreciseBrushCmd::OvPreciseBrushCmd (ControlInfo* c) : Command(c) {} OvPreciseBrushCmd::OvPreciseBrushCmd (Editor* ed) : Command(ed) {} OvPreciseBrushCmd::~OvPreciseBrushCmd () {} Command* OvPreciseBrushCmd::Copy () { Command* copy = new OvPreciseBrushCmd(CopyControlInfo()); InitCopy(copy); return copy; } void OvPreciseBrushCmd::Execute () { static char* default_widthstr = strdup("0.0"); char* widthstr = StrEditDialog::post(GetEditor()->GetWindow(), "Enter brush width in pixels:", default_widthstr); if (widthstr) { std::istrstream in(widthstr); float width = 0; in >> width; if (width>=0.0) { Catalog* catalog = unidraw->GetCatalog(); PSBrush* br = catalog->FindBrush(0xffff, width); BrushCmd* brushCmd = new BrushCmd(GetEditor(), br); brushCmd->Execute(); brushCmd->Log(); } delete default_widthstr; default_widthstr = widthstr; } } ivtools-1.2.11a1/src/OverlayUnidraw/ovprecise.h000066400000000000000000000061101214471147700214350ustar00rootroot00000000000000/* * Copyright (c) 1998,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Precise move commands for OverlayUnidraw */ #ifndef ovprecise_h #define ovprecise_h #include #include class Glyph; class ObservableEnum; //: glyphified PreciseMoveCmd. class OvPreciseMoveCmd : public PreciseMoveCmd { public: OvPreciseMoveCmd(ControlInfo*); OvPreciseMoveCmd(Editor* = nil); virtual ~OvPreciseMoveCmd(); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); Glyph* unit_buttons(); protected: ObservableEnum* _unit_enum; static char* _default_movestr; static int _default_enumval; }; //: glyphified PreciseScaleCmd. class OvPreciseScaleCmd : public PreciseScaleCmd { public: OvPreciseScaleCmd(ControlInfo*); OvPreciseScaleCmd(Editor* = nil); virtual ~OvPreciseScaleCmd(); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: glyphified PreciseRotateCmd. class OvPreciseRotateCmd : public PreciseRotateCmd { public: OvPreciseRotateCmd(ControlInfo*); OvPreciseRotateCmd(Editor* = nil); virtual ~OvPreciseRotateCmd(); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: glyphified PrecisePageCmd. class OvPrecisePageCmd : public PrecisePageCmd { public: OvPrecisePageCmd(ControlInfo*); OvPrecisePageCmd(Editor* = nil); virtual ~OvPrecisePageCmd(); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: precise brush-width (line-width) command. class OvPreciseBrushCmd : public Command { public: OvPreciseBrushCmd(ControlInfo*); OvPreciseBrushCmd(Editor* = nil); virtual ~OvPreciseBrushCmd(); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovprint.cc000066400000000000000000000130021214471147700212730ustar00rootroot00000000000000/* * Copyright (c) 1995 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OvPrintCmd implementation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ ClassId OvPrintCmd::GetClassId () { return OVPRINT_CMD; } boolean OvPrintCmd::IsA (ClassId id) { return OVPRINT_CMD == id || Command::IsA(id); } OvPrintCmd::OvPrintCmd (ControlInfo* c, PrintChooser* f) : Command(c) { Init(f); } OvPrintCmd::OvPrintCmd (Editor* ed, PrintChooser* f) : Command(ed) { Init(f); } OvPrintCmd::~OvPrintCmd () { Resource::unref(chooser_); } void OvPrintCmd::Init (PrintChooser* f) { chooser_ = f; Resource::ref(chooser_); } Command* OvPrintCmd::Copy () { OvPrintCmd* copy = new OvPrintCmd(CopyControlInfo()); InitCopy(copy); return copy; } boolean OvPrintCmd::Reversible () { return false; } void OvPrintCmd::Execute () { Editor* ed = GetEditor(); Style* style; boolean reset_caption = false; if (chooser_ == nil) { style = new Style(Session::instance()->style()); style->attribute("subcaption", "Save postscript to file:"); style->attribute("open", "Print"); chooser_ = new PrintChooser(".", WidgetKit::instance(), Session::instance()->style()); Resource::ref(chooser_); } else { style = chooser_->style(); } /* loop on reading input until an ok break */ boolean again; while (again = chooser_->post_for(ed->GetWindow())) { const String* str = chooser_->selected(); if (str != nil) { NullTerminatedString ns(*str); const char* name = ns.string(); Catalog* catalog = unidraw->GetCatalog(); boolean ok = true; if (!chooser_->to_printer() && catalog->Exists(name) && catalog->Writable(name)) { char buf[CHARBUFSIZE]; sprintf(buf, "\"%s\" already exists,", name); GConfirmDialog* dialog = new GConfirmDialog(buf, "Overwrite?"); Resource::ref(dialog); ok = dialog->post_for(ed->GetWindow()); Resource::unref(dialog); } if (ok) { filebuf fbuf; char* tmpfilename; if (chooser_->to_printer()) { tmpfilename = tmpnam(nil); ok = fbuf.open(tmpfilename, output) != 0; } else { ok = fbuf.open(ns.string(), output) != 0; } if (ok) { ed->GetWindow()->cursor(hourglass); chooser_->twindow()->cursor(hourglass); ostream out(&fbuf); GraphicComp* comps = GetGraphicComp(); OverlayPS* ovpsv = (OverlayPS*) comps->Create(POSTSCRIPT_VIEW); comps->Attach(ovpsv); ovpsv->SetCommand(this); ovpsv->Update(); ok = ovpsv->Emit(out); out.flush(); delete ovpsv; if (chooser_->to_printer()) { ok = print(ns.string(), tmpfilename) == 0; } } if (ok) { again = false; break; } else { style->attribute("caption", ""); style->attribute("caption", "Printing to file failed!"); reset_caption = true; ed->GetWindow()->cursor(arrow); chooser_->twindow()->cursor(arrow); } } } } /* end of looping on reading input until an ok break */ chooser_->unmap(); if (reset_caption) { style->attribute("caption", ""); } if (!again) ed->GetWindow()->cursor(arrow); return; } int OvPrintCmd::print (const char* print_cmd, const char* file) { char cmd[CHARBUFSIZE]; if (strstr(print_cmd, "%s")) { char buf[CHARBUFSIZE]; sprintf(buf, print_cmd, file); sprintf(cmd, "(%s;rm %s)&", buf, file); } else sprintf(cmd, "(%s %s ;rm %s)&", print_cmd, file, file); return system(cmd); } boolean OvPrintCmd::to_printer() { return chooser_->to_printer(); } boolean OvPrintCmd::idraw_format() { return chooser_->idraw_format(); } ivtools-1.2.11a1/src/OverlayUnidraw/ovprint.h000066400000000000000000000041731214471147700211460ustar00rootroot00000000000000/* * Copyright (c) 1995,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OvPrintCmd - a command for printing graphical objects */ #ifndef ov_print_h #define ov_print_h #include class PrintChooser; //: evolved clone of PrintCmd. class OvPrintCmd : public Command { public: OvPrintCmd(ControlInfo*, PrintChooser* = nil); OvPrintCmd(Editor* = nil, PrintChooser* = nil); virtual ~OvPrintCmd(); virtual void Execute(); virtual boolean Reversible(); // returns false. virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual boolean to_printer(); // return flag that indicates whether "to printer" is checked in dialog box. virtual boolean idraw_format(); // return flag that indicates whether "idraw format" is checked in dialog box. int print(const char* cmd, const char* file); protected: PrintChooser* chooser_; void Init(PrintChooser*); }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovpspict.cc000066400000000000000000000051441214471147700214510ustar00rootroot00000000000000/* * Copyright (c) 1994 Vectaport Inc., Cartoactive Systems * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * PicturePS definition */ #include #include #include #include #include #include #include #include #include /*****************************************************************************/ ClassId PicturePS::GetClassId () { return PICTURE_PS; } boolean PicturePS::IsA (ClassId id) { return PICTURE_PS == id || OverlaysPS::IsA(id); } PicturePS::PicturePS (OverlayComp* subj) : OverlaysPS(subj) { } PicturePS::~PicturePS () { DeleteComps(); } void PicturePS::Update () { DeleteViews(); Picture* picture = (Picture*) GetGraphicComp()->GetGraphic(); Iterator i; for (picture->First(i); !picture->Done(i); picture->Next(i)) { Graphic* graphic = picture->GetGraphic(i); OverlayPS* ovpsv = CreateOvPSViewFromGraphic(graphic); if (ovpsv != nil) { OverlayComp* comp = new OverlayComp(graphic); comp->Attach(ovpsv); ovpsv->Update(); _views->Append(new UList(ovpsv)); } } } void PicturePS::DeleteComps () { Iterator i; First(i); while (!Done(i)) { GraphicComp* comp = (GraphicComp*)GetView(i)->GetSubject(); comp->SetGraphic(nil); delete comp; Next(i); } } ivtools-1.2.11a1/src/OverlayUnidraw/ovpspict.h000066400000000000000000000034001214471147700213040ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1994 Vectaport Inc., Cartoactive Systems * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * PicturePS */ #ifndef ovpspict_h #define ovpspict_h #include #include //: general purpose "PostScript" view for any OverlayComp with a composite graphic. class PicturePS : public OverlaysPS { public: PicturePS(OverlayComp* = nil); virtual ~PicturePS(); virtual void Update(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: void DeleteComps(); }; #include #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovpsview.cc000066400000000000000000000351141214471147700214640ustar00rootroot00000000000000/* * Copyright (c) 1994 Vectaport Inc., Cartoactive Systems * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlayView and OverlaysView definitions */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ static const float GRID_XINCR = 8; // default grid spacing static const float GRID_YINCR = 8; static Transformer* SaveTransformer (Graphic* g) { Transformer* orig = g->GetTransformer(); Ref(orig); g->SetTransformer(new Transformer(orig)); return orig; } static void RestoreTransformer (Graphic* g, Transformer* orig) { g->SetTransformer(orig); Unref(orig); } // ScaleToPostscriptCoords scales the picture to Postscript // coordinates if screen and Postscript inches are different. static void ScaleToPostScriptCoords (Graphic* g) { const double ps_inch = 72.; if (ivinch != ps_inch) { double factor = ps_inch / ivinch; g->Scale(factor, factor); } } static boolean Uncollected (const char* name, UList* fonts) { for (UList* u = fonts->First(); u != fonts->End(); u = u->Next()) { PSFont* font = (PSFont*) (*u)(); if (strcmp(font->GetPrintFont(), name) == 0) { return false; } } return true; } static void CollectFontsFromGraphic (Graphic* gr, UList* fonts) { PSFont* font = gr->GetFont(); if (font != nil && Uncollected(font->GetPrintFont(), fonts)) { fonts->Append(new UList(font)); } Iterator i; for (gr->First(i); !gr->Done(i); gr->Next(i)) { CollectFontsFromGraphic(gr->GetGraphic(i), fonts); } } /*****************************************************************************/ boolean OverlayPS::_idraw_format = true; ClassId OverlayPS::GetClassId () { return OVERLAY_PS; } boolean OverlayPS::IsA (ClassId id) { return OVERLAY_PS == id || PostScriptView::IsA(id); } OverlayPS::OverlayPS (OverlayComp* subj) : PostScriptView(subj) { _command = nil; } void OverlayPS::Creator (ostream& out) { out << "%%Creator: " << (idraw_format() ? "idraw" : "unidraw") << "\n"; } UList* OverlayPS::GetPSFonts () { if (_fonts == nil) { _fonts = new UList; CollectFontsFromGraphic(GetGraphicComp()->GetGraphic(), _fonts); } return _fonts; } void OverlayPS::SetCommand(Command* command) { _command = command; } Command* OverlayPS::GetCommand() { return _command; } OverlayPS* OverlayPS::CreateOvPSView (GraphicComp* comp) { OverlayPS* ovpsv = (OverlayPS*) comp->Create(POSTSCRIPT_VIEW); if (ovpsv != nil) { comp->Attach(ovpsv); ovpsv->SetCommand(GetCommand()); ovpsv->Update(); } return ovpsv; } OverlayPS* OverlayPS::CreateOvPSViewFromGraphic (Graphic* graphic, boolean comptree) { ClassId compid = graphic->CompId(); ClassId ovpsid = 0; if (compid == GRAPHIC_COMPS) { if (!comptree) ovpsid = PICTURE_PS; else ovpsid = OVERLAYS_PS; } else if (compid == ARROWLINE_COMP) ovpsid = ARROWLINE_PS; else if (compid == ARROWMULTILINE_COMP) ovpsid = ARROWMULTILINE_PS; else if (compid == ARROWSPLINE_COMP) ovpsid = ARROWSPLINE_PS; else if (compid == CLOSEDSPLINE_COMP) ovpsid = CLOSEDSPLINE_PS; else if (compid == ELLIPSE_COMP) ovpsid = ELLIPSE_PS; else if (compid == LINE_COMP) ovpsid = LINE_PS; else if (compid == MULTILINE_COMP) ovpsid = MULTILINE_PS; else if (compid == POLYGON_COMP) ovpsid = POLYGON_PS; else if (compid == RASTER_COMP) ovpsid = RASTER_PS; else if (compid == RECT_COMP) ovpsid = RECT_PS; else if (compid == SPLINE_COMP) ovpsid = SPLINE_PS; else if (compid == STENCIL_COMP) ovpsid = STENCIL_PS; else if (compid == TEXT_COMP) ovpsid = TEXT_PS; OverlayPS* ovpsv = (OverlayPS*) unidraw->GetCatalog()->GetCreator()->Create(ovpsid); if (ovpsv) ovpsv->SetCommand(GetCommand()); return ovpsv; } OverlayComp* OverlayPS::GetOverlayComp () { return (OverlayComp*) GetSubject(); } boolean OverlayPS::idraw_format() { boolean format = OverlayPS::_idraw_format; Command* cmd = GetCommand(); if (cmd) { if (GetCommand()->IsA(OV_EXPORT_CMD)) format = ((OvExportCmd*)GetCommand())->idraw_format(); else if (GetCommand() && GetCommand()->IsA(OVPRINT_CMD)) format = ((OvPrintCmd*)GetCommand())->idraw_format(); } return format; } void OverlayPS::idraw_format(boolean flag) { _idraw_format = flag; } /*****************************************************************************/ ClassId OverlaysPS::GetClassId () { return OVERLAYS_PS; } boolean OverlaysPS::IsA (ClassId id) { return OVERLAYS_PS == id || OverlayPS::IsA(id); } OverlaysPS::OverlaysPS (OverlayComp* subj) : OverlayPS(subj) { _views = new UList; } OverlaysPS::~OverlaysPS () { DeleteViews(); delete _views; } boolean OverlaysPS::Emit (ostream& out) { SetPSFonts(); Graphic* g = GetGraphicComp()->GetGraphic(); Transformer* t = SaveTransformer(g); ScaleToPostScriptCoords(g); Comments(out); Prologue(out); Version(out); GridSpacing(out); out << "\n\n%%Page: 1 1\n\n"; out << "Begin\n"; FullGS(out); out << "/originalCTM matrix currentmatrix def\n\n"; boolean status = PreorderView::Definition(out); out << "End " << MARK << " eop\n\n"; out << "showpage\n\n"; Trailer(out); RestoreTransformer(g, t); return status; } boolean OverlaysPS::Definition (ostream& out) { out << "Begin " << MARK << " Pict\n"; FullGS(out); out << "\n"; boolean status = PreorderView::Definition(out); out << "End " << MARK << " eop\n\n"; return status; } void OverlaysPS::Update () { DeleteViews(); GraphicComp* comps = GetGraphicComp(); Iterator i; for (comps->First(i); !comps->Done(i); comps->Next(i)) { GraphicComp* comp = comps->GetComp(i); OverlayPS* ovpsv = CreateOvPSView(comp); if (!ovpsv) { ovpsv = CreateOvPSViewFromGraphic(comp->GetGraphic()); if (ovpsv != nil) { comp->Attach(ovpsv); ovpsv->Update(); } } if (ovpsv != nil) _views->Append(new UList(ovpsv)); } } OverlaysComp* OverlaysPS::GetOverlaysComp () { return (OverlaysComp*) GetSubject(); } UList* OverlaysPS::Elem (Iterator i) { return (UList*) i.GetValue(); } void OverlaysPS::First (Iterator& i) { i.SetValue(_views->First()); } void OverlaysPS::Last (Iterator& i) { i.SetValue(_views->Last()); } void OverlaysPS::Next (Iterator& i) { i.SetValue(Elem(i)->Next()); } void OverlaysPS::Prev (Iterator& i) { i.SetValue(Elem(i)->Prev()); } boolean OverlaysPS::Done (Iterator i) { return Elem(i) == _views->End(); } ExternView* OverlaysPS::GetView (Iterator i) { return View(Elem(i)); } void OverlaysPS::SetView (ExternView* ev, Iterator& i) { i.SetValue(_views->Find(ev)); } void OverlaysPS::DeleteView (Iterator& i) { UList* doomed = Elem(i); ExternView* view = GetView(i); Next(i); _views->Remove(doomed); SetParent(view, nil); delete doomed; delete view; } void OverlaysPS::DeleteViews () { Iterator i; First(i); while (!Done(i)) { DeleteView(i); } } /*****************************************************************************/ OverlayIdrawPS::OverlayIdrawPS (OverlayComp* subj) : OverlaysPS(subj) { } ClassId OverlayIdrawPS::GetClassId () { return OVERLAY_IDRAW_PS; } boolean OverlayIdrawPS::IsA (ClassId id) { return OVERLAY_IDRAW_PS == id || OverlaysPS::IsA(id); } void OverlayIdrawPS::Prologue (ostream& out) { out << "%%BeginIdrawPrologue\n"; ArrowHeader(out); out << "%%EndIdrawPrologue\n\n"; OverlaysPS::Prologue(out); } void OverlayIdrawPS::MiscProcs (ostream& out) { PostScriptView::MiscProcs(out); } void OverlayIdrawPS::GridSpacing (ostream& out) { out << "Grid " << GRID_XINCR << " " << GRID_YINCR << " "; } void OverlayIdrawPS::ConstProcs (ostream& out) { int arrowWidth = Math::round(ARROWWIDTH*ivpoints); int arrowHeight = Math::round(ARROWHEIGHT*ivpoints); out << "/arrowHeight " << arrowHeight << " def\n"; out << "/arrowWidth " << arrowWidth << " def\n\n"; OverlaysPS::ConstProcs(out); } void OverlayIdrawPS::LineProc (ostream& out) { out << "/Line {\n"; out << "0 begin\n"; out << "2 storexyn\n"; out << "newpath\n"; out << "x 0 get y 0 get moveto\n"; out << "x 1 get y 1 get lineto\n"; out << "brushNone not { istroke } if\n"; out << "0 0 1 1 leftarrow\n"; out << "0 0 1 1 rightarrow\n"; out << "end\n"; out << "} dup 0 4 dict put def\n\n"; } void OverlayIdrawPS::MultiLineProc (ostream& out) { out << "/MLine {\n"; out << "0 begin\n"; out << "storexyn\n"; out << "newpath\n"; out << "n 1 gt {\n"; out << "x 0 get y 0 get moveto\n"; out << "1 1 n 1 sub {\n"; out << "/i exch def\n"; out << "x i get y i get lineto\n"; out << "} for\n"; out << "patternNone not brushLeftArrow not brushRightArrow not and and "; out << "{ ifill } if\n"; out << "brushNone not { istroke } if\n"; out << "0 0 1 1 leftarrow\n"; out << "n 2 sub dup n 1 sub dup rightarrow\n"; out << "} if\n"; out << "end\n"; out << "} dup 0 4 dict put def\n\n"; } void OverlayIdrawPS::BSplineProc (ostream& out) { out << "/BSpl {\n"; out << "0 begin\n"; out << "storexyn\n"; out << "newpath\n"; out << "n 1 gt {\n"; out << "0 0 0 0 0 0 1 1 true subspline\n"; out << "n 2 gt {\n"; out << "0 0 0 0 1 1 2 2 false subspline\n"; out << "1 1 n 3 sub {\n"; out << "/i exch def\n"; out << "i 1 sub dup i dup i 1 add dup i 2 add dup false subspline\n"; out << "} for\n"; out << "n 3 sub dup n 2 sub dup n 1 sub dup 2 copy false subspline\n"; out << "} if\n"; out << "n 2 sub dup n 1 sub dup 2 copy 2 copy false subspline\n"; out << "patternNone not brushLeftArrow not brushRightArrow not and and "; out << "{ ifill } if\n"; out << "brushNone not { istroke } if\n"; out << "0 0 1 1 leftarrow\n"; out << "n 2 sub dup n 1 sub dup rightarrow\n"; out << "} if\n"; out << "end\n"; out << "} dup 0 4 dict put def\n\n"; } void OverlayIdrawPS::SetBrushProc (ostream& out) { out << "/SetB {\n"; out << "dup type /nulltype eq {\n"; out << "pop\n"; out << "false /brushRightArrow idef\n"; out << "false /brushLeftArrow idef\n"; out << "true /brushNone idef\n"; out << "} {\n"; out << "/brushDashOffset idef\n"; out << "/brushDashArray idef\n"; out << "0 ne /brushRightArrow idef\n"; out << "0 ne /brushLeftArrow idef\n"; out << "/brushWidth idef\n"; out << "false /brushNone idef\n"; out << "} ifelse\n"; out << "} def\n\n"; } void OverlayIdrawPS::ArrowHeader (ostream& out) { out << "/arrowhead {\n"; out << "0 begin\n"; out << "transform originalCTM itransform\n"; out << "/taily exch def\n"; out << "/tailx exch def\n"; out << "transform originalCTM itransform\n"; out << "/tipy exch def\n"; out << "/tipx exch def\n"; out << "/dy tipy taily sub def\n"; out << "/dx tipx tailx sub def\n"; out << "/angle dx 0 ne dy 0 ne or { dy dx atan } { 90 } ifelse def\n"; out << "gsave\n"; out << "originalCTM setmatrix\n"; out << "tipx tipy translate\n"; out << "angle rotate\n"; out << "newpath\n"; out << "arrowHeight neg arrowWidth 2 div moveto\n"; out << "0 0 lineto\n"; out << "arrowHeight neg arrowWidth 2 div neg lineto\n"; out << "patternNone not {\n"; out << "originalCTM setmatrix\n"; out << "/padtip arrowHeight 2 exp 0.25 arrowWidth 2 exp mul add sqrt "; out << "brushWidth mul\n"; out << "arrowWidth div def\n"; out << "/padtail brushWidth 2 div def\n"; out << "tipx tipy translate\n"; out << "angle rotate\n"; out << "padtip 0 translate\n"; out << "arrowHeight padtip add padtail add arrowHeight div dup scale\n"; out << "arrowheadpath\n"; out << "ifill\n"; out << "} if\n"; out << "brushNone not {\n"; out << "originalCTM setmatrix\n"; out << "tipx tipy translate\n"; out << "angle rotate\n"; out << "arrowheadpath\n"; out << "istroke\n"; out << "} if\n"; out << "grestore\n"; out << "end\n"; out << "} dup 0 9 dict put def\n\n"; out << "/arrowheadpath {\n"; out << "newpath\n"; out << "arrowHeight neg arrowWidth 2 div moveto\n"; out << "0 0 lineto\n"; out << "arrowHeight neg arrowWidth 2 div neg lineto\n"; out << "} def\n\n"; out << "/leftarrow {\n"; out << "0 begin\n"; out << "y exch get /taily exch def\n"; out << "x exch get /tailx exch def\n"; out << "y exch get /tipy exch def\n"; out << "x exch get /tipx exch def\n"; out << "brushLeftArrow { tipx tipy tailx taily arrowhead } if\n"; out << "end\n"; out << "} dup 0 4 dict put def\n\n"; out << "/rightarrow {\n"; out << "0 begin\n"; out << "y exch get /tipy exch def\n"; out << "x exch get /tipx exch def\n"; out << "y exch get /taily exch def\n"; out << "x exch get /tailx exch def\n"; out << "brushRightArrow { tipx tipy tailx taily arrowhead } if\n"; out << "end\n"; out << "} dup 0 4 dict put def\n\n"; } ivtools-1.2.11a1/src/OverlayUnidraw/ovpsview.h000066400000000000000000000112001214471147700213140ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1994 Vectaport Inc., Cartoactive Systems * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlayPS and related classes */ #ifndef ovpsview_h #define ovpsview_h #include #include #include class Command; //: base class of "PostScript" views for OverlayComp objects. class OverlayPS : public PostScriptView { public: virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual UList* GetPSFonts(); void SetCommand(Command*); // set command associated with this view, for reference by sub-views // when updating themselves. Command* GetCommand(); // get command associated with this view, for reference by sub-views // when updating themselves. OverlayPS* CreateOvPSView(GraphicComp*); // utility method for creating a "PostScript" view from a component. OverlayPS* CreateOvPSViewFromGraphic(Graphic*, boolean comptree=false); // utility method for creating a "PostScript" view from a graphic. // The 'comptree' flag indicates whether any composite graphic is part // of a tree of components or not. OverlayComp* GetOverlayComp(); virtual void Creator(ostream&); // output idraw as creator boolean idraw_format(); // true if exporting idraw EPS void idraw_format(boolean); // set flag for exporting idraw EPS // can be overridden by flag associated with Command objects protected: OverlayPS(OverlayComp* = nil); static boolean _idraw_format; Command* _command; }; //: "PostScript" view of an OverlaysComp. class OverlaysPS : public OverlayPS { public: OverlaysPS(OverlayComp* = nil); virtual ~OverlaysPS(); virtual boolean Emit(ostream&); // output entire "PostScript" document to ostream. virtual boolean Definition(ostream&); // output fragment of "PostScript" document that corresponds to this // sub-tree of the entire component tree. virtual void Update(); OverlaysComp* GetOverlaysComp(); virtual ExternView* GetView(Iterator); // get sub-view pointed to by Iterator. virtual void SetView(ExternView*, Iterator&); // set sub-view pointed to by Iterator. virtual void First(Iterator&); // set iterator to first sub-view. virtual void Last(Iterator&); // set iterator to last sub-view. virtual void Next(Iterator&); // set iterator to sub-view immediately following current Iterator setting. virtual void Prev(Iterator&); // set iterator to sub-view immediately proceeding current Iterator setting. virtual boolean Done(Iterator); // return true if Iterator points off the end or beginning of list of sub-views. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: UList* Elem(Iterator); void DeleteView(Iterator&); void DeleteViews(); protected: UList* _views; }; //: "PostScript" view of OverlayIdrawComp. class OverlayIdrawPS : public OverlaysPS { public: OverlayIdrawPS(OverlayComp* = nil); protected: virtual void MiscProcs(ostream&); virtual void ArrowHeader(ostream&); virtual void ConstProcs(ostream&); virtual void GridSpacing(ostream&); virtual void LineProc(ostream&); virtual void MultiLineProc(ostream&); virtual void BSplineProc(ostream&); virtual void Prologue(ostream&); virtual void SetBrushProc(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #include #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovraster.cc000066400000000000000000001547131214471147700214560ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1997 R.B. Kissh & Associates, Vectaport Inc. * Copyright (c) 1994-1996 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * RasterOvComp definitions. */ // #define RASTER_DAMAGE1 // define for incremental flushing of raster // #define RASTER_DAMAGE2 // define to use mbr of incrementally loaded region for raster damage. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::cerr; implementList(CopyStringList,CopyString) boolean RasterOvComp::_use_gray_raster = false; boolean RasterOvComp::_warned = false; /*****************************************************************************/ ParamList* RasterOvComp::_ovraster_params = nil; static const int color_depth = 8; // bits per color in PostScript static char hexcharmap[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; /*****************************************************************************/ int RasterOvComp::_symid = -1; static ostream& operator<<(ostream& out, const CopyStringList& sl) { for (ListItr(CopyStringList) i(sl); i.more(); i.next()) { out << i.cur_ref().string() << "\n"; } out << "\n"; return out; } ClassId RasterOvComp::GetClassId () { return OVRASTER_COMP; } boolean RasterOvComp::IsA (ClassId id) { return OVRASTER_COMP == id || OverlayComp::IsA(id); } Component* RasterOvComp::Copy () { RasterOvComp* nc = new RasterOvComp( (OverlayRasterRect*) GetGraphic()->Copy(), _pathname, (OverlayComp*)GetParent() ); if (attrlist()) nc->SetAttributeList(new AttributeList(attrlist())); for (ListItr(CopyStringList) i(_commands); i.more(); i.next()) { nc->_commands.append(i.cur_ref()); } nc->_com_exp = _com_exp; return nc; } RasterOvComp::RasterOvComp (OverlayRasterRect* s, const char* pathname, OverlayComp* parent) : OverlayComp(s, parent), _com_exp("") { _pathname = (pathname == nil) ? nil : strdup(pathname); if(pathname) _import_flags |= bypath_mask; } RasterOvComp::RasterOvComp(istream& in, OverlayComp* parent) : OverlayComp(nil, parent), _com_exp("") { _pathname = nil; _import_flags = 0x0; _valid = GetParamList()->read_args(in, this); // update the size of the raster OverlayRasterRect* orr; if (orr=GetOverlayRasterRect()) { OverlayRaster* r; if (r=orr->GetOverlayRaster()) if (orr->xbeg() != -1) r->init_rep( orr->xend() - orr->xbeg() + 1, orr->yend() - orr->ybeg() + 1 ); } } ParamList* RasterOvComp::GetParamList() { if (!_ovraster_params) GrowParamList(_ovraster_params = new ParamList()); return _ovraster_params; } void RasterOvComp::GrowParamList(ParamList* pl) { pl->add_param("pathname", ParamStruct::optional, &RasterScript::ReadRaster, this, this); pl->add_param("rgb", ParamStruct::keyword, &RasterScript::ReadRGB, this, this); pl->add_param("gray", ParamStruct::keyword, &RasterScript::ReadGrayUChar, this, this); pl->add_param("graychar", ParamStruct::keyword, &RasterScript::ReadGrayChar, this, this); pl->add_param("grayuchar", ParamStruct::keyword, &RasterScript::ReadGrayUChar, this, this); pl->add_param("grayint", ParamStruct::keyword, &RasterScript::ReadGrayInt, this, this); pl->add_param("grayuint", ParamStruct::keyword, &RasterScript::ReadGrayUInt, this, this); pl->add_param("graylong", ParamStruct::keyword, &RasterScript::ReadGrayLong, this, this); pl->add_param("grayulong", ParamStruct::keyword, &RasterScript::ReadGrayULong, this, this); pl->add_param("grayfloat", ParamStruct::keyword, &RasterScript::ReadGrayFloat, this, this); pl->add_param("graydouble", ParamStruct::keyword, &RasterScript::ReadGrayDouble, this, this); pl->add_param("alpha", ParamStruct::keyword, &RasterScript::ReadAlpha, this, this); pl->add_param("proc", ParamStruct::keyword, &RasterScript::ReadProcess, this, this); OverlayRasterRect* orr = new OverlayRasterRect(); _gr = orr; pl->add_param_indirect("sub", ParamStruct::optional, &ParamList::read_int, this, &_gr, &orr->_xbeg, &orr->_xend, &orr->_ybeg, &orr->_yend); delete orr; _gr = nil; OverlayComp::GrowParamList(pl); return; } RasterOvComp::~RasterOvComp () { if (_pathname) { delete _pathname; _pathname = 0; } OvImportCmd::detach(this); // maybe in the process of downloading } OverlayRasterRect* RasterOvComp::GetOverlayRasterRect () { return (OverlayRasterRect*) GetGraphic(); } void RasterOvComp::SetPathName(const char* path) { delete _pathname; if (path) _pathname = strdup(path); } const char* RasterOvComp::GetPathName () { return _pathname; } boolean RasterOvComp::operator == (OverlayComp& comp) { if (GetClassId() != comp.GetClassId()) return false; OverlayRasterRect* rasta = GetOverlayRasterRect(); OverlayRasterRect* rastb = ((RasterOvComp&)comp).GetOverlayRasterRect(); return strcmp(GetPathName(), ((RasterOvComp&)comp).GetPathName()) && rasta->xbeg() == rastb->xbeg() && rasta->ybeg() == rastb->ybeg() && rasta->xend() == rastb->xend() && rasta->yend() == rastb->yend() && OverlayComp::operator==(comp); } void RasterOvComp::Interpret (Command* cmd) { OverlayRasterRect* gr = GetOverlayRasterRect(); if (gr == nil) { return; } if (cmd->IsA(IMAGE_CMD)) { ImageCmd* icmd = (ImageCmd*)cmd; _commands.append(icmd->Cmd()); #ifndef NDEBUG cerr << _commands; #endif } else { OverlayComp::Interpret(cmd); } } void RasterOvComp::Uninterpret (Command* cmd) { Graphic* gr = GetGraphic(); if (gr == nil) { return; } if (cmd->IsA(IMAGE_CMD)) { _commands.remove(_commands.count() - 1); #ifndef NDEBUG cerr << _commands; #endif } else { OverlayComp::Uninterpret(cmd); } } void RasterOvComp::Configure(Editor* ed) { #ifndef NDEBUG cerr << "Configure: " << _com_exp.string() << endl; #endif if (_com_exp != "") { RasterTerp terp(ed); CopyString tmp(_com_exp); _com_exp = ""; int result = terp.execute(this, tmp); // ignoring result #### } if (GetOverlayRasterRect()->GetOverlayRaster()->status() && !_warned) { _warned = true; GAcknowledgeDialog::post(ed->GetWindow(), "unable to allocate enough colormap entries on the X server", "quit other programs and restart", "colormap problem"); } } ParamList* RasterOvComp::get_param_list() { if (!_ovraster_params) { RasterOvComp raster; raster.GrowParamList(_ovraster_params = new ParamList()); } return _ovraster_params; } /*****************************************************************************/ RasterOvComp* RasterOvView::GetRasterOvComp () { return (RasterOvComp*) GetSubject(); } ClassId RasterOvView::GetClassId () { return OVRASTER_VIEW; } boolean RasterOvView::IsA (ClassId id) { return OVRASTER_VIEW == id || OverlayView::IsA(id); } RasterOvView::RasterOvView (RasterOvComp* subj) : OverlayView(subj) { } void RasterOvView::Update () { OverlayRasterRect* raster = (OverlayRasterRect*)GetGraphic(); OverlayRasterRect* subj = (OverlayRasterRect*)GetRasterOvComp()->GetGraphic(); #if defined(RASTER_DAMAGE2) if (!subj->damage_done()) #endif IncurDamage(raster); *raster = *subj; #if defined(RASTER_DAMAGE2) if (!subj->damage_done()) #endif IncurDamage(raster); EraseHandles(); } Graphic* RasterOvView::GetGraphic () { Graphic* graphic = GraphicView::GetGraphic(); if (graphic == nil) { OverlayRasterRect* rr = GetRasterOvComp()->GetOverlayRasterRect(); OverlayRaster* r = rr ? rr->GetOverlayRaster() : nil; graphic = r ? new OverlayRasterRect(r, rr) : nil; SetGraphic(graphic); } return graphic; } OverlayRaster* RasterOvView::GetOverlayRaster () { return GetOverlayRasterRect()->GetOverlayRaster(); } /*****************************************************************************/ RasterPS::RasterPS (OverlayComp* subj) : OverlayPS(subj) { } ClassId RasterPS::GetClassId () { return RASTER_PS; } boolean RasterPS::IsA (ClassId id) { return RASTER_PS == id || OverlayPS::IsA(id); } boolean RasterPS::Definition (ostream& out) { RasterOvComp* comp = (RasterOvComp*) GetGraphicComp(); OverlayRasterRect* rr = (OverlayRasterRect*) comp->GetGraphic(); OverlayRaster* raster = (OverlayRaster*)rr->GetOriginal(); const char* pathname = comp->GetPathName(); if (!raster->initialized()) rr->load_image(pathname); Coord w = raster->Width(); Coord h = raster->Height(); if (idraw_format()) { out << "Begin " << MARK << " " << "Rast\n"; Transformation(out); out << MARK << "\n"; out << w << " " << h << " " << color_depth << " Rast "; out << "{ currentfile "; out << (w * color_depth + 7) / 8 << " "; out << "string readhexstring pop }\n"; out << "image"; IdrawCatalog* catalog = (IdrawCatalog*)unidraw->GetCatalog(); catalog->IdrawCatalog::WriteGraymapData(raster, out); catalog->Mark(out); out << "colorimage"; catalog->IdrawCatalog::WriteRasterData(raster, out); out << "\nEnd\n\n"; return out.good(); } if (comp->GetPathName() && strstr(comp->GetPathName(), ".pgm")) { out << "Begin " << MARK << " " << "GrayRast\n"; Transformation(out); out << MARK << "\n"; out << w << " " << h << " " << color_depth << " Rast "; out << "{ currentfile "; out << (w * color_depth + 7) / 8 << " "; out << "string readhexstring pop }\n"; out << "image"; Catalog* catalog = unidraw->GetCatalog(); catalog->WriteGraymapData(raster, out); out << "\nEnd\n\n"; } else { out << "Begin " << MARK << " " << "ColorRast\n"; Transformation(out); out << "\n/readstring {\n"; out << " currentfile exch readhexstring pop\n"; out << "} bind def\n"; out << "/rpicstr " << w << " string def\n"; out << "/gpicstr " << w << " string def\n"; out << "/bpicstr " << w << " string def\n\n"; out << w << " " << h << " scale\n"; out << w << " " << h << " 8\n"; out << "[ " << w << " 0 0 -" << h << " 0 " << h << " ]\n"; out << "{ rpicstr readstring }\n"; out << "{ gpicstr readstring }\n"; out << "{ bpicstr readstring }\n"; out << "true 3\n"; out << "colorimage\n"; ColorIntensity r, g, b; float alpha; int count = 0; int i; for (int j = h-1; j>=0; --j) { for (i=0; ipeek(i, j, r, g, b, alpha); int ir = (int)(r*255); out << hexcharmap[ir/16] << hexcharmap[ir%16]; if (++count%40 == 0) out << "\n"; } for (i=0; ipeek(i, j, r, g, b, alpha); int ig = (int)(g*255); out << hexcharmap[ig/16] << hexcharmap[ig%16]; if (++count%40 == 0) out << "\n"; } for (i=0; ipeek(i, j, r, g, b, alpha); int ib = (int)(b*255); out << hexcharmap[ib/16] << hexcharmap[ib%16]; if (++count%40 == 0) out << "\n"; } } out << "\nEnd\n\n"; } return out.good(); } /*****************************************************************************/ ClassId RasterScript::GetClassId () { return RASTER_SCRIPT; } boolean RasterScript::IsA (ClassId id) { return RASTER_SCRIPT == id || OverlayScript::IsA(id); } RasterScript::RasterScript (RasterOvComp* subj) : OverlayScript(subj) { } boolean RasterScript::Definition (ostream& out) { RasterOvComp* comp = (RasterOvComp*) GetSubject(); OverlayRasterRect* rr = comp->GetOverlayRasterRect(); OverlayRaster* raster = (OverlayRaster*)rr->GetOriginal(); out << (GetFromCommandFlag() && GetByPathnameFlag() && comp->GetPathName() ? "ovfile(:popen " : "raster("); if (GetByPathnameFlag() && comp->GetPathName()){ out << "\"" << comp->GetPathName() << "\""; } else { const char* pathname = comp->GetPathName(); if (raster->grayraster()) { switch (raster->value_type()) { case AttributeValue::CharType: out << ":graychar "; break; case AttributeValue::UCharType: out << ":grayuchar "; break; case AttributeValue::ShortType: out << ":grayshort "; break; case AttributeValue::UShortType: out << ":grayushort "; break; case AttributeValue::IntType: out << ":grayint "; break; case AttributeValue::UIntType: out << ":grayuint "; break; case AttributeValue::LongType: out << ":graylong "; break; case AttributeValue::ULongType: out << ":grayulong "; break; case AttributeValue::FloatType: out << ":grayfloat "; break; case AttributeValue::DoubleType: out << ":graydouble "; break; default: out << ":gray "; break; } } else if (raster->gray_flag()) out << ":gray "; else out << ":rgb "; raster->write(out); } if (rr->alphaval() != 1.0) out << " :alpha " << rr->alphaval(); if (rr->xbeg()>=0 || rr->xend()>=0 || rr->ybeg()>=0 || rr->yend()>=0) out << " :sub " << rr->xbeg() << "," << rr->xend() << "," << rr->ybeg() << "," << rr->yend(); MinGS(out); Annotation(out); const long count = comp->_commands.count(); if (count) { out << " :proc \""; int j = 0; for (ListItr(CopyStringList) i(comp->_commands); i.more(); i.next()) { out << i.cur_ref().string(); if (++j != count) { out << "; "; } } out << "\""; } Attributes(out); out << ")"; return out.good(); } int RasterScript::ReadRaster (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { char pathname[BUFSIZ]; RasterOvComp* comp = (RasterOvComp*)addr1; ParamList::parse_pathname(in, pathname, BUFSIZ, comp->GetBaseDir()); if (!in.good()) { cerr << "Error in reading pathname for raster\n"; return -1; } boolean urlflag = ParamList::urltest(pathname); const char* creator = !urlflag ? OvImportCmd::ReadCreator(pathname) : nil; if (!creator && !urlflag) { cerr << "Error in reading creator for raster: " << pathname << "\n"; return -1; } OverlayRaster* ovraster = nil; const boolean delayed = true; boolean already_ref = false; if (!urlflag && strcmp(creator, "TIFF") == 0) { ovraster = OvImportCmd::TIFF_Raster(pathname); } else if (!urlflag && strcmp(creator, "PGM") == 0) { ovraster = OvImportCmd::PGM_Raster(pathname, delayed); } else if (!urlflag && strcmp(creator, "PPM") == 0) { ovraster = OvImportCmd::PPM_Raster(pathname, delayed); } else if (!urlflag && (strcmp(creator, "JPEG") == 0 || strcmp(creator, "GIF")==0 || strcmp(creator, "PNG")==0)) { OvImportCmd importcmd((Editor*)nil); OverlayComp* tempcomp = (OverlayComp*)importcmd.Import(pathname); if (tempcomp && tempcomp->IsA(OVRASTER_COMP)) { OverlayRasterRect* ovrrect = ((RasterOvComp*)tempcomp)->GetOverlayRasterRect(); ovraster = ovrrect ? ovrrect->GetOverlayRaster() : nil; if (ovraster) ovraster->ref(); // to protect from deletion already_ref = true; delete tempcomp; } } else if (urlflag) { ovraster = OvImportCmd::CreatePlaceImage(); ovraster->initialized(false); } if (ovraster) { comp->_gr = new OverlayRasterRect(ovraster); if (already_ref) { ovraster->unref(); } comp->_pathname = strdup(pathname); comp->SetByPathnameFlag(true); return 0; } else { cerr << "Unable to access image path: " << pathname << "\n"; return -1; } } int RasterScript::ReadRGB (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { RasterOvComp* comp = (RasterOvComp*)addr1; int w, h; int x = 0; int y = 0; int ir, ig, ib; char paren, delim; in >> w >> delim >> h >> delim; OverlayRaster* raster = new OverlayRaster(w, h); raster->read(in); if (in.good()) { comp->_gr = new OverlayRasterRect(raster); return 0; } else { delete raster; cerr << "Unable to create image from file." << "\n"; return -1; } } int RasterScript::ReadGrayChar (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { RasterOvComp* comp = (RasterOvComp*)addr1; int w, h, x, y; char delim; in >> w >> delim >> h >> delim; GrayRaster* raster = new GrayRaster(w, h, AttributeValue::CharType); raster->read(in); raster->top2bottom(false); if (in.good()) { comp->_gr = new OverlayRasterRect(raster); return 0; } else { delete raster; cerr << "Unable to create char data raster from file." << "\n"; return -1; } } int RasterScript::ReadGrayUChar (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { RasterOvComp* comp = (RasterOvComp*)addr1; int w, h, x, y; char delim; in >> w >> delim >> h >> delim; GrayRaster* raster = new GrayRaster(w, h, AttributeValue::UCharType); raster->read(in); raster->top2bottom(false); if (in.good()) { comp->_gr = new OverlayRasterRect(raster); return 0; } else { delete raster; cerr << "Unable to create unsigned char data raster from file." << "\n"; return -1; } } int RasterScript::ReadGrayShort (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { RasterOvComp* comp = (RasterOvComp*)addr1; int w, h, x, y; char delim; in >> w >> delim >> h >> delim; GrayRaster* raster = new GrayRaster(w, h, AttributeValue::ShortType); raster->read(in); raster->top2bottom(false); if (in.good()) { comp->_gr = new OverlayRasterRect(raster); return 0; } else { delete raster; cerr << "Unable to create short data raster from file." << "\n"; return -1; } } int RasterScript::ReadGrayUShort (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { RasterOvComp* comp = (RasterOvComp*)addr1; int w, h, x, y; char delim; in >> w >> delim >> h >> delim; GrayRaster* raster = new GrayRaster(w, h, AttributeValue::UShortType); raster->read(in); raster->top2bottom(false); if (in.good()) { comp->_gr = new OverlayRasterRect(raster); return 0; } else { delete raster; cerr << "Unable to create unsigned short data raster from file." << "\n"; return -1; } } int RasterScript::ReadGrayInt (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { RasterOvComp* comp = (RasterOvComp*)addr1; int w, h, x, y; char delim; in >> w >> delim >> h >> delim; GrayRaster* raster = new GrayRaster(w, h, AttributeValue::IntType); raster->read(in); raster->top2bottom(false); if (in.good()) { comp->_gr = new OverlayRasterRect(raster); return 0; } else { delete raster; cerr << "Unable to create int data raster from file." << "\n"; return -1; } } int RasterScript::ReadGrayUInt (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { RasterOvComp* comp = (RasterOvComp*)addr1; int w, h, x, y; char delim; in >> w >> delim >> h >> delim; GrayRaster* raster = new GrayRaster(w, h, AttributeValue::UIntType); raster->read(in); raster->top2bottom(false); if (in.good()) { comp->_gr = new OverlayRasterRect(raster); return 0; } else { delete raster; cerr << "Unable to create unsigned int data raster from file." << "\n"; return -1; } } int RasterScript::ReadGrayLong (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { RasterOvComp* comp = (RasterOvComp*)addr1; int w, h, x, y; char delim; in >> w >> delim >> h >> delim; GrayRaster* raster = new GrayRaster(w, h, AttributeValue::LongType); raster->read(in); raster->top2bottom(false); if (in.good()) { comp->_gr = new OverlayRasterRect(raster); return 0; } else { delete raster; cerr << "Unable to create long data raster from file." << "\n"; return -1; } } int RasterScript::ReadGrayULong (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { RasterOvComp* comp = (RasterOvComp*)addr1; int w, h, x, y; char delim; in >> w >> delim >> h >> delim; GrayRaster* raster = new GrayRaster(w, h, AttributeValue::ULongType); raster->read(in); raster->top2bottom(false); if (in.good()) { comp->_gr = new OverlayRasterRect(raster); return 0; } else { delete raster; cerr << "Unable to create unsigned long data raster from file." << "\n"; return -1; } } int RasterScript::ReadGrayFloat (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { RasterOvComp* comp = (RasterOvComp*)addr1; int w, h, x, y; char delim; in >> w >> delim >> h >> delim; GrayRaster* raster = new GrayRaster(w, h, AttributeValue::FloatType); raster->read(in); raster->top2bottom(false); if (in.good()) { comp->_gr = new OverlayRasterRect(raster); return 0; } else { delete raster; cerr << "Unable to create float data raster from file." << "\n"; return -1; } } int RasterScript::ReadGrayDouble (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { RasterOvComp* comp = (RasterOvComp*)addr1; int w, h, x, y; char delim; in >> w >> delim >> h >> delim; GrayRaster* raster = new GrayRaster(w, h, AttributeValue::DoubleType); raster->read(in); raster->top2bottom(false); if (in.good()) { comp->_gr = new OverlayRasterRect(raster); return 0; } else { delete raster; cerr << "Unable to create double data raster from file." << "\n"; return -1; } } int RasterScript::ReadSub (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { IntCoord xbeg; IntCoord xend; IntCoord ybeg; IntCoord yend; char delim; OverlayRasterRect* gr = *(OverlayRasterRect**)addr1; ParamList::skip_space(in); in >> xbeg >> delim >> xend >> delim >> ybeg >> delim >> yend; if (!in.good()) { return -1; } else { gr->xbeg(xbeg); gr->xend(xend); gr->ybeg(ybeg); gr->yend(yend); return 0; } } int RasterScript::ReadAlpha (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { RasterOvComp* comp = (RasterOvComp*)addr1; float alpha; OverlayRasterRect* gr = comp ? (OverlayRasterRect*) comp->GetGraphic() : nil; ParamList::skip_space(in); in >> alpha; if (!in.good()) { return -1; } else { if (gr) gr->alphaval(alpha); return 0; } } int RasterScript::ReadProcess ( istream& in, void* addr1, void*, void*, void* ) { ParamList::skip_space(in); if (ParamList::parse_string(in,sbuf,SBUFSIZE) >= 0) { RasterOvComp* comp = (RasterOvComp*)addr1; comp->_com_exp = sbuf; return 0; } else { return -1; } } boolean RasterScript::GetByPathnameFlag() { RasterOvComp* comp = (RasterOvComp*) GetSubject(); return comp->GetByPathnameFlag() && ((OverlayScript*)GetParent())->GetByPathnameFlag(); } boolean RasterScript::GetFromCommandFlag() { RasterOvComp* comp = (RasterOvComp*) GetSubject(); return comp->GetFromCommandFlag(); } /*****************************************************************************/ OverlayRasterRect::OverlayRasterRect(OverlayRaster* r, Graphic* gr) : RasterRect(r, gr) { #if 0 /* now done in OverlayGraphic::new_painter() */ Unref(_p); _p = new OverlayPainter(); Resource::ref(_p); #endif _xbeg = _xend = _ybeg = _yend = -1; _damage_done = 0; _clippts = nil; _alphaval = 1.0; } OverlayRasterRect::~OverlayRasterRect () { Unref(_clippts);} void OverlayRasterRect::clippts(MultiLineObj* pts) { _clippts = pts; Resource::ref(_clippts); } void OverlayRasterRect::clippts(int* x, int* y, int n) { Resource::unref(_clippts); if (x && y) { _clippts = MultiLineObj::make_pts(x, y, n); Resource::ref(_clippts); } } MultiLineObj* OverlayRasterRect::clippts() { return _clippts; } Graphic* OverlayRasterRect::Copy () { OverlayRasterRect* new_rr; new_rr = new OverlayRasterRect( ((OverlayRaster*)GetOriginal())->copy(), this); new_rr->xbeg(_xbeg); new_rr->xend(_xend); new_rr->ybeg(_ybeg); new_rr->yend(_yend); new_rr->clippts(_clippts); new_rr->alphaval(_alphaval); return new_rr; } #undef RasterRect void OverlayRasterRect::draw (Canvas *c, Graphic* gs) { update(gs); ((OverlayPainter*)_p)->RasterRect(c, 0, 0, this); } const char* OverlayRasterRect::path() const { OverlayRasterRect* th = (OverlayRasterRect*)this; return ((RasterOvView*)th->GetTag())->GetRasterOvComp()->GetPathName(); } OverlayRaster* OverlayRasterRect::GetOverlayRaster() { return (OverlayRaster*)GetOriginal(); } void OverlayRasterRect::load_image(const char* pathname) { if (GetOverlayRaster()->initialized()) return; if (!pathname) pathname = ((RasterOvView*)GetTag())->GetRasterOvComp()->GetPathName(); if (pathname) { if (!ParamList::urltest(pathname)) { /* local file */ const char* creator = OvImportCmd::ReadCreator(pathname); if (strcmp(creator, "PGM") == 0) OvImportCmd::PGM_Raster( pathname, false, (OverlayRaster*)_raster, _xbeg, _xend, _ybeg, _yend ); else if (strcmp(creator, "PPM") == 0) OvImportCmd::PPM_Raster( pathname, false, (OverlayRaster*)_raster, _xbeg, _xend, _ybeg, _yend); else cerr << "unexpected image file format (" << creator << ") in " << pathname << "\n"; } else { /* file by URL */ OvImportCmd importcmd((Editor*)nil); OverlayComp* tempcomp = (OverlayComp*)importcmd.Import(pathname); if (tempcomp && tempcomp->IsA(OVRASTER_COMP)) { OvImportCmd::changeComp( (RasterOvComp*)tempcomp, ((RasterOvView*)GetTag())->GetRasterOvComp() ); #if 0 OverlayRasterRect* ovrrect = ((RasterOvComp*)tempcomp)->GetOverlayRasterRect(); OverlayRaster* ovraster = ovrrect ? ovrrect->GetOverlayRaster() : nil; if (ovraster) ovraster->ref(); // to protect from deletion delete tempcomp; Unref(_raster); _raster = ovraster; uncacheParents(); ((OverlayRaster*)_raster)->initialize(); #else uncacheParents(); // necessary? ((OverlayRaster*)_raster)->initialize(); #endif } } } if (_raster->pwidth()) ((OverlayRaster*)_raster)->initialize(); } void OverlayRasterRect::xbeg(IntCoord xbeg) { _xbeg = xbeg; } void OverlayRasterRect::xend(IntCoord xend) { _xend = xend; } void OverlayRasterRect::ybeg(IntCoord ybeg) { _ybeg = ybeg; } void OverlayRasterRect::yend(IntCoord yend) { _yend = yend; } IntCoord OverlayRasterRect::xbeg() const { return _xbeg; } IntCoord OverlayRasterRect::xend() const { return _xend; } IntCoord OverlayRasterRect::ybeg() const { return _ybeg; } IntCoord OverlayRasterRect::yend() const { return _yend; } OverlayRasterRect& OverlayRasterRect::operator = (OverlayRasterRect& rect) { Graphic::operator=(rect); _xbeg = rect.xbeg(); _xend = rect.xend(); _ybeg = rect.ybeg(); _yend = rect.yend(); if( _damage_done = rect.damage_done()) { _damage_l = rect._damage_l; _damage_b = rect._damage_b; _damage_r = rect._damage_r; _damage_t = rect._damage_t; } Unref(_raster); _raster = rect._raster; Resource::ref(_raster); Unref(_clippts); _clippts = rect._clippts; Resource::ref(_clippts); _alphaval = rect.alphaval(); return *this; } void OverlayRasterRect::damage_flush() { if (_raster) { #if defined(RASTER_DAMAGE1) if (_damage_done) { _raster->flushrect(_damage_l, _damage_b, _damage_r, _damage_t); _damage_done = 0; } else #endif _raster->flush(); } } void OverlayRasterRect::damage_rect(IntCoord l, IntCoord b, IntCoord r, IntCoord t) { _damage_l = l; _damage_b = b; _damage_r = r; _damage_t = t; _damage_done = 1; } /*****************************************************************************/ XColor* OverlayRaster::_gray_map = nil; int OverlayRaster::_unique_grays = 0; boolean OverlayRaster::_gray_initialized = false; XColor* OverlayRaster::_color_map = nil; int OverlayRaster::_unique_colors = 0; #ifdef LEAKCHECK LeakChecker* OverlayRaster::_leakchecker = nil; #endif OverlayRaster::OverlayRaster(unsigned long width, unsigned long height) : Raster (new RasterRep) { init_rep(width, height); _grayflag = false; _init = true; #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("OverlayRaster"); _leakchecker->create(); #endif } OverlayRaster::OverlayRaster(const OverlayRaster& raster) : Raster(new RasterRep) { construct(raster); _grayflag = false; _init = true; #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("OverlayRaster"); _leakchecker->create(); #endif } OverlayRaster::OverlayRaster(const Raster& raster) : Raster(new RasterRep) { construct(raster); _grayflag = false; _init = true; #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("OverlayRaster"); _leakchecker->create(); #endif } OverlayRaster::OverlayRaster( unsigned long width, unsigned long height, unsigned long bwidth ) : Raster (new RasterRep) { init_rep(width, height); _grayflag = false; _init = true; RasterRep* r = rep(); DisplayRep* dr = r->display_->rep(); XDisplay* dpy = dr->display_; r->pixmap_ = XCreatePixmap( dpy, dr->root_, r->pwidth_, r->pheight_, dr->default_visual_->depth() ); r->gc_ = XCreateGC(dpy, r->pixmap_, 0, nil); const Style* s = Session::instance()->style(); // this bg/fg code is in World, but want to avoid that class String v("#ffffff"); if (!s->find_attribute("background", v)) { s->find_attribute("Background", v); } const Color* bc = Color::lookup( Session::instance()->default_display(), v ); if (bc == nil) { bc = new Color(1.0, 1.0, 1.0, 1.0); } Resource::ref(bc); v = "#000000"; if (!s->find_attribute("foreground", v)) { s->find_attribute("Foreground", v); } const Color* fc = Color::lookup( Session::instance()->default_display(), v ); if (fc == nil) { fc = new Color(0.0, 0.0, 0.0, 1.0); } Resource::ref(fc); // oh brother String rv; if (s->find_attribute("reverseVideo", rv)) { if (rv.case_insensitive_equal("on")) { const Color* swap = bc; bc = fc; fc = swap; } } // set up GC GC gc = XCreateGC(dpy, r->pixmap_, 0, nil); ColorRep* cr = fc->rep(dr->default_visual_); unsigned long fpixel = cr->xcolor_.pixel; cr = bc->rep(dr->default_visual_); unsigned long bpixel = cr->xcolor_.pixel; XSetForeground(dpy, gc, bpixel); XFillRectangle(dpy, r->pixmap_, gc, 0, 0, r->pwidth_, r->pheight_); // draw the border outline here bwidth = (bwidth % 2) ? bwidth + 1 : bwidth; XSetForeground(dpy, gc, fpixel); XSetLineAttributes(dpy, gc, bwidth, LineSolid, CapButt, JoinMiter); XDrawRectangle( dpy, r->pixmap_, gc, bwidth/2, bwidth/2, r->pwidth_ - bwidth, r->pheight_ - bwidth ); Resource::unref(fc); Resource::unref(bc); XFreeGC(dpy, gc); #ifdef XSHM init_shared_memory(); #endif if (!r->shared_memory_) { r->image_ = XGetImage( dpy, r->pixmap_, 0, 0, r->pwidth_, r->pheight_, AllPlanes, ZPixmap ); } #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("OverlayRaster"); _leakchecker->create(); #endif } void OverlayRaster::construct(const Raster& raster) { _grayflag = false; RasterRep* r = rep(); raster.flush(); RasterRep& rr = *(raster.rep()); r->display_ = rr.display_; r->modified_ = true; r->width_ = rr.width_; r->height_ = rr.height_; r->left_ = rr.left_; r->bottom_ = rr.bottom_; r->right_ = rr.right_; r->top_ = rr.top_; r->pwidth_ = rr.pwidth_; r->pheight_ = rr.pheight_; r->shared_memory_ = false; if (rr.pixmap_) { DisplayRep* dr = r->display_->rep(); XDisplay* dpy = dr->display_; r->pixmap_ = XCreatePixmap( dpy, dr->root_, r->pwidth_, r->pheight_, dr->default_visual_->depth() ); r->gc_ = XCreateGC(dpy, r->pixmap_, 0, nil); XCopyArea( dpy, rr.pixmap_, r->pixmap_, r->gc_, 0, 0, r->pwidth_, r->pheight_, 0, 0 ); #ifdef XSHM init_shared_memory(); #endif if (!r->shared_memory_) { r->image_ = XGetImage( dpy, r->pixmap_, 0, 0, r->pwidth_, r->pheight_, AllPlanes, ZPixmap ); } } else { r->pixmap_ = nil; r->gc_ = nil; r->image_ = nil; } #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("OverlayRaster"); _leakchecker->create(); #endif } OverlayRaster::~OverlayRaster() { OverlayPainter::Uncache(this); #ifdef LEAKCHECK _leakchecker->destroy(); #endif } void OverlayRaster::init_rep(unsigned long w, unsigned long h) { RasterRep* r = rep(); Display* d = Session::instance()->default_display(); r->display_ = d; r->modified_ = false; r->pwidth_ = (unsigned int)w; r->pheight_ = (unsigned int)h; r->width_ = d->to_coord(r->pwidth_); r->height_ = d->to_coord(r->pheight_); r->left_ = 0; r->bottom_ = 0; r->right_ = r->width_; r->top_ = r->height_; r->pixmap_ = nil; r->gc_ = nil; r->image_ = nil; r->shared_memory_ = false; } void OverlayRaster::init_space() { RasterRep* r = rep(); if (r->pixmap_) return; DisplayRep* dr = r->display_->rep(); XDisplay* dpy = dr->display_; r->pixmap_ = XCreatePixmap( dpy, dr->root_, r->pwidth_, r->pheight_, dr->default_visual_->depth() ); r->gc_ = XCreateGC(dpy, r->pixmap_, 0, nil); #ifdef XSHM init_shared_memory(); #endif if (!r->shared_memory_) { r->image_ = XGetImage( dpy, r->pixmap_, 0, 0, r->pwidth_, r->pheight_, AllPlanes, ZPixmap ); } } void OverlayRasterRect::SetRaster(OverlayRaster* nr) { Unref(_raster); _raster = nr; Resource::ref(_raster); _xbeg = _xend = _ybeg = _yend = -1; } OverlayRaster* OverlayRaster::copy() const { return new OverlayRaster(*this); } void OverlayRaster::poke( unsigned long x, unsigned long y, ColorIntensity red, ColorIntensity green, ColorIntensity blue, float alpha ) { RasterRep* r = rep(); if (!r->pixmap_) init_space(); Raster::poke(x, y, red, green, blue, alpha); } void OverlayRaster::graypeek(unsigned long x, unsigned long y, unsigned int& i) { float rval, gval, bval, aval; peek(x, y, rval, gval, bval, aval); i = (unsigned int) (gval*(float)0xff); } void OverlayRaster::graypeek(unsigned long x, unsigned long y, unsigned long& l) { float rval, gval, bval, aval; peek(x, y, rval, gval, bval, aval); l = (unsigned long) (gval*(float)0xff); } void OverlayRaster::graypeek(unsigned long x, unsigned long y, float& f) { float rval, gval, bval, aval; peek(x, y, rval, gval, bval, aval); f = (float) (gval*(float)0xff); } void OverlayRaster::graypeek(unsigned long x, unsigned long y, double& d) { float rval, gval, bval, aval; peek(x, y, rval, gval, bval, aval); d = (double) (gval*(float)0xff); } void OverlayRaster::graypeek(unsigned long x, unsigned long y, AttributeValue& val) { float rval, gval, bval, aval; peek(x, y, rval, gval, bval, aval); val.double_ref() = (double) (gval*(float)0xff); val.type(AttributeValue::DoubleType); } void OverlayRaster::graypoke(unsigned long x, unsigned long y, unsigned int i) { if (!gray_initialized()) gray_init(); RasterRep* r = rep(); if (!_gray_map) { float value = float(i)/0xff; poke(x, y, value, value, value, 1.0); } else { if (!r->pixmap_) init_space(); XPutPixel(r->image_, (unsigned int)x, r->pheight_ - (unsigned int)y - 1, _gray_map[i].pixel); } r->modified_ = true; } void OverlayRaster::graypoke(unsigned long x, unsigned long y, unsigned long l) { graypoke(x, y, (unsigned int)l); } void OverlayRaster::graypoke(unsigned long x, unsigned long y, float f) { graypoke(x, y, (unsigned int)f); } void OverlayRaster::graypoke(unsigned long x, unsigned long y, double d) { graypoke(x, y, (unsigned int)d); } void OverlayRaster::graypoke(unsigned long x, unsigned long y, AttributeValue val) { graypoke(x, y, val.uint_val()); } long OverlayRaster::gray_lookup(int byte) { if (!gray_initialized()) gray_init(); if (_gray_map) return _gray_map[byte].pixel; else return -1; } void OverlayRaster::initialized(boolean init) { _init = init; } boolean OverlayRaster::initialized() { RasterRep* r = rep(); return ((r->pixmap_ != 0) & _init) ? true : false; } void OverlayRaster::initialize() { _init = true; flush(); // ensure that pixmap_ is created init_space(); } void OverlayRaster::flush() const { RasterRep* r = rep(); if (r->pixmap_) Raster::flush(); } void OverlayRaster::flushrect(IntCoord left, IntCoord bottom, IntCoord right, IntCoord top) const { RasterRep* r = rep(); if (r->pixmap_) Raster::flushrect(left, bottom, right, top); } int OverlayRaster::status() const { return 0; // ok by default } int OverlayRaster::gray_init() { if (gray_initialized()) return 0; int status = gray_init(7); if (status) status = gray_init(6); if (status) status = gray_init(5); if (status) { delete _gray_map; _gray_map = nil; } _gray_initialized = true; return status; } int OverlayRaster::gray_init(int nbits) { if (gray_initialized()) return 0; /* allocate graymap for 8 bit images */ const int GRAY_LEVELS = 256; if (!_gray_map) _gray_map = new XColor[GRAY_LEVELS]; _unique_grays = 2<<(nbits-1); /* Allocate a contiguous block within this color map */ /* one greater than _unique_grays in length. */ XColormap colormap = DefaultColormap(Session::instance()->default_display()->rep()->display_, Session::instance()->default_display()->rep()->screen_); unsigned long* indices = new unsigned long[_unique_grays+1]; if( XAllocColorCells(Session::instance()->default_display()->rep()->display_, colormap, true, 0, 0, indices, _unique_grays+1 ) == 0 ) { delete indices; return -1; } /* Adjust the allocated block of color cells so it */ /* starts on an even boundary. */ int free_cell = (indices[0]&0x1) ? _unique_colors : 0; int status = XFreeColors( Session::instance()->default_display()->rep()->display_, colormap, indices+free_cell, 1, 0 ); int align = free_cell==0 ? 1 : 0; /* Set up the colormap, such that contiguous entries in the color */ /* map are differing in the most-significant bit. */ unsigned long delta = 65536/_unique_grays; unsigned long lo_color = 0; unsigned long hi_color = 32768; int repfactor = GRAY_LEVELS/_unique_grays; int off_lo; int off_hi; #if 0 cerr << "nbits: " << nbits << "\t_unique_grays: " << _unique_grays << "\tdelta: " << delta << "\n"; #endif for(int i=0; i<_unique_grays; i+=2 ) { /* Lower half of the gray scale, values replicated GRAY_LEVELS/_unique_grays */ off_lo = i*repfactor/2; #if 0 cerr << "off_lo: " << off_lo << "\tlo_color: " << lo_color << "\n"; #endif _gray_map[off_lo].red = _gray_map[off_lo].green = _gray_map[off_lo].blue = lo_color; _gray_map[off_lo].pixel = indices[align+i]; _gray_map[off_lo].flags = DoRed | DoGreen | DoBlue; for (int k=1; kdefault_display()->rep()->display_, colormap,_gray_map+off_lo); #if 0 cerr << "low color: " << (_gray_map+off_lo)->red << "\n"; #endif lo_color+=delta; /* Upper half of the gray scale, values replicated GRAY_LEVELS/_unique_grays */ off_hi = i*repfactor/2 + GRAY_LEVELS/2; #if 0 cerr << "off_hi: " << off_hi << "\thi_color: " << hi_color << "\n"; #endif _gray_map[off_hi].red = _gray_map[off_hi].green = _gray_map[off_hi].blue = hi_color; _gray_map[off_hi].pixel = indices[align+i+1]; _gray_map[off_hi].flags = DoRed | DoGreen | DoBlue; for (int k=1; kdefault_display()->rep()->display_, colormap,_gray_map+off_hi); #if 0 cerr << "\thi color: " << (_gray_map+off_hi)->red << "\n"; #endif hi_color+=delta; } delete indices; _gray_initialized = true; return 0; } int OverlayRaster::color_init(int nlevels) { if (_color_map) return 0; if (nlevels > 6 || nlevels < 5) return -1; /* allocate colormap for 8 bit images */ _unique_colors = nlevels*nlevels*nlevels; _color_map = new XColor[_unique_colors]; /* Allocate a contiguous block within this color map */ /* one greater than _unique_colors in length. */ XColormap colormap = DefaultColormap(Session::instance()->default_display()->rep()->display_, Session::instance()->default_display()->rep()->screen_); unsigned long* indices = new unsigned long[_unique_colors+1]; if( XAllocColorCells(Session::instance()->default_display()->rep()->display_, colormap, true, 0, 0, indices, _unique_colors+1 ) == 0 ) { delete indices; return -1; } /* Adjust the allocated block of color cells so it */ /* starts on an even boundary. */ int index0 = indices[0]; int free_cell = (indices[0]&0x1) ? _unique_colors : 0; int status = XFreeColors( Session::instance()->default_display()->rep()->display_, colormap, indices+free_cell, 1, 0 ); int align = free_cell==0 ? 1 : 0; /* Set up the colormap, such that contiguous entries in the color */ /* map are differing as much as possible */ unsigned long delta = 65536/(nlevels-1); unsigned long red_lo = 0; unsigned long grn_lo = 0; unsigned long blu_lo = 0; unsigned long red_hi = nlevels==6 ? 3*delta : 2*delta; unsigned long grn_hi = nlevels==6 ? 0 : 2*delta; unsigned long blu_hi = nlevels==6 ? 0 : 3*delta; for(int i=0; i<_unique_colors; i+=2 ) { /* Lower half of the color scale */ _color_map[i].red = red_lo; _color_map[i].green = grn_lo; _color_map[i].blue = blu_lo; int offset = _unique_colors%2 ? _unique_colors-1 : _unique_colors-2; _color_map[i].pixel = indices[offset - (i-align)]; _color_map[i].flags = DoRed | DoGreen | DoBlue; XStoreColor(Session::instance()->default_display()->rep()->display_, colormap,_color_map+i); if ((blu_lo += delta) > 65536) { blu_lo = 0; if ((grn_lo += delta) > 65536) { grn_lo = 0; red_lo += delta; if (red_lo == 65536) red_lo--; } else if (grn_lo==65536) grn_lo--; } else if (blu_lo == 65536) blu_lo--; int j = i+1; if (j==_unique_colors) break; /* Upper half of the color scale */ _color_map[j].red = red_hi; _color_map[j].green = grn_hi; _color_map[j].blue = blu_hi; _color_map[j].pixel = indices[j-align]; _color_map[j].flags = DoRed | DoGreen | DoBlue; XStoreColor(Session::instance()->default_display()->rep()->display_, colormap,_color_map+j); if ((blu_hi += delta) > 65536) { blu_hi = 0; if ((grn_hi += delta) > 65536) { grn_hi = 0; red_hi += delta; if (red_hi == 65536) red_hi--; } else if (grn_hi==65536) grn_hi--; } else if (blu_hi == 65536) blu_hi--; } delete indices; return 0; } OverlayRaster* OverlayRaster::scale( ColorIntensity mingray, ColorIntensity maxgray, CopyString& cmd ) { OverlayRaster* nrast = new OverlayRaster(*this); nrast->scale(mingray, maxgray); cmd = ScaleGrayFunc::CommandString(mingray,maxgray); return nrast; } OverlayRaster* OverlayRaster::pseudocolor( ColorIntensity mingray, ColorIntensity maxgray, CopyString& cmd ) { OverlayRaster* nrast = pseudocolor(mingray, maxgray); cmd = PseudocolorFunc::CommandString(mingray,maxgray); return nrast; } OverlayRaster* OverlayRaster::logscale( ColorIntensity minintensity, ColorIntensity maxintensity, CopyString& cmd ) { OverlayRaster* nrast = new OverlayRaster(*this); nrast->logscale(minintensity, maxintensity); cmd = LogScaleFunc::CommandString(minintensity, maxintensity); return nrast; } OverlayRaster* OverlayRaster::addgrayramp( CopyString& cmd, RampAlignment algn ) { OverlayRaster* nrast = new OverlayRaster(*this); nrast->_addgrayramp(algn); cmd = GrayRampFunc::CommandString(algn); return nrast; } OverlayRaster* OverlayRaster::addgrayramp( CopyString& cmd, Coord x, Coord y ) { OverlayRaster* nrast = new OverlayRaster(*this); RampAlignment algn = ramppos(x, y); nrast->_addgrayramp(algn); cmd = GrayRampFunc::CommandString(algn); return nrast; } void OverlayRaster::scale( ColorIntensity mingray, ColorIntensity maxgray ) { RasterRep* rp = rep(); float fmin = mingray * 0xff; float fmax = maxgray * 0xff; int min = Math::round(fmin); int max = Math::round(fmax); float ratio = ((fmax - fmin) == 0) ? 0. : (0xff / (max - min)); unsigned int width = rp->pwidth_; unsigned int height = rp->pheight_; unsigned int byte; int w,h; for (w = 0; w < width; w++) { for (h = 0; h < height; h++) { graypeek(w, h, byte); if (byte < min) byte = min; if (byte > max) byte = max; unsigned int newval = Math::round((byte - min) * ratio); graypoke(w, h, newval); } } } OverlayRaster* OverlayRaster::pseudocolor( ColorIntensity mingray, ColorIntensity maxgray ) { OverlayRaster* color = new OverlayRaster(pwidth(), pheight()); float ratio = (1.0 / (maxgray - mingray)); int steps = 5; unsigned int byte; float gray; RasterRep* rp = rep(); unsigned int width = rp->pwidth_; unsigned int height = rp->pheight_; int w,h; for (w = 0; w < width; w++) { for (h = 0; h < height; h++) { graypeek(w, h, byte); gray = byte / float(0xff); if (gray < mingray) gray = mingray; if (gray > maxgray) gray = maxgray; float grayfract = (gray - mingray) * ratio; grayfract = (grayfract*steps - fmod(grayfract*steps,1.0)) / (float)steps; float newr, newg, newb; #if 0 newr = grayfract * maxgray; newg = (1.0 - grayfract) * maxgray; newb = 0.0; #else grayfract *= maxgray; newr = grayfract < 0.5 ? 0.0 : (grayfract-.5)*2; newg = grayfract < 0.5 ? grayfract*2 : 1.0 - (grayfract-.5)*2; newb = grayfract < 0.5 ? 1.0 - (grayfract-.5)*2 : 0.0; newr = max((float)0.0, newr); newg = max((float)0.0, newg); newb = max((float)0.0, newb); #endif color->poke(w, h, newr, newg, newb, 1.0); } } return color; } void OverlayRaster::logscale ( ColorIntensity mingray, ColorIntensity maxgray ) { int n = 255; int min, max; min = Math::round(mingray * 0xff); max = Math::round(maxgray * 0xff); RasterRep* rp = rep(); unsigned int width = rp->pwidth_; unsigned int height = rp->pheight_; int w,h; unsigned int byte; int nvals = max-min+1; double e = exp(1.0); for (w = 0; w < width; w++) { for (h = 0; h < height; h++) { graypeek(w, h, byte); if (byte < min) byte = min; if (byte > max) byte = max; #if 0 unsigned int ival = (unsigned int)Math::round(pow( mingray, ((n - byte) / float(n) ) ) * float(n)); #else double val = (byte-((double)min)) / nvals * (e - 1.0) + 1.0; unsigned int ival = (unsigned int) (log(val)*n); #endif graypoke(w, h, ival); } } } static float dist( float x1, float y1, float x2, float y2 ) { float xd = x2 - x1; float yd = y2 - y1; return sqrt((xd*xd) + (yd*yd)); } RampAlignment OverlayRaster::ramppos(IntCoord x, IntCoord y) { float xside[4]; float yside[4]; xside[0] = 0; yside[0] = y; // l xside[1] = pwidth() - 1; yside[1] = y; // r xside[2] = x; yside[2] = 0; // b xside[3] = x; yside[3] = pheight() - 1 ; // t float dists[4]; int i; for (i = 0; i < 4; i++) { dists[i] = dist(x, y, xside[i], yside[i]); } float side = min(min(dists[0], dists[1]), min(dists[2], dists[3])); RampAlignment align; if ( side == dists[0] ) { align = (y > pheight() / 2) ? R_LT : R_LB; } else if ( side == dists[1] ) { align = (y > pheight() / 2) ? R_RT : R_RB; } else if ( side == dists[2] ) { align = (x > pwidth() / 2) ? R_BR : R_BL; } else { align = (x > pwidth() / 2) ? R_TR : R_TL; } return align; } void OverlayRaster::computeramp( boolean vert, RampAlignment align, IntCoord& width, IntCoord& height ) { // the length will be 1/size * length of longer dimension float size = 4.; const char* csize = unidraw->GetCatalog()->GetAttribute("rampsize"); if (csize) { size = atoi(csize); if (size < 1. || size > 30.) { cerr << "rampsize < 1 or > 30 is ignored, using default\n"; size = 4.; } } float fw, fh; if (pwidth() > pheight()) { if (vert) { fw = pwidth() / (size * 4.); fh = fw * 4.; if (fh > pheight()) { fh = pheight(); fw = fh / 4.; } } else { fw = pwidth() / size; fh = fw / 4.; if (fh > pheight()) { fh = pheight(); fw = (fh * 4.) < pwidth() ? (fh * 4.) : pwidth(); } } } else { if (vert) { fh = pheight() / size; fw = fh / 4.; if (fw > pwidth()) { fw = pwidth(); fh = (fw * 4.) < pheight() ? (fw * 4.) : pheight(); } } else { fh = pheight() / (size * 4.); fw = fh * 4.; if (fw > pwidth()) { fw = pwidth(); fh = fw / 4.; } } } width = Math::round(fw); height = Math::round(fh); } void OverlayRaster::_addgrayramp( RampAlignment align, IntCoord w, IntCoord h ) { u_long l, b; boolean horiz = false; switch (align) { case R_TL: case R_TR: case R_BL: case R_BR: horiz = true; break; } if (w == 0 || h == 0) { computeramp(!horiz, align, w, h); } switch (align) { case R_TL: case R_LT: l = 0; b = pheight() - h; break; case R_TR: case R_RT: l = pwidth() - w; b = pheight() - h; break; case R_BL: case R_LB: l = 0; b = 0; break; case R_BR: case R_RB: l = pwidth() - w; b = 0; break; } paintgrayramp(b, l, h, w, horiz); } void OverlayRaster::paintgrayramp (IntCoord l, IntCoord b, unsigned int w, unsigned int h, boolean horiz) { IntCoord rows = b + h; IntCoord cols = l + w; float gray; IntCoord row; IntCoord col; for (row = b; row < rows; row++) { for (col = l; col < cols; col++) { if (horiz) { gray = (float(col) - l) / (((cols - l) == 1) ? 1 : ((cols - l) - 1)); } else { gray = (float(row) - b) / (((rows - b) == 1) ? 1 : ((rows - b) - 1)); } poke(col, row, gray, gray, gray, 1.); } } } boolean OverlayRaster::write (ostream& out) { Coord w = Width(); Coord h = Height(); if (!gray_flag()) { out << w << "," << h << ","; int x = 0; int y = 0; ColorIntensity r, g, b; int ir, ig, ib; float alpha; for (y; y < h; y++) { x = 0; for (x; x < w; x++) { peek(x, y, r, g, b, alpha); int ir = (int)(r*255); int ig = (int)(g*255); int ib = (int)(b*255); out << "(" << ir << "," << ig << "," << ib << ")"; if (!(y == h-1 && x == w-1)) out << ","; } if (y != h-1) out << "\n"; } } else { out << w << "," << h << ","; int x = 0; int y = 0; unsigned int byte; for (y; y < h; y++) { x = 0; for (x; x < w; x++) { graypeek(x, y, byte); out << byte; if (!(y == h-1 && x == w-1)) out << ","; } if (y != h-1) out << "\n"; } } return true; } boolean OverlayRaster::read(istream& in) { int w = Width(); int h = Height(); char delim; if (!gray_flag()) { char paren; int ir, ig, ib; for (int y=0; y < h; y++) { for (int x=0; x < w; x++) { in >> paren >> ir >> delim >> ig >> delim >> ib >> paren; poke(x, y, float(ir)/0xff, float(ig)/0xff, float(ib)/0xff, 1.0); if (!(y == h-1 && x == w-1)) in >> delim; } } } else { unsigned int byte; for (int y=0; y < h; y++) { for (int x=0; x < w; x++) { in >> byte; graypoke(x, y, byte); if (!(y == h-1 && x == w-1)) in >> delim; } } } return true; } ivtools-1.2.11a1/src/OverlayUnidraw/ovraster.h000066400000000000000000000433261214471147700213150ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1997 R.B. Kissh & Associates, Vectaport Inc. * Copyright (c) 1994-1996 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #define NDEBUG /* * Overlay Raster component declarations. */ #ifndef overlay_rastercomp_h #define overlay_rastercomp_h #include #include #include #include #include #include #include #include #include #include #include #undef None class OvImportCmd; class OverlayRaster; class OverlayRasterRect; class RasterScript; #include //: alignment of gray-level ramp when embbeded in a OverlayRaster. enum RampAlignment { R_LB, R_LT, R_TL, R_TR, R_RT, R_RB, R_BR, R_BL }; declareList(CopyStringList,CopyString) //: clone of RasterComp derived from OverlayComp. class RasterOvComp : public OverlayComp { public: RasterOvComp(OverlayRasterRect* = nil, const char* pathname = nil, OverlayComp* parent = nil); RasterOvComp(istream&, OverlayComp* parent = nil); virtual ~RasterOvComp(); OverlayRasterRect* GetOverlayRasterRect(); // return pointer to graphic. virtual void SetPathName(const char*); // set pathname associated with raster. virtual const char* GetPathName(); // return pathname associated with raster. virtual boolean GetByPathnameFlag() { return _import_flags & bypath_mask;} // return flag that indicates whether component will be serialized // by data or by pathname. virtual void SetByPathnameFlag(boolean flag) { _import_flags = flag ? _import_flags |= bypath_mask : _import_flags &= ~bypath_mask;} // set flag that indicates whether component will be serialized // by data or by pathname. virtual boolean GetFromCommandFlag() { return _import_flags & fromcomm_mask;} // return flag that indicates whether component will be serialized // by data or by pathname. virtual void SetFromCommandFlag(boolean flag) { _import_flags = flag ? _import_flags |= fromcomm_mask : _import_flags &= ~fromcomm_mask;} // set flag that indicates whether component will be serialized // by data or by pathname. virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual boolean operator == (OverlayComp&); virtual void Interpret(Command*); // interpret an image command, otherwise pass to base class. virtual void Uninterpret(Command*); // uninterpret an image command, otherwise pass to base class. virtual void Configure(Editor*); // hook for initializing component after Editor is constructed. static boolean UseGrayRaster() { return _use_gray_raster; } // return flag that indicates whether GrayRaster or OverlayRaster should be used. static void UseGrayRaster(boolean flag) { _use_gray_raster = flag; } // set flag that indicates whether GrayRaster or OverlayRaster should be used. static ParamList* get_param_list(); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _ovraster_params; char* _pathname; int _import_flags; CopyStringList _commands; CopyString _com_exp; static boolean _use_gray_raster; static boolean _warned; friend class RasterScript; CLASS_SYMID2("RasterComp", OVRASTER_COMP); }; //: graphical view of RasterOvComp. class RasterOvView : public OverlayView { public: RasterOvView(RasterOvComp* = nil); virtual void Update(); RasterOvComp* GetRasterOvComp(); virtual Graphic* GetGraphic(); OverlayRasterRect* GetOverlayRasterRect() {return (OverlayRasterRect*)GetGraphic();} // return pointer to graphic. OverlayRaster* GetOverlayRaster (); // return pointer to raster inside graphic. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: "PostScript" view of RasterOvComp. class RasterPS : public OverlayPS { public: RasterPS(OverlayComp* = nil); virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: serialized view of RasterOvComp. class RasterScript : public OverlayScript { public: RasterScript(RasterOvComp* = nil); virtual boolean Definition(ostream&); // output variable-length ASCII record that defines the component. static int ReadRaster(istream&, void*, void*, void*, void*); // read raster pathname if it exists, and construct OverlayRasterRect // a OverlayRaster or GrayRaster inside. static int ReadRGB(istream&, void*, void*, void*, void*); // read RGB pixel values directly from serialized file. static int ReadGrayChar(istream&, void*, void*, void*, void*); // read 8-bit pixel values directly from serialized file. static int ReadGrayUChar(istream&, void*, void*, void*, void*); // read unsigned 8-bit pixel values directly from serialized file. static int ReadGrayShort(istream&, void*, void*, void*, void*); // read 16-bit pixel values directly from serialized file. static int ReadGrayUShort(istream&, void*, void*, void*, void*); // read unsigned 16-bit pixel values directly from serialized file. static int ReadGrayInt(istream&, void*, void*, void*, void*); // read integer pixel values directly from serialized file. static int ReadGrayUInt(istream&, void*, void*, void*, void*); // read unsigned integer pixel values directly from serialized file. static int ReadGrayLong(istream&, void*, void*, void*, void*); // read long pixel values directly from serialized file. static int ReadGrayULong(istream&, void*, void*, void*, void*); // read unsigned long pixel values directly from serialized file. static int ReadGrayFloat(istream&, void*, void*, void*, void*); // read floating point pixel values directly from serialized file. static int ReadGrayDouble(istream&, void*, void*, void*, void*); // read double floating point pixel values directly from serialized file. static int ReadAlpha(istream&, void*, void*, void*, void*); // read alpha-transparency value specification. static int ReadSub(istream&, void*, void*, void*, void*); // read sub-image specification. static int ReadProcess(istream&, void*, void*, void*, void*); // read image-processing command string. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); boolean GetByPathnameFlag(); boolean GetFromCommandFlag(); }; class MultiLineObj; class OverlayRaster; //: derived RasterRect Graphic for use with OverlayRaster and GrayRaster. class OverlayRasterRect : public RasterRect { public: OverlayRasterRect(OverlayRaster* = nil, Graphic* = nil); virtual ~OverlayRasterRect(); void clippts(MultiLineObj*); // set polygon used for additional clipping void clippts(int* x, int* y, int n); // set polygon used for additional clipping MultiLineObj* clippts(); // return polygon used for additional clipping void alphaval(float alpha) { _alphaval = alpha; } // set alpha-transparency value, default is 1.0 float alphaval() { return _alphaval; } // return alpha-transparency value. virtual Graphic* Copy(); OverlayRaster* GetOriginal() { return (OverlayRaster*)_raster; } // return raster associated with this graphic. virtual void SetRaster(OverlayRaster*); // set raster associated with this graphic. OverlayRaster* GetOverlayRaster(); // return raster associated with this graphic. const char* path() const; // return pathname associated with the raster. void load_image(const char* pathname = nil); // method for deferred loading of raster by pathname. void draw(Canvas *c, Graphic* gs); // drawing method. void xbeg(IntCoord); // set xbeg of subimage specification (disabled == -1). void xend(IntCoord); // set xend of subimage specification (disabled == -1). void ybeg(IntCoord); // set ybeg of subimage specification (disabled == -1). void yend(IntCoord); // set yend of subimage specification (disabled == -1). IntCoord xbeg() const; // xbeg of subimage specification (disabled == -1). IntCoord xend() const; // xend of subimage specification (disabled == -1). IntCoord ybeg() const; // ybeg of subimage specification (disabled == -1). IntCoord yend() const; // yend of subimage specification (disabled == -1). virtual OverlayRasterRect& operator = (OverlayRasterRect&); // assignment operator. boolean damage_done() { return _damage_done; } // indicates if a damage rectangle has been set for this raster. void damage_done(boolean flag) { _damage_done = flag; } // set flag that indicates damage rectangle specified for this // raster. void damage_flush(); // if a damage rectangle is set this does a partial flush // by calling Raster::flushrect. This clears the flag // returned by ::damage_done. void damage_rect(IntCoord l, IntCoord b, IntCoord r, IntCoord t); // set rectangle used by ::damage_flush for calling Raster::flushrect. protected: IntCoord _xbeg; IntCoord _xend; IntCoord _ybeg; IntCoord _yend; boolean _damage_done; IntCoord _damage_l; IntCoord _damage_b; IntCoord _damage_r; IntCoord _damage_t; MultiLineObj* _clippts; float _alphaval; friend class RasterOvComp; friend class RasterOvView; }; #include //: specialized Raster object for use with RasterOvComp. class OverlayRaster : public Raster { public: OverlayRaster(unsigned long width, unsigned long height); // construct an empty raster ready to accept width*height of pixel values. OverlayRaster( unsigned long width, unsigned long height, unsigned long bwidth ); // initialize with a border of width bwidth using the default fg/bg colors OverlayRaster(const OverlayRaster& raster); // copy constructor OverlayRaster(const Raster& raster); // conversion constructor virtual ~OverlayRaster(); virtual boolean initialized(); // get initialized flag. virtual void initialized(boolean); // set initialized flag. virtual void initialize(); // creates pixmap_ with correct data virtual void poke( unsigned long x, unsigned long y, ColorIntensity red, ColorIntensity green, ColorIntensity blue, float alpha ); // lookup Color that best matches a given 'red', 'green', 'blue', and // 'alpha' value, and poke corresponding entry in the colormap into // the raster. virtual void graypeek(unsigned long x, unsigned long y, unsigned int&); // get green pixel value at 'x','y' and convert to an unsigned int. virtual void graypeek(unsigned long x, unsigned long y, unsigned long&); // get green pixel value at 'x','y' and convert to an unsigned long. virtual void graypeek(unsigned long x, unsigned long y, float&); // get green pixel value at 'x','y' and convert to a float. virtual void graypeek(unsigned long x, unsigned long y, double&); // get green pixel value at 'x','y' and convert to a double. virtual void graypeek(unsigned long x, unsigned long y, AttributeValue&); // get green pixel value at 'x','y' and place in an AttributeValue. virtual void graypoke(unsigned long x, unsigned long y, unsigned int); // set rgb pixel values at 'x','y' with an unsigned int. virtual void graypoke(unsigned long x, unsigned long y, unsigned long); // set rgb pixel values at 'x','y' with an unsigned long. virtual void graypoke(unsigned long x, unsigned long y, float); // set rgb pixel values at 'x','y' with a float. virtual void graypoke(unsigned long x, unsigned long y, double); // set rgb pixel values at 'x','y' with a double. virtual void graypoke(unsigned long x, unsigned long y, AttributeValue); // set rgb pixel values at 'x','y' with the contents of an AttributeValue. virtual void highlight(unsigned long x, unsigned long y) {} // saturate the red value at 'x','y' to highlight a pixel. Implemented // only in GrayRaster. virtual void unhighlight() {} // clear the highlighted pixels. Implemented only in GrayRaster. virtual void flush() const; // flush internal XImage data structure to a pixmap on the X server. virtual void flushrect(IntCoord l, IntCoord b, IntCoord s, IntCoord t) const; // flush rectangular region of internal XImage data structure // to a pixmap on the X server. virtual int status() const; virtual OverlayRaster* copy() const; virtual OverlayRaster* scale( ColorIntensity mingray, ColorIntensity maxgray, CopyString& cmd ); // create new raster scaled between 'mingray' and 'maxgray', and return // command string to reproduce this effect after save/restore. virtual OverlayRaster* pseudocolor( ColorIntensity mingray, ColorIntensity maxgray, CopyString& cmd ); // create new raster pseudo-colored between 'mingray' and 'maxgray', // and return command string to reproduce this effect after save/restore. virtual OverlayRaster* logscale( ColorIntensity mingray, ColorIntensity maxgray, CopyString& cmd ); // create new raster logarithmically scaled between 'mingray' and 'maxgray', // and return command string to reproduce this effect after save/restore. virtual boolean write(ostream& out); // write pixel values of raster to ostream as comma-separated // parenthesized rgb triples in ASCII. virtual boolean read(istream& in); // read pixels values written out by write method. virtual void gray_flag(boolean flag) { _grayflag = flag; } // set flag that indicates this a graylevel image (r==g==b). virtual boolean gray_flag() { return _grayflag; } // return flag that indicates this a graylevel image. virtual boolean grayraster() { return false; } // return flag that indicates whether this is a GrayRaster // (always false for OverlayRaster). virtual AttributeValue::ValueType value_type() const { return AttributeValue::UCharType; } // arbitrary type is not enabled in this class, only GrayRaster. virtual boolean is_type(AttributeValue::ValueType type) { return value_type() == type; } // arbitrary type is not enabled in this class, only GrayRaster. virtual OverlayRaster* addgrayramp( CopyString& cmd, RampAlignment = R_LT ); // embed gray-level ramp in raster at given alignment, and return 'cmd' // string to reproduce this effect after save/restore. virtual OverlayRaster* addgrayramp( CopyString& cmd, IntCoord x, IntCoord y ); // embed gray-level ramp in raster at given alignment, and return 'cmd' // string to reproduce this effect after save/restore. virtual void paintgrayramp( IntCoord left, IntCoord bottom, unsigned width, unsigned height, boolean horiz ); // utility method for painting the grayramp. // protected: static int gray_init(); // setup colormap for viewing graylevel imagery with good rubberband // visibility. static int gray_init(int nbits); // setup colormap for viewing graylevel imagery with good rubberband // visibility, using a specified number of gray-level bits. static boolean gray_initialized() {return _gray_initialized;} // returns true if graylevel colormap has been initialized. static int color_init(int nlevels); // setup colormap for 'nlevels' of R, G, B, i.e. if 'nlevels'==6, // the number of entries set up in the colormap is 216 (6*6*6). static long gray_lookup(int byte); // lookup the original gray-level value associated with a colormap entry. protected: void construct(const Raster&); void init_rep(unsigned long width, unsigned long height); virtual void init_space(); virtual OverlayRaster* pseudocolor( ColorIntensity mingray, ColorIntensity maxgray ); virtual void scale( ColorIntensity mingray, ColorIntensity maxgray ); virtual void logscale( ColorIntensity mingray, ColorIntensity maxgray ); void _addgrayramp( RampAlignment algn, IntCoord w = 0, IntCoord h = 0 ); void computeramp(boolean vert, RampAlignment, IntCoord& w, IntCoord& h); RampAlignment ramppos(IntCoord x, IntCoord y); protected: static XColor* _gray_map; static int _unique_grays; static boolean _gray_initialized; static XColor* _color_map; static int _unique_colors; boolean _grayflag; boolean _init; friend class OvImportCmd; friend class RasterOvComp; #ifdef LEAKCHECK public: static LeakChecker* _leakchecker; #endif }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovrect.cc000066400000000000000000000312151214471147700211020ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Rect component definitions. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ ParamList* RectOvComp::_ovrect_params = nil; int RectOvComp::_symid = -1; ClassId RectOvComp::GetClassId () { return OVRECT_COMP; } boolean RectOvComp::IsA (ClassId id) { return OVRECT_COMP == id || OverlayComp::IsA(id); } Component* RectOvComp::Copy () { RectOvComp* comp = new RectOvComp((SF_Rect*) GetGraphic()->Copy()); if (attrlist()) comp->SetAttributeList(new AttributeList(attrlist())); return comp; } RectOvComp::RectOvComp (SF_Rect* graphic, OverlayComp* parent) : OverlayComp(graphic, parent) { } RectOvComp::RectOvComp(istream& in, OverlayComp* parent) : OverlayComp(nil, parent) { _valid = GetParamList()->read_args(in, this); } ParamList* RectOvComp::GetParamList() { if (!_ovrect_params) GrowParamList(_ovrect_params = new ParamList()); return _ovrect_params; } void RectOvComp::GrowParamList(ParamList* pl) { pl->add_param("original", ParamStruct::required, &RectScript::ReadOriginal, this, &_gr); OverlayComp::GrowParamList(pl); return; } SF_Rect* RectOvComp::GetRect () { return (SF_Rect*) GetGraphic(); } boolean RectOvComp::operator == (OverlayComp& comp) { if (GetClassId() != comp.GetClassId()) return false; SF_Rect* recta = GetRect(); SF_Rect* rectb = ((RectOvComp&)comp).GetRect(); IntCoord ax0, ay0, ax1, ay1; IntCoord bx0, by0, bx1, by1; recta->GetOriginal(ax0, ay0, ax1, ay1); rectb->GetOriginal(bx0, by0, bx1, by1); return ax0 = bx0 && ay0 == by0 && ax1 == bx1 && ay1 == by1 && OverlayComp::operator==(comp); } /*****************************************************************************/ RectOvComp* RectOvView::GetRectOvComp () { return (RectOvComp*) GetSubject(); } ClassId RectOvView::GetClassId () { return OVRECT_VIEW; } boolean RectOvView::IsA (ClassId id) { return OVRECT_VIEW == id || OverlayView::IsA(id); } RectOvView::RectOvView (RectOvComp* subj) : OverlayView(subj) { } void RectOvView::Interpret (Command* cmd) { if (cmd->IsA(ALIGNTOGRID_CMD)) { SF_Rect* rect = (SF_Rect*) GetGraphic(); Transformer total; rect->TotalTransformation(total); Coord x0, y0, x1, y1; float tx0, ty0; rect->GetOriginal(x0, y0, x1, y1); total.Transform(float(x0), float(y0), tx0, ty0); ((AlignToGridCmd*) cmd)->Align(this, tx0, ty0); } else { OverlayView::Interpret(cmd); } } void RectOvView::Update () { Graphic* rect = GetGraphic(); IncurDamage(rect); *rect = *GetRectOvComp()->GetGraphic(); IncurDamage(rect); EraseHandles(); } void RectOvView::CreateHandles () { Coord x[4], y[4]; Viewer* v = GetViewer(); if (v != nil) { GetCorners(x, y); _handles = new RubberHandles(nil, nil, x, y, 4, 0, HANDLE_SIZE); v->InitRubberband(_handles); } } Manipulator* RectOvView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Coord x[5], y[5]; Rubberband* rub = nil; Manipulator* m = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { v->Constrain(e.x, e.y); rub = new RubberRect(nil, nil, e.x, e.y, e.x, e.y); m = new DragManip( v, rub, rel, tool, DragConstraint(XYEqual | Gravity) ); } else if (tool->IsA(RESHAPE_TOOL)) { RubberGroup* rub = new RubberGroup(nil, nil); Coord x[4], y[4]; v->Constrain(e.x, e.y); GetCorners(x, y); _reshapeCorner = ClosestPoint(x, y, 4, e.x, e.y); if (_reshapeCorner > 0) { rub->Append( new RubberLine( nil, nil, x[_reshapeCorner-1], y[_reshapeCorner-1], e.x,e.y ) ); } else { rub->Append(new RubberLine(nil,nil,x[3],y[3],e.x,e.y)); } if (_reshapeCorner < 3) { rub->Append( new RubberLine( nil, nil, x[_reshapeCorner+1], y[_reshapeCorner+1], e.x,e.y ) ); } else { rub->Append(new RubberLine(nil, nil, x[0], y[0], e.x, e.y)); } m = new DragManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else if (tool->IsA(MOVE_TOOL) && !FixedLocation()) { v->Constrain(e.x, e.y); GetCorners(x, y); x[4] = x[0]; y[4] = y[0]; rub = new SlidingLineList(nil, nil, x, y, 5, e.x, e.y); m = new OpaqueDragManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity), GetGraphic() ); } else if (tool->IsA(SCALE_TOOL)) { v->Constrain(e.x, e.y); GetCorners(x, y); x[4] = x[0]; y[4] = y[0]; rub = new ScalingLineList(nil,nil,x,y,5, (x[0]+x[2])/2, (y[0]+y[2])/2); m = new OpaqueDragManip(v, rub, rel, tool, Gravity, GetGraphic()); } else if (tool->IsA(ROTATE_TOOL)) { v->Constrain(e.x, e.y); GetCorners(x, y); x[4] = x[0]; y[4] = y[0]; rub = new RotatingLineList( nil, nil, x, y, 5, (x[0]+x[2])/2, (y[0]+y[2])/2, e.x, e.y ); m = new OpaqueDragManip(v, rub, rel, tool, Gravity, GetGraphic()); } else { m = OverlayView::CreateManipulator(v, e, rel, tool); } return m; } Command* RectOvView::InterpretManipulator (Manipulator* m) { DragManip* dm = (DragManip*) m; Editor* ed = dm->GetViewer()->GetEditor(); Tool* tool = dm->GetTool(); Transformer* rel = dm->GetTransformer(); Command* cmd = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { RubberRect* rr = (RubberRect*) dm->GetRubberband(); Coord x0, y0, x1, y1; rr->GetCurrent(x0, y0, x1, y1); if (x0 != x1 || y0 != y1) { BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar"); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } Graphic* pg = GetGraphicComp()->GetGraphic(); SF_Rect* rect = new SF_Rect(x0, y0, x1, y1, pg); if (brVar != nil) rect->SetBrush(brVar->GetBrush()); if (patVar != nil) rect->SetPattern(patVar->GetPattern()); if (colVar != nil) { rect->FillBg(!colVar->GetBgColor()->None()); rect->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } rect->SetTransformer(rel); Unref(rel); cmd = new PasteCmd(ed, new Clipboard(new RectOvComp(rect))); } } else if (tool->IsA(RESHAPE_TOOL)) { RubberGroup* rubberGroup = (RubberGroup*) dm->GetRubberband(); RubberLine* rubberLine = (RubberLine*) rubberGroup->First(); SF_Polygon* polygon; Coord x[4], y[4]; Coord x0, y0; GetCorners(x, y); rubberLine->GetCurrent(x0, y0, x[_reshapeCorner], y[_reshapeCorner]); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } polygon = new SF_Polygon(x, y, 4, GetGraphic()); polygon->SetTransformer(rel); Unref(rel); cmd = new ReplaceCmd(ed, new PolygonOvComp(polygon)); } else if (tool->IsA(MOVE_TOOL)) { SlidingLineList* sll; Transformer* rel = dm->GetTransformer(); Coord* ox, *oy, *cx, *cy; float fx0, fy0, fx1, fy1; int n; sll = (SlidingLineList*) dm->GetRubberband(); sll->GetOriginal(ox, oy, n); sll->GetCurrent(cx, cy, n); if (rel != nil) { rel->InvTransform(float(ox[0]), float(oy[0]), fx0, fy0); rel->InvTransform(float(cx[0]), float(cy[0]), fx1, fy1); } delete ox; delete oy; delete cx; delete cy; cmd = new MoveCmd(ed, fx1 - fx0, fy1 - fy0); } else if (tool->IsA(SCALE_TOOL)) { ScalingLineList* sll = (ScalingLineList*) dm->GetRubberband(); float sxy = sll->CurrentScaling(); cmd = new ScaleCmd(ed, sxy, sxy); } else if (tool->IsA(ROTATE_TOOL)) { RotatingLineList* rll = (RotatingLineList*) dm->GetRubberband(); float angle = rll->CurrentAngle() - rll->OriginalAngle(); cmd = new RotateCmd(ed, angle); } else { cmd = OverlayView::InterpretManipulator(m); } return cmd; } void RectOvView::GetCorners (Coord* x, Coord* y) { SF_Rect* rect = (SF_Rect*) GetGraphic(); Coord tx[4], ty[4]; Transformer t; rect->GetOriginal(tx[0], ty[0], tx[2], ty[2]); rect->GetOriginal(tx[3], ty[1], tx[1], ty[3]); rect->TotalTransformation(t); t.TransformList((Coord*) tx, (Coord*) ty, 4, x, y); } Graphic* RectOvView::GetGraphic () { Graphic* graphic = OverlayView::GetGraphic(); if (graphic == nil) { RectOvComp* rectComp = GetRectOvComp(); graphic = rectComp->GetGraphic()->Copy(); SetGraphic(graphic); } return graphic; } /*****************************************************************************/ RectPS::RectPS (OverlayComp* subj) : OverlayPS(subj) { } ClassId RectPS::GetClassId () { return RECT_PS; } boolean RectPS::IsA (ClassId id) { return RECT_PS == id || OverlayPS::IsA(id); } boolean RectPS::Definition (ostream& out) { Coord l, b, r, t; Rect* rect = (Rect*) GetGraphicComp()->GetGraphic(); rect->GetOriginal(l, b, r, t); out << "Begin " << MARK << " Rect\n"; MinGS(out); out << MARK << "\n"; out << l << " " << b << " " << r << " " << t << " Rect\n"; out << "End\n\n"; return out.good(); } /*****************************************************************************/ RectScript::RectScript (RectOvComp* subj) : OverlayScript(subj) { } ClassId RectScript::GetClassId () { return RECT_SCRIPT; } boolean RectScript::IsA (ClassId id) { return RECT_SCRIPT == id || OverlayScript::IsA(id); } boolean RectScript::Definition (ostream& out) { Coord l, b, r, t; RectOvComp* comp = (RectOvComp*) GetSubject(); comp->GetRect()->GetOriginal(l, b, r, t); if (!svg_format()) { out << "rectangle("; out << l << "," << b << "," << r << "," << t; } else { out << "\n"; return out.good(); } int RectScript::ReadOriginal (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { Coord l, b, r , t ; char delim; char ch = in.peek(); if (ch != ')' && ch != ':') in >> l >> delim >> b >> delim >> r >> delim >> t ; else l = b = r = t = 0; if (!in.good()) { return -1; } else { *(SF_Rect**)addr1 = new SF_Rect(l, b, r, t); return 0; } } ivtools-1.2.11a1/src/OverlayUnidraw/ovrect.h000066400000000000000000000074171214471147700207530ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Rect component declarations. */ #ifndef overlay_rect_h #define overlay_rect_h #include #include #include #include #include class SF_Rect; #include //: clone of RectComp derived from OverlayComp. class RectOvComp : public OverlayComp { public: RectOvComp(SF_Rect* = nil, OverlayComp* parent = nil); RectOvComp(istream&, OverlayComp* parent = nil); SF_Rect* GetRect(); // return pointer to graphic. virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual boolean operator == (OverlayComp&); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _ovrect_params; friend class OverlaysScript; CLASS_SYMID2("RectComp", OVRECT_COMP); }; //: graphical view of RectOvComp. class RectOvView : public OverlayView { public: RectOvView(RectOvComp* = nil); virtual void Interpret(Command*); // interpret align-to-grid command, otherwise pass to base class. virtual void Update(); virtual Manipulator* CreateManipulator(Viewer*, Event&,Transformer*,Tool*); // create manipulator to create, reshape, move, scale, or rotate rectangle. virtual Command* InterpretManipulator(Manipulator*); // interpret manipulator to create, reshape, move, scale, or rotate rectangle. virtual void GetCorners(Coord* xvals, Coord* yvals); // return four corners of rectangle in current screen coordinates. RectOvComp* GetRectOvComp(); // return pointer to associated component. virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual void CreateHandles(); protected: int _reshapeCorner; }; //: "PostScript" view of RectOvComp. class RectPS : public OverlayPS { public: RectPS(OverlayComp* = nil); virtual boolean Definition(ostream&); // output PostScript fragment for SF_Rect. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: serialized view of RectOvComp. class RectScript : public OverlayScript { public: RectScript(RectOvComp* = nil); virtual boolean Definition(ostream&); // output variable-length ASCII record that defines the component. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); static int ReadOriginal(istream&, void*, void*, void*, void*); // read l,b,r,t arguments and construct a SF_Rect. }; #include #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovrestimage.cc000066400000000000000000000151051214471147700221250ustar00rootroot00000000000000/* * Copyright (c) 1996-1997 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ // #define COMPRESSED_OK #include #include #include #include #include #include #include #include OvRestrictedImage::~OvRestrictedImage() { } // ------------------------------------------------------------------------- OvFileImage::OvFileImage() : _file(nil) { } OvFileImage::~OvFileImage() { if (_file) { if (_compressed) { pclose(_file); } else { fclose(_file); } } } int OvFileImage::Width() const { return _xend - _xbeg + 1; } int OvFileImage::Height() const { return _yend - _ybeg + 1; } void OvFileImage::initialize() { } /* static */ OvFileImage* OvFileImage::create( Display* d, const OverlayRasterRect* rr ) { int ppm_else_pgm; int ncols, nrows; boolean compressed; boolean tiled; int twidth, theight; boolean ok = false; const char* creator = OvImportCmd::ReadCreator(rr->path()); if (strcmp(creator, "PGM") == 0) { ppm_else_pgm = 0; ok = true; } else if (strcmp(creator, "PPM") == 0) { ppm_else_pgm = 1; ok = true; } OvFileImage* fi = nil; if (ok) { PortableImageHelper* ignored; FILE* file = OvImportCmd::Portable_Raster_Open( ignored, rr->path(), ppm_else_pgm, ncols, nrows, compressed, tiled, twidth, theight ); if (file) { if (tiled) { fi = new OvTiledFileImage; } else { fi = new OvPortableFileImage; } fi->_file = file; fi->_bytes_per_pixel = ppm_else_pgm ? 3 : 1; fi->_ppm = (ppm_else_pgm == 1) ? true : false; fi->_compressed = compressed; fi->_file_width = ncols; fi->_file_height = nrows; fi->_pos = 0; fi->_display = d; fi->_xbeg = rr->xbeg(); fi->_xend = rr->xend(); fi->_ybeg = rr->ybeg(); fi->_yend = rr->yend(); fi->initialize(); } } return fi; } void OvFileImage::seek_fwd_rel(long count) { if (count) { _pos += count; if (!_compressed) { fseek(_file, count, 1); } else { int i = 0; for(; irep()->display_, _display->rep()->screen_ ); } else { #endif seek_fwd_rel(move); if (_ppm) { u_short red = (u_short)((float(getc(_file))/0xff)*0xffff); u_short green = (u_short)((float(getc(_file))/0xff)*0xffff); u_short blue = (u_short)((float(getc(_file))/0xff)*0xffff); _pos += 3; XColor xc; _display->rep()->default_visual_->find_color( red, green, blue, xc ); return xc.pixel; } else { // pgm int byte = getc(_file); _pos += 1; return OverlayRaster::gray_lookup(byte); } #ifdef COMPRESSED_OK } #endif } // --------------------------------------------------------------------------- OvTiledFileImage::OvTiledFileImage() : OvFileImage() { } OvTiledFileImage::~OvTiledFileImage() { } void OvTiledFileImage::initialize() { seek_fwd_rel(to_offset(0, 0)); } // as implemented you may not peek twice at the same point unsigned long OvTiledFileImage::Peek(IntCoord x, IntCoord y) { long move = to_offset(x,y) - _pos; #ifdef COMPRESSED_OK if (move < 0) { assert(0); cerr << "illegal peek pos returning black\n"; return XBlackPixel( _display->rep()->display_, _display->rep()->screen_ ); } else { #endif seek_fwd_rel(move); if (_ppm) { u_short red = (u_short)((float(getc(_file))/0xff)*0xffff); u_short green = (u_short)((float(getc(_file))/0xff)*0xffff); u_short blue = (u_short)((float(getc(_file))/0xff)*0xffff); _pos += 3; XColor xc; _display->rep()->default_visual_->find_color( red, green, blue, xc ); return xc.pixel; } else { // pgm int byte = getc(_file); _pos += 1; return OverlayRaster::gray_lookup(byte); } #ifdef COMPRESSED_OK } #endif } // ------------------------------------------------------------------------- OvMemoryImage::OvMemoryImage(XImage* i) : _image(i) { } OvMemoryImage::~OvMemoryImage() { } int OvMemoryImage::Width() const { return _image->width; } int OvMemoryImage::Height() const { return _image->height; } unsigned long OvMemoryImage::Peek(IntCoord x, IntCoord y) { return XGetPixel(_image, x, y); } ivtools-1.2.11a1/src/OverlayUnidraw/ovrestimage.h000066400000000000000000000101141214471147700217620ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1996-1997 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef ov_rest_image_h #define ov_rest_image_h #include #include #include #include //: base class image object for large-image handling. // N.B. 0,0 is the upper left corner, NOT IV conventions. class OvRestrictedImage { public: virtual ~OvRestrictedImage(); virtual unsigned long Peek(IntCoord x, IntCoord y) = 0; virtual int Width() const = 0; virtual int Height() const = 0; }; class OverlayRasterRect; //: file-based image object for large-image handling. class OvFileImage : public OvRestrictedImage { public: virtual ~OvFileImage(); static OvFileImage* create(Display*, const OverlayRasterRect*); virtual unsigned long Peek(IntCoord x, IntCoord y) = 0; virtual int Width() const; virtual int Height() const; protected: OvFileImage(); virtual void initialize(); void seek_fwd_rel(long count); protected: FILE* _file; int _bytes_per_pixel; boolean _ppm; // else pgm boolean _compressed; IntCoord _file_width; IntCoord _file_height; long _pos; Display* _display; IntCoord _xbeg; // these are IV coords IntCoord _xend; IntCoord _ybeg; IntCoord _yend; }; //: specialization of OvFileImage for untiled pbmplus image formats. class OvPortableFileImage : public OvFileImage { friend class OvFileImage; public: virtual ~OvPortableFileImage(); virtual unsigned long Peek(IntCoord x, IntCoord y); protected: OvPortableFileImage(); virtual void initialize(); long to_offset(IntCoord x, IntCoord y) const; }; inline long OvPortableFileImage::to_offset(IntCoord x, IntCoord y) const { x = _xbeg + x; y = (_file_height - 1) - _yend + y; return (y * _file_width * _bytes_per_pixel) + (x * _bytes_per_pixel); } //: specialization of OvFileImage for internally tiled pbmplus image formats. // Note that this class is optimized for iterations that begin at 0,0 and // proceed 1,0 2,0 3,0 ... 0,1 1,1 2,1 ... class OvTiledFileImage : public OvFileImage { friend class OvFileImage; public: virtual ~OvTiledFileImage(); virtual unsigned long Peek(IntCoord x, IntCoord y); protected: OvTiledFileImage(); virtual void initialize(); long to_offset(IntCoord x, IntCoord y) const; }; inline long OvTiledFileImage::to_offset(IntCoord x, IntCoord y) const { return( ((_xbeg * (_yend + 1)) + ((_file_width - _xbeg) * _ybeg) // to the tile + (y * (_xend - _xbeg + 1) + x)) // to x, y * _bytes_per_pixel ); } //: in-memory image object for large-image handling. class OvMemoryImage : public OvRestrictedImage { public: OvMemoryImage(XImage*); virtual ~OvMemoryImage(); virtual unsigned long Peek(IntCoord x, IntCoord y); virtual int Width() const; virtual int Height() const; protected: XImage* _image; }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovselect.cc000066400000000000000000000073671214471147700214370ustar00rootroot00000000000000/* * Copyright (c) 1997 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlaySelect tool definitions. */ #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ ClassId OverlaySelectTool::GetClassId () { return OVSELECT_TOOL; } boolean OverlaySelectTool::IsA (ClassId id) { return OVSELECT_TOOL == id || SelectTool::IsA(id); } OverlaySelectTool::OverlaySelectTool (ControlInfo* m, const int* ignore_ids, int num_ignores) : SelectTool(m) { _nignores = num_ignores; _ignores = new int[_nignores]; for (int i=0; i<_nignores; i++) _ignores[i] = ignore_ids[i]; } OverlaySelectTool::~OverlaySelectTool() { delete _ignores; } Tool* OverlaySelectTool::Copy () { return new OverlaySelectTool(CopyControlInfo(), _ignores, _nignores); } Manipulator* OverlaySelectTool::CreateManipulator ( Viewer* v, Event& e, Transformer* rel ) { Manipulator* m = nil; GraphicView* views = v->GetGraphicView(); Selection* s = v->GetSelection(); OverlaySelection *newSel = (OverlaySelection*) views->ViewIntersecting(e.x-SLOP, e.y-SLOP, e.x+SLOP, e.y+SLOP); if (e.shift) { Localize(s, v); } else { s->Clear(); Iterator i; newSel->First(i); while (!newSel->Done(i)) { OverlayView* view = newSel->GetView(i); if (ignored(view)) newSel->Remove(i); else newSel->Next(i); } } if (newSel->IsEmpty()) { // select w/RubberRect if nothing hit m = new DragManip(v, new RubberRect(nil,nil, e.x,e.y,e.x,e.y), rel); } else { // else user selected object directly s->Exclusive(newSel); } delete newSel; return m; } Command* OverlaySelectTool::InterpretManipulator (Manipulator* m) { DragManip* dm = (DragManip*) m; Viewer* viewer = dm->GetViewer(); GraphicView* views = viewer->GetGraphicView(); Selection* s = viewer->GetSelection(); RubberRect* rr = (RubberRect*) dm->GetRubberband(); Selection* newSel; Coord l, b, r, t; rr->GetCurrent(l, b, r, t); newSel = views->ViewsWithin(l, b, r, t); s->Exclusive(newSel); delete newSel; return nil; } boolean OverlaySelectTool::ignored(OverlayView* view) { boolean is_ignored = false; for (int j=0; j<_nignores; j++) is_ignored = is_ignored || view->IsA(_ignores[j]); return is_ignored; } ivtools-1.2.11a1/src/OverlayUnidraw/ovselect.h000066400000000000000000000034611214471147700212700ustar00rootroot00000000000000/* * Copyright (c) 1997,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef ovselect_h #define ovselect_h #include class OverlayView; //: derived SelectTool. class OverlaySelectTool : public SelectTool { public: OverlaySelectTool(ControlInfo* =nil, const int* ignore_ids = nil, int num_ignores=0); virtual ~OverlaySelectTool(); virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer* =nil); virtual Command* InterpretManipulator(Manipulator*); virtual Tool* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: boolean ignored(OverlayView* view); int* _ignores; int _nignores; }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovselection.cc000066400000000000000000000141521214471147700221330ustar00rootroot00000000000000/* * Copyright (c) 1994 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Implementation of OverlaySelection class. */ #include #include #include #include #include #include /*****************************************************************************/ OverlaySelection::OverlaySelection (OverlaySelection* s) : Selection(s) { _clear_to_repair = false; _handles_disabled = false; } OverlaySelection::OverlaySelection (Selection* s) : Selection(s) { _clear_to_repair = false; _handles_disabled = false; } void OverlaySelection::Show (Viewer* viewer) { #if 0 if (!viewer) return; #else if (!viewer) { Iterator i; First(i); if (Done(i)) return; viewer = GetView(i)->GetViewer(); } #endif if (ShowHighlights(viewer)) viewer->GetDamage()->Repair(); if (HandlesEnabled()) ShowHandles(viewer); } void OverlaySelection::Hide (Viewer* viewer) { #if 0 if (!viewer) return; #else if (!viewer) { Iterator i; First(i); if (Done(i)) return; viewer = GetView(i)->GetViewer(); } #endif if (HandlesEnabled()) HideHandles(viewer); if (HideHighlights(viewer)) viewer->GetDamage()->Repair(); } void OverlaySelection::Update (Viewer* viewer) { #if 0 if (!viewer) return; #else if (!viewer) { Iterator i; First(i); if (Done(i)) return; viewer = GetView(i)->GetViewer(); } #endif if (HandlesEnabled()) HideHandles(viewer); ShowHighlights(viewer); viewer->GetDamage()->Repair(); if (HandlesEnabled()) ShowHandles(viewer); } void OverlaySelection::Clear (Viewer* viewer) { if (HandlesEnabled()) HideHandles(viewer); _clear_to_repair = HideHighlights(viewer) != nil; Iterator i; First(i); while (!Done(i)) Remove(i); } void OverlaySelection::RepairClear(Viewer* viewer, boolean flag) { if (_clear_to_repair && flag) viewer->GetDamage()->Repair(); _clear_to_repair = false; } void OverlaySelection::Merge (Selection* s) { Iterator i; OverlayView* ov = nil; for (s->First(i); !s->Done(i); s->Next(i)) { ov = GetView(i); if (!Includes(ov)) { Append(ov); } } if (ov) Update(ov->GetViewer()); } void OverlaySelection::Exclusive (Selection* s) { Iterator i; OverlayView* ov = nil; for (s->First(i); !s->Done(i); s->Next(i)) { ov = GetView(i); if (Includes(ov)) { if (ov->Highlightable()) ov->Unhighlight(); else { if (HandlesEnabled()) ov->EraseHandles(); } Remove(ov); } else { Append(ov); } } if (ov) Update(ov->GetViewer()); } void OverlaySelection::ShowHandles (Viewer* viewer) { Iterator i; for (First(i); !Done(i); Next(i)) { OverlayView* view = GetView(i); if (view->Highlightable()) continue; if (viewer == nil || view->GetViewer() == viewer) if (HandlesEnabled()) view->RedrawHandles(); } } void OverlaySelection::HideHandles (Viewer* viewer) { Iterator i; for (First(i); !Done(i); Next(i)) { OverlayView* view = GetView(i); if (view->Highlightable()) continue; if (viewer == nil || view->GetViewer() == viewer) if (HandlesEnabled()) view->EraseHandles(); } } OverlayViewer* OverlaySelection::ShowHighlights (Viewer* viewer) { Iterator i; OverlayViewer* ovviewer = nil; for (First(i); !Done(i); Next(i)) { OverlayView* view = GetView(i); if (!view->Highlightable()) continue; ovviewer = (OverlayViewer*)view->GetViewer(); if (viewer == nil || ovviewer == viewer) view->Highlight(); } return ovviewer; } OverlayViewer* OverlaySelection::HideHighlights (Viewer* viewer) { Iterator i; OverlayViewer* ovviewer = nil; for (First(i); !Done(i); Next(i)) { OverlayView* view = GetView(i); if (!view->Highlightable()) continue; ovviewer = (OverlayViewer*)view->GetViewer(); if (viewer == nil || ovviewer == viewer) view->Unhighlight(); } return ovviewer; } void OverlaySelection::EnableHandles() { _handles_disabled = false; ShowHandles(); } void OverlaySelection::DisableHandles() { HideHandles(); _handles_disabled = true; } boolean OverlaySelection::HandlesEnabled() { return !_handles_disabled; } boolean OverlaySelection::HandlesDisabled() { return _handles_disabled; } OverlayView* OverlaySelection::GetView (Iterator i) { return (OverlayView*) View(Elem(i)); } void OverlaySelection::SetView (OverlayView* ov, Iterator& i) { i.SetValue(_ulist->Find(ov)); } OverlaySelection* OverlaySelection::ViewsWithin(IntCoord l, IntCoord b, IntCoord r, IntCoord t) { OverlaySelection* newSel = new OverlaySelection; Iterator i; for (First(i); !Done(i); Next(i)) { OverlayView* view = GetView(i); newSel->Merge(view->ViewsWithin(l, b, r, t)); } return newSel; } ivtools-1.2.11a1/src/OverlayUnidraw/ovselection.h000066400000000000000000000052741214471147700220020ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlaySelection - manages a set of selected components in an overlay style. */ #ifndef ov_selection_h #define ov_selection_h #include class OverlayView; class OverlayViewer; //: derived Selection object // specialized Selection object with support for highlighting by // changing graphic state (as opposed to only using tic mark handles). // Also adds ability to globally disable tic mark handles. class OverlaySelection : public Selection { public: OverlaySelection(OverlaySelection* = nil); OverlaySelection(Selection*); virtual void Show(Viewer* = nil); virtual void Hide(Viewer* = nil); virtual void Update(Viewer* = nil); virtual void Clear(Viewer* = nil); virtual void RepairClear(Viewer*, boolean); virtual void Exclusive(Selection*); virtual void Merge(Selection*); virtual void ShowHandles(Viewer* = nil); virtual void HideHandles(Viewer* = nil); virtual OverlayViewer* ShowHighlights(Viewer* = nil); virtual OverlayViewer* HideHighlights(Viewer* = nil); void EnableHandles(); void DisableHandles(); boolean HandlesEnabled(); boolean HandlesDisabled(); OverlayView* GetView(Iterator); void SetView(OverlayView*, Iterator&); OverlaySelection* ViewsWithin(IntCoord l, IntCoord b, IntCoord r, IntCoord t); virtual void Reserve() { return; } // for use of derived classes protected: boolean _clear_to_repair; boolean _handles_disabled; }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovshowhide.cc000066400000000000000000000157251214471147700217670ustar00rootroot00000000000000/* * Copyright (c) 1994-1995 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * HideViewCmd implementation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ ClassId HideViewCmd::GetClassId () { return HIDE_VIEW_CMD; } boolean HideViewCmd::IsA (ClassId id) { return HIDE_VIEW_CMD == id || Command::IsA(id); } HideViewCmd::HideViewCmd (Viewer* viewer, ControlInfo* c) : Command(c) { _viewer = viewer; } HideViewCmd::HideViewCmd (Viewer* viewer, Editor* ed) : Command(ed) { _viewer = viewer; } HideViewCmd::~HideViewCmd () { } Command* HideViewCmd::Copy () { HideViewCmd* copy = new HideViewCmd(_viewer, CopyControlInfo()); InitCopy(copy); return copy; } void HideViewCmd::Log () { ((OverlayUnidraw*)unidraw)->Log(this, false); } void HideViewCmd::Execute () { Editor* ed = GetEditor(); Selection* s = ed->GetSelection(); Clipboard* cb = GetClipboard(); if (!cb) { if (!s) return; SetClipboard(cb = new Clipboard); cb->Init(s); } Iterator i; for (cb->First(i); !cb->Done(i); cb->Next(i)) { GraphicView* views = _viewer->GetGraphicView(); GraphicView* view = views->GetGraphicView(cb->GetComp(i)); view->Interpret(this); } if (s) s->Clear(); unidraw->Update(); return; } void HideViewCmd::Unexecute () { Editor* ed = GetEditor(); Clipboard* cb = GetClipboard(); if (!cb) return; Iterator i; for (cb->First(i); !cb->Done(i); cb->Next(i)) { GraphicView* views = _viewer->GetGraphicView(); GraphicView* view = views->GetGraphicView(cb->GetComp(i)); view->Uninterpret(this); } unidraw->Update(); return; } /*****************************************************************************/ ClassId UnhideViewsCmd::GetClassId () { return UNHIDE_VIEWS_CMD; } boolean UnhideViewsCmd::IsA (ClassId id) { return UNHIDE_VIEWS_CMD == id || Command::IsA(id); } UnhideViewsCmd::UnhideViewsCmd (ControlInfo* c) : Command(c) { } UnhideViewsCmd::UnhideViewsCmd (Editor* ed) : Command(ed) { } UnhideViewsCmd::~UnhideViewsCmd () { } Command* UnhideViewsCmd::Copy () { UnhideViewsCmd* copy = new UnhideViewsCmd(CopyControlInfo()); InitCopy(copy); return copy; } boolean UnhideViewsCmd::Reversible () { return false; } void UnhideViewsCmd::Execute () { Editor* ed = GetEditor(); Selection* s = ed->GetSelection(); if (s->IsEmpty()) { return; } Iterator i; for (s->First(i); !s->Done(i); s->Next(i)) { GraphicView* view = s->GetView(i); view->GetSubject()->Interpret(this); } s->Clear(); unidraw->Update(); return; } /*****************************************************************************/ ClassId DesensitizeViewCmd::GetClassId () { return DESENSITIZE_VIEW_CMD; } boolean DesensitizeViewCmd::IsA (ClassId id) { return DESENSITIZE_VIEW_CMD == id || Command::IsA(id); } DesensitizeViewCmd::DesensitizeViewCmd (Viewer* viewer, ControlInfo* c) : Command(c) { _viewer = viewer; } DesensitizeViewCmd::DesensitizeViewCmd (Viewer* viewer, Editor* ed) : Command(ed) { _viewer = viewer; } DesensitizeViewCmd::~DesensitizeViewCmd () { } Command* DesensitizeViewCmd::Copy () { DesensitizeViewCmd* copy = new DesensitizeViewCmd(_viewer, CopyControlInfo()); InitCopy(copy); return copy; } void DesensitizeViewCmd::Log () { ((OverlayUnidraw*)unidraw)->Log(this, false); } void DesensitizeViewCmd::Execute () { Editor* ed = GetEditor(); Selection* s = ed->GetSelection(); Clipboard* cb = GetClipboard(); if (!cb) { if (!s) return; SetClipboard(cb = new Clipboard); cb->Init(s); } Iterator i; for (cb->First(i); !cb->Done(i); cb->Next(i)) { GraphicView* views = _viewer->GetGraphicView(); GraphicView* view = views->GetGraphicView(cb->GetComp(i)); view->Interpret(this); } if (s) s->Clear(); unidraw->Update(); return; } void DesensitizeViewCmd::Unexecute () { Editor* ed = GetEditor(); Clipboard* cb = GetClipboard(); if (!cb) return; Iterator i; for (cb->First(i); !cb->Done(i); cb->Next(i)) { GraphicView* views = _viewer->GetGraphicView(); GraphicView* view = views->GetGraphicView(cb->GetComp(i)); view->Uninterpret(this); } unidraw->Update(); return; } /*****************************************************************************/ ClassId SensitizeViewsCmd::GetClassId () { return SENSITIZE_VIEWS_CMD; } boolean SensitizeViewsCmd::IsA (ClassId id) { return SENSITIZE_VIEWS_CMD == id || Command::IsA(id); } SensitizeViewsCmd::SensitizeViewsCmd (ControlInfo* c) : Command(c) { } SensitizeViewsCmd::SensitizeViewsCmd (Editor* ed) : Command(ed) { } SensitizeViewsCmd::~SensitizeViewsCmd () { } Command* SensitizeViewsCmd::Copy () { SensitizeViewsCmd* copy = new SensitizeViewsCmd(CopyControlInfo()); InitCopy(copy); return copy; } boolean SensitizeViewsCmd::Reversible () { return false; } void SensitizeViewsCmd::Execute () { Editor* ed = GetEditor(); Selection* s = ed->GetSelection(); if (s->IsEmpty()) { return; } Iterator i; for (s->First(i); !s->Done(i); s->Next(i)) { GraphicView* view = s->GetView(i); view->GetSubject()->Interpret(this); } s->Clear(); unidraw->Update(); return; } ivtools-1.2.11a1/src/OverlayUnidraw/ovshowhide.h000066400000000000000000000060241214471147700216210ustar00rootroot00000000000000/* * Copyright (c) 1994-1995,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * command for hiding and desensitizing selected views */ #ifndef ov_showhide_h #define ov_showhide_h #include class Viewer; //: command to hide a graphic view in this viewer. class HideViewCmd : public Command { public: HideViewCmd(Viewer*, ControlInfo*); HideViewCmd(Viewer*, Editor* = nil); virtual ~HideViewCmd(); virtual void Log(); virtual void Execute(); virtual void Unexecute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Viewer* _viewer; }; //: command to unhide a graphic view in all other viewers. class UnhideViewsCmd : public Command { public: UnhideViewsCmd(ControlInfo*); UnhideViewsCmd(Editor* = nil); virtual ~UnhideViewsCmd(); virtual boolean Reversible(); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: }; //: command to desensitize a graphic view in this viewer. class DesensitizeViewCmd : public Command { public: DesensitizeViewCmd(Viewer*, ControlInfo*); DesensitizeViewCmd(Viewer*, Editor* = nil); virtual ~DesensitizeViewCmd(); virtual void Log(); virtual void Execute(); virtual void Unexecute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Viewer* _viewer; }; //: command to sensitize a graphic view in all other viewers. class SensitizeViewsCmd : public Command { public: SensitizeViewsCmd(ControlInfo*); SensitizeViewsCmd(Editor* = nil); virtual ~SensitizeViewsCmd(); virtual boolean Reversible(); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovspline.cc000066400000000000000000000366251214471147700214510ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Spline component definitions. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::cerr; /****************************************************************************/ ParamList* SplineOvComp::_ovspline_params = nil; ParamList* ClosedSplineOvComp::_ovclosed_spline_params = nil; int SplineOvComp::_symid = -1; ClassId SplineOvComp::GetClassId () { return OVSPLINE_COMP; } boolean SplineOvComp::IsA (ClassId id) { return OVSPLINE_COMP == id || VerticesOvComp::IsA(id); } Component* SplineOvComp::Copy () { SplineOvComp* comp = new SplineOvComp((SFH_OpenBSpline*) GetGraphic()->Copy()); if (attrlist()) comp->SetAttributeList(new AttributeList(attrlist())); return comp; } SplineOvComp::SplineOvComp (SFH_OpenBSpline* graphic, OverlayComp* parent) : VerticesOvComp(graphic, parent) { } SplineOvComp::SplineOvComp(istream& in, OverlayComp* parent) : VerticesOvComp(nil, parent) { _valid = GetParamList()->read_args(in, this); } ParamList* SplineOvComp::GetParamList() { if (!_ovspline_params) GrowParamList(_ovspline_params = new ParamList()); return _ovspline_params; } void SplineOvComp::GrowParamList(ParamList* pl) { pl->add_param("points", ParamStruct::required, &SplineScript::ReadPoints, this, &_gr); VerticesOvComp::GrowParamList(pl); return; } SFH_OpenBSpline* SplineOvComp::GetSpline () { return (SFH_OpenBSpline*) GetGraphic(); } /****************************************************************************/ SplineOvView::SplineOvView (SplineOvComp* subj) : VerticesOvView(subj) { } SplineOvComp* SplineOvView::GetSplineOvComp () { return (SplineOvComp*) GetSubject(); } ClassId SplineOvView::GetClassId () { return OVSPLINE_VIEW; } boolean SplineOvView::IsA (ClassId id) { return OVSPLINE_VIEW == id || VerticesOvView::IsA(id); } boolean SplineOvView::VertexChanged () { SFH_OpenBSpline* gview = (SFH_OpenBSpline*) GetGraphic(); SFH_OpenBSpline* gsubj = (SFH_OpenBSpline*) GetSplineOvComp()->GetGraphic(); return *gview != *gsubj; } Manipulator* SplineOvView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Manipulator* m = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { ((OverlayEditor*)v->GetEditor())->MouseDocObservable()->textvalue(OverlayKit::mouse_tack); v->Constrain(e.x, e.y); Coord x[1], y[1]; x[0] = e.x; y[0] = e.y; GrowingVertices* rub = new GrowingBSpline( nil, nil, x, y, 1, -1, HANDLE_SIZE ); if (((OverlayViewer*)v)->scribble_pointer()) m = new ScribbleVertexManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); else m = new VertexManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else if (tool->IsA(RESHAPE_TOOL)) { ((OverlayEditor*)v->GetEditor())->MouseDocObservable()->textvalue(OverlayKit::mouse_tack); Coord* x, *y; int n; v->Constrain(e.x, e.y); GetVertices(x, y, n); GrowingBSpline* rub = new GrowingBSpline( nil, nil, x, y, n, ClosestPoint(x, y, n, e.x, e.y), HANDLE_SIZE ); delete x; delete y; m = new VertexManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else { m = VerticesOvView::CreateManipulator(v, e, rel, tool); } return m; } Command* SplineOvView::InterpretManipulator (Manipulator* m) { DragManip* dm = (DragManip*) m; Editor* ed = dm->GetViewer()->GetEditor(); Tool* tool = dm->GetTool(); Transformer* rel = dm->GetTransformer(); Command* cmd = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { GrowingVertices* gv = (GrowingVertices*) dm->GetRubberband(); ((OverlayEditor*)ed)->MouseDocObservable()->textvalue(OverlayKit::mouse_ospl); Coord* x, *y; int n, pt; gv->GetCurrent(x, y, n, pt); if (n > 2 || x[0] != x[1] || y[0] != y[1]) { BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar"); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } Graphic* pg = GetGraphicComp()->GetGraphic(); SFH_OpenBSpline* spline = new SFH_OpenBSpline(x, y, n, pg); if (brVar != nil) spline->SetBrush(brVar->GetBrush()); if (patVar != nil) spline->SetPattern(patVar->GetPattern()); if (colVar != nil) { spline->FillBg(!colVar->GetBgColor()->None()); spline->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } spline->SetTransformer(rel); Unref(rel); cmd = new PasteCmd(ed, new Clipboard(new SplineOvComp(spline))); } delete x; delete y; } else if (tool->IsA(RESHAPE_TOOL)) { GrowingVertices* gv = (GrowingVertices*) dm->GetRubberband(); ((OverlayEditor*)ed)->MouseDocObservable()->textvalue(OverlayKit::mouse_ospl); Coord* x, *y; int n, pt; gv->RemoveVertex(); gv->GetCurrent(x, y, n, pt); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } SFH_OpenBSpline* spline = new SFH_OpenBSpline(x, y, n, GetGraphic()); delete x; delete y; spline->SetTransformer(rel); Unref(rel); cmd = new ReplaceCmd(ed, new SplineOvComp(spline)); } else { cmd = VerticesOvView::InterpretManipulator(m); } return cmd; } /*****************************************************************************/ ClassId SplinePS::GetClassId () { return SPLINE_PS; } boolean SplinePS::IsA (ClassId id) { return SPLINE_PS == id || VerticesPS::IsA(id); } SplinePS::SplinePS (OverlayComp* subj) : VerticesPS(subj) { } const char* SplinePS::Name () { return "BSpl"; } /*****************************************************************************/ ClassId SplineScript::GetClassId () { return SPLINE_SCRIPT; } boolean SplineScript::IsA (ClassId id) { return SPLINE_SCRIPT == id || VerticesScript::IsA(id); } SplineScript::SplineScript (SplineOvComp* subj) : VerticesScript(subj) { } const char* SplineScript::Name () { return "bspline"; } int SplineScript::ReadPoints (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { Coord* x, *y; int n, bad; char ch = in.peek(); if (ch != ')' && ch != ':') bad = ParamList::parse_points(in, x, y, n); else { x = y = nil; n = 0; bad = 0; } if (!in.good() || bad) { delete x; delete y; cerr << "abnormal exit from SplineScript::ReadPoints\n"; return -1; } else { *(SFH_OpenBSpline**)addr1 = new SFH_OpenBSpline(x, y, n); delete x; delete y; return 0; } } /*****************************************************************************/ int ClosedSplineOvComp::_symid = -1; ClassId ClosedSplineOvComp::GetClassId () { return OVCLOSEDSPLINE_COMP; } boolean ClosedSplineOvComp::IsA (ClassId id) { return OVCLOSEDSPLINE_COMP == id || VerticesOvComp::IsA(id); } Component* ClosedSplineOvComp::Copy () { ClosedSplineOvComp* comp = new ClosedSplineOvComp((SFH_ClosedBSpline*) GetGraphic()->Copy()); if (attrlist()) comp->SetAttributeList(new AttributeList(attrlist())); return comp; } ClosedSplineOvComp::ClosedSplineOvComp ( SFH_ClosedBSpline* graphic, OverlayComp* parent ) : VerticesOvComp(graphic, parent) { } ClosedSplineOvComp::ClosedSplineOvComp(istream& in, OverlayComp* parent) : VerticesOvComp(nil, parent) { _valid = GetParamList()->read_args(in, this); } ParamList* ClosedSplineOvComp::GetParamList() { if (!_ovclosed_spline_params) GrowParamList(_ovclosed_spline_params = new ParamList()); return _ovclosed_spline_params; } void ClosedSplineOvComp::GrowParamList(ParamList* pl) { pl->add_param("points", ParamStruct::required, &ClosedSplineScript::ReadPoints, this, &_gr); VerticesOvComp::GrowParamList(pl); return; } SFH_ClosedBSpline* ClosedSplineOvComp::GetClosedSpline () { return (SFH_ClosedBSpline*) GetGraphic(); } /****************************************************************************/ ClosedSplineOvView::ClosedSplineOvView ( ClosedSplineOvComp* subj ) : VerticesOvView(subj) { } ClosedSplineOvComp* ClosedSplineOvView::GetClosedSplineOvComp () { return (ClosedSplineOvComp*) GetSubject(); } ClassId ClosedSplineOvView::GetClassId () { return OVCLOSEDSPLINE_VIEW; } boolean ClosedSplineOvView::IsA (ClassId id) { return OVCLOSEDSPLINE_VIEW == id || VerticesOvView::IsA(id); } boolean ClosedSplineOvView::VertexChanged () { SFH_ClosedBSpline* gview = (SFH_ClosedBSpline*) GetGraphic(); SFH_ClosedBSpline* gsubj = (SFH_ClosedBSpline*) GetClosedSplineOvComp()->GetGraphic(); return gview->GetOriginal() != gsubj->GetOriginal(); } Manipulator* ClosedSplineOvView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Manipulator* m = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { ((OverlayEditor*)v->GetEditor())->MouseDocObservable()->textvalue(OverlayKit::mouse_tack); v->Constrain(e.x, e.y); Coord x[1], y[1]; x[0] = e.x; y[0] = e.y; GrowingVertices* rub = new GrowingClosedBSpline( nil, nil, x, y, 1, -1, HANDLE_SIZE ); m = new VertexManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else if (tool->IsA(RESHAPE_TOOL)) { ((OverlayEditor*)v->GetEditor())->MouseDocObservable()->textvalue(OverlayKit::mouse_tack); Coord* x, *y; int n; v->Constrain(e.x, e.y); GetVertices(x, y, n); GrowingClosedBSpline* rub = new GrowingClosedBSpline( nil, nil, x, y, n, ClosestPoint(x, y, n, e.x, e.y), HANDLE_SIZE ); delete x; delete y; m = new VertexManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else { m = VerticesOvView::CreateManipulator(v, e, rel, tool); } return m; } Command* ClosedSplineOvView::InterpretManipulator (Manipulator* m) { DragManip* dm = (DragManip*) m; Editor* ed = dm->GetViewer()->GetEditor(); Tool* tool = dm->GetTool(); Transformer* rel = dm->GetTransformer(); Command* cmd = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { GrowingVertices* gv = (GrowingVertices*) dm->GetRubberband(); ((OverlayEditor*)ed)->MouseDocObservable()->textvalue(OverlayKit::mouse_cspl); Coord* x, *y; int n, pt; gv->GetCurrent(x, y, n, pt); if (n > 2 || x[0] != x[1] || y[0] != y[1]) { BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar"); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } Graphic* pg = GetGraphicComp()->GetGraphic(); SFH_ClosedBSpline* cbs = new SFH_ClosedBSpline(x, y, n, pg); if (brVar != nil) cbs->SetBrush(brVar->GetBrush()); if (patVar != nil) cbs->SetPattern(patVar->GetPattern()); if (colVar != nil) { cbs->FillBg(!colVar->GetBgColor()->None()); cbs->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } cbs->SetTransformer(rel); Unref(rel); cmd = new PasteCmd(ed, new Clipboard(new ClosedSplineOvComp(cbs))); } delete x; delete y; } else if (tool->IsA(RESHAPE_TOOL)) { GrowingVertices* gv = (GrowingVertices*) dm->GetRubberband(); ((OverlayEditor*)ed)->MouseDocObservable()->textvalue(OverlayKit::mouse_cspl); Coord* x, *y; int n, pt; gv->RemoveVertex(); gv->GetCurrent(x, y, n, pt); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } SFH_ClosedBSpline* cbs = new SFH_ClosedBSpline(x, y, n, GetGraphic()); delete x; delete y; cbs->SetTransformer(rel); Unref(rel); cmd = new ReplaceCmd(ed, new ClosedSplineOvComp(cbs)); } else { cmd = VerticesOvView::InterpretManipulator(m); } return cmd; } /*****************************************************************************/ ClassId ClosedSplinePS::GetClassId () { return CLOSEDSPLINE_PS; } boolean ClosedSplinePS::IsA (ClassId id) { return CLOSEDSPLINE_PS == id || VerticesPS::IsA(id); } ClosedSplinePS::ClosedSplinePS (OverlayComp* subj) : VerticesPS(subj) { } const char* ClosedSplinePS::Name () { return "CBSpl"; } /*****************************************************************************/ ClassId ClosedSplineScript::GetClassId () { return CLOSEDSPLINE_SCRIPT; } boolean ClosedSplineScript::IsA (ClassId id) { return CLOSEDSPLINE_SCRIPT == id || VerticesScript::IsA(id); } ClosedSplineScript::ClosedSplineScript (ClosedSplineOvComp* subj) : VerticesScript(subj) { } const char* ClosedSplineScript::Name () { return "closedspline"; } int ClosedSplineScript::ReadPoints (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { Coord* x, *y; int n, bad; char ch = in.peek(); if (ch != ')' && ch != ':') bad = ParamList::parse_points(in, x, y, n); else { x = y = nil; n = 0; bad = 0; } if (!in.good() || bad) { delete x; delete y; cerr << "abnormal exit from ClosedSplineScript::ReadPoints\n"; return -1; } else { *(SFH_ClosedBSpline**)addr1 = new SFH_ClosedBSpline(x, y, n); delete x; delete y; return 0; } } ivtools-1.2.11a1/src/OverlayUnidraw/ovspline.h000066400000000000000000000124531214471147700213040ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Spline component declarations. */ #ifndef overlay_spline_h #define overlay_spline_h #include class SFH_OpenBSpline; class SFH_ClosedBSpline; #include //: clone of SplineComp derived from OverlayComp. class SplineOvComp : public VerticesOvComp { public: SplineOvComp(SFH_OpenBSpline* = nil, OverlayComp* parent = nil); SplineOvComp(istream&, OverlayComp* parent = nil); SFH_OpenBSpline* GetSpline(); // return pointer to graphic. virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _ovspline_params; friend class OverlaysScript; CLASS_SYMID2("SplineComp", OVSPLINE_COMP); }; //: graphic view of SplineOvComp. class SplineOvView : public VerticesOvView { public: SplineOvView(SplineOvComp* = nil); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); // create manipulator to create or reshape a spline. virtual Command* InterpretManipulator(Manipulator*); // interpret manipulator to create or reshape a spline. SplineOvComp* GetSplineOvComp(); // return pointer to associated component. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual boolean VertexChanged(); }; //: "PostScript" view of SplineOvComp. class SplinePS : public VerticesPS { public: SplinePS(OverlayComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual const char* Name(); // return name to differentiate from other VerticesPS. }; //: serialized view of SplineOvComp. class SplineScript : public VerticesScript { public: SplineScript(SplineOvComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); static int ReadPoints(istream&, void*, void*, void*, void*); // read set of points and construct a SFH_OpenBSpline. protected: virtual const char* Name(); // return name to differentiate from other VerticesScript. }; //: clone of ClosedSplineComp derived from OverlayComp. class ClosedSplineOvComp : public VerticesOvComp { public: ClosedSplineOvComp(SFH_ClosedBSpline* = nil, OverlayComp* parent = nil); ClosedSplineOvComp(istream&, OverlayComp* parent = nil); SFH_ClosedBSpline* GetClosedSpline(); // return pointer to graphic. virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _ovclosed_spline_params; friend class OverlaysScript; CLASS_SYMID2("ClosedSplineComp", OVCLOSEDSPLINE_COMP); }; //: graphic view of ClosedSplineOvComp. class ClosedSplineOvView : public VerticesOvView { public: ClosedSplineOvView(ClosedSplineOvComp* = nil); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); // create manipulator to create or reshape a spline. virtual Command* InterpretManipulator(Manipulator*); // interpret manipulator to create or reshape a spline. ClosedSplineOvComp* GetClosedSplineOvComp(); // return pointer to associated component. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual boolean VertexChanged(); }; //: "PostScript" view of ClosedSplineOvComp. class ClosedSplinePS : public VerticesPS { public: ClosedSplinePS(OverlayComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual const char* Name(); // return name to differentiate from other VerticesPS. }; //: serialized view of ClosedSplineOvComp. class ClosedSplineScript : public VerticesScript { public: ClosedSplineScript(ClosedSplineOvComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); static int ReadPoints(istream&, void*, void*, void*, void*); // read set of points and construct a SFH_ClosedBSpline. protected: virtual const char* Name(); // return name to differentiate from other VerticesScript. }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovstates.cc000066400000000000000000000037151214471147700214540ustar00rootroot00000000000000/* * Copyright 1994, 1995, 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include using std::cerr; /*****************************************************************************/ PtrLocState::PtrLocState(PixelCoord x, PixelCoord y, OverlayEditor* ed) :NameState(nil) { init(ed); ptrcoords(x, y); } PtrLocState::PtrLocState() : NameState(nil) { _buf = nil; _ed = nil; } void PtrLocState::init(OverlayEditor* ed) { _buf = (char*) new char[256]; _ed = ed; } PtrLocState::~PtrLocState() { delete _buf; } void PtrLocState::ptrcoords(PixelCoord x, PixelCoord y) { ((OverlayViewer*)_ed->GetViewer())->ScreenToDrawing(x, y, _x, _y); sprintf(_buf, "%.2f %.2f", _x, _y); name(_buf, true); } ivtools-1.2.11a1/src/OverlayUnidraw/ovstates.h000066400000000000000000000034301214471147700213100ustar00rootroot00000000000000/* * Copyright 1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef ovstates_h #define ovstates_h #include #include class OverlayEditor; //: state variable to display pointer location in drawing coordinates. class PtrLocState : public NameState { public: PtrLocState(PixelCoord x, PixelCoord y, OverlayEditor*); virtual ~PtrLocState(); virtual void ptrcoords(PixelCoord x, PixelCoord y); // set current pointer coordinates. protected: PtrLocState(); // empty constructor for use of derived class void init(OverlayEditor*); float _x; float _y; char* _buf; OverlayEditor* _ed; }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovstencil.cc000066400000000000000000000265701214471147700216160ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay StencilComp definitions. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::cerr; /*****************************************************************************/ ParamList* StencilOvComp::_ovstencil_params = nil; int StencilOvComp::_symid = -1; static const int no_mask = 0; static const int mask_equals_image = 1; static const int valid_mask = 2; /*****************************************************************************/ ClassId StencilOvComp::GetClassId () { return OVSTENCIL_COMP; } boolean StencilOvComp::IsA (ClassId id) { return OVSTENCIL_COMP == id || OverlayComp::IsA(id); } Component* StencilOvComp::Copy () { StencilOvComp* comp = new StencilOvComp((UStencil*) GetGraphic()->Copy(), _pathname); if (attrlist()) comp->SetAttributeList(new AttributeList(attrlist())); return comp; } StencilOvComp::StencilOvComp (UStencil* s, const char* pathname, OverlayComp* parent ) : OverlayComp(s, parent) { _pathname = (pathname == nil) ? nil : strdup(pathname); _by_pathname = pathname ? true : false; } StencilOvComp::StencilOvComp(istream& in, OverlayComp* parent) : OverlayComp(nil, parent) { _pathname = nil; _by_pathname = false; _valid = GetParamList()->read_args(in, this); } ParamList* StencilOvComp::GetParamList() { if (!_ovstencil_params) GrowParamList(_ovstencil_params = new ParamList()); return _ovstencil_params; } void StencilOvComp::GrowParamList(ParamList* pl) { pl->add_param("by pathname", ParamStruct::optional, &StencilScript::ReadStencil, this, this); pl->add_param("imagebm", ParamStruct::keyword, &StencilScript::ReadImageBitmap, this, this); pl->add_param("maskbm", ParamStruct::keyword, &StencilScript::ReadMaskBitmap, this, this); OverlayComp::GrowParamList(pl); return; } StencilOvComp::~StencilOvComp () { delete _pathname; } UStencil* StencilOvComp::GetStencil () { return (UStencil*) GetGraphic(); } void StencilOvComp::SetPathName(const char* path) { delete _pathname; if (path) _pathname = strdup(path); } const char* StencilOvComp::GetPathName () { return _pathname; } boolean StencilOvComp::operator == (OverlayComp& comp) { if (GetClassId() != comp.GetClassId()) return false; return strcmp(GetPathName(), ((StencilOvComp&)comp).GetPathName()) && OverlayComp::operator==(comp); } /*****************************************************************************/ StencilOvComp* StencilOvView::GetStencilOvComp () { return (StencilOvComp*) GetSubject(); } ClassId StencilOvView::GetClassId () { return OVSTENCIL_VIEW; } boolean StencilOvView::IsA (ClassId id) { return OVSTENCIL_VIEW == id || OverlayView::IsA(id); } StencilOvView::StencilOvView (StencilOvComp* subj) : OverlayView(subj) { } void StencilOvView::Update () { Graphic* stencil = GetGraphic(); IncurDamage(stencil); *stencil = *GetStencilOvComp()->GetGraphic(); IncurDamage(stencil); EraseHandles(); } Graphic* StencilOvView::GetGraphic () { Graphic* graphic = GraphicView::GetGraphic(); if (graphic == nil) { StencilOvComp* stencilComp = GetStencilOvComp(); Bitmap* image, *mask; stencilComp->GetStencil()->GetOriginal(image, mask); graphic = new UStencil(image, mask, stencilComp->GetGraphic()); SetGraphic(graphic); } return graphic; } /*****************************************************************************/ StencilPS::StencilPS (OverlayComp* subj) : OverlayPS(subj) { } ClassId StencilPS::GetClassId () { return STENCIL_PS; } boolean StencilPS::IsA (ClassId id) { return STENCIL_PS == id || OverlayPS::IsA(id); } boolean StencilPS::Definition (ostream& out) { UStencil* stencil = (UStencil*) GetGraphicComp()->GetGraphic(); Bitmap* image, *mask; stencil->GetOriginal(image, mask); const char* tag = (image == mask) ? "SSten" : "FSten"; Coord w = image->Width(); Coord h = image->Height(); out << "Begin " << MARK << " " << tag << "\n"; FgColor(out); BgColor(out); Transformation(out); out << MARK << "\n"; out << w << " " << h << " " << tag << " "; out << "{ currentfile "<< (w + 7) / 8 << " string readhexstring pop }\n"; out << "imagemask"; unidraw->GetCatalog()->WriteBitmapData(image, out); out << "\nEnd\n\n"; return out.good(); } /*****************************************************************************/ StencilScript::StencilScript (StencilOvComp* subj) : OverlayScript(subj) { } ClassId StencilScript::GetClassId () { return STENCIL_SCRIPT; } boolean StencilScript::IsA (ClassId id) { return STENCIL_SCRIPT == id || OverlayScript::IsA(id); } boolean StencilScript::Definition (ostream& out) { StencilOvComp* comp = (StencilOvComp*) GetSubject(); UStencil* stencil = comp->GetStencil(); out << "stencil("; if (GetByPathnameFlag()) out << "\"" << comp->GetPathName() << "\""; else { Bitmap* image_bitmap; Bitmap* mask_bitmap; stencil->GetOriginal(image_bitmap, mask_bitmap); Coord w = (int)image_bitmap->width(); Coord h = (int)image_bitmap->height(); if (w>0 && h>0) { out << " :imagebm " << w << "," << h << ",\n"; for (int y=0; y < h; y++) { out << "\""; for (int x= 0; x < w; x++) { boolean val = image_bitmap->peek(x, y); out << (val ? "1" : "0"); } if (y+1width(); h = (int)mask_bitmap->height(); if (mask_bitmap!=image_bitmap && w>0 && h>0) { out << " :maskbm " << w << "," << h << ",\n"; for (int y=0; y < h; y++) { out << "\""; for (int x= 0; x < w; x++) { boolean val = image_bitmap->peek(x, y); out << (val ? "1" : "0"); } if (y+1GetBaseDir()); if (!in.good()) return -1; #if 1 boolean urlflag = ParamList::urltest(pathname); boolean already_ref = false; const char* creator = !urlflag ? OvImportCmd::ReadCreator(pathname) : nil; if (!creator && !urlflag) { cerr << "Error in reading creator for raster: " << pathname << "\n"; return -1; } #else const char* creator = OvImportCmd::ReadCreator(pathname); if (!creator) return -1; #endif Bitmap* bitmap = nil; if (!urlflag && strcmp(creator, "X11") == 0) bitmap = OvImportCmd::XBitmap_Bitmap(pathname); else if (!urlflag && strcmp(creator, "PBM") == 0) bitmap = OvImportCmd::PBM_Bitmap(pathname); else if (urlflag || strcmp(creator, "JPEG") == 0 || strcmp(creator, "GIF") == 0 || strcmp(creator, "PNG")==0) { OvImportCmd importcmd((Editor*)nil); OverlayComp* tempcomp = (OverlayComp*)importcmd.Import(pathname); if (tempcomp && tempcomp->IsA(OVSTENCIL_COMP)) { UStencil* ustencil = ((StencilOvComp*)tempcomp)->GetStencil(); Bitmap* mask = nil; if(ustencil) ustencil->GetOriginal(bitmap, mask); if (bitmap) bitmap->ref(); // to protect from deletion already_ref = true; delete tempcomp; } } if (bitmap != nil) { if(!already_ref) bitmap->ref(); bitmap->flush(); comp->_gr = new UStencil(bitmap, bitmap, stdgraphic); comp->_pathname = strdup(pathname); return 0; } else { cerr << "Unable to access stencil file: " << pathname << "\n"; return -1; } } boolean StencilScript::GetByPathnameFlag() { StencilOvComp* comp = (StencilOvComp*) GetSubject(); return comp->GetByPathnameFlag() && ((OverlayScript*)GetParent())->GetByPathnameFlag(); } Bitmap* StencilScript::read_bitmap(istream& in) { int w, h; char delim; in >> w >> delim >> h >> delim; void* nilpointer = nil; Bitmap* bitmap = new Bitmap(nilpointer, w, h); for (int y=0; y < h; y++) { ParamList::skip_space(in); char ch; in >> ch; if (ch == '"') { for (int x=0; x < w; x++) { in >> ch; if (ch != '"') bitmap->poke(ch=='1' ? 1 : 0, x, y); else break; } if (ch != '"') in >> ch; in >> ch; if (ch != ',') { in.putback(ch); break; } } } if (bitmap) bitmap->flush(); return bitmap; } int StencilScript::ReadImageBitmap (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { StencilOvComp* comp = (StencilOvComp*)addr1; char delim; Bitmap* bitmap = read_bitmap(in); if (in.good() && bitmap) { bitmap->ref(); if (comp->_gr) { UStencil* stencil = (UStencil*)comp->_gr; Bitmap *i, *m; stencil->GetOriginal(i, m); Unref(i); Unref(m); if (i==m) stencil->SetOriginal(bitmap, bitmap); else stencil->SetOriginal(bitmap, m); } else comp->_gr = new UStencil(bitmap, bitmap); return 0; } else { delete bitmap; cerr << "Unable to create bitmap from file." << "\n"; return -1; } } int StencilScript::ReadMaskBitmap (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { StencilOvComp* comp = (StencilOvComp*)addr1; char delim; Bitmap* bitmap = read_bitmap(in); if (in.good() && bitmap) { bitmap->ref(); if (comp->_gr) { UStencil* stencil = (UStencil*)comp->_gr; Bitmap *i, *m; stencil->GetOriginal(i, m); Unref(i); Unref(m); stencil->SetOriginal(i, bitmap); } else comp->_gr = new UStencil(nil, bitmap); return 0; } else { delete bitmap; cerr << "Unable to create bitmap from file." << "\n"; return -1; } } ivtools-1.2.11a1/src/OverlayUnidraw/ovstencil.h000066400000000000000000000106131214471147700214470ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Stencil component declarations. */ #ifndef overlay_stencil_h #define overlay_stencil_h #include #include #include #include class StencilScript; class UStencil; #include //: clone of StencilComp derived from OverlayComp. class StencilOvComp : public OverlayComp { public: StencilOvComp(UStencil* = nil, const char* pathname = nil, OverlayComp* parent = nil); StencilOvComp(istream&, OverlayComp* parent = nil); virtual ~StencilOvComp(); UStencil* GetStencil(); // return pointer to graphic. virtual void SetPathName(const char*); // set pathname associated with this stencil const char* GetPathName(); // return pathname associated with this stencil virtual boolean GetByPathnameFlag() { return _by_pathname;} // return flag that indicates whether component will be serialized // by data or by pathname. virtual void SetByPathnameFlag(boolean flag) { _by_pathname = flag;} // set flag that indicates whether component will be serialized // by data or by pathname. virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual boolean operator == (OverlayComp&); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _ovstencil_params; protected: char* _pathname; boolean _by_pathname; friend class StencilScript; CLASS_SYMID2("StencilComp", OVSTENCIL_COMP); }; //: graphical view of StencilOvComp. class StencilOvView : public OverlayView { public: StencilOvView(StencilOvComp* = nil); virtual void Update(); StencilOvComp* GetStencilOvComp(); // return pointer to associated component. virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: "PostScript" view of StencilOvComp. class StencilPS : public OverlayPS { public: StencilPS(OverlayComp* = nil); virtual boolean Definition(ostream&); // output "PostScript" fragment for this component. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: serialized view of StencilOvComp. class StencilScript : public OverlayScript { public: StencilScript(StencilOvComp* = nil); virtual boolean Definition(ostream&); // output variable-length ASCII record that defines the component. static int ReadStencil(istream&, void*, void*, void*, void*); // read stencil pathname if it exists, and construct a Ustencil // with two Bitmap's inside (image and mask). static int ReadImageBitmap(istream&, void*, void*, void*, void*); // read bits (1's and 0's separated by commas) of the image part of // a stencil directly from istream. static int ReadMaskBitmap(istream&, void*, void*, void*, void*); // read bits (1's and 0's separated by commas) of the mask part of // a stencil directly from istream. static Bitmap* read_bitmap(istream&); // read bits (1's and 0's separated by commas) and construct a Bitmap. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); boolean GetByPathnameFlag(); }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovtext.cc000066400000000000000000000334201214471147700211310ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Text component definitions. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ ParamList* TextOvComp::_ovtext_params = nil; int TextOvComp::_symid = -1; /*****************************************************************************/ ClassId TextOvComp::GetClassId () { return OVTEXT_COMP; } boolean TextOvComp::IsA (ClassId id) { return OVTEXT_COMP == id || OverlayComp::IsA(id); } Component* TextOvComp::Copy () { TextOvComp* comp = new TextOvComp((TextGraphic*) GetGraphic()->Copy()); if (attrlist()) comp->SetAttributeList(new AttributeList(attrlist())); return comp; } TextOvComp::TextOvComp (TextGraphic* graphic, OverlayComp* parent) : OverlayComp(graphic, parent) { } TextOvComp::TextOvComp(istream& in, OverlayComp* parent) : OverlayComp(nil, parent) { _valid = GetParamList()->read_args(in, this); /* correct font vertical position */ PSFont* f = _gr->GetFont(); float sep = 1 - (f ? f->GetLineHt() : 0); Transformer* t = _gr->GetTransformer(); float dx = 0., dy = sep; if (t != nil) { float x0, y0, x1, y1; t->Transform(0., 0., x0, y0); t->Transform(0., sep, x1, y1); dx = x1 - x0; dy = y1 - y0; } _gr->Translate(dx, dy); } ParamList* TextOvComp::GetParamList() { if (!_ovtext_params) GrowParamList(_ovtext_params = new ParamList()); return _ovtext_params; } void TextOvComp::GrowParamList(ParamList* pl) { pl->add_param("text", ParamStruct::required, &TextScript::ReadText, this, &_gr); OverlayComp::GrowParamList(pl); return; } void TextOvComp::Interpret (Command* cmd) { TextGraphic* gr = (TextGraphic*) GetGraphic(); if (cmd->IsA(BRUSH_CMD) || cmd->IsA(PATTERN_CMD)) { // do nothing } else if (cmd->IsA(FONT_CMD)) { PSFont* font = ((FontCmd*) cmd)->GetFont(); cmd->Store(this, new VoidData(gr->GetFont())); gr->SetFont(font); gr->SetLineHeight(font->GetLineHt()); // hack; should be state var Notify(); } else { OverlayComp::Interpret(cmd); } } void TextOvComp::Uninterpret (Command* cmd) { Graphic* gr = GetGraphic(); if (cmd->IsA(BRUSH_CMD) || cmd->IsA(PATTERN_CMD)) { // do nothing } else if (cmd->IsA(FONT_CMD)) { VoidData* vd = (VoidData*) cmd->Recall(this); PSFont* font = (PSFont*) vd->_void; gr->SetFont(font); Notify(); } else { OverlayComp::Uninterpret(cmd); } } TextGraphic* TextOvComp::GetText () { return (TextGraphic*) GetGraphic(); } boolean TextOvComp::operator == (OverlayComp& comp) { if (GetClassId() != comp.GetClassId()) return false; TextGraphic* texta = GetText(); TextGraphic* textb = ((TextOvComp&)comp).GetText(); int lha = texta->GetLineHeight(); int lhb = textb->GetLineHeight(); return lha == lhb && strcmp(texta->GetOriginal(), textb->GetOriginal()) == 0 && OverlayComp::operator==(comp); } /****************************************************************************/ TextOvComp* TextOvView::GetTextOvComp () { return (TextOvComp*) GetSubject(); } ClassId TextOvView::GetClassId () { return OVTEXT_VIEW; } boolean TextOvView::IsA (ClassId id) { return OVTEXT_VIEW == id || OverlayView::IsA(id); } TextOvView::TextOvView (TextOvComp* subj) : OverlayView(subj) { } boolean TextOvView::TextChanged () { TextGraphic* gview = (TextGraphic*) GetGraphic(); TextGraphic* gsubj = (TextGraphic*) GetTextOvComp()->GetGraphic(); return *gview != *gsubj; } void TextOvView::Interpret (Command* cmd) { if (cmd->IsA(ALIGNTOGRID_CMD)) { Transformer total; GetGraphic()->TotalTransformation(total); float tx0, ty0; total.Transform(0., 0., tx0, ty0); ((AlignToGridCmd*) cmd)->Align(this, tx0, ty0); } else { OverlayView::Interpret(cmd); } } void TextOvView::Update () { TextGraphic* gview = (TextGraphic*) GetGraphic(); TextGraphic* gsubj = (TextGraphic*) GetTextOvComp()->GetGraphic(); IncurDamage(gview); * (Graphic*) gview = * (Graphic*) gsubj; gview->SetLineHeight(gsubj->GetLineHeight()); IncurDamage(gview); EraseHandles(); } Manipulator* TextOvView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Manipulator* m = nil; Editor* ed = v->GetEditor(); int tabWidth = Math::round(.5*ivinch); if (tool->IsA(GRAPHIC_COMP_TOOL)) { FontVar* fontVar = (FontVar*) ed->GetState("FontVar"); ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar"); PSFont* font = (fontVar == nil) ? psstdfont : fontVar->GetFont(); PSColor* fg = (colVar == nil) ? psblack : colVar->GetFgColor(); int lineHt = font->GetLineHt(); Painter* painter = new Painter; painter->FillBg(false); painter->SetFont(font); painter->SetColors(fg, nil); Orientation o = v->GetOrientation(); if (o!=Rotated) painter->SetTransformer(rel); else { rel = new Transformer(rel); rel->Rotate(90.0); painter->SetTransformer(rel); Unref(rel); } m = new TextManip(v, painter, lineHt, tabWidth, tool); } else if (tool->IsA(RESHAPE_TOOL)) { TextGraphic* textgr = (TextGraphic*) GetGraphic(); Painter* painter = new Painter; int lineHt = textgr->GetLineHeight(); Coord xpos, ypos; rel = new Transformer; const char* text = textgr->GetOriginal(); int size = strlen(text); textgr->TotalTransformation(*rel); rel->Transform(0, 0, xpos, ypos); painter->FillBg(false); painter->SetFont(textgr->GetFont()); painter->SetColors(textgr->GetFgColor(), nil); painter->SetTransformer(rel); Unref(rel); m = new TextManip( v, text, size, xpos, ypos, painter, lineHt, tabWidth, tool ); } else { m = OverlayView::CreateManipulator(v, e, rel, tool); } return m; } Command* TextOvView::InterpretManipulator (Manipulator* m) { Viewer* v = m->GetViewer(); Editor* ed = v->GetEditor(); Tool* tool = m->GetTool(); Command* cmd = nil; if (tool->IsA(GRAPHIC_COMP_TOOL) || tool->IsA(RESHAPE_TOOL)) { TextManip* tm = (TextManip*) m; int size; const char* text = tm->GetText(size); if (size == 0) { if (tool->IsA(RESHAPE_TOOL)) { cmd = new OvDeleteCmd(ed); } else { v->Update(); // to repair text display-incurred damage } } else { Coord xpos, ypos; tm->GetPosition(xpos, ypos); Painter* p = tm->GetPainter(); Transformer* rel = tm->GetPainter()->GetTransformer(); int lineHt = tm->GetLineHeight(); Graphic* pg = GetGraphicComp()->GetGraphic(); TextGraphic* textgr = new TextGraphic(text, lineHt, pg); if (tool->IsA(GRAPHIC_COMP_TOOL)) { textgr->SetTransformer(nil); } if (rel != nil) { if (v->GetOrientation()==Rotated && !tool->IsA(RESHAPE_TOOL)) rel->Rotate(-90); rel->InvTransform(xpos, ypos); } if (v->GetOrientation()==Rotated && !tool->IsA(RESHAPE_TOOL)) textgr->Rotate(90.0); textgr->Translate(xpos, ypos); textgr->FillBg(false); textgr->SetFont((PSFont*) p->GetFont()); textgr->SetColors((PSColor*) p->GetFgColor(), nil); if (tool->IsA(GRAPHIC_COMP_TOOL)) { cmd = new PasteCmd(ed, new Clipboard(new TextOvComp(textgr))); } else { cmd = new ReplaceCmd(ed, new TextOvComp(textgr)); } } } else { cmd = OverlayView::InterpretManipulator(m); } return cmd; } Graphic* TextOvView::GetGraphic () { TextOvComp* ovtextcomp; Graphic* graphic = OverlayView::GetGraphic(); if (graphic == nil) { ovtextcomp = GetTextOvComp(); graphic = ovtextcomp->GetGraphic()->Copy(); SetGraphic(graphic); } return graphic; } /****************************************************************************/ ClassId TextPS::GetClassId () { return TEXT_PS; } boolean TextPS::IsA (ClassId id) { return TEXT_PS == id || OverlayPS::IsA(id); } TextPS::TextPS (OverlayComp* subj) : OverlayPS(subj) { } boolean TextPS::Definition (ostream& out) { TextGraphic* g = (TextGraphic*) GetGraphicComp()->GetGraphic(); const char* text = g->GetOriginal(); int count = strlen(text); out << "Begin " << MARK << " Text\n"; float sep = g->GetLineHeight() - 1; // correct for vert shift Transformer corrected, *t = g->GetTransformer(); corrected.Translate(0., sep); if (t == nil) { g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); } else { t->Reference(); corrected.Postmultiply(t); g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); Unref(t); } out << MARK << "\n"; out << "[\n"; int beg, end, lineSize, nextBeg, ypos = 0; for (beg = 0; beg < count; beg = nextBeg) { GetLine(text, count, beg, end, lineSize, nextBeg); const char* string = Filter(&text[beg], end - beg + 1); out << "(" << string << ")\n"; } out << "] Text\n"; out << "End\n\n"; return out.good(); } // Filter escapes embedded special characters that would cause syntax // errors in a Postscript string. const char* TextPS::Filter (const char* string, int len) { TextBuffer stext(sbuf, 0, SBUFSIZE); int dot; for (dot = 0; len--; string++) { char c = *string; if (!isascii(c) || iscntrl(c)) { char buf[5]; ParamList::octal(c, &buf[sizeof(buf) - 1]); dot += stext.Insert(dot, buf, sizeof(buf) - 1); } else { switch (c) { case '(': case ')': case '\\': dot += stext.Insert(dot, "\\", 1); // fall through default: dot += stext.Insert(dot, string, 1); } } } stext.Insert(dot, "", 1); return stext.Text(); } /****************************************************************************/ ClassId TextScript::GetClassId () { return TEXT_SCRIPT; } boolean TextScript::IsA (ClassId id) { return TEXT_SCRIPT == id || OverlayScript::IsA(id); } TextScript::TextScript (TextOvComp* subj) : OverlayScript(subj) { } boolean TextScript::Definition (ostream& out) { TextOvComp* comp = (TextOvComp*) GetSubject(); TextGraphic* g = comp->GetText(); const char* text = g->GetOriginal(); int h = g->GetLineHeight(); out << "text("; out << h << ","; int indent_level = 0; Component* parent = comp; do { parent = parent->GetParent(); indent_level++; } while (parent != nil); ParamList::output_text(out, text, indent_level); float sep = g->GetLineHeight() - 1; // correct for vert shift Transformer corrected, *t = g->GetTransformer(); corrected.Translate(0., sep); if (t == nil) { g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); } else { t->Reference(); corrected.Postmultiply(t); g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); Unref(t); } Annotation(out); Attributes(out); out << ")"; return out.good(); } int TextScript::ReadText (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { int line_height; char delim; char buf[BUFSIZ]; in >> line_height >> delim; if (in.good()) ParamList::parse_text(in, buf, BUFSIZ); if (!in.good()) { return -1; } else { TextGraphic* tg = new TextGraphic(buf, line_height); tg->FillBg(false); *(TextGraphic**)addr1 = tg; return 0; } } ivtools-1.2.11a1/src/OverlayUnidraw/ovtext.h000066400000000000000000000077031214471147700210000ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Text component declarations. */ #ifndef overlay_text_h #define overlay_text_h #include #include #include #include #include #include class TextGraphic; class TextManip; #include //: clone of TextComp derived from OverlayComp. class TextOvComp : public OverlayComp { public: TextOvComp(TextGraphic* = nil, OverlayComp* parent = nil); TextOvComp(istream&, OverlayComp* parent = nil); virtual void Interpret(Command*); // interpret brush, pattern, and font commands, pass rest to base class. virtual void Uninterpret(Command*); // uninterpret brush, pattern, and font commands, pass rest to base class. TextGraphic* GetText(); // return pointer to graphic. virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual boolean operator == (OverlayComp&); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _ovtext_params; friend class OverlaysScript; CLASS_SYMID2("TextComp", OVTEXT_COMP); }; //: graphical view of TextOvComp. class TextOvView : public OverlayView { public: TextOvView(TextOvComp* = nil); virtual void Interpret(Command*); // interpret align-to-grid command, pass rest to base class. virtual void Update(); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); // create manipulator for creating and reshaping a text component. virtual Command* InterpretManipulator(Manipulator*); // interpret manipulator for creating and reshaping a text component. TextOvComp* GetTextOvComp(); // return pointer to associated component. virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual boolean TextChanged(); }; //: "PostScript" view of TextOvComp. class TextPS : public OverlayPS { public: TextPS(OverlayComp* = nil); virtual boolean Definition(ostream&); // output "PostScript" fragment for this component. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: const char* Filter(const char*, int); }; //: serialized view of TextOvComp. class TextScript : public OverlayScript { public: TextScript(TextOvComp* = nil); virtual boolean Definition(ostream&); // output variable-length ASCII record that defines the component. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); static int ReadText(istream&, void*, void*, void*, void*); // read text string and construct a TextGraphic. }; #include #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovunidraw.cc000066400000000000000000000160011214471147700216120ustar00rootroot00000000000000/* * Copyright (c) 1994 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Implementation of OverlayUnidraw class. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include MacroCmd* OverlayUnidraw::_cmdq = nil; boolean* OverlayUnidraw::_updated_ptr = nil; ComTerpServ* OverlayUnidraw::_comterp = nil; int OverlayUnidraw::_npause = nil; boolean OverlayUnidraw::_deferred_notifications = 0; /*****************************************************************************/ OverlayUnidraw::OverlayUnidraw (Catalog* c, int& argc, char** argv, OptionDesc* od, PropertyData* pd) : Unidraw(c, argc, argv, od, pd) { _cmdq = new MacroCmd(); _ovviewer = nil; _comterp = nil; _npause = 0; _run_once = 0; _sec = _usec = -1; /* replace default Painter with an OverlayPainter */ OverlayGraphic::new_painter(); } OverlayUnidraw::OverlayUnidraw (Catalog* c, World* w) : Unidraw(c, w) { _cmdq = new MacroCmd(); _ovviewer = nil; _comterp = nil; _npause = 0; _run_once = 0; _sec = _usec = -1; } OverlayUnidraw::~OverlayUnidraw () { delete _cmdq; OverlayPainter::FreeCache(); } void OverlayUnidraw::Append(Command* cmd) { _cmdq->Append(cmd); } boolean OverlayUnidraw::unidraw_updated() { return *_updated_ptr; } boolean OverlayUnidraw::npause_lessened() { return _comterp && _npause > _comterp->npause(); } boolean OverlayUnidraw::unidraw_updated_or_command_pushed() { Iterator it; _cmdq->First(it); return !_cmdq->Done(it) || unidraw_updated(); } boolean OverlayUnidraw::unidraw_updated_or_command_pushed_or_npause_lessened() { Iterator it; _cmdq->First(it); return !_cmdq->Done(it) || unidraw_updated() || npause_lessened(); } void OverlayUnidraw::Run () { Session* session = GetWorld()->session(); Event e; Iterator it; alive(true); _npause = _comterp ? _comterp->npause() : 0; static long tempsec = 0, tempusec = 0; while (alive() && !session->done() && !npause_lessened()) { updated(false); _updated_ptr = &_updated; // session->read(e, &unidraw_updated); // session->read(e, &unidraw_updated_or_command_pushed); if(_sec<0) session->read(e, &unidraw_updated_or_command_pushed_or_npause_lessened); else { if( tempsec==0 && tempusec==0 ) { tempsec = _sec; tempusec = _usec; } if( !session->read(&tempsec, &tempusec, e, &unidraw_updated_or_command_pushed_or_npause_lessened)){ if(_comterp && _comterp->npause()) _comterp->npause()--; break; } } if (!updated()) { e.handle(); session->default_display()->flush(); } for (_cmdq->First(it); !_cmdq->Done(it); _cmdq->First(it)) { unidraw->ExecuteCmd(_cmdq->GetCommand(it)->Copy()); _cmdq->Remove(_cmdq->GetCommand(it)); } Process(); Sweep(); if (updated()) { Update(true); } if(run_once()) { _run_once--; break; } } _npause = _comterp ? _comterp->npause() : 0; } void OverlayUnidraw::Log (Command* cmd, boolean dirty) { if (cmd->Reversible()) { Editor* ed = cmd->GetEditor(); Component* comp = ed->GetComponent()->GetRoot(); UList* past, *future; GetHistory(comp, past, future); Resource::ref(ed); ClearHistory(future); if (IsClean(ed) && dirty) { DirtyCmd* dc = new DirtyCmd(ed); dc->Execute(); cmd = new MacroCmd(ed, cmd, dc); } past->Prepend(new UList(cmd)); ClearHistory(past, _histlen+1); } } /* static */ void OverlayUnidraw::pointer_tracker_func(Event& e) { if (e.type() != Event::motion || !e.window()) return; PixelCoord x = e.rep()->xevent_.xmotion.x; PixelCoord y = e.rep()->xevent_.xmotion.y; WindowRep& ewr = *e.window()->rep(); Iterator i; for (unidraw->First(i); !unidraw->Done(i); unidraw->Next(i)) { OverlayEditor* ed = (OverlayEditor*) unidraw->GetEditor(i); Viewer* v; if (!(v = ed->GetViewer())) continue; Canvas* c; if (!(c = v->GetCanvas())) continue; Window* cw; if (!(cw = c->window())) continue; /* if event is associated with the ApplicationWindow */ if (ed->GetWindow() == e.window()) { /* adjust for delta between application window and Unidraw canvas */ PixelCoord deltax, deltay; WindowRep& cwr = *cw->rep(); if (cwr.xpos_) // this test requires a window setup where xpos_ is zero after Window::bind { deltax = cwr.xpos_ - ewr.xpos_; deltay = cwr.ypos_ - ewr.ypos_; } else { cw->offset_from_toplevel(deltax, deltay); } x -= deltax; y -= deltay; ed->ptrlocstate()->ptrcoords(x, cwr.canvas_->pheight() - y - 1); break; } /* else if event is associated with the Unidraw canvas */ else if (cw == e.window()) { /* coordinates will already be in the canvas coordinate system */ ed->ptrlocstate()->ptrcoords(x, ewr.canvas_->pheight() - y - 1); break; } } } void OverlayUnidraw::DeferredNotify() { UList* e = _editors->First(); ((OverlayComp*)editor(e)->GetComponent())->DeferredNotify(); } void OverlayUnidraw::Update (boolean immediate) { if (deferred_notifications()) DeferredNotify(); if (immediate) { DoUpdate(); } updated(!immediate); } ivtools-1.2.11a1/src/OverlayUnidraw/ovunidraw.h000066400000000000000000000074731214471147700214710ustar00rootroot00000000000000/* * Copyright (c) 1994,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlayUnidraw - Unidraw derived for OverlayUnidraw library */ #ifndef ovunidraw_h #define ovunidraw_h #include class AttributeList; class Command; class ComTerpServ; class Event; class MacroCmd; class OverlayViewer; //: derived Unidraw object with extra mechanisms. // derived Unidraw object with extra mechanisms for logging and deferred // execution of commands. class OverlayUnidraw : public Unidraw { public: OverlayUnidraw( Catalog*, int& argc, char** argv, OptionDesc* = nil, PropertyData* = nil ); OverlayUnidraw(Catalog*, World*); virtual ~OverlayUnidraw(); virtual void Update(boolean immediate = false); virtual void Run(); virtual void Log(Command*, boolean dirty); void Append(Command*); virtual boolean PrintAttributeList(ostream& out, AttributeList* list) { return false; } // alternate method for serializing an AttributeList // returns false if really not there. static boolean unidraw_updated(); static boolean npause_lessened(); static boolean unidraw_updated_or_command_pushed(); static boolean unidraw_updated_or_command_pushed_or_npause_lessened(); static void pointer_tracker_func(Event&); static int npause() { return _npause; } void CurrentViewer(OverlayViewer* viewer) { _ovviewer = viewer; } OverlayViewer* CurrentViewer() { return _ovviewer; } ComTerpServ* comterp() { return _comterp; } void comterp(ComTerpServ* comterp) { _comterp = comterp; } void DeferredNotify(); // do all deferred notifications static boolean deferred_notifications() { return _deferred_notifications; } // return flag that indicates deferred notifications static void deferred_notifications(boolean flag) { _deferred_notifications = flag; } // set flag that indicates deferred notifications void run_once(int flag) { _run_once = true; } int run_once() { return _run_once; } virtual void RunOnce() { run_once(10);Run(); } // run OverlayUnidraw just once void set_timeout(long sec, long usec) { _sec = sec; _usec = usec; } // set amount of delay before timing out Run() void get_timeout(long& sec, long& usec) { sec= _sec; usec = _usec; } // get amount of delay before timing out Run() protected: int _run_once; long _sec; // seconds of delay before exiting Run long _usec; // micro-seconds of delay before exiting Run static MacroCmd* _cmdq; static boolean* _updated_ptr; OverlayViewer* _ovviewer; static ComTerpServ* _comterp; static int _npause; static boolean _deferred_notifications; }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovvars.cc000066400000000000000000000025401214471147700211170ustar00rootroot00000000000000/* * Copyright (c) 1994 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Implementation of overlay-specific state variables */ #include /*****************************************************************************/ ivtools-1.2.11a1/src/OverlayUnidraw/ovvars.h000066400000000000000000000024431214471147700207630ustar00rootroot00000000000000/* * Copyright (c) 1994 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay-specific state variables */ #ifndef ovvars_h #define ovvars_h #include #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovvertices.cc000066400000000000000000000157751214471147700220060ustar00rootroot00000000000000/* * Copyright (c) 1994-1996 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Vertices component definitions. */ #include #include #include #include #include #include #include #include #include #include #include /****************************************************************************/ int VerticesOvComp::_symid = -1; ClassId VerticesOvComp::GetClassId () { return OVVERTICES_COMP; } boolean VerticesOvComp::IsA (ClassId id) { return OVVERTICES_COMP == id || OverlayComp::IsA(id); } VerticesOvComp::VerticesOvComp (Vertices* graphic, OverlayComp* parent) : OverlayComp(graphic, parent) { } VerticesOvComp::VerticesOvComp(istream& in, OverlayComp* parent) : OverlayComp(nil, parent) { } Vertices* VerticesOvComp::GetVertices () { return (Vertices*) GetGraphic(); } void VerticesOvComp::GrowParamList(ParamList* pl) { pl->add_param("pts", ParamStruct::keyword, &VerticesScript::ReadPts, this, this, &_gr); OverlayComp::GrowParamList(pl); return; } boolean VerticesOvComp::operator == (OverlayComp& comp) { if (GetClassId() != comp.GetClassId()) return false; Vertices* verta = GetVertices(); Vertices* vertb = ((VerticesOvComp&)comp).GetVertices(); return *verta == *vertb && OverlayComp::operator==(comp); } /****************************************************************************/ VerticesOvComp* VerticesOvView::GetVerticesOvComp () { return (VerticesOvComp*) GetSubject(); } ClassId VerticesOvView::GetClassId () { return OVVERTICES_VIEW; } boolean VerticesOvView::IsA (ClassId id) { return OVVERTICES_VIEW == id || OverlayView::IsA(id); } VerticesOvView::VerticesOvView (VerticesOvComp* subj) : OverlayView(subj) { } void VerticesOvView::Update () { Graphic* vertices = GetGraphic(); IncurDamage(vertices); if (VertexChanged()) { // unimplemented } *vertices = *GetVerticesOvComp()->GetGraphic(); IncurDamage(vertices); EraseHandles(); } void VerticesOvView::CreateHandles () { Coord* x, *y; int n; Viewer* v = GetViewer(); if (v != nil) { GetVertices(x, y, n); _handles = new RubberHandles(nil, nil, x, y, n, 0, HANDLE_SIZE); v->InitRubberband(_handles); delete x; delete y; } } boolean VerticesOvView::VertexChanged () { return false; } void VerticesOvView::Interpret (Command* cmd) { if (cmd->IsA(ALIGNTOGRID_CMD)) { Vertices* verts = (Vertices*) GetGraphic(); Transformer total; verts->TotalTransformation(total); float tx0, ty0; const Coord* x, *y; int n = verts->GetOriginal(x, y); total.Transform(float(x[0]), float(y[0]), tx0, ty0); ((AlignToGridCmd*) cmd)->Align(this, tx0, ty0); } else { OverlayView::Interpret(cmd); } } void VerticesOvView::GetVertices (Coord*& x, Coord*& y, int& n) { Vertices* vertices = (Vertices*) GetGraphic(); Transformer t; const Coord* origx, *origy; n = vertices->GetOriginal(origx, origy); ArrayDup(origx, origy, n, x, y); vertices->TotalTransformation(t); t.TransformList(x, y, n); } Graphic* VerticesOvView::GetGraphic () { Graphic* graphic = GraphicView::GetGraphic(); if (graphic == nil) { VerticesOvComp* verticesComp = GetVerticesOvComp(); graphic = verticesComp->GetGraphic()->Copy(); SetGraphic(graphic); } return graphic; } /****************************************************************************/ ClassId VerticesPS::GetClassId () { return VERTICES_PS; } boolean VerticesPS::IsA (ClassId id) { return VERTICES_PS == id || OverlayPS::IsA(id); } VerticesPS::VerticesPS (OverlayComp* subj) : OverlayPS(subj) { } const char* VerticesPS::Name () { return ""; } boolean VerticesPS::Definition (ostream& out) { const Coord* x; const Coord* y; int n; Vertices* vertices = (Vertices*) GetGraphicComp()->GetGraphic(); n = vertices->GetOriginal(x, y); out << "Begin " << MARK << " " << Name() << "\n"; MinGS(out); out << MARK << " " << n << "\n"; for (int i = 0; i < n; i++) { out << x[i] << " " << y[i] << "\n"; } out << n << " " << Name() << "\n"; out << "End\n\n"; return out.good(); } /****************************************************************************/ ClassId VerticesScript::GetClassId () { return VERTICES_SCRIPT; } boolean VerticesScript::IsA (ClassId id) { return VERTICES_SCRIPT == id || OverlayScript::IsA(id); } VerticesScript::VerticesScript (VerticesOvComp* subj) : OverlayScript(subj) { } const char* VerticesScript::Name () { return "vertices"; } boolean VerticesScript::Definition (ostream& out) { const Coord* x; const Coord* y; int n; VerticesOvComp* comp = (VerticesOvComp*) GetSubject(); n = comp->GetVertices()->GetOriginal(x, y); out << Name() << "("; Clipboard* cb = GetPtsList(); if (cb) { out << " :pts " << MatchedPts(cb); } else { for (int i = 0; i < n; ) { for (int j = 0; j < 10 && i < n; j++, i++) { if (ptlist_parens()) out << "(" << x[i] << "," << y[i] << ")"; else out << x[i] << "," << y[i]; if (i+1 < n ) out << ","; } if (i+1 < n ) { out << "\n"; Indent(out); } } } MinGS(out); Annotation(out); Attributes(out); out << ")"; return out.good(); } int VerticesScript::ReadPts (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { OverlayComp* comp = (OverlayComp*)addr1; Vertices* vert = *(Vertices**)addr2; int id; in >> id; if (id>=0) vert->SetOriginal(comp->GetIndexedPts(id)); return in.good() ? 0 : -1; } ivtools-1.2.11a1/src/OverlayUnidraw/ovvertices.h000066400000000000000000000073701214471147700216400ustar00rootroot00000000000000/* * Copyright (c) 1994-1996,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Vertices component declarations. A vertices component's * geometry is defined by a set of vertices. */ #ifndef overlay_vertices_h #define overlay_vertices_h #include #include #include #include #include class Vertices; #include //: clone of VerticesComp derived from OverlayComp. // base class for all multi-point components. class VerticesOvComp : public OverlayComp { public: Vertices* GetVertices(); // return generic pointer to graphic. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); void GrowParamList(ParamList*); virtual boolean operator == (OverlayComp&); protected: VerticesOvComp(Vertices* = nil, OverlayComp* parent = nil); VerticesOvComp(istream&, OverlayComp* parent = nil); CLASS_SYMID2("VerticesComp", OVVERTICES_COMP); }; //: graphical view of VerticesOvComp. // base class for all multi-point OverlayView objects. class VerticesOvView : public OverlayView { public: virtual void Interpret(Command*); virtual void Update(); virtual void GetVertices(Coord*&, Coord*&, int&); VerticesOvComp* GetVerticesOvComp(); virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: VerticesOvView(VerticesOvComp* = nil); virtual void CreateHandles(); virtual boolean VertexChanged(); protected: int _reshapePt; }; //: "PostScript" view of VerticesOvComp. // base class for all multi-point OverlayPS objects. class VerticesPS : public OverlayPS { public: virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: VerticesPS(OverlayComp* = nil); virtual const char* Name(); // method to be filled in by derivative classes to tell them apart. }; //: serialized view of VerticesOvComp. // base class for all multi-point OverlayScript objects. class VerticesScript : public OverlayScript { public: virtual boolean Definition(ostream&); // output variable-length ASCII record that defines the component. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); static int ReadPts(istream&, void*, void*, void*, void*); // read and set point list in a Vertices graphic. protected: VerticesScript(VerticesOvComp* = nil); virtual const char* Name(); // method to be filled in by derivative classes to tell them apart. }; #include #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovviewer.cc000066400000000000000000000344041214471147700214510ustar00rootroot00000000000000/* * Copyright (c) 1994-1997 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlayViewer implementation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ Painter* OverlayViewer::xorPainter = nil; /*****************************************************************************/ OverlayViewer::OverlayViewer ( Editor* ed, GraphicView* gv, UPage* page, Grid* grid, Coord w, Coord h, Orientation orientation, Alignment align, Zooming zoom ) : Viewer(ed, gv, page, grid, w, h, orientation) { delete _damage; _damage = new OverlayDamage; _damage->SetGraphic(_graphic); if (xorPainter == nil) { xorPainter = new Painter; Ref(xorPainter); } _needs_resize = true; SetColorMap(); _pan_chain = _zoom_chain = _scribble_pointer = false; } OverlayViewer::~OverlayViewer () {} void OverlayViewer::Update () { ((OverlayUnidraw*)unidraw)->CurrentViewer(this); if (_needs_resize) return; OverlaySelection* s = (OverlaySelection*)GetSelection(); OverlayView* view = GetOverlayView(); Component* viewComp = view->GetOverlayComp(); OverlayComp* edComp = (OverlayComp*)_editor->GetComponent(); if (viewComp != edComp) { GraphicView* newView = (GraphicView*)edComp->Create(ViewCategory()); if (newView->IsA(GRAPHIC_VIEW)) { edComp->Attach(newView); newView->Update(); SetGraphicView(newView); } else { delete newView; } } else { s->HideHandles(this); _viewerView->Update(); GraphicBlock::UpdatePerspective(); s->ShowHighlights(); _damage->Repair(); s->ShowHandles(this); } GetEditor()->GetWindow()->repair(); GetEditor()->GetWindow()->display()->flush(); GetEditor()->GetWindow()->cursor(arrow); } void OverlayViewer::Draw() { ((OverlayUnidraw*)unidraw)->CurrentViewer(this); OverlaySelection* s = (OverlaySelection*)GetSelection(); _editor->GetWindow()->cursor(hourglass); StartBuffering(); s->ShowHighlights(this); GraphicBlock::Draw(); FinishBuffering(true); s->Init(this); s->ShowHandles(this); _editor->GetWindow()->cursor(arrow); _damage->Reset(); } void OverlayViewer::Redraw(Coord x0, Coord y0, Coord x1, Coord y1) { ((OverlayUnidraw*)unidraw)->CurrentViewer(this); OverlaySelection* s = (OverlaySelection*)GetSelection(); _editor->GetWindow()->cursor(hourglass); StartBuffering(); s->ShowHighlights(this); GraphicBlock::Redraw(x0, y0, x1, y1); FinishBuffering(true); xorPainter->Clip(canvas, x0, y0, x1, y1); s->ShowHandles(this); xorPainter->NoClip(); _editor->GetWindow()->cursor(arrow); } void OverlayViewer::PrepareDoubleBuf() { /* prepare for double buffering within viewer canvas */ canvas->rep()->unbind(); canvas->rep()->bind(true); canvas->rep()->clip_.x = 0; canvas->rep()->clip_.y = 0; canvas->rep()->clip_.width = (unsigned short)canvas->rep()->pwidth_; canvas->rep()->clip_.height = (unsigned short)canvas->rep()->pheight_; canvas->rep()->xdrawable_ = canvas->rep()->copybuffer_; } void OverlayViewer::Resize() { Viewer::Resize(); PrepareDoubleBuf(); /* initial drawing commands, if any */ if (_needs_resize) { ((OverlayEditor*)_editor)->InformComponents(); ((OverlayEditor*)_editor)->InitCommands(); _needs_resize = false; } } void OverlayViewer::StartBuffering() { canvas->rep()->xdrawable_ = canvas->rep()->drawbuffer_; } void OverlayViewer::FinishBuffering(boolean refresh_needed) { if (refresh_needed) canvas->rep()->swapbuffers(); canvas->rep()->xdrawable_ = canvas->rep()->copybuffer_; } void OverlayViewer::UseTool (Tool* t, Event& e) { Transformer* relative = ComputeGravityRel(); Manipulator* m = t->CreateManipulator(this, e, relative); if (m != nil) { Manipulate(m, e); Command* cmd = t->InterpretManipulator(m); if (cmd != nil) { #if 0 cmd->Execute(); if (cmd->Reversible()) { cmd->Log(); } else { delete cmd; } #else ((OverlayEditor*)GetEditor())->ExecuteCmd(cmd); #endif ((OverlaySelection*)GetSelection())->RepairClear(this, t->IsA(SELECT_TOOL)); } else ((OverlaySelection*)GetSelection())->RepairClear(this, true); delete m; } else ((OverlaySelection*)GetSelection())->RepairClear(this, true); Unref(relative); } void OverlayViewer::Zoom (Perspective& np) { float factor = ScaleFactor(np); factor = LimitMagnification(GetMagnification() * factor)/GetMagnification(); register Perspective* p = perspective; IntCoord halfw, halfh; halfw = p->curwidth/2; halfh = p->curheight/2; GetOverlayView()->AdjustForZoom(factor, halfw, halfh); Viewer::Zoom(np); } void OverlayViewer::Scroll (Perspective& np) { register Perspective* p = perspective; Coord dx, dy; dx = p->curx - np.curx; dy = p->cury - np.cury; if (dx==0 && dy==0) return; GetOverlayView()->AdjustForPan((float)dx, (float)dy); Viewer::Scroll(np); } OverlayView* OverlayViewer::GetOverlayView () { return (OverlayView*) _gview; } void OverlayViewer::Chain(boolean pan, boolean zoom) { _pan_chain = pan ? true : _pan_chain; _zoom_chain = zoom ? true : _zoom_chain; } void OverlayViewer::Unchain(boolean pan, boolean zoom) { _pan_chain = pan ? false : _pan_chain; _zoom_chain = zoom ? false : _zoom_chain; } boolean OverlayViewer::Chained() { return _pan_chain || _zoom_chain; } boolean OverlayViewer::ChainedPan() { return _pan_chain; } boolean OverlayViewer::ChainedZoom() { return _zoom_chain; } void OverlayViewer::Adjust (Perspective& np) { Editor* ed = GetEditor(); Perspective basep = *GetPerspective(); Viewer::Adjust(np); if (Chained()) { Iterator i; int dx = np.curx - basep.curx; int dy = np.cury - basep.cury; float xfactor = (float) np.curwidth / basep.curwidth; float yfactor = (float) np.curheight / basep.curheight; for (unidraw->First(i); !unidraw->Done(i); unidraw->Next(i)) { OverlayViewer* v = (OverlayViewer*) unidraw->GetEditor(i)->GetViewer(); if (v->Chained() && v != this) { Perspective p = *v->GetPerspective(); p.cury += dy * p.height / basep.height; p.curx += dx * p.width / basep.width; p.curwidth = (int) (xfactor * p.curwidth); p.curheight = (int) (yfactor * p.curheight); Perspective np = p; v->Normalize(np); if (np.curwidth != canvas->Width() || np.curheight!=canvas->Height()) { if (ChainedZoom()) v->Viewer::Adjust(p); } else { if (ChainedPan()) v->Viewer::Adjust(p); } } } } } void OverlayViewer::SetColorMap() { Catalog* catalog = unidraw->GetCatalog(); const char* col6 = catalog->GetAttribute("color6"); const char* nocol6 = catalog->GetAttribute("nocolor6"); const char* col5 = catalog->GetAttribute("color5"); const char* gr7 = catalog->GetAttribute("gray7"); const char* gr6 = catalog->GetAttribute("gray6"); const char* gr5 = catalog->GetAttribute("gray5"); boolean color6 = col6 ? strcmp(col6 ? col6 : "", "true") == 0 : false; boolean nocolor6 = nocol6 ? strcmp(col6 ? col6 : "", "true") == 0 : false; boolean color5 = strcmp(col5 ? col5 : "", "true") == 0; boolean gray7 = strcmp(gr7 ? gr7 : "", "true") == 0; boolean gray6 = strcmp(gr6 ? gr6 : "", "true") == 0; boolean gray5 = strcmp(gr5 ? gr5 : "", "true") == 0; color6 = color6 && !nocolor6; if (color6 || color5) { if (color6) color5 = OverlayRaster::color_init(6) != 0; if (color5) OverlayRaster::color_init(5); } if (gray7 || gray6 || gray5) { if (gray7) gray6 = OverlayRaster::gray_init(7) != 0; if (gray6) gray5 = OverlayRaster::gray_init(6) != 0; if (gray5) OverlayRaster::gray_init(5); } return; } void OverlayViewer::Manipulate (Manipulator* m, Event& e) { Listen(allEvents); m->Grasp(e); /* * boolean b is just here to workaround a cfront 3.0 bug. */ boolean b = false; GetCanvas()->window()->grab_pointer(); do { Read(e); /* correct for motion events that arrive before the */ /* GetCanvas()->window()->grab_pointer() takes affect */ /* this also has the pleasant side effect of fixing a */ /* bug in computing x,y location when the mouse rolls */ /* off the canvas */ if (e.type() == Event::motion && e.window() && e.window() != GetCanvas()->window()) { WindowRep& ew = *e.window()->rep(); WindowRep& cw = *GetCanvas()->window()->rep(); e.x -= cw.xpos_-ew.xpos_; e.y += cw.ypos_-ew.ypos_; } b = m->Manipulating(e); } while (b); GetCanvas()->window()->ungrab_pointer(); m->Effect(e); Listen(input); } void OverlayViewer::ScreenToDrawing(float xscreen, float yscreen, float& xdraw, float& ydraw) { Transformer* rel = GetRel(); rel->Invert(); rel->Transform(xscreen, yscreen, xdraw, ydraw); rel->unref(); return; } void OverlayViewer::ScreenToDrawing(Coord xscreen, Coord yscreen, float& xdraw, float& ydraw) { ScreenToDrawing(float(xscreen), float(yscreen), xdraw, ydraw); } void OverlayViewer::DrawingToScreen(float xdraw, float ydraw, float& xscreen, float& yscreen) { Transformer* rel = GetRel(); float f_xscreen, f_yscreen; rel->Transform(xdraw, ydraw, xscreen, yscreen); rel->unref(); return; } void OverlayViewer::DrawingToScreen(float xdraw, float ydraw, Coord& xscreen, Coord& yscreen) { float fxscreen, fyscreen; DrawingToScreen(xdraw, ydraw, fxscreen, fyscreen); // xscreen = int(fxscreen); // yscreen = int(fyscreen); xscreen = Math::round(fxscreen); yscreen = Math::round(fyscreen); return; } void OverlayViewer::ScreenToGraphic (float xscreen, float yscreen, Graphic* gr, float& xgr, float& ygr) { if (!gr) { xgr = xscreen; ygr = yscreen; return; } /* compute origin of graphic in drawing */ /* typically the lower-left corner of screen when graphic originally */ /* pasted, except for rasters, stencils, and text, where it is the */ /* lower left corner of the graphic itself */ float xorig_gr = 0.0, yorig_gr = 0.0; if (gr->GetTransformer()) gr->GetTransformer()->Transform(0.,0., xorig_gr, yorig_gr); /* convert screen coordinates to drawing coordinates */ float xdraw, ydraw; ScreenToDrawing(xscreen, yscreen, xdraw, ydraw); /* compute graphic relative coordinates */ float xone_gr = 1.0, yone_gr = 1.0; if (gr->GetTransformer()) gr->GetTransformer()->Transform(1.0, 1.0, xone_gr, yone_gr); float xscale = xone_gr-xorig_gr; float yscale = yone_gr-yorig_gr; xgr = (xdraw - xorig_gr)/xscale; ygr = (ydraw - yorig_gr)/yscale; return; } void OverlayViewer::ScreenToGraphic (Coord xscreen, Coord yscreen, Graphic* gr, float& xgr, float& ygr) { ScreenToGraphic(float(xscreen), float(yscreen), gr, xgr, ygr); } void OverlayViewer::GraphicToScreen (Graphic* gr, float xgr, float ygr, float& xscreen, float& yscreen) { if (!gr) { xscreen = Math::round(xgr); yscreen = Math::round(ygr); return; } /* convert graphic coordinates to drawing coordinates */ float xdrawgr, ydrawgr; if (gr->GetTransformer()) gr->GetTransformer()->Transform(xgr, ygr, xdrawgr, ydrawgr); /* convert drawing coordinates to screen coordinates */ DrawingToScreen(xdrawgr, ydrawgr, xscreen, yscreen); return; } void OverlayViewer::GraphicToScreen (Graphic* gr, float xgr, float ygr, int& xscreen, int& yscreen) { float fxscreen, fyscreen; GraphicToScreen(gr, xgr, ygr, fxscreen, fyscreen); xscreen = int(fxscreen); yscreen = int(fyscreen); } void OverlayViewer::CenterToScreen(int sx, int sy) { Perspective* p = GetPerspective(); p->curx = sx - p->curwidth/2; p->cury = sy - p->curheight/2; Adjust(*p); } void OverlayViewer::SetMagnification (float newmag) { newmag = LimitMagnification(newmag); float oldmag = GetMagnification(); float factor = newmag/oldmag; GraphicView* topview = GetGraphicView(); if (topview) { register Perspective* p = perspective; IntCoord halfw, halfh; halfw = p->curwidth/2; halfh = p->curheight/2; GetOverlayView()->AdjustForZoom(factor, halfw, halfh); } Viewer::SetMagnification(newmag); } ivtools-1.2.11a1/src/OverlayUnidraw/ovviewer.h000066400000000000000000000144011214471147700213060ustar00rootroot00000000000000/* * Copyright (c) 1994-1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlayViewer - a Viewer with support for overlay operations */ #ifndef overlay_viewer_h #define overlay_viewer_h #include #include #include class OverlayView; class Transformer; //: specialized Viewer. class OverlayViewer : public Viewer { public: OverlayViewer( Editor*, GraphicView*, UPage*, Grid* = nil, Coord = 0, Coord = 0, Orientation = Normal, Alignment = Center, Zooming = Continuous ); virtual ~OverlayViewer(); virtual GraphicView* GetCurrentGraphicView() { return GetGraphicView(); } // allow for other than the top-level graphic view void Update(); // double-buffered damage repair. void Draw(); // double-buffered drawing of entire screen. void Redraw(Coord, Coord, Coord, Coord); // double-buffered drawing of sub-screen. void Resize(); // called after screen canvas is allocated. From here the ::Configure // method is called on any components, and the OverlayEditor::InitCommands // is called as well. virtual void UseTool(Tool*, Event&); virtual void StartBuffering(); // start up double buffering. All subsequent draws go to an offscreen buffer. virtual void FinishBuffering(boolean); // finish up double buffering, and copy modified part of buffer to the screen. virtual OverlayView* GetOverlayView(); void Chain(boolean pan = true, boolean zoom = true); // chain the panning or zooming of this viewer to other chained viewers. void Unchain(boolean pan = true, boolean zoom = true); // unchain the panning or zooming of this viewer from the other chained viewers. boolean Chained(); // true if panning or zooming chained. boolean ChainedPan(); // true if panning chained. boolean ChainedZoom(); // true if zooming chained. void SetColorMap(); // handle these command line arguments: -color6, -color5, -gray7, -gray6, -gray5. virtual void Adjust(Perspective&); void ScreenToDrawing(float xscreen, float yscreen, float& xdraw, float& ydraw); // utility method for converting screen coordinates to drawing coordinates. void ScreenToDrawing(Coord xscreen, Coord yscreen, float& xdraw, float& ydraw); // utility method for converting screen coordinates to drawing coordinates. void DrawingToScreen(float xdraw, float ydraw, float& xscreen, float& yscreen); // utility method for converting drawing coordinates to screen coordinates. void DrawingToScreen(float xdraw, float ydraw, Coord& xscreen, Coord& yscreen); // utility method for converting drawing coordinates to screen coordinates. void CenterToScreen(int sx, int sy); // pan xo that 'sx','sy' is at the center of the screen. void ScreenToGraphic (float xscreen, float yscreen, Graphic* gr, float& xgr, float& ygr); // utility method for converting screen coordinates to graphic relative // coordinates. The graphic coordinates are relative to the origin of the // screen when the graphic was originally drawn , expect for rasters, stencils, // and text which use their own origin instead. void ScreenToGraphic (Coord xscreen, Coord yscreen, Graphic* gr, float& xgr, float& ygr); // utility method for converting screen coordinates to graphic relative // coordinates. void GraphicToScreen (Graphic* gr, float xgr, float ygr, float &xscreen, float& yscreen); // utility method for converting graphic relative coordinates to screen // coordinates. The graphic coordinates are relative to the origin of the // screen when the graphic was originally drawn , expect for rasters, stencils, // and text which use their own origin instead. void GraphicToScreen (Graphic* gr, float xgr, float ygr, int &xscreen, int& yscreen); // utility method for converting graphic relative coordinates to screen // coordinates. virtual OverlayView* GetCurrent() { return GetOverlayView(); } boolean scribble_pointer() { return _scribble_pointer; } // return flag that indicates whether the mouse is in continuous mode, // for smooth drawing of polygons and other multi-point graphics. void scribble_pointer(boolean flag) { _scribble_pointer = flag; } // set flag that indicates whether the mouse is in continuous mode, // for smooth drawing of polygons and other multi-point graphics. virtual void SetMagnification(float); void ExecuteCmd(Command* cmd); // indirect command execution for distributed whiteboard mechanism. // bulk of mechanism implemented in ComEditor. boolean needs_resize() { return _needs_resize; } // goes false after initialization is done protected: virtual void Zoom(Perspective&); virtual void Scroll(Perspective&); virtual void Manipulate(Manipulator*, Event&); // direct manipulation loop void PrepareDoubleBuf(); protected: boolean _needs_resize; boolean _pan_chain; boolean _zoom_chain; boolean _scribble_pointer; static Painter* xorPainter; }; #include #endif ivtools-1.2.11a1/src/OverlayUnidraw/ovviews.cc000066400000000000000000000463261214471147700213130ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1994 Vectaport Inc., Cartoactive Systems * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlayView and OverlaysView definitions */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef LEAKCHECK LeakChecker* OverlayView::_leakchecker = nil; #endif /*****************************************************************************/ OverlayView::OverlayView(OverlayComp* subj) : GraphicView(subj) { _touched = false; UnfixSize(); UnfixLocation(); _hilite_gs = nil; #ifdef LEAKCHECK if(!_leakchecker) _leakchecker = new LeakChecker("OverlayView"); _leakchecker->create(); #endif } OverlayView::~OverlayView () { #ifdef LEAKCHECK _leakchecker->destroy(); #endif } ClassId OverlayView::GetClassId () { return OVERLAY_VIEW; } boolean OverlayView::IsA (ClassId id) { return OVERLAY_VIEW == id || GraphicView::IsA(id); } OverlayComp* OverlayView::GetOverlayComp () { return (OverlayComp*) GetSubject(); } void OverlayView::DrawHandles () { if (Highlightable()) { Highlight(); } else GraphicView::DrawHandles(); _touched = true; } void OverlayView::RedrawHandles () { if (Highlightable()) { Highlight(); } else GraphicView::RedrawHandles(); _touched = true; } void OverlayView::InitHandles () { if (!Highlightable()) GraphicView::InitHandles(); } void OverlayView::EraseHandles () { if (!_touched) return; if (Highlightable()) { Unhighlight(); } else GraphicView::EraseHandles(); } boolean OverlayView::Highlightable () { return HighlightGraphic() != nil; } boolean OverlayView::Highlighted () { return HighlightGraphic() != nil && _touched; } Graphic* OverlayView::HighlightGraphic() { return _hilite_gs; } void OverlayView::HighlightGraphic(Graphic* hilite_gs) { delete _hilite_gs; _hilite_gs = new FullGraphic(hilite_gs); } void OverlayView::Highlight() { Graphic* hgr = HighlightGraphic(); if (!hgr) return; Viewer* viewer = GetViewer(); Graphic* gview = GetGraphic(); if (viewer) viewer->GetDamage()->Incur(gview); gview->concatGS(gview,hgr,gview); if (viewer) viewer->GetDamage()->Incur(gview); } void OverlayView::Unhighlight() { Graphic* gview = GetGraphic(); Graphic* gsubj = GetOverlayComp()->GetGraphic(); Viewer* viewer = GetViewer(); if (viewer) viewer->GetDamage()->Incur(gview); Transformer* t = gview->GetTransformer(); Ref(t); gview->SetTransformer(nil); *gview = *gsubj; gview->SetTransformer(t); Unref(t); if (viewer) viewer->GetDamage()->Incur(gview); } boolean OverlayView::Hidable() { return true; } boolean OverlayView::Hidden() { return _gr->Hidden(); } void OverlayView::Hide() { _gr->Hide(); IncurDamage(_gr);} void OverlayView::Show() { _gr->Show(); IncurDamage(_gr);} boolean OverlayView::Desensitizable() { return true; } boolean OverlayView::Desensitized() { return _gr->Desensitized(); } void OverlayView::Desensitize() { _gr->Desensitize(); } void OverlayView::Sensitize() { _gr->Sensitize(); } Selection* OverlayView::MakeSelection() { return ((OverlayEditor*)GetViewer()->GetEditor())->overlay_kit()->MakeSelection(); } void OverlayView::AdjustForZoom(float factor, Coord cx, Coord cy) { if (factor==1.0) return; if (!_fixed_size && !_fixed_location) return; int power2 = 0; float ftest = factor; if (ftest > 1.0) { while (ftest > 1.0) { power2++; ftest /= 2.0; } } else { while (ftest < 1.0) { power2++; ftest *= 2.0; } } Graphic* gr = GetGraphic(); float gxc, gyc; gr->GetCenter(gxc, gyc); if (_fixed_size) { float actfact = factor<1.0 ? .5/_fixed_size_factor : 2.0*_fixed_size_factor; for (int p=0; pScale(1.0/actfact,1.0/actfact,gxc,gyc); } if (_fixed_location) { Graphic *root, *parent = gr; do { root = parent; parent = root->Parent(); } while (parent != nil); root->Scale(factor, factor, cx, cy); float nxc, nyc; gr->GetCenter(nxc, nyc); float mag = GetViewer()->GetMagnification()*factor; gr->Translate((gxc-nxc)/mag, (gyc-nyc)/mag); root->Scale(1.0/factor, 1.0/factor, cx, cy); } } void OverlayView::AdjustForPan(float dx, float dy) { if (!dx && !dy) return; if (_fixed_location) { Graphic* gr = GetGraphic(); float mag = GetViewer()->GetMagnification(); gr->Translate(-dx/mag, -dy/mag); } } void OverlayView::FixSize (float factor) { _fixed_size = true; _fixed_size_factor = factor; } void OverlayView::UnfixSize() { _fixed_size = false; } void OverlayView::FixLocation() { _fixed_location = true; } void OverlayView::UnfixLocation() { _fixed_location = false; } OverlayView* OverlayView::View (UList* r) { return (OverlayView*) (*r)(); } OverlayView* OverlayView::GetOverlayView (Graphic* g) { return (OverlayView*) g->GetTag(); } void OverlayView::Interpret (Command* cmd) { if (cmd->IsA(HIDE_VIEW_CMD)) { Hide(); Desensitize(); } else if (cmd->IsA(DESENSITIZE_VIEW_CMD)) { Desensitize(); } else if (cmd->IsA(FIX_VIEW_CMD)) { FixViewCmd* fv_cmd = (FixViewCmd*) cmd; if (fv_cmd->Size()) FixSize(); if (fv_cmd->Location()) FixLocation(); } else if (cmd->IsA(UNFIX_VIEW_CMD)) { FixViewCmd* fv_cmd = (FixViewCmd*) cmd; if (fv_cmd->Size()) UnfixSize(); if (fv_cmd->Location()) UnfixLocation(); } else { GraphicView::Interpret(cmd); } } void OverlayView::Uninterpret (Command* cmd) { if (cmd->IsA(HIDE_VIEW_CMD)) { Sensitize(); Show(); } else if (cmd->IsA(DESENSITIZE_VIEW_CMD)) { Sensitize(); } else if (cmd->IsA(FIX_VIEW_CMD)) { FixViewCmd* fv_cmd = (FixViewCmd*) cmd; if (fv_cmd->Size()) UnfixSize(); if (fv_cmd->Location()) UnfixLocation(); } else if (cmd->IsA(UNFIX_VIEW_CMD)) { FixViewCmd* fv_cmd = (FixViewCmd*) cmd; if (fv_cmd->Size()) FixSize(); if (fv_cmd->Location()) FixLocation(); } else { GraphicView::Interpret(cmd); } } Manipulator* OverlayView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Rubberband* rub = nil; Manipulator* m = nil; IntCoord l, b, r, t; if (tool->IsA(MOVE_TOOL)) { if (!FixedLocation()) { v->Constrain(e.x, e.y); v->GetSelection()->GetBox(l, b, r, t); rub = new SlidingRect(nil, nil, l, b, r, t, e.x, e.y); m = new OpaqueDragManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity), GetGraphic() ); } } else if (tool->IsA(SCALE_TOOL)) { v->Constrain(e.x, e.y); GetGraphic()->GetBox(l, b, r, t); rub = new ScalingRect(nil, nil, l, b, r, t, (l+r)/2, (b+t)/2); m = new OpaqueDragManip(v, rub, rel, tool, Gravity, GetGraphic()); } else if (tool->IsA(STRETCH_TOOL)) { m = CreateStretchManip(v, e, rel, tool); } else if (tool->IsA(ROTATE_TOOL)) { v->Constrain(e.x, e.y); GetGraphic()->GetBox(l, b, r, t); rub = new RotatingRect( nil, nil, l, b, r, t, (l+r)/2, (b+t)/2, e.x, e.y ); m = new OpaqueDragManip(v, rub, rel, tool, Gravity, GetGraphic()); } else m = GraphicView::CreateManipulator(v, e, rel, tool); return m; } boolean OverlayView::FixedSize() { return _fixed_size; } boolean OverlayView::FixedLocation() { return _fixed_location; } Manipulator* OverlayView::CreateStretchManip ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Coord l, b, r, t, tmp; DragConstraint dc = HorizOrVert; v->Constrain(e.x, e.y); GetGraphic()->GetBox(l, b, r, t); boolean horizCtr = e.x > (2*l + r)/3 && e.x < (l + 2*r)/3; boolean vertCtr = e.y > (2*b + t)/3 && e.y < (b + 2*t)/3; if (e.x < (l + r)/2) { tmp = r; r = l; l = tmp; } if (e.y < (b + t)/2) { tmp = t; t = b; b = tmp; } if (horizCtr && !vertCtr) { dc = XFixed; } else if (!horizCtr && vertCtr) { dc = YFixed; } RubberRect* rub = new RubberRect(nil, nil, l, b, r, t); return new OpaqueDragManip( v, rub, rel, tool, DragConstraint(dc | Gravity), r, t, GetGraphic() ); } /*****************************************************************************/ OverlayViewRef::OverlayViewRef (OverlayComp* subj) : OverlayView(subj) { } OverlayViewRef::~OverlayViewRef () {} ClassId OverlayViewRef::GetClassId () { return OVERLAY_VIEW_REF; } boolean OverlayViewRef::IsA (ClassId id) { return OVERLAY_VIEW_REF == id || OverlayView::IsA(id); } /*****************************************************************************/ OverlaysView::OverlaysView (OverlaysComp* subj) : OverlayView(subj) { _views = new UList; } ClassId OverlaysView::GetClassId () { return OVERLAYS_VIEW; } boolean OverlaysView::IsA (ClassId id) { return OVERLAYS_VIEW == id || OverlayView::IsA(id); } OverlaysView::~OverlaysView () { Iterator i; Graphic* parent = GetGraphic(); First(i); while (!Done(i)) { UList* doomed = Elem(i); OverlayView* view = (OverlayView*) GetView(i); Graphic* g = view->GetGraphic(); Next(i); _views->Remove(doomed); parent->Remove(g); delete doomed; delete view; } delete _views; delete _hilite_gs; } static OverlayView* GetLeaf (OverlayView* ov) { Iterator i; ov->First(i); if (!ov->Done(i)) { ov = GetLeaf((OverlayView*) ov->GetView(i)); } return ov; } void OverlaysView::Interpret (Command* cmd) { if (cmd->IsA(ALIGNTOGRID_CMD)) { Viewer* viewer = GetViewer(); Grid* grid = (viewer == nil) ? nil : viewer->GetGrid(); if (grid == nil) { return; } AlignToGridCmd* acmd = (AlignToGridCmd*) cmd; OverlayView* leaf = GetLeaf(this); Graphic* leafg = leaf->GetGraphic(); float cx, cy, dx, dy; leafg->GetCenter(cx, cy); leaf->Interpret(acmd); leafg->GetCenter(dx, dy); leaf->Uninterpret(acmd); dx -= cx; dy -= cy; Coord rcx = 0, rcy = 0; grid->Constrain(rcx, rcy); acmd->Align(this, float(rcx) - dx, float(rcy) - dy); } else { OverlayView::Interpret(cmd); } } void OverlaysView::Update () { GVUpdater gvu(this); gvu.Update(); } UList* OverlaysView::Elem (Iterator i) { return (UList*) i.GetValue(); } void OverlaysView::First (Iterator& i) { i.SetValue(_views->First()); } void OverlaysView::Last (Iterator& i) { i.SetValue(_views->Last()); } void OverlaysView::Next (Iterator& i) { i.SetValue(Elem(i)->Next()); } void OverlaysView::Prev (Iterator& i) { i.SetValue(Elem(i)->Prev()); } boolean OverlaysView::Done (Iterator i) { return Elem(i) == _views->End(); } GraphicView* OverlaysView::GetView (Iterator i) { return this->View(Elem(i)); } void OverlaysView::SetView (GraphicView* gv, Iterator& i) { i.SetValue(_views->Find(gv)); } int OverlaysView::Index(Iterator pos) { int idx = 0; Iterator i; for (First(i); !Done(i); Next(i)) { if (i.GetValue() == pos.GetValue()) return idx; idx++; } return -1; } Selection* OverlaysView::SelectAll () { Iterator i; Selection* selection = MakeSelection(); for (First(i); !Done(i); Next(i)) { OverlayView* view = (OverlayView*) GetView(i); if (!view->Desensitized()) selection->Append(view); } return selection; } Selection* OverlaysView::ViewContaining (Coord x, Coord y) { Selection* s = MakeSelection(); PointObj pt(x, y); Graphic* g = GetGraphic()->LastGraphicContaining(pt); if (g != nil) { OverlayView* ov = GetOverlayView(g); if (ov != nil) { s->Append(ov); } } return s; } Selection* OverlaysView::ViewsContaining (Coord x, Coord y) { Iterator i; Selection* s = MakeSelection(); PointObj pt(x, y); for (First(i); !Done(i); Next(i)) { OverlayView* view = (OverlayView*) GetView(i); if (view->GetGraphic()->Contains(pt)) { s->Append(view); } } return s; } Selection* OverlaysView::ViewIntersecting ( Coord x0, Coord y0, Coord x1, Coord y1 ) { Selection* s = MakeSelection(); BoxObj b(x0, y0, x1, y1); Graphic* g = GetGraphic()->LastGraphicIntersecting(b); if (g != nil) { OverlayView* ov = GetOverlayView(g); if (ov != nil) { s->Append(ov); } } return s; } Selection* OverlaysView::ViewsIntersecting ( Coord x0, Coord y0, Coord x1, Coord y1 ) { Iterator i; Selection* s = MakeSelection(); BoxObj b(x0, y0, x1, y1); for (First(i); !Done(i); Next(i)) { OverlayView* view = (OverlayView*) GetView(i); if (view->GetGraphic()->Intersects(b)) { s->Append(view); } } return s; } Selection* OverlaysView::ViewsWithin (Coord x0, Coord y0, Coord x1, Coord y1){ Iterator i; Selection* s = MakeSelection(); BoxObj b(x0, y0, x1, y1); for (First(i); !Done(i); Next(i)) { OverlayView* view = (OverlayView*) GetView(i); BoxObj tmpbox; if (view->Desensitized()) continue; view->GetGraphic()->GetBox(tmpbox); if (tmpbox.Within(b)) { s->Append(view); } } return s; } Graphic* OverlaysView::GetGraphic () { Graphic* g = OverlayView::GetGraphic(); if (g == nil) { OverlaysComp* comp = GetOverlaysComp(); Graphic* compgr = comp->GetGraphic(); g = new Picture; if (compgr && compgr->GetTransformer()) g->SetTransformer(new Transformer(compgr->GetTransformer())); Iterator i; for (First(i); !Done(i); Next(i)) { g->Append(GetView(i)->GetGraphic()); } SetGraphic(g); } return g; } OverlaysComp* OverlaysView::GetOverlaysComp () { return (OverlaysComp*) GetSubject(); } void OverlaysView::Add (GraphicView* view) { Graphic* g = view->GetGraphic(); Graphic* parent = GetGraphic(); UList* rv = new UList(view); _views->Append(rv); parent->Append(g); SetParent(view, this); } void OverlaysView::Append (GraphicView* view) { Graphic* g = view->GetGraphic(); Graphic* parent = GetGraphic(); UList* rv = new UList(view); _views->Append(rv); parent->Append(g); SetParent(view, this); } void OverlaysView::InsertBefore (Iterator i, GraphicView* view) { Graphic* g = view->GetGraphic(); Graphic* parent = GetGraphic(); UList* r = Elem(i); UList* rv = new UList(view); r->Append(rv); if (r == _views->End()) { parent->Append(g); } else { Iterator j; parent->SetGraphic(this->View(r)->GetGraphic(), j); parent->InsertBefore(j, g); } SetParent(view, this); } void OverlaysView::Remove (Iterator& i) { UList* doomed = Elem(i); OverlayView* view = (OverlayView*) GetView(i); Graphic* g = view->GetGraphic(); Graphic* parent = GetGraphic(); Next(i); view->EraseHandles(); _views->Remove(doomed); parent->Remove(g); SetParent(view, nil); delete doomed; } void OverlaysView::DeleteView (Iterator& i) { UList* doomed = Elem(i); OverlayView* view = (OverlayView*) GetView(i); Graphic* g = view->GetGraphic(); Graphic* parent = GetGraphic(); Next(i); IncurDamage(g); view->EraseHandles(); _views->Remove(doomed); parent->Remove(g); delete doomed; delete view; } void OverlaysView::AdjustForZoom(float factor, Coord cx, Coord cy) { if (factor==1.0) return; Iterator i; for (First(i); !Done(i); Next(i)) { ((OverlayView*)GetView(i))->AdjustForZoom(factor, cx, cy); } OverlayView::AdjustForZoom(factor, cx, cy); } void OverlaysView::AdjustForPan(float dx, float dy) { if (!dx && !dy) return; Iterator i; for (First(i); !Done(i); Next(i)) { ((OverlayView*)GetView(i))->AdjustForPan(dx, dy); } OverlayView::AdjustForPan(dx, dy); } Manipulator* OverlaysView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Rubberband* rub = nil; Manipulator* m = nil; IntCoord l, b, r, t; if (tool->IsA(GRAPHIC_COMP_TOOL)) { v->Constrain(e.x, e.y); m = new DragManip(v, nil, rel, tool, DragConstraint(XFixed | YFixed)); } else m = OverlayView::CreateManipulator(v, e, rel, tool); return m; } Command* OverlaysView::InterpretManipulator(Manipulator* m) { Tool* tool = m->GetTool(); Command* cmd = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { DragManip* dm = (DragManip*) m; Editor* ed = dm->GetViewer()->GetEditor(); Transformer* rel = dm->GetTransformer(); Event initial = dm->GraspEvent(); Coord x = initial.x; Coord y = initial.y; if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } /* get the comp */ OverlaysComp* comp = (OverlaysComp*)GetSubject()->Copy(); Transformer* t = comp->GetGraphic()->GetTransformer(); if (!t) { t = new Transformer(); comp->GetGraphic()->SetTransformer(t); } t->Translate(x, y); t->postmultiply(rel); Unref(rel); cmd = new PasteCmd(ed, new Clipboard(comp)); } else { cmd = OverlayView::InterpretManipulator(m); } return cmd; } /*****************************************************************************/ OverlayIdrawView::OverlayIdrawView (OverlayIdrawComp* subj) : OverlaysView(subj) { } ClassId OverlayIdrawView::GetClassId () { return OVERLAY_IDRAW_VIEW; } boolean OverlayIdrawView::IsA (ClassId id) { return OVERLAY_IDRAW_VIEW == id || OverlaysView::IsA(id); } ivtools-1.2.11a1/src/OverlayUnidraw/ovviews.h000066400000000000000000000211011214471147700211350ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1994 Vectaport Inc., Cartoactive Systems * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * OverlayView - view of an OverlayComp. * OverlaysView - view of an OverlaysComp. */ #ifndef overlay_views_h #define overlay_views_h #include #include #include #include #include class Canvas; class OverlayComp; class OverlaysComp; class OverlayIdrawComp; //: base class for graphic view of an OverlayComp. class OverlayView : public GraphicView { public: OverlayComp* GetOverlayComp(); virtual void DrawHandles(); // draw tic mark handles and highlight some things with a new graphic state. virtual void RedrawHandles(); // redraw tic mark handles and highlight some things with a new graphic state. virtual void InitHandles(); // initialize tic mark handles and set up to highlight some things with a new // graphic state. virtual void EraseHandles(); // erase tic mark handles and unhighlight some things by replacing their // old graphic state. virtual boolean Highlightable(); // true if set up to be highlighted with a graphic state. virtual boolean Highlighted(); // true if highlighted with a graphic state. virtual void Highlight(); // cause highlighting by graphic state to happen. virtual void Unhighlight(); // undo any highlighting by graphic state to happen. virtual boolean Hidable(); // true for this class. virtual boolean Hidden(); // true if hidden. virtual void Hide(); // hide the graphic. virtual void Show(); // unhide the graphic. virtual boolean Desensitizable(); // true for this class. virtual boolean Desensitized(); // true if desensitized. virtual void Desensitize(); // desensitize the graphic (ignore mouse events) virtual void Sensitize(); // resensitize the graphic (pay attention to mouse events) virtual Graphic* HighlightGraphic(); // graphic used to highlight by changing graphic state. // A nil returned from this method disables the mechanism. virtual void HighlightGraphic(Graphic* hilite_gs); // graphic used to highlight by changing graphic state. // A nil returned from this method disables the mechanism. virtual Selection* MakeSelection(); // factor method to construct an OverlaySelection. virtual void AdjustForZoom(float factor, Coord cx, Coord cy); // called once per OverlayView before each zoom, to let // fixed size graphics adjust accordingly. virtual void AdjustForPan(float dx, float dy); // called once per OverlayView before each pan, to let // fixed location graphics adjust accordingly. virtual void Interpret(Command*); // interpret hide-view, desensitize-view, (un)fix-size, and (un)fix-location // commands. virtual void Uninterpret(Command*); // uninterpret hide-view, desensitize-view, (un)fix-size, and (un)fix-location // commands. virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); // create move tool manipulator. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); void FixSize(float factor=1.0); // fix size of graphic, with optional factor to reduce or increase effect. void UnfixSize(); // disable fixing of graphic size. boolean FixedSize(); // return flag to indicate if graphic is of fixed size. void FixLocation(); // enable fixing of graphic location. void UnfixLocation(); // disable fixing of graphic location. boolean FixedLocation(); // return flag to indicate if graphic is of fixed location. Manipulator* CreateStretchManip(Viewer*, Event&, Transformer*, Tool*); // specialized method to construct OpaqueDragManip instead of DragManip. virtual ComponentView* Duplicate() { return new OverlayView(); } virtual ~OverlayView(); protected: OverlayView(OverlayComp* = nil); OverlayView* View(UList*); OverlayView* GetOverlayView(Graphic*); boolean _touched; boolean _fixed_size; float _fixed_size_factor; boolean _fixed_location; Graphic* _hilite_gs; #ifdef LEAKCHECK public: static LeakChecker* _leakchecker; #endif }; //: OverlayView used as Resource class OverlayViewRef : public OverlayView { public: OverlayViewRef(OverlayComp* = nil); virtual ~OverlayViewRef(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: graphical view of OverlaysComp. class OverlaysView : public OverlayView { public: OverlaysView(OverlaysComp* = nil); virtual ~OverlaysView(); virtual void Interpret(Command*); // interpret align-to-grid command, pass rest to base class. virtual void Update(); virtual Graphic* GetGraphic(); OverlaysComp* GetOverlaysComp(); // return pointer to associated graphic. virtual void First(Iterator&); // set iterator to first sub-view. virtual void Last(Iterator&); // set iterator to last sub-view. virtual void Next(Iterator&); // set iterator to next sub-view. virtual void Prev(Iterator&); // set iterator to previous sub-view. virtual boolean Done(Iterator); // return true if iterator off the end or beginning of list of sub-views. int Index(Iterator); // return index of where the iterator is pointing in the list of sub-views. virtual GraphicView* GetView(Iterator); // return sub-view pointed at by iterator. virtual void SetView(GraphicView*, Iterator&); // set sub-view pointed at by iterator. virtual Selection* SelectAll(); // return selection with all sub-views. virtual Selection* ViewContaining(Coord, Coord); // return selection of foremost subview that contains a point. virtual Selection* ViewsContaining(Coord, Coord); // return selection of all subviews that contains a point. virtual Selection* ViewIntersecting(Coord, Coord, Coord, Coord); // return selection of foremost subview that intersect a rectangle. virtual Selection* ViewsIntersecting(Coord, Coord, Coord, Coord); // return selection of all subviews that intersect a rectangle. virtual Selection* ViewsWithin(Coord, Coord, Coord, Coord); // return selection of all subviews that fit within a rectangle. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual void AdjustForZoom(float factor, Coord cx, Coord cy); // called once per OverlayView before each zoom, to let // fixed size graphics adjust accordingly. virtual void AdjustForPan(float dx, float dy); // called once per OverlayView before each pan, to let // fixed location graphics adjust accordingly. virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); // create manipulator for laying down composite graphic virtual Command* InterpretManipulator(Manipulator*); // interpret manipulator by copying prototype protected: UList* Elem(Iterator); virtual void Add(GraphicView*); virtual void Append(GraphicView*); virtual void InsertBefore(Iterator, GraphicView*); virtual void Remove(Iterator&); virtual void DeleteView(Iterator&); protected: UList* _views; }; //: graphical view of OverlayIdrawComp. class OverlayIdrawView : public OverlaysView { public: OverlayIdrawView(OverlayIdrawComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #include #endif ivtools-1.2.11a1/src/OverlayUnidraw/paramlist.h000066400000000000000000000023231214471147700214340ustar00rootroot00000000000000/* * Copyright (c) 1994-1996 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include ivtools-1.2.11a1/src/OverlayUnidraw/phold.h000066400000000000000000000256051214471147700205560ustar00rootroot00000000000000/* GIMP header image file format (RGB-only): /tmp/phold.h */ static unsigned int phold_width = 50; static unsigned int phold_height = 50; /* Call this macro repeatedly. After each use, the pixel data can be extracted */ #define HEADER_PIXEL(data,pixel) \ pixel[0] = (((data[0] - 33) << 2) | ((data[1] - 33) >> 4)); \ pixel[1] = ((((data[1] - 33) & 0xF) << 4) | ((data[2] - 33) >> 2)); \ pixel[2] = ((((data[2] - 33) & 0x3) << 6) | ((data[3] - 33))); \ data += 4; static const char *phold_data = "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(LQ>6LQ>6LQ>6LQ>6LQ>6LQ>6LQ>6Z!=A`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(Z!=ALQ>6LQ>6$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S?A?)LQ>6" "SA=[`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(LQ>6$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S" "$Q@S$Q@S8Q?D`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S$Q@S$Q@S`Q=(`Q=(`Q=(LQ>6$Q@S" "$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(F!>P+A@8$Q@S$Q@S$Q@S`Q=(`Q=(`Q=(" "Z!=A?A?)$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S$Q@S$Q@S$Q@S8Q?D" "SA=[`Q=(`Q=(LQ>6$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S8Q?D`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S$Q@S$Q@S" "$Q@S$Q@SLQ>6`Q=(`Q=(LQ>6$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(SA=[+A@88Q?D8Q?D$Q@S2!?^Z!=A`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S" "$Q@S$Q@S$Q@S$Q@SLQ>6`Q=(`Q=(LQ>6$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S`Q=(" "`Q=(`Q=(`Q=(`Q=(Z!=A2!?^F!>P`Q=(`Q=(2!?^$Q@S?A?)`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "8Q?D$Q@S$Q@S$Q@S$Q@S$Q@SLQ>6`Q=(`Q=(LQ>6$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S" "$Q@S`Q=(`Q=(`Q=(`Q=(`Q=(LQ>6$Q@S`Q=(`Q=(`Q=(Z!=A?A?)$Q@SF!>P`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(8Q?D$Q@S$Q@S$Q@S`Q=(`Q=(`Q=(`Q=(LQ>6$Q@S$Q@S$Q@S$Q@S" "$Q@S$Q@S$Q@S`Q=(`Q=(`Q=(`Q=(`Q=(LQ>6$Q@SSA=[`Q=(`Q=(`Q=(LQ>6$Q@S" "8Q?D`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(SA=[LQ>6LQ>6LQ>6`Q=(`Q=(`Q=(`Q=(LQ>6$Q@S$Q@S" "$Q@S$Q@S$Q@S$Q@SLQ>6`Q=(`Q=(`Q=(`Q=(`Q=(LQ>6$Q@SF!>P`Q=(`Q=(`Q=(" "LQ>6$Q@S8Q?D`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(SA=[2!?^" "$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(Z!=ALQ>6`Q=(`Q=(" "`Q=(SA=[2!?^$Q@S8Q?D`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "LQ>6$Q@S$Q@S$Q@S$Q@S$Q@S+A@88Q?D`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(LQ>6$Q@S2!?^`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(SA=[?A?)$Q@S$Q@S$Q@S$Q@S2!?^F!>P`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(?A?)$Q@SLQ>6`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(8Q?D$Q@S$Q@S$Q@S$Q@S$Q@SLQ>6`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=($Q@S2!?^Z!=A`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S$Q@S$Q@S`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D8Q?D`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(F!>P+A@8$Q@S2!?^LQ>6`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?DF!>P`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S$Q@S8Q?D`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S+A@8F!>P`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(F!>P`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S8Q?D`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S" "8Q?D`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(SA=[8Q?D`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(LQ>6$Q@S$Q@S8Q?D`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(SA=[2!?^$Q@SF!>P`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(8Q?D8Q?D8Q?D8Q?DF!>P`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(Z!=ALQ>6`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(Z!=ALQ>6$Q@S$Q@S$Q@S$Q@S2!?^LQ>6`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(LQ>6$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(LQ>6$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(LQ>6$Q@S$Q@S$Q@S$Q@S$Q@S$Q@S" "$Q@S`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(LQ>6$Q@S$Q@S$Q@S$Q@S" "$Q@S$Q@S$Q@S`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(Z!=ALQ>6$Q@S" "$Q@S$Q@S$Q@S2!?^LQ>6`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(8Q?D8Q?D8Q?D8Q?DF!>P`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(SA=[LQ>6LQ>6LQ>6LQ>6`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S$Q@S$Q@S$Q@S$Q@S2!?^SA=[`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D+A@88Q?D8Q?D2!?^$Q@S$Q@S2!?^`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(SA=[`Q=(`Q=(`Q=(`Q=($Q@S$Q@S$Q@S" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(Z!=A$Q@S" "$Q@S8Q?D`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "?A?)$Q@S8Q?DZ!=A`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(?A?)$Q@S$Q@SSA=[`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(?A?)$Q@S$Q@SLQ>6`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S$Q@SLQ>6`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(SA=[LQ>6LQ>6Z!=A`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S$Q@SLQ>6`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(8Q?D$Q@S$Q@SLQ>6`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(" "`Q=(`Q=(`Q=(`Q=("; ivtools-1.2.11a1/src/OverlayUnidraw/ptinpoly.cc000066400000000000000000000026261214471147700214620ustar00rootroot00000000000000/* * Copyright (c) 1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include int point_in_poly(float x, float y, int pn, float* px, float* py) { FPointObj pt(x, y); FFillPolygonObj poly(px, py, pn); return poly.Contains(pt); } ivtools-1.2.11a1/src/OverlayUnidraw/ptinpoly.h000066400000000000000000000025401214471147700213170ustar00rootroot00000000000000/* * Copyright (c) 1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef ptinpoly_h #define ptinpoly_h //: Simple wrapper around geomobjs to avoid clippoly collisions. int point_in_poly(float x, float y, int pn, float* px, float* py); #endif ivtools-1.2.11a1/src/OverlayUnidraw/rastercmds.cc000066400000000000000000000146741214471147700217610ustar00rootroot00000000000000/* * Copyright (c) 2002 Scott E. Johnston * Copyright (c) 1997 Vectaport Inc. and R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include #include #include #include #include #include #include #include // ----------------------------------------------------------------------- ClassId ReplaceRasterCmd::GetClassId () { return REPLACE_RASTER_CMD; } boolean ReplaceRasterCmd::IsA (ClassId id) { return REPLACE_RASTER_CMD == id || Command::IsA(id); } ReplaceRasterCmd::ReplaceRasterCmd (ControlInfo* c) : Command(c) { } ReplaceRasterCmd::ReplaceRasterCmd () : Command((Editor*)nil) { } ReplaceRasterCmd::ReplaceRasterCmd ( Editor* ed, RasterOvComp* comp, OverlayRaster* nras ) : Command(ed), _comp(comp), _nras(nras), _orig(nil) { _nras->ref(); } ReplaceRasterCmd::ReplaceRasterCmd( ControlInfo* c, RasterOvComp* comp, OverlayRaster* nras ) : Command(c), _comp(comp), _nras(nras), _orig(nil) { _nras->ref(); } ReplaceRasterCmd::~ReplaceRasterCmd() { _orig->unref(); _nras->unref(); } void ReplaceRasterCmd::Execute() { OverlayRasterRect* rr = _comp->GetOverlayRasterRect(); if (!_orig) { _orig = rr->GetOriginal(); _orig->ref(); } rr->SetRaster( _nras ); _comp->Notify(); unidraw->Update(); } void ReplaceRasterCmd::Unexecute() { OverlayRasterRect* rr = _comp->GetOverlayRasterRect(); if (_orig) rr->SetRaster((OverlayRaster*)_orig); _comp->Notify(); unidraw->Update(); } Command* ReplaceRasterCmd::Copy () { ReplaceRasterCmd* copy = new ReplaceRasterCmd( CopyControlInfo(), _comp, _nras ); InitCopy(copy); return copy; } boolean ReplaceRasterCmd::Reversible() { return true; } /*-----------------------------------------------------------------*/ UnhighlightRasterCmd::UnhighlightRasterCmd(ControlInfo* ci) : Command(ci) { } Command* UnhighlightRasterCmd::Copy() { Command* copy = new UnhighlightRasterCmd(CopyControlInfo()); InitCopy(copy); return copy; } ClassId UnhighlightRasterCmd::GetClassId () { return UNHIGHLIGHT_RASTER_CMD; } boolean UnhighlightRasterCmd::IsA (ClassId id) { return UNHIGHLIGHT_RASTER_CMD == id || Command::IsA(id); } boolean UnhighlightRasterCmd::Reversible() { return false; } void UnhighlightRasterCmd::Execute() { // find the rasters in the current comp and unhighlight OverlayEditor* ed = (OverlayEditor*)GetEditor(); OverlayViewer* v = ed->GetOverlayViewer(); OverlayView* views = v->GetCurrent(); RasterOvView* rastview = nil; Iterator i; for (views->Last(i); !views->Done(i); views->Prev(i)) { GraphicView* view = views->GetView(i); if (view->IsA(OVRASTER_VIEW)) { rastview = (RasterOvView*)view; if (rastview) { OverlayRaster* raster = rastview->GetOverlayRaster(); if (raster) { raster->unhighlight(); } } } } } /*-----------------------------------------------------------------*/ AlphaTransparentRasterCmd::AlphaTransparentRasterCmd(ControlInfo* ci) : Command(ci) { _alpha_set = false; } Command* AlphaTransparentRasterCmd::Copy() { Command* copy = new AlphaTransparentRasterCmd(CopyControlInfo()); InitCopy(copy); ((AlphaTransparentRasterCmd*)copy)->_alpha = _alpha; ((AlphaTransparentRasterCmd*)copy)->_oldalpha = _oldalpha; ((AlphaTransparentRasterCmd*)copy)->_alpha_set = _alpha_set; return copy; } ClassId AlphaTransparentRasterCmd::GetClassId () { return ALPHATRANSPARENT_CMD; } boolean AlphaTransparentRasterCmd::IsA (ClassId id) { return ALPHATRANSPARENT_CMD == id || Command::IsA(id); } boolean AlphaTransparentRasterCmd::Reversible() { return true; } void AlphaTransparentRasterCmd::Execute() { if (!_alpha_set) { char* newalpha = StrEditDialog::post (GetEditor()->GetWindow(), "Enter alpha value", "0.5"); if (newalpha) _alpha = atof(newalpha); else _alpha = 1.0; _alpha_set = true; } OverlayEditor* ed = (OverlayEditor*)GetEditor(); OverlaySelection* sel = (OverlaySelection*) ed->GetSelection(); Iterator i; for (sel->First(i); !sel->Done(i); sel->Next(i)) { GraphicView* view = sel->GetView(i); if (view->IsA(OVRASTER_VIEW)) { RasterOvView* rastview = (RasterOvView*)view; if (rastview) { RasterOvComp* rastcomp = (RasterOvComp*)rastview->GetSubject(); OverlayRasterRect* rr = rastcomp->GetOverlayRasterRect(); if (rr) { _oldalpha = rr->alphaval(); rr->alphaval(_alpha); rastcomp->Notify(); unidraw->Update(); } } } } } void AlphaTransparentRasterCmd::Unexecute() { OverlayEditor* ed = (OverlayEditor*)GetEditor(); OverlaySelection* sel = (OverlaySelection*) ed->GetSelection(); Iterator i; for (sel->First(i); !sel->Done(i); sel->Next(i)) { GraphicView* view = sel->GetView(i); if (view->IsA(OVRASTER_VIEW)) { RasterOvView* rastview = (RasterOvView*)view; if (rastview) { RasterOvComp* rastcomp = (RasterOvComp*)rastview->GetSubject(); OverlayRasterRect* rr = rastcomp->GetOverlayRasterRect(); if (rr) { rr->alphaval(_oldalpha); rastcomp->Notify(); unidraw->Update(); } } } } } ivtools-1.2.11a1/src/OverlayUnidraw/rastercmds.h000066400000000000000000000054221214471147700216120ustar00rootroot00000000000000/* * Copyright (c) 2002 Scott E. Johnston * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1997 Vectaport Inc., R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef rastercmds_h #define rastercmds_h #include class ControlInfo; class RasterOvComp; class OverlayRaster; //: command to replace raster in a component. class ReplaceRasterCmd : public Command { public: ReplaceRasterCmd(); ReplaceRasterCmd(ControlInfo*); ReplaceRasterCmd(ControlInfo* c, RasterOvComp* comp, OverlayRaster* nras); ReplaceRasterCmd(Editor* ed, RasterOvComp* comp, OverlayRaster* nras); virtual ~ReplaceRasterCmd(); virtual void Execute(); virtual void Unexecute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual boolean Reversible(); protected: OverlayRaster* _orig; RasterOvComp* _comp; OverlayRaster* _nras; }; //: command to unhighlight a raster. class UnhighlightRasterCmd : public Command { public: UnhighlightRasterCmd(); UnhighlightRasterCmd(ControlInfo*); virtual void Execute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual boolean Reversible(); }; //: command to make raster alpha-transparent class AlphaTransparentRasterCmd : public Command { public: AlphaTransparentRasterCmd(ControlInfo* ci); virtual void Execute(); virtual void Unexecute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual boolean Reversible(); protected: float _alpha; float _oldalpha; boolean _alpha_set; }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/scriptview.cc000066400000000000000000001071211214471147700217770ustar00rootroot00000000000000/* * Copyright (C) 2002 Scott E. Johnston * Copyright (C) 1994-1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representation about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * OverlayScript implementation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::cerr; /*****************************************************************************/ boolean OverlayScript::_ptlist_parens = true; char* OverlayScript::_format = NULL; ClassId OverlayScript::GetClassId () { return OVERLAY_SCRIPT; } boolean OverlayScript::IsA (ClassId id) { return OVERLAY_SCRIPT == id || OverlayPS::IsA(id); } OverlayScript::OverlayScript (OverlayComp* subj) : OverlayPS(subj) { _parent = nil; } OverlayScript::~OverlayScript () { } void OverlayScript::FillBg (ostream& out) { int filled = GetOverlayComp()->GetGraphic()->BgFilled(); if (!svg_format()) { out << " :fillbg " << filled; } } void OverlayScript::Brush (ostream& out) { PSBrush* brush = (PSBrush*) GetOverlayComp()->GetGraphic()->GetBrush(); if (brush != nil) { if (brush->None()) { if (!svg_format()) { out << " :nonebr"; } } else { int p = brush->GetLinePattern(); float w = brush->width(); if (!svg_format()) { out << " :brush "; out << p << ","; out << w; } else { out << "stroke-width: " << w << "; "; if (p != 0xffff) { out << "stroke-dasharray: "; /* reverse dash bit field */ int reverse_p = 0; for (int i=0; i<16; i++) { reverse_p <<= 1; reverse_p |= p & 0x1; p >>= 1; } /* output count of on/off runs */ boolean lastbit=1; int dashlen = 0; for (int i=0; i<16; i++) { boolean bit = reverse_p & 1; if (lastbit==bit) dashlen++; if (lastbit != bit || i==15) { out << dashlen; if (i != 15 ) out << ", "; dashlen=1; } lastbit = bit; reverse_p >>= 1; } out << "; "; } } } } } void OverlayScript::Colors (ostream& out) { if (!svg_format()) { FgColor(out); BgColor(out); } else { PSColor* fgcolor = (PSColor*) GetOverlayComp()->GetGraphic()->GetFgColor(); PSColor* bgcolor = (PSColor*) GetOverlayComp()->GetGraphic()->GetBgColor(); ColorIntensity fr, fg, fb; fgcolor->GetIntensities(fr, fg, fb); out << "stroke: rgb(" << (int)(fr*100) << "%," << (int)(fg*100) << "%," << (int)(fb*100) << "%); "; ColorIntensity br, bg, bb; bgcolor->GetIntensities(br, bg, bb); PSPattern* pat = (PSPattern*) GetOverlayComp()->GetGraphic()->GetPattern(); if (pat != nil && !pat->None() && pat->GetGrayLevel()>=0.0 && pat->GetGrayLevel()<=1.0) { float fp = 100.0*(1.0-pat->GetGrayLevel()); float bp = 100.0-fp; out << "fill: rgb(" << (int)(fr*fp+br*bp) << "%," << (int)(fg*fp+bg*bp) << "%," << (int)(fb*fp+bb*bp) << "%); "; } } } void OverlayScript::FgColor (ostream& out) { PSColor* fgcolor = (PSColor*) GetOverlayComp()->GetGraphic()->GetFgColor(); if (fgcolor != nil) { const char* name = fgcolor->GetName(); ColorIntensity r, g, b; fgcolor->GetIntensities(r, g, b); out << " :fgcolor \"" << name << "\""; out << "," << r << "," << g << "," << b; } } void OverlayScript::BgColor (ostream& out) { PSColor* bgcolor = (PSColor*) GetOverlayComp()->GetGraphic()->GetBgColor(); if (bgcolor != nil) { const char* name = bgcolor->GetName(); ColorIntensity r, g, b; bgcolor->GetIntensities(r, g, b); out << " :bgcolor \"" << name << "\""; out << "," << r << "," << g << "," << b; } } void OverlayScript::Font (ostream& out) { PSFont* font = (PSFont*) GetOverlayComp()->GetGraphic()->GetFont(); if (font != nil) { const char* name = font->GetName(); const char* pf = font->GetPrintFont(); const char* ps = font->GetPrintSize(); if (!svg_format()) { out << " :font \"" << name << "\"" << ","; out << "\"" << pf << "\"" << ","; out << ps; } } } void OverlayScript::Pattern (ostream& out) { PSPattern* pat = (PSPattern*) GetOverlayComp()->GetGraphic()->GetPattern(); if (pat != nil) { if (pat->None()) { if (!svg_format()) out << " :nonepat"; else out << "fill: none;"; } else if (pat->GetSize() > 0) { const int* data = pat->GetData(); int size = pat->GetSize(); char buf[BUFSIZ]; if (!svg_format()) { out << " :pattern "; if (size <= 8) { for (int i = 0; i < 8; i++) { sprintf(buf, "0x%02x", data[i] & 0xff); out << buf; if (i < 7 ) out << ","; } } else { for (int i = 0; i < patternHeight; i++) { sprintf(buf, "0x%0*x", patternWidth/4, data[i]); if (i != patternHeight - 1) { out << buf << ","; } else { out << buf; } } } } } else { float graylevel = pat->GetGrayLevel(); if (!svg_format()) { out << " :graypat " << graylevel; } } } } void OverlayScript::Transformation(ostream& out, const char* keyword, Graphic* gr) { Transformer* t = gr ? gr->GetTransformer() : GetOverlayComp()->GetGraphic()->GetTransformer(); Transformer identity; if (t != nil && *t != identity) { char key[strlen(keyword)+4]; sprintf(key," :%s ",keyword); float a00, a01, a10, a11, a20, a21; t->GetEntries(a00, a01, a10, a11, a20, a21); out << key; out << a00 << "," << a01 << "," << a10 << ","; out << a11 << "," << a20 << "," << a21; } } void OverlayScript::Transformation (ostream& out) { Graphic *gr = GetOverlayComp()->GetGraphic(); Transformer* t = gr ? gr->GetTransformer() : nil; Transformer identity; if (t != nil && *t != identity) { float a00, a01, a10, a11, a20, a21; t->GetEntries(a00, a01, a10, a11, a20, a21); if (!svg_format()) { out << " :transform "; out << a00 << "," << a01 << "," << a10 << ","; out << a11 << "," << a20 << "," << a21; } else { out << "transform=\"matrix("; out << a00 << " " << a01 << " " << a10 << " "; out << a11 << " " << a20 << " " << a21 << ")\""; } } } void OverlayScript::Annotation (ostream& out) { OverlayComp* comp = GetOverlayComp(); const char* anno = comp->GetAnnotation(); if (!anno) return; if (!svg_format()) { out << " :annotation " << "\n"; int indent = Indent(out); ParamList::output_text(out, anno, indent); } } OverlayScript* OverlayScript::CreateOverlayScript (OverlayComp* comp) { OverlayScript* sv = (OverlayScript*) comp->Create(OVERLAY_SCRIPT); if (sv != nil) { comp->Attach(sv); sv->SetCommand(GetCommand()); sv->Update(); } return sv; } int OverlayScript::Indent (ostream& out, int extra) { Component* comp = this->GetSubject(); int i = 0; do { out << " "; comp = comp->GetParent(); i++; } while (comp != nil); for (int x=0; x!=extra; x++) out << " "; return i; } boolean OverlayScript::GetByPathnameFlag() { return _parent ? _parent->GetByPathnameFlag() : false; } boolean OverlayScript::skip_comp(istream& in) { char ch; ParamList::skip_space(in); ch = in.get(); if (ch==',') { ParamList::skip_space(in); ch = in.get(); ParamList::skip_space(in); } in.unget(); if (ch=='(') { Parser parser(in); if (!parser.skip_matched_parens()) cerr << "error in skipping matched parens\n"; } else { cerr << "not positioned at left-paren for skipping component\n"; } return true; } boolean OverlayScript::svg_format() { const char* formatstr = OverlayScript::_format; boolean format = formatstr ? strcmp("svg", formatstr)==0 : 0; Command* cmd = GetCommand(); if (cmd) { if (GetCommand()->IsA(OV_EXPORT_CMD)) format = ((OvExportCmd*)GetCommand())->svg_format(); } return format; } void OverlayScript::svg_format(boolean flag) { if(flag) { delete _format; _format = strnew("svg"); } else { delete _format; _format = NULL; } } /*****************************************************************************/ int OverlayScript::ReadGS (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { OverlayComp* comp = (OverlayComp*)addr1; Graphic* gs = *(Graphic**)addr2; if (!gs) { gs = new FullGraphic(); comp->SetGraphic(gs); } int id; in >> id; Graphic* gr = comp->GetIndexedGS(id); if (gr) *gs = *gr; #if 0 else cerr << ":gs reference without gs records\n"; #endif return in.good() ? 0 : -1; } int OverlayScript::ReadFillBg (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { Graphic* gs = *(Graphic**)addr1; int filled; in >> filled; if (!in.good()) { return -1; } else { gs->FillBg(filled); return 0; } } int OverlayScript::ReadNoneBr (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { if (!Component::use_unidraw()) return 0; Graphic* gs = *(Graphic**)addr1; if (!in.good()) { gs->SetBrush(nil); return -1; } else { PSBrush* brush = OverlayCatalog::Instance()->FindNoneBrush(); gs->SetBrush(brush); return 0; } } int OverlayScript::ReadBrush (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { if (!Component::use_unidraw()) return 0; int p; float w; char delim; Graphic* gs = *(Graphic**)addr1; ParamList::skip_space(in); in >> p >> delim >> w; if (!in.good()) { gs->SetBrush(nil); return -1; } else { PSBrush* brush = OverlayCatalog::Instance()->FindBrush(p,w); gs->SetBrush(brush); return 0; } } int OverlayScript::ReadFgColor (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { if (!Component::use_unidraw()) return 0; char lookahead = '"'; char name[BUFSIZ]; boolean name_arg = false; ColorIntensity r = 0, g = 0, b = 0; Graphic* gs = *(Graphic**)addr1; char delim; char buf[BUFSIZ]; ParamList::skip_space(in); in >> lookahead; in.putback(lookahead); if (lookahead == '"') { name_arg = true; ParamList::parse_string(in, name, BUFSIZ); if (!in.good()) { gs->SetColors(nil, gs->GetBgColor()); return -1; } } if (name_arg) { in >> lookahead; in.putback(lookahead); } if (lookahead == ',' || !name_arg) { in >> delim >> r >> delim >> g >> delim >> b; if (!in.good()) { gs->SetColors(nil, gs->GetBgColor()); return -1; } else { int ir = Math::round(r * float(0xffff)); int ig = Math::round(g * float(0xffff)); int ib = Math::round(b * float(0xffff)); PSColor* fgcolor = OverlayCatalog::Instance()->FindColor(name_arg ? name : "no_name", ir, ig, ib); gs->SetColors(fgcolor, gs->GetBgColor()); return 0; } } return -1; } int OverlayScript::ReadBgColor (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { if (!Component::use_unidraw()) return 0; char lookahead = '"'; char name[BUFSIZ]; boolean name_arg = false; ColorIntensity r = 0, g = 0, b = 0; Graphic* gs = *(Graphic**)addr1; char delim; ParamList::skip_space(in); in >> lookahead; in.putback(lookahead); if (lookahead == '"') { name_arg = true; ParamList::parse_string(in, name, BUFSIZ); if (!in.good()) { gs->SetColors(gs->GetFgColor(), nil); return -1; } } if (name_arg) { in >> lookahead; in.putback(lookahead); } if (lookahead == ',' || !name_arg) { in >> delim >> r >> delim >> g >> delim >> b; if (!in.good()) { gs->SetColors(gs->GetFgColor(), nil); return -1; } else { int ir = Math::round(r * float(0xffff)); int ig = Math::round(g * float(0xffff)); int ib = Math::round(b * float(0xffff)); PSColor* bgcolor = OverlayCatalog::Instance()->FindColor(name_arg ? name : "no_name", ir, ig, ib); gs->SetColors(gs->GetFgColor(), bgcolor); return 0; } } return -1; } int OverlayScript::ReadFont (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { if (!Component::use_unidraw()) return 0; char name[BUFSIZ]; char printfont[BUFSIZ]; int printsize; char printsizebuf[BUFSIZ]; char delim; Graphic* gs = *(Graphic**)addr1; boolean pf = false; boolean ps = false; ParamList::skip_space(in); ParamList::parse_string(in, name, BUFSIZ); in >> delim; if (in.good() && delim == ',') { ParamList::parse_string(in, printfont, BUFSIZ); pf = true; in >> delim; if (in.good() && delim == ',') { in >> printsize; ps = true; sprintf(printsizebuf, "%d", printsize); } } if (!in.good()) { gs->SetFont(nil); return -1; } else { PSFont* font = OverlayCatalog::Instance()->FindFont(name, pf ? printfont : "", ps ? printsizebuf : ""); gs->SetFont(font); return 0; } } int OverlayScript::ReadNonePat (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { if (!Component::use_unidraw()) return 0; Graphic* gs = *(Graphic**)addr1; if (!in.good()) { gs->SetPattern(nil); return -1; } else { PSPattern* pattern = OverlayCatalog::Instance()->FindNonePattern(); gs->SetPattern(pattern); return 0; } } int OverlayScript::ReadPattern (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { if (!Component::use_unidraw()) return 0; char delim = ','; int data[patternHeight]; int size = 0; Graphic* gs = *(Graphic**)addr1; char buf[BUFSIZ]; ParamList::skip_space(in); while(delim == ',' && size < patternHeight) { ParamList::parse_token(in, buf, BUFSIZ, delim); char* bufptr = buf; if (buf[0] == '0' && buf[1] == 'x') bufptr += 2; sscanf(bufptr, "%x", &data[size++]); in.get(delim); } if (!in.good()) { gs->SetPattern(nil); return -1; } else { if (delim==')') in.putback(delim); PSPattern* pattern = OverlayCatalog::Instance()->FindPattern(data, size); gs->SetPattern(pattern); return 0; } } int OverlayScript::ReadGrayPat (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { if (!Component::use_unidraw()) return 0; Graphic* gs = *(Graphic**)addr1; float graylevel; ParamList::skip_space(in); in >> graylevel; if (!in.good()) { gs->SetPattern(nil); return -1; } else { PSPattern* pattern = OverlayCatalog::Instance()->FindGrayLevel(graylevel); gs->SetPattern(pattern); return 0; } } int OverlayScript::ReadTransform (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { float a00, a01, a10, a11, a20, a21; char delim; Graphic* gs = *(Graphic**)addr1; ParamList::skip_space(in); in >> a00 >> delim >> a01 >> delim >> a10 >> delim >> a11 >> delim >> a20 >> delim >> a21; if (!in.good()) { return -1; } else { Transformer* t = new Transformer(a00, a01, a10, a11, a20, a21); if (gs) gs->SetTransformer(t); else fprintf(stderr, "OverlayScript::ReadTransform: no graphic for transformer\n"); Unref(t); return 0; } } int OverlayScript::ReadAnnotation (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { char* buf = ParamList::parse_textbuf(in); if (!in.good()) { delete buf; return -1; } else { *(char**)addr1 = buf; return 0; } } int OverlayScript::ReadOther(istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { OverlayComp* comp = (OverlayComp*)addr1; AttributeList* attrlist = comp->GetAttributeList(); char* keyword = (char*)addr4; AttributeValueList* avlist = nil; AttributeValue* val; do { char ch; if ((ch=in.peek()) == '\"') { sbuf[0] = '\"'; ParamList::parse_string(in, sbuf+1, SBUFSIZE-1, true); strcat(sbuf, "\"\n"); } else if (ch!=')') { ParamList::parse_token(in, sbuf, SBUFSIZE, " \t\n,"); strcat(sbuf, "\n"); } else strcpy(sbuf, "1\n"); if (!in.good() && attrlist && keyword) { return -1; } else { int negate = sbuf[0] == '-'; int slen = strlen(sbuf); val = ParamList::lexscan()->get_attrval(sbuf+negate, slen-negate); if (negate) val->negate(); //attrlist->add_attr(keyword, val); //return 0; ParamList::skip_space(in); if (in.peek() == ',') { char comma; in.get(comma); if (!avlist) { avlist = new AttributeValueList(); Resource::ref(avlist); } avlist->Append(val); } else { if (avlist) avlist->Append(val); break; } } } while(1); if (avlist == nil) { attrlist->add_attr(keyword, val); return 0; } else { attrlist->add_attr(keyword, new AttributeValue(avlist)); return 0; } } boolean OverlayScript::DefaultGS() { Graphic* gr = GetGraphicComp()->GetGraphic(); return !gr->GetBrush() && !gr->GetFgColor() && !gr->GetBgColor() && !gr->GetFont() && !gr->GetPattern(); } int OverlayScript::MatchedGS(Clipboard* cb) { int count; MatchedGS(cb, count); return count; } Iterator OverlayScript::MatchedGS(Clipboard* cb, int& count) { Graphic* gr = GetGraphicComp()->GetGraphic(); Iterator i; count = 0; for (cb->First(i); !cb->Done(i); cb->Next(i)) { Graphic* test = cb->GetComp(i)->GetGraphic(); if (gr->GetBrush() == test->GetBrush() && gr->GetFgColor() == test->GetFgColor() && gr->GetBgColor() == test->GetBgColor() && gr->GetFont() == test->GetFont() && gr->GetPattern() == test->GetPattern() && gr->BgFilled() == test->BgFilled()) return i; count++; } Iterator j; count = -1; return j; } boolean OverlayScript::EmitGS(ostream& out, Clipboard* cb, boolean prevout) { if ( !DefaultGS() && MatchedGS(cb)<0) { if (prevout) { out << ",\n"; } else { out << "\n"; } prevout = true; out << " gs("; FillBg(out); Brush(out); Colors(out); Font(out); Pattern(out); out << ")"; cb->Append(GetGraphicComp()); } return prevout; } int OverlayScript::MatchedPts(Clipboard* cb) { int count; MatchedPts(cb, count); return count; } Iterator OverlayScript::MatchedPts(Clipboard* cb, int& count) { OverlayComp* comp = GetOverlayComp(); count = -1; Iterator j; if (!comp->IsA(OVVERTICES_COMP)) return j; Vertices* verts = (Vertices*)comp->GetGraphic(); Iterator i; count = 0; for (cb->First(i); !cb->Done(i); cb->Next(i)) { Vertices* test = (Vertices*) cb->GetComp(i)->GetGraphic(); if ((void*) test->GetOriginal() == (void*) verts->GetOriginal()) return i; count++; } count = -1; return j; } int OverlayScript::MatchedPic(Clipboard* cb) { int count; MatchedPic(cb, count); return count; } Iterator OverlayScript::MatchedPic(Clipboard* cb, int& count) { count = -1; OverlayComp* comp = GetOverlayComp(); Iterator j; if (!comp->IsA(OVERLAYS_COMP)) return j; Iterator i; count = 0; for (cb->First(i); !cb->Done(i); cb->Next(i)) { if (*comp == *(OverlayComp*)cb->GetComp(i)) return i; count++; } count = -1; return j; } boolean OverlayScript::EmitPts(ostream& out, Clipboard* cb, boolean prevout) { if (GetGraphicComp()->IsA(OVVERTICES_COMP) && MatchedPts(cb)<0) { MultiLineObj* pts = ((Vertices*)GetGraphicComp()->GetGraphic())->GetOriginal(); if (pts && pts->count()>0) { if (prevout) out << ",\n "; else out << "\n "; prevout = true; out << "pts("; const int rowsz = 10; Coord* x = pts->x(); Coord* y = pts->y(); int count = pts->count(); for (int i=0; iAppend(GetGraphicComp()); } } return prevout; } boolean OverlayScript::EmitPic(ostream& out, Clipboard* cb1, Clipboard* cb2, boolean prevout) { return prevout; } /*--------------------------------------------------------------------*/ void OverlayScript::MinGS (ostream& out) { if (!DefaultGS()) { Clipboard* cb = GetGSList(); if (cb && !svg_format()) out << " :gs " << MatchedGS(cb); else { if (svg_format()) out << "style=\""; FillBg(out); Brush(out); Colors(out); Pattern(out); if (svg_format()) out << "\" "; } } Transformation(out); } void OverlayScript::FullGS (ostream& out) { if (!DefaultGS()) { Clipboard* cb = GetGSList(); if (cb) out << " :gs " << MatchedGS(cb); else { FillBg(out); Brush(out); Colors(out); Font(out); Pattern(out); } } Transformation(out); } void OverlayScript::TextGS (ostream& out) { if (!DefaultGS()) { Clipboard* cb = GetGSList(); if (cb) out << " :gs " << MatchedGS(cb); else { FillBg(out); FgColor(out); Font(out); } } Transformation(out); } void OverlayScript::StencilGS (ostream& out) { if (!DefaultGS()) { Clipboard* cb = GetGSList(); if (cb) out << " :gs " << MatchedGS(cb); else { Colors(out); } } Transformation(out); } void OverlayScript::Attributes(ostream& out) { AttributeList* attrlist = GetOverlayComp()->GetAttributeList(); if( attrlist->Number() && (!unidraw || !((OverlayUnidraw*)unidraw)->PrintAttributeList(out, attrlist))) out << *attrlist; } Clipboard* OverlayScript::GetGSList() { OverlayScript* curr = this; OverlayScript* parent = (OverlayScript*) GetParent(); while (parent != nil) { curr = parent; parent = (OverlayScript*) curr->GetParent(); } return curr != this ? curr->GetGSList() : nil; } Clipboard* OverlayScript::GetPtsList() { OverlayScript* curr = this; OverlayScript* parent = (OverlayScript*) GetParent(); while (parent != nil) { curr = parent; parent = (OverlayScript*) curr->GetParent(); } return curr != this ? curr->GetPtsList() : nil; } Clipboard* OverlayScript::GetPicList() { OverlayScript* curr = this; OverlayScript* parent = (OverlayScript*) GetParent(); while (parent != nil) { curr = parent; parent = (OverlayScript*) curr->GetParent(); } return curr != this ? curr->GetPicList() : nil; } /*****************************************************************************/ ClassId OverlaysScript::GetClassId () { return OVERLAYS_SCRIPT; } boolean OverlaysScript::IsA (ClassId id) { return OVERLAYS_SCRIPT == id || OverlayScript::IsA(id); } OverlaysScript::OverlaysScript (OverlaysComp* subj) : OverlayScript(subj) { _views = new UList; } OverlaysScript::~OverlaysScript () { DeleteViews(); delete _views; } boolean OverlaysScript::Definition (ostream& out) { Iterator i; boolean status = true; Clipboard* cb = GetPicList(); if (cb) { out << "picture( :pic " << MatchedPic(cb); } else { out << "picture(\n"; static int readonly_symval = symbol_add("readonly"); boolean outflag = false; for (First(i); status && !Done(i); ) { OverlayScript* sv = (OverlayScript*)GetView(i); AttributeList* al; boolean readonly = false; if (al = sv->GetOverlayComp()->attrlist()) { AttributeValue* av = al->find(readonly_symval); if (av) readonly = av->is_true(); } if (!readonly) { if (outflag) out << "\n"; Indent(out); status = sv->Definition(out); outflag = true; } Next(i); } } if (!cb) { out << "\n"; Indent(out); FullGS(out); Annotation(out); Attributes(out); } else { Transformation(out); } out << ")"; return status; } boolean OverlaysScript::EmitGS(ostream& out, Clipboard* cb, boolean prevout) { prevout = OverlayScript::EmitGS(out, cb, prevout); Iterator i; for (First(i); !Done(i); Next(i)) { prevout = GetScript(i)->EmitGS(out, cb, prevout); } return prevout; } boolean OverlaysScript::EmitPts(ostream& out, Clipboard* cb, boolean prevout) { prevout = OverlayScript::EmitPts(out, cb, prevout); Iterator i; for (First(i); !Done(i); Next(i)) { prevout = GetScript(i)->EmitPts(out, cb, prevout); } return prevout; } boolean OverlaysScript::EmitPic(ostream& out, Clipboard* cb1, Clipboard* cb2, boolean prevout) { if (!GetGraphicComp()->IsA(OVERLAYS_COMP) ) return prevout; /* operate on all the children first */ Iterator i; for (First(i); !Done(i); Next(i)) { prevout = GetScript(i)->EmitPic(out, cb1, cb2, prevout); } if (prevout) out << ",\n "; else out << "\n "; out << "pic(\n"; prevout = true; boolean status = true; for (First(i); status && !Done(i); ) { OverlayScript* sv = (OverlayScript*)GetView(i); out << " "; status = sv->Definition(out); Next(i); if (!Done(i)) out << ",\n"; } out << ")"; cb1->Append(GetGraphicComp()); return prevout; } int OverlaysScript::read_name(istream& in, char* buf, int bufsiz) { char close_paren = ')'; char key = ':'; char lookahead; ParamList::skip_space(in); in.get(lookahead); /* keyword section */ if (lookahead == ':' || lookahead == ')') { in.putback(lookahead); return -1; } if (lookahead != ',') in.putback(lookahead); else ParamList::skip_space(in); ParamList::parse_token(in, buf, bufsiz); return 0; } int OverlaysScript::read_gsptspic(const char* name, istream& in, OverlaysComp* comps) { if (strcmp(name, "gs") == 0) { OverlayComp* gscomp = new OverlayComp(in); comps->GrowIndexedGS(gscomp->GetGraphic()->Copy()); delete gscomp; return 1; } else if (strcmp(name, "pts") == 0) { Coord *x = nil; Coord *y = nil; int n = 0; ParamList::skip_space(in); char ch = in.get(); if (ch != '(') { cerr << "missing (\n"; return -1; } int status = ParamList::parse_points(in, x, y, n); if (!in.good() || status!= 0) cerr << "bad point list\n"; else { MultiLineObj* mlo = MultiLineObj::make_pts(x, y, n); comps->GrowIndexedPts(mlo); } delete x; delete y; ParamList::skip_space(in); ch = in.get(); if (ch != ')') { cerr << "missing )\n"; return -1; } return 1; } else if (strcmp(name, "pic") == 0 ) { OverlaysComp* gscomp = new OverlaysComp(in,comps); comps->GrowIndexedPic(gscomp); return 1; } return 0; } int OverlaysScript::ReadChildren (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { OverlayComp* child = nil; OverlaysComp* comps = (OverlaysComp*)addr1; char buf1[BUFSIZ]; char buf2[BUFSIZ]; char* buf = buf1; while (in.good()) { if (read_name(in, buf, BUFSIZ)) break; int status; if (status = read_gsptspic(buf, in, comps)) { if (status==-1) break; } else { child = read_obj(buf, in, comps); } if (child) { if (in.good() && child->valid()) { comps->Append(child); } else { /* report failure even if one child fails */ if (!*buf && (buf==buf1 ? *buf2 : *buf1)) cerr << "Error after reading " << (buf==buf1 ? buf2 : buf1) << "\n"; delete child; return -1; } } buf = buf==buf1 ? buf2 : buf1; } return 0; } void OverlaysScript::Update () { DeleteViews(); OverlayComp* comps = GetOverlayComp(); Iterator i; for (comps->First(i); !comps->Done(i); comps->Next(i)) { OverlayComp* comp = (OverlayComp*) comps->GetComp(i); OverlayScript* sv = CreateOverlayScript(comp); if (sv != nil) { _views->Append(new UList(sv)); SetParent(sv, this); } } } OverlaysComp* OverlaysScript::GetOverlaysComp () { return (OverlaysComp*) GetSubject(); } UList* OverlaysScript::Elem (Iterator i) { return (UList*) i.GetValue(); } void OverlaysScript::First (Iterator& i) { i.SetValue(_views->First()); } void OverlaysScript::Last (Iterator& i) { i.SetValue(_views->Last()); } void OverlaysScript::Next (Iterator& i) { i.SetValue(Elem(i)->Next()); } void OverlaysScript::Prev (Iterator& i) { i.SetValue(Elem(i)->Prev()); } boolean OverlaysScript::Done (Iterator i) { return Elem(i) == _views->End(); } ExternView* OverlaysScript::GetView (Iterator i) { return View(Elem(i)); } void OverlaysScript::SetView (ExternView* ev, Iterator& i) { i.SetValue(_views->Find(ev)); } OverlayScript* OverlaysScript::GetScript (Iterator i) { return (OverlayScript*) View(Elem(i)); } void OverlaysScript::SetScript (OverlayScript* ev, Iterator& i) { i.SetValue(_views->Find(ev)); } void OverlaysScript::DeleteView (Iterator& i) { UList* doomed = Elem(i); ExternView* view = GetView(i); Next(i); _views->Remove(doomed); SetParent(view, nil); delete doomed; delete view; } void OverlaysScript::DeleteViews () { Iterator i; First(i); while (!Done(i)) { DeleteView(i); } } ComponentView* OverlayScript::GetParent() { return _parent; } void OverlayScript::SetParent(ComponentView* view, ComponentView* parent) { if (parent && view->IsA(OVERLAY_SCRIPT) && parent->IsA(OVERLAY_SCRIPT)) ((OverlayScript*)view)->_parent = (OverlayScript*) parent; else if (!parent && view->IsA(OVERLAY_SCRIPT)) ((OverlayScript*)view)->_parent = nil; } void OverlaysScript::SetCompactions(boolean gs, boolean pts, boolean pic) { } int OverlaysScript::ReadPic (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { OverlayComp* comp = (OverlayComp*)addr1; int id; in >> id; OverlaysComp* pic = comp->GetIndexedPic(id); if (pic) { Iterator i; for (pic->First(i); !pic->Done(i); pic->Next(i)) comp->Append((OverlayComp*)pic->GetComp(i)->Copy()); } else cerr << ":pic reference without pic records\n"; return in.good() ? 0 : -1; } OverlayComp* OverlaysScript::read_obj(const char* name, istream& in, OverlaysComp* comps) { OverlayCatalog* catalog = OverlayCatalog::Instance(); return catalog->ReadComp(name, in, comps); } /*****************************************************************************/ OverlayIdrawScript::OverlayIdrawScript (OverlayIdrawComp* subj) : OverlaysScript(subj) { _gslist = nil; _ptslist = nil; _piclist1 = _piclist2 = nil; _gs_compacted = _pts_compacted = _pic_compacted = false; _by_pathname = true; } OverlayIdrawScript::~OverlayIdrawScript() { delete _gslist; delete _ptslist; delete _piclist1; delete _piclist2; } ClassId OverlayIdrawScript::GetClassId () { return OVERLAY_IDRAW_SCRIPT; } boolean OverlayIdrawScript::IsA (ClassId id) { return OVERLAY_IDRAW_SCRIPT == id || OverlaysScript::IsA(id); } boolean OverlayIdrawScript::Emit (ostream& out) { if (svg_format()) return EmitSvg(out); out << "drawtool("; /* make list and output unique point lists */ boolean prevout = false; if (_pts_compacted) { _ptslist = new Clipboard(); prevout = EmitPts(out, _ptslist, prevout); } /* make list and output unique graphic states */ if (_gs_compacted) { _gslist = new Clipboard(); prevout = EmitGS(out, _gslist, prevout); } /* make list and output unique picture graphics */ if (_pic_compacted) { _piclist1 = new Clipboard(); _piclist2 = new Clipboard(); prevout = EmitPic(out, _piclist1, _piclist2, prevout); } /* output graphic components */ boolean status = true; Iterator i; First(i); if (!Done(i) ) { if (prevout) out << ","; out << "\n"; } static int readonly_symval = symbol_add("readonly"); for (; status && !Done(i); ) { OverlayScript* ev = (OverlayScript*)GetView(i); boolean readonly = false; AttributeList *al; if (al = ev->GetOverlayComp()->attrlist()) { AttributeValue* av = al->find(readonly_symval); if (av) readonly = av->is_true(); } if (!readonly) { Indent(out); status = ev->Definition(out); } Next(i); if (!Done(i) && !readonly) out << ",\n"; } out << "\n"; FullGS(out); Annotation(out); Attributes(out); out << ")\n"; return status; } boolean OverlayIdrawScript::EmitPic(ostream& out, Clipboard* cb1, Clipboard* cb2, boolean prevout) { Iterator i; for (First(i); !Done(i); Next(i)) { prevout = GetScript(i)->EmitPic(out, cb1, cb2, prevout); } return prevout; } Clipboard* OverlayIdrawScript::GetGSList() { return _gslist; } Clipboard* OverlayIdrawScript::GetPtsList() { return _ptslist; } Clipboard* OverlayIdrawScript::GetPicList() { return _piclist1; } void OverlayIdrawScript::SetCompactions(boolean gs, boolean pts, boolean pic) { _gs_compacted = gs; _pts_compacted = pts; _pic_compacted = pic; } void OverlayIdrawScript::SetByPathnameFlag(boolean flag) { _by_pathname = flag; } boolean OverlayIdrawScript::GetByPathnameFlag() { return _by_pathname; } boolean OverlayIdrawScript::EmitSvg (ostream& out) { out << "\n"; out << "\n"; Coord l, b, r, t; GetBox(l, b, r, t); Coord w = r - l; Coord h = t - b; out << "\n"; out << "ivtools drawing\n"; out << "ivtools drawing\n"; out << "\n"; /* output graphic components */ boolean status = true; Iterator i; First(i); static int readonly_symval = symbol_add("readonly"); for (; status && !Done(i); ) { OverlayScript* ev = (OverlayScript*)GetView(i); boolean readonly = false; AttributeList *al; if (al = ev->GetOverlayComp()->attrlist()) { AttributeValue* av = al->find(readonly_symval); if (av) readonly = av->is_true(); } if (!readonly) { Indent(out); status = ev->Definition(out); } Next(i); } out << "\n"; out << "\n"; return status; } ivtools-1.2.11a1/src/OverlayUnidraw/scriptview.h000066400000000000000000000333421214471147700216440ustar00rootroot00000000000000/* * Copyright (C) 2002 Scott E. Johnston * Copyright (C) 1994-1997,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representation about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * OverlayScript - command-oriented external representation of component. */ #ifndef script_view_h #define script_view_h #include class Clipboard; class OverlayComp; class OverlaysComp; class OverlayIdrawComp; #include //: serialized view of OverlayComp. // the OverlayScript class hierarchy is a tree of ExternView classes // that are derived from OverlayPS and PostScriptView for convenience, // to inherit a complete mechanism for writing and reading graphical data. //

// This capability is similar to the serialization mechanism of JavaBeans, // but there is no need for a versioning system because the format used // for the ASCII serialization supports arbitrary extension of an object's // format by adding defaulted keyword-prefixed arguments. //

// An older program can read newer formats, because the deserialization // is set up to convert unknown keyword arguments into attributes on // in a property list. A newer program can read older formats by // using default values for missing keyword-prefixed arguments. class OverlayScript : public OverlayPS { public: OverlayScript(OverlayComp* = nil); virtual ~OverlayScript(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); int Indent(ostream&, int extra = 0); // method to indent nested object output. virtual void MinGS(ostream&); // output a minimal description of a graphic state. virtual void FullGS(ostream&); // output a full description of a graphic state. virtual void TextGS(ostream&); // output a description of a graphic state adequate for a text graphic (TextGraphic). virtual void StencilGS(ostream&); // output a description of a graphic state adequate for a stencil graphic (UStencil). boolean DefaultGS(); // return true if this is default gs, with no brush, colors, font, or pattern // specified. int MatchedGS(Clipboard*); // return index of where the graphic state of this component // matches the graphic state of a component in the clipboard. Iterator MatchedGS(Clipboard*, int&); // return iterator that points to where the graphic state of this component // matches the graphic state of a component in the clipboard. virtual boolean EmitGS(ostream&, Clipboard*, boolean); // output a decription of this component's graphic state, and append a // copy to a clipboard used to avoid outputting it twice. virtual Clipboard* GetGSList(); // return pointer to clipboard of components with unique graphic states. int MatchedPts(Clipboard*); // return index of where the point list of this component // matches the point list of a component in the clipboard. Iterator MatchedPts(Clipboard*, int&); // return iterator that points to where the point list of this component // matches the point list of a component in the clipboard. virtual boolean EmitPts(ostream&, Clipboard*, boolean); // output a decription of this component's point list, and append a // copy to a clipboard used to avoid outputting it twice. virtual Clipboard* GetPtsList(); // return pointer to clipboard of components with unique point lists. int MatchedPic(Clipboard*); // return index of where the compound graphic of this component // matches the compound graphic of a component in the clipboard. Iterator MatchedPic(Clipboard*, int&); // return iterator that points to where the compound graphic of this component // matches the compound graphic of a component in the clipboard. virtual boolean EmitPic(ostream&, Clipboard*, Clipboard*, boolean); // output a decription of this component's compound graphic, and append a // copy to a clipboard used to avoid outputting it twice. virtual Clipboard* GetPicList(); // return pointer to clipboard of components with unique compound graphics. virtual boolean GetByPathnameFlag(); // return flag that indicates whether to serialize component // by only a pathname or by the raw data. static int ReadGS(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // a description of graphic state. static int ReadFillBg(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // the fill-background flag of a graphic state. static int ReadNoneBr(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // the none-brush description. static int ReadBrush(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // all brush descriptions except for a none-brush. static int ReadFgColor(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // a foreground-color description. static int ReadBgColor(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // a background-color description. static int ReadFont(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // a font description. static int ReadNonePat(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // the none-pattern description. static int ReadPattern(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // all brush descriptions except for a none-pattern and gray-pattern. static int ReadGrayPat(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // the gray-pattern description. static int ReadTransform(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // a 6-parameter affine transform (a 2x3 matrix). static int ReadAnnotation(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // an annotation. static int ReadOther(istream&, void*, void*, void*, void*); // method used by OverlayComp istream constructor to deserialize // any keyword-prefixed argument with unknown keyword symbol, by // adding the value to a components property list (an AttributeList). static boolean skip_comp(istream& in); // skip the text for the current component while de-serializing. static boolean ptlist_parens() { return _ptlist_parens; } // get flag that indicates putting parens around pointlist's static void ptlist_parens(boolean flag) { _ptlist_parens = flag; } // set flag that indicates putting parens around pointlist's boolean svg_format(); // true if exporting SVG void svg_format(boolean); // set flag for exporting SVG // can be overridden by flag associated with Command objects static const char* format() { return _format; } // get global format string static void format(const char* fmt) { delete _format; _format = strnew(fmt); } // set global format string protected: virtual void FillBg(ostream& out); virtual void Brush(ostream& out); virtual void Colors(ostream& out); virtual void FgColor(ostream& out); virtual void BgColor(ostream& out); virtual void Font(ostream& out); virtual void Pattern(ostream& out); virtual void Transformation(ostream& out); virtual void Transformation(ostream& out, const char* keyword, Graphic* gr = nil); virtual void Annotation(ostream& out); void Attributes(ostream& out); OverlayScript* CreateOverlayScript(OverlayComp*); virtual ComponentView* GetParent(); virtual void SetParent(ComponentView* child, ComponentView* parent); OverlayScript* _parent; static boolean _ptlist_parens; static char* _format; }; //: composite version of OverlayScript. // a serialized view of OverlaysComp. class OverlaysScript : public OverlayScript { public: OverlaysScript(OverlaysComp* = nil); virtual ~OverlaysScript(); virtual void Update(); // construct all sub-views. OverlaysComp* GetOverlaysComp(); // return pointer to associated component. virtual void SetCompactions (boolean gs = false, boolean pts = false, boolean pic=false); // set flags to indicate what should be compacted when serialized, // graphic state ('gs'), point lists ('pts'), or composite graphics ('pic'). virtual boolean EmitGS(ostream&, Clipboard*, boolean); // iterate over sub-views, outputting decriptions of each unique graphic state. virtual boolean EmitPts(ostream&, Clipboard*, boolean); // iterate over sub-views, outputting decriptions of each unique point list. virtual boolean EmitPic(ostream&, Clipboard*, Clipboard*, boolean); // iterate over sub-views, outputting decriptions of each unique // composite graphic. This is not yet fully generalized, because there are // questions as to what that would mean. virtual boolean Definition(ostream&); // output variable-length ASCII record that defines the component. static int read_name(istream&, char* buf, int bufsiz); // static method to read the name of an object when de-serializing. static int read_gsptspic(const char* name, istream&, OverlaysComp* comps); // static method to read either a graphic state, a point list, or a // compound graphic when de-serializing. static OverlayComp* read_obj(const char* name, istream&, OverlaysComp* comps); // static method to read an arbitrary object when de-serializing. static int ReadChildren(istream&, void*, void*, void*, void*); // static method to read a list of arbitrary objects when de-serializing. static int ReadPic(istream&, void*, void*, void*, void*); // static method to read a composite graphic id (a pic), and substitute // the corresponding component from a list. virtual ExternView* GetView(Iterator); // get sub-view pointed to by the Iterator. virtual void SetView(ExternView*, Iterator&); // set sub-view pointed to by the Iterator. virtual OverlayScript* GetScript(Iterator); // get sub-view pointed to by the Iterator. virtual void SetScript(OverlayScript*, Iterator&); // set sub-view pointed to by the Iterator. virtual void First(Iterator&); // set Iterator to point to first sub-view. virtual void Last(Iterator&); // set Iterator to point to last sub-view. virtual void Next(Iterator&); // set Iterator to point to next sub-view. virtual void Prev(Iterator&); // set Iterator to point to prev sub-view. virtual boolean Done(Iterator); // return true if Iterator points off the front or end of list of sub-views. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: UList* Elem(Iterator); void DeleteView(Iterator&); void DeleteViews(); UList* _views; }; //: serialized view of top-level OverlayIdrawComp. class OverlayIdrawScript : public OverlaysScript { public: OverlayIdrawScript(OverlayIdrawComp* = nil); virtual ~OverlayIdrawScript(); virtual void SetCompactions (boolean gs = false, boolean pts = false, boolean pic=false); // set flags to indicate what should be compacted when serialized, // graphic state ('gs'), point lists ('pts'), or composite graphics ('pic'). virtual void SetByPathnameFlag(boolean); // set flag that indicates whether to serialize component // by only a pathname or by the raw data. virtual boolean GetByPathnameFlag(); // return flag that indicates whether to serialize component // by only a pathname or by the raw data. virtual boolean Emit(ostream&); // serialize entire document to ostream. virtual boolean EmitPic(ostream&, Clipboard*, Clipboard*, boolean); // serialize a composite graphic. virtual Clipboard* GetGSList(); // return pointer to list of graphic states that are stored in components. virtual Clipboard* GetPtsList(); // return pointer to list of point lists that are stored in components. virtual Clipboard* GetPicList(); // return pointer to list of composite graphics that are stored in components. virtual boolean EmitSvg(ostream&); // serialize entire document to ostream in SVG format. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Clipboard* _gslist; Clipboard* _ptslist; Clipboard* _piclist1; Clipboard* _piclist2; boolean _gs_compacted; boolean _pts_compacted; boolean _pic_compacted; boolean _by_pathname; }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/setattrbyexpr.cc000066400000000000000000000141731214471147700225240ustar00rootroot00000000000000/* * Copyright (c) 1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * SetAttrByExprCmd implementation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ ClassId SetAttrByExprCmd::GetClassId () { return SLCT_BY_ATTR_CMD; } boolean SetAttrByExprCmd::IsA (ClassId id) { return SETATTRBYEXPR_CMD == id || Command::IsA(id); } SetAttrByExprCmd::SetAttrByExprCmd (Editor* ed, AttrDialog* t) : Command(ed) { Init(t); } SetAttrByExprCmd::SetAttrByExprCmd (ControlInfo* c, AttrDialog* t) : Command(c) { Init(t); } void SetAttrByExprCmd::Init(AttrDialog* t) { calculator_ = t ? t : &AttrDialog::instance(); Resource::ref(calculator_); clipboard_ = new Clipboard(); comps_ = nil; } Clipboard* SetAttrByExprCmd::clipboard() { return clipboard_; } void SetAttrByExprCmd::Execute () { Editor* ed = GetEditor(); if (ed->GetSelection()->IsEmpty()) { GAcknowledgeDialog::post(ed->GetWindow(), "Compute Attributes: Selection is empty", nil, "no selection"); return; } if (!comps_) { comps_ = (OverlaysComp*)ed->GetComponent(); ComTerpServ* terp = calculator_->comterpserv(); Iterator* iter = new Iterator; const char* nextcomm = "next_"; terp->add_command(nextcomm, new NextInSelectionFunc(terp, calculator_, GetEditor()->GetSelection(), iter)); calculator_->next_expr(nextcomm); #if 0 const char* truecomm = "true_"; terp->add_command(truecomm, new BothSetAttrFunc(terp, calculator_, comps_, iter, clipboard_)); calculator_->true_expr(truecomm); const char* falsecomm = "false_"; terp->add_command(falsecomm, new BothSetAttrFunc(terp, calculator_, comps_, iter, clipboard_)); calculator_->false_expr(falsecomm); const char* donecomm = "done_"; terp->add_command(donecomm, new DoneSetAttrFunc(terp, calculator_, comps_, iter, clipboard_, ed->GetViewer())); calculator_->done_expr(donecomm); #endif } Style* style; boolean reset_caption = false; if (calculator_ == nil) { calculator_ = &AttrDialog::instance(); Resource::ref(calculator_); } else { style = calculator_->style(); } clipboard_->Clear(); calculator_->post_for(ed->GetWindow()); return; } boolean SetAttrByExprCmd::Reversible () { return false; } Command* SetAttrByExprCmd::Copy () { SetAttrByExprCmd* copy = new SetAttrByExprCmd(CopyControlInfo()); InitCopy(copy); return copy; } Clipboard* SetAttrByExprCmd::PostDialog () { return nil; } /* move to next component in the selection */ NextInSelectionFunc::NextInSelectionFunc (ComTerp* comterp, AttrDialog* attrdialog, Selection* sel, Iterator* i) : AttrListFunc(comterp, attrdialog, nil, i, nil, sel) { selection_->First(*compiter_); OverlayView* view = (OverlayView*)selection_->GetView(*compiter_); OverlayComp* comp = view ? view->GetOverlayComp() : nil; if (comp) _comterp->set_attributes(comp->GetAttributeList()); } void NextInSelectionFunc::execute() { selection_->Next(*compiter_); OverlayView* view = (OverlayView*)selection_->GetView(*compiter_); OverlayComp* comp = view ? view->GetOverlayComp() : nil; _comterp->set_attributes(comp ? comp->GetAttributeList() : nil); push_stack(selection_->Done(*compiter_) ? ComValue::falseval() : ComValue::trueval()); return; } /* something to get called everytime, regardless if true or false value */ BothSetAttrFunc::BothSetAttrFunc (ComTerp* comterp, AttrDialog* attrdialog, OverlaysComp* comps, Iterator* i, Clipboard* cb) : AttrListFunc(comterp, attrdialog, comps, i, cb) {} void BothSetAttrFunc::execute() { #if 0 // copy of TrueAttrListFunc::execute OverlayComp* comp = (OverlayComp*)comps_->GetComp(*compiter_); clipboard_->Append(comp); push_stack(ComValue::trueval()); return; #endif } /* at the end do nothing, at least nothing yet */ DoneSetAttrFunc::DoneSetAttrFunc (ComTerp* comterp, AttrDialog* attrdialog, OverlaysComp* comps, Iterator* i, Clipboard* cb, Viewer* v) : AttrListFunc(comterp, attrdialog, comps, i, cb) { viewer_ = v; } void DoneSetAttrFunc::execute() { #if 0 // copy of DoneAttrListFunc::execute Iterator i; viewer_->GetSelection()->Clear(); for (clipboard_->First(i); !clipboard_->Done(i); clipboard_->Next(i)) { OverlayComp* comp = (OverlayComp*)clipboard_->GetComp(i); OverlayView* view = comp->FindView(viewer_); if (view) viewer_->GetSelection()->Append(view); } comps_->First(*compiter_); clipboard_->Clear(); viewer_->Update(); push_stack(ComValue::trueval()); return; #endif } ivtools-1.2.11a1/src/OverlayUnidraw/setattrbyexpr.h000066400000000000000000000072241214471147700223650ustar00rootroot00000000000000/* * Copyright (c) 1998-1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * SetAttrByExprCmd - a command for setting attributes by expression */ #ifndef set_attr_by_expr_h #define set_attr_by_expr_h #include #include class Clipboard; class AttrDialog; //: command to set attributes on a component by evaluating an expression. // This command checks for a non-empty selection in the current editor, // then pops up a dialog box for entering attribute expressions to evaluate. // symbols on the right hand side of an assigment operator are used to // look up and return values from the property list (AttributeList) of // a component. symbols on the left-hand side of an assignment operator are // used to create or modify an entry in the same component property list. class SetAttrByExprCmd : public Command { public: SetAttrByExprCmd(Editor* = nil, AttrDialog* = nil); SetAttrByExprCmd(ControlInfo* = nil, AttrDialog* = nil); void Init(AttrDialog*); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual void Execute(); virtual boolean Reversible(); virtual Clipboard* PostDialog(); Selection* selection(); Clipboard* clipboard(); protected: AttrDialog* calculator_; OverlaysComp* comps_; Clipboard* clipboard_; }; //: interpreter command for plugging together AttrDialog and SetAttrByExprCmd. // interpreter command used to iterate over all the components in the current // selection. class NextInSelectionFunc : public AttrListFunc { public: NextInSelectionFunc(ComTerp*, AttrDialog*, Selection* sel, Iterator* i); virtual void execute(); }; //: interpreter command for plugging together AttrDialog and SetAttrByExprCmd. // interpreter command used to do nothing whether the attribute expression // evalutes to true or false, because the assignment of values by interpreting // assignment commands has already occurred. class BothSetAttrFunc : public AttrListFunc { public: BothSetAttrFunc(ComTerp*, AttrDialog*, OverlaysComp* comps, Iterator* i, Clipboard* cb); virtual void execute(); }; //: interpreter command for plugging together AttrDialog and SetAttrByExprCmd. // interpreter command used to indicate when done iterating over all the components // in the current selection. class DoneSetAttrFunc : public AttrListFunc { public: DoneSetAttrFunc(ComTerp*, AttrDialog*, OverlaysComp* comps, Iterator* i, Clipboard* cb, Viewer* v); virtual void execute(); protected: Viewer* viewer_; }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/slctbyattr.cc000066400000000000000000000146541214471147700220030ustar00rootroot00000000000000/* * Copyright (c) 1997 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * SlctByAttrCmd implementation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ ClassId SlctByAttrCmd::GetClassId () { return SLCT_BY_ATTR_CMD; } boolean SlctByAttrCmd::IsA (ClassId id) { return SLCT_BY_ATTR_CMD == id || Command::IsA(id); } SlctByAttrCmd::SlctByAttrCmd (Editor* ed, AttrDialog* t) : Command(ed) { Init(t); } SlctByAttrCmd::SlctByAttrCmd (ControlInfo* c, AttrDialog* t) : Command(c) { Init(t); } void SlctByAttrCmd::Init(AttrDialog* t) { calculator_ = t ? t : &AttrDialog::instance(); Resource::ref(calculator_); clipboard_ = new Clipboard(); comps_ = nil; } Clipboard* SlctByAttrCmd::clipboard() { return clipboard_; } void SlctByAttrCmd::Execute () { Editor* ed = GetEditor(); if (!comps_) { comps_ = (OverlaysComp*)ed->GetComponent(); ComTerpServ* terp = calculator_->comterpserv(); Iterator* iter = new Iterator; const char* nextcomm = "next_"; terp->add_command(nextcomm, new NextAttrListFunc(terp, calculator_, comps_, iter, clipboard_)); calculator_->next_expr(nextcomm); const char* truecomm = "true_"; terp->add_command(truecomm, new TrueAttrListFunc(terp, calculator_, comps_, iter, clipboard_)); calculator_->true_expr(truecomm); const char* falsecomm = "false_"; terp->add_command(falsecomm, new FalseAttrListFunc(terp, calculator_, comps_, iter, clipboard_)); calculator_->false_expr(falsecomm); const char* donecomm = "done_"; terp->add_command(donecomm, new DoneAttrListFunc(terp, calculator_, comps_, iter, clipboard_, ed->GetViewer())); calculator_->done_expr(donecomm); } Style* style; boolean reset_caption = false; if (calculator_ == nil) { calculator_ = &AttrDialog::instance(); Resource::ref(calculator_); } else { style = calculator_->style(); } clipboard_->Clear(); calculator_->post_for(ed->GetWindow()); return; } boolean SlctByAttrCmd::Reversible () { return false; } Command* SlctByAttrCmd::Copy () { SlctByAttrCmd* copy = new SlctByAttrCmd(CopyControlInfo()); InitCopy(copy); return copy; } Clipboard* SlctByAttrCmd::PostDialog () { return nil; } AttrListFunc::AttrListFunc(ComTerp* comterp, AttrDialog* attrdialog, OverlaysComp* comps, Iterator* i, Clipboard* cb, Selection* sel) : ComFunc(comterp) { attrdialog_ = attrdialog; Resource::ref(attrdialog_); comps_ = comps; compiter_ = i; clipboard_ = cb; selection_ = sel; } AttrListFunc::~AttrListFunc() { Unref(attrdialog_); } /* move to next component in the list */ NextAttrListFunc::NextAttrListFunc (ComTerp* comterp, AttrDialog* attrdialog, OverlaysComp* comps, Iterator* i, Clipboard* cb) : AttrListFunc(comterp, attrdialog, comps, i, cb) { comps_->First(*compiter_); OverlayComp* comp = (OverlayComp*)comps_->GetComp(*compiter_); if (comp) _comterp->set_attributes(comp->GetAttributeList()); } void NextAttrListFunc::execute() { comps_->Next(*compiter_); OverlayComp* comp = (OverlayComp*)comps_->GetComp(*compiter_); _comterp->set_attributes(comp ? comp->GetAttributeList() : nil); push_stack(comps_->Done(*compiter_) ? ComValue::falseval() : ComValue::trueval()); return; } /* if expression evaluates to true for this component, add to clipboard */ TrueAttrListFunc::TrueAttrListFunc (ComTerp* comterp, AttrDialog* attrdialog, OverlaysComp* comps, Iterator* i, Clipboard* cb) : AttrListFunc(comterp, attrdialog, comps, i, cb) {} void TrueAttrListFunc::execute() { OverlayComp* comp = (OverlayComp*)comps_->GetComp(*compiter_); clipboard_->Append(comp); push_stack(ComValue::trueval()); return; } /* if expression evaluates to false for this component, do nothing */ FalseAttrListFunc::FalseAttrListFunc (ComTerp* comterp, AttrDialog* attrdialog, OverlaysComp* comps, Iterator* i, Clipboard* cb) : AttrListFunc(comterp, attrdialog, comps, i, cb) {} void FalseAttrListFunc::execute() { push_stack(ComValue::falseval()); return; } /* at the end build new selection from clipboard */ DoneAttrListFunc::DoneAttrListFunc (ComTerp* comterp, AttrDialog* attrdialog, OverlaysComp* comps, Iterator* i, Clipboard* cb, Viewer* v) : AttrListFunc(comterp, attrdialog, comps, i, cb) { viewer_ = v; } void DoneAttrListFunc::execute() { Iterator i; viewer_->GetSelection()->Clear(); for (clipboard_->First(i); !clipboard_->Done(i); clipboard_->Next(i)) { OverlayComp* comp = (OverlayComp*)clipboard_->GetComp(i); OverlayView* view = comp->FindView(viewer_); if (view) viewer_->GetSelection()->Append(view); } comps_->First(*compiter_); clipboard_->Clear(); viewer_->Update(); push_stack(ComValue::trueval()); return; } ivtools-1.2.11a1/src/OverlayUnidraw/slctbyattr.h000066400000000000000000000102211214471147700216270ustar00rootroot00000000000000/* * Copyright (c) 1997,1999 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * SlctByAttrCmd - a command for selecting by attribute expression */ #ifndef slct_by_attr_h #define slct_by_attr_h #include class Clipboard; class AttrDialog; //: command to select components by evaluating an expression. // This command pops up a dialog box for entering attribute expressions // to evaluate on all the components in an editor. unknown // symbols are replaced with the corresponding AttributeValue on the // AttributeList associated with the component. expressions that evaluate // to non-zero cause that component to be added to the current selection // of the drawing editor. class SlctByAttrCmd : public Command { public: SlctByAttrCmd(Editor* = nil, AttrDialog* = nil); SlctByAttrCmd(ControlInfo* = nil, AttrDialog* = nil); void Init(AttrDialog*); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual void Execute(); virtual boolean Reversible(); virtual Clipboard* PostDialog(); Clipboard* clipboard(); protected: AttrDialog* calculator_; Clipboard* clipboard_; OverlaysComp* comps_; }; #include class AttrDialogImpl; class AttrListFunc : public ComFunc { public: AttrListFunc(ComTerp*, AttrDialog*, OverlaysComp* comps, Iterator* i, Clipboard* cb, Selection* sel=nil); virtual ~AttrListFunc(); protected: AttrDialog* attrdialog_; OverlaysComp* comps_; Iterator* compiter_; Clipboard* clipboard_; Selection* selection_; }; class OverlaysComp; //: interpreter command for plugging together AttrDialog and SlctByAttrCmd. // interpreter command used to iterate over all the components in an editor. // selection. class NextAttrListFunc : public AttrListFunc { public: NextAttrListFunc(ComTerp*, AttrDialog*, OverlaysComp* comps, Iterator* i, Clipboard* cb); virtual void execute(); }; //: interpreter command for plugging together AttrDialog and SlctByAttrCmd. // interpreter command for adding component to current selection when // attribute expression evaluates to true. class TrueAttrListFunc : public AttrListFunc { public: TrueAttrListFunc(ComTerp*, AttrDialog*, OverlaysComp* comps, Iterator* i, Clipboard* cb); virtual void execute(); }; //: interpreter command for plugging together AttrDialog and SlctByAttrCmd. // interpreter command used to not add a component to current selection when // attribute expression evaluates to false. class FalseAttrListFunc : public AttrListFunc { public: FalseAttrListFunc(ComTerp*, AttrDialog*, OverlaysComp* comps, Iterator* i, Clipboard* cb); virtual void execute(); }; //: interpreter command for plugging together AttrDialog and SlctByAttrCmd. // interpreter command used to indicate when done iterating over components. class DoneAttrListFunc : public AttrListFunc { public: DoneAttrListFunc(ComTerp*, AttrDialog*, OverlaysComp* comps, Iterator* i, Clipboard* cb, Viewer* v); virtual void execute(); protected: Viewer* viewer_; }; #endif ivtools-1.2.11a1/src/OverlayUnidraw/textfile.cc000066400000000000000000000252571214471147700214350ustar00rootroot00000000000000/* * Copyright (c) 1995,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Overlay Text from File component definitions. */ #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ ParamList* TextFileComp::_textfile_params = nil; int TextFileComp::_symid = -1; /*****************************************************************************/ ClassId TextFileComp::GetClassId () { return TEXTFILE_COMP; } boolean TextFileComp::IsA (ClassId id) { return TEXTFILE_COMP == id || TextOvComp::IsA(id); } Component* TextFileComp::Copy () { TextFileComp* comp = new TextFileComp(_pathname, _begstr, _endstr, _linewidth, GetGraphic()); if (attrlist()) comp->SetAttributeList(new AttributeList(attrlist())); return comp; } TextFileComp::TextFileComp (const char* pathname, const char* begstr, const char* endstr, int linewidth, Graphic *gs, OverlayComp* parent) : TextOvComp(nil, parent) { _pathname = strdup(pathname); _begstr = begstr ? strdup(begstr) : nil; _endstr = endstr ? strdup(endstr) : nil; _linewidth = linewidth; _gr = new TextGraphic("", gs->GetFont()->GetLineHt(), gs); _gr->FillBg(false); Init(); } TextFileComp::TextFileComp(istream& in, OverlayComp* parent) : TextOvComp(nil, parent) { _pathname = _begstr = _endstr = nil; _linewidth = -1; _valid = GetParamList()->read_args(in, this); Init(); } TextFileComp::~TextFileComp() { delete _pathname; delete _begstr; delete _endstr; } void TextFileComp::Init() { /* read in the text from begstr to endstr */ FILE* fptr = fopen(_pathname, "r"); char *buffer; if (_linewidth == 0) { buffer = new char[1]; buffer[0] = '\0'; fclose (fptr); return; } if (!fptr) { buffer = new char[1]; buffer[0] = '\0'; } else { char inbuf[BUFSIZ]; int nsub; buffer = new char[BUFSIZ]; int bufsiz = BUFSIZ; int buflen = 0; fgets( inbuf, BUFSIZ, fptr); if (_begstr) while (!feof(fptr) && strncmp(_begstr, inbuf, strlen(_begstr)) != 0) fgets( inbuf, BUFSIZ, fptr); int len; int nc = 0; int wordc = 0; char* wordbuf; char c; /* loop until eof or endstr is found */ while (!feof(fptr) && (_endstr ? strncmp(_endstr, inbuf, strlen(_endstr)) != 0 : true)) { len = strlen(inbuf); if (_linewidth > -1) nsub = len / _linewidth; else nsub = 0; /* double buffer length if needed */ if (buflen+len+nsub >= bufsiz) { bufsiz *= 2; char* newbuffer = new char[bufsiz]; strcpy( newbuffer, buffer ); delete buffer; buffer = newbuffer; } if (_linewidth > -1) { wordbuf = new char[len+nsub+1]; for (int i = 0; i < len; i++) { c = inbuf[i]; ++nc; if (c == ' ' || c == '\t' || c == '\n') { if (nc > _linewidth+1) { strcpy(buffer+buflen, "\n"); ++buflen; if (c == '\n' && nc > 1 ) { wordbuf[wordc] = ' '; } else { wordbuf[wordc] = c; } wordbuf[wordc+1] = '\0'; nc = strlen(wordbuf); wordc = 0; strcpy(buffer+buflen, wordbuf); buflen += strlen(wordbuf); } else { if (c == '\n' && nc > 1 && i > 0) { wordbuf[wordc] = ' '; wordbuf[wordc+1] = '\0'; } else if (c == '\n' && i == 0) { wordbuf[wordc] = c; wordbuf[wordc+1] = c; wordbuf[wordc+2] = '\0'; nc = 0; } else { wordbuf[wordc] = c; wordbuf[wordc+1] = '\0'; } wordc = 0; if (buffer[buflen-1] != ' ' || wordbuf[0] != ' ') { strcpy(buffer+buflen, wordbuf); buflen += strlen(wordbuf); } else { strcpy(buffer+buflen, wordbuf+1); buflen += strlen(wordbuf) - 1; } } } else { if (c=='\\') { c = inbuf[++i]; if (isdigit(c)) { char buf[4]; buf[0] = c; buf[1] = buf[2] = buf[3] = '\0'; if (isdigit(inbuf[i+1])) { buf[1] = inbuf[++i]; if (isdigit(inbuf[i+1])) { buf[2] = inbuf[++i]; } } c = ParamList::octal(buf); } } wordbuf[wordc] = c; ++wordc; } } delete wordbuf; } else { strcpy(buffer+buflen, inbuf); buflen += strlen(inbuf); } fgets( inbuf, BUFSIZ, fptr); } /* done looping until eof or endstr is found */ } fclose(fptr); /* setup the graphic */ ((TextGraphic*)_gr)->SetOriginal(buffer); delete buffer; /* correct font vertical position */ PSFont* f = _gr->GetFont(); float sep = 1 - f->GetLineHt(); Transformer* t = _gr->GetTransformer(); float dx = 0., dy = sep; if (t != nil) { float x0, y0, x1, y1; t->Transform(0., 0., x0, y0); t->Transform(0., sep, x1, y1); dx = x1 - x0; dy = y1 - y0; } _gr->Translate(dx, dy); } ParamList* TextFileComp::GetParamList() { if (!_textfile_params) GrowParamList(_textfile_params = new ParamList()); return _textfile_params; } void TextFileComp::GrowParamList(ParamList* pl) { pl->add_param("textfile", ParamStruct::required, &TextFileScript::ReadTextFile, this, this); pl->add_param("begstr", ParamStruct::keyword, &ParamList::read_string, this, &_begstr); pl->add_param("endstr", ParamStruct::keyword, &ParamList::read_string, this, &_endstr); pl->add_param("linewidth", ParamStruct::keyword, &ParamList::read_int, this, &_linewidth); OverlayComp::GrowParamList(pl); return; } boolean TextFileComp::operator == (OverlayComp& comp) { if (GetClassId() != comp.GetClassId()) return false; return strcmp(GetPathname(), ((TextFileComp&)comp).GetPathname()) && strcmp(GetBegstr(), ((TextFileComp&)comp).GetBegstr()) && strcmp(GetEndstr(), ((TextFileComp&)comp).GetEndstr()) && GetLineWidth() == ((TextFileComp&)comp).GetLineWidth() && OverlayComp::operator==(comp); } /****************************************************************************/ TextFileComp* TextFileView::GetTextFileComp () { return (TextFileComp*) GetSubject(); } ClassId TextFileView::GetClassId () { return TEXTFILE_VIEW; } boolean TextFileView::IsA (ClassId id) { return TEXTFILE_VIEW == id || TextOvView::IsA(id); } TextFileView::TextFileView (TextFileComp* subj) : TextOvView(subj) { } Manipulator* TextFileView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Manipulator* m = nil; Editor* ed = v->GetEditor(); if (tool->IsA(GRAPHIC_COMP_TOOL)) { // do nothing } else if (tool->IsA(RESHAPE_TOOL)) { // do nothing } else { m = TextOvView::CreateManipulator(v, e, rel, tool); } return m; } Command* TextFileView::InterpretManipulator (Manipulator* m) { Viewer* v = m->GetViewer(); Editor* ed = v->GetEditor(); Tool* tool = m->GetTool(); Command* cmd = nil; if (tool->IsA(GRAPHIC_COMP_TOOL) || tool->IsA(RESHAPE_TOOL)) { // do nothing } else { cmd = TextOvView::InterpretManipulator(m); } return cmd; } /****************************************************************************/ ClassId TextFileScript::GetClassId () { return TEXTFILE_SCRIPT; } boolean TextFileScript::IsA (ClassId id) { return TEXTFILE_SCRIPT == id || TextScript::IsA(id); } TextFileScript::TextFileScript (TextFileComp* subj) : TextScript(subj) { } boolean TextFileScript::Definition (ostream& out) { TextFileComp* comp = (TextFileComp*) GetSubject(); TextGraphic* g = comp->GetText(); int h = g->GetLineHeight(); out << "textfile("; out << h << ",\"" << comp->GetPathname() << "\""; if (comp->GetBegstr()) { out << " :begstr "; ParamList::output_text(out, comp->GetBegstr(), 0); } if (comp->GetEndstr()) { out << " :endstr "; ParamList::output_text(out, comp->GetEndstr(), 0); } if (comp->GetLineWidth() > -1) out << " :linewidth " << comp->GetLineWidth(); float sep = g->GetLineHeight() - 1; // correct for vert shift Transformer corrected, *t = g->GetTransformer(); corrected.Translate(0., sep); if (t == nil) { g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); } else { t->Reference(); corrected.Postmultiply(t); g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); Unref(t); } Annotation(out); Attributes(out); out << ")"; return out.good(); } int TextFileScript::ReadTextFile (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { int line_height; char delim; char pathname[BUFSIZ]; TextFileComp* textfilecomp = (TextFileComp*)addr1; in >> line_height; ParamList::skip_space(in); in >> delim; if (delim == ',' && in.good()) { ParamList::skip_space(in); if (ParamList::parse_pathname(in, pathname, BUFSIZ, textfilecomp->GetBaseDir()) != 0) return -1; } if (!in.good()) { return -1; } else { textfilecomp->_pathname = strdup(pathname); TextGraphic* tg = new TextGraphic("", line_height); tg->SetFont(psstdfont); tg->SetColors(psblack, nil); tg->FillBg(false); textfilecomp->SetGraphic(tg); return 0; } } ivtools-1.2.11a1/src/OverlayUnidraw/textfile.h000066400000000000000000000063601214471147700212710ustar00rootroot00000000000000/* * Copyright (c) 1995,1999 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Text from File component declarations. */ #ifndef textfile_h #define textfile_h #include #include class TextFileScript; //: TextOvComp constructed by reading text from a file. class TextFileComp : public TextOvComp { public: TextFileComp(const char* pathname, const char* begstr, const char* endstr, int linewidth = -1, Graphic* gs = nil, OverlayComp* parent = nil); TextFileComp(istream&, OverlayComp* parent = nil); virtual ~TextFileComp(); virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); const char* GetPathname() { return _pathname; } const char* GetBegstr() { return _begstr; } const char* GetEndstr() { return _endstr; } int GetLineWidth() { return _linewidth; } void Init(); virtual boolean operator == (OverlayComp&); protected: ParamList* GetParamList(); void GrowParamList(ParamList*); static ParamList* _textfile_params; char* _pathname; char* _begstr; char* _endstr; int _linewidth; friend class TextFileScript; CLASS_SYMID2("TextFileComp", OVTEXTFILE_COMP); }; //: graphical view of a TextOvComp. class TextFileView : public TextOvView { public: TextFileView(TextFileComp* = nil); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); TextFileComp* GetTextFileComp(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: serialized view of a TextOvComp. class TextFileScript : public TextScript { public: TextFileScript(TextFileComp* = nil); virtual boolean Definition(ostream&); // output variable-length ASCII record that defines the component. virtual ClassId GetClassId(); virtual boolean IsA(ClassId); static int ReadTextFile(istream&, void*, void*, void*, void*); // method to read pathname of text file then read that file // in order to initialize a TextGraphic. }; #include #endif ivtools-1.2.11a1/src/TIFF/000077500000000000000000000000001214471147700150445ustar00rootroot00000000000000ivtools-1.2.11a1/src/TIFF/Copyright000066400000000000000000000022161214471147700167400ustar00rootroot00000000000000Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler Copyright (c) 1991, 1992 Silicon Graphics, Inc. Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the names of Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Sam Leffler and Silicon Graphics. THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ivtools-1.2.11a1/src/TIFF/HOWTO000066400000000000000000000013261214471147700156710ustar00rootroot00000000000000How To Obtain This Software (in case all you get is this file) The software is available for public ftp on sgi.com graphics/tiff/v3.0.tar.Z (192.48.153.1) ucbvax.berkeley.edu pub/tiff/v3.0.tar.Z (128.32.130.12) For example, ftp -n sgi.com .... user anonymous ... cd graphics/tiff binary get v3.0.tar.Z The software comes in a compressed tar file. To extract the information: zcat v3.0.tar.Z | tar xf - (uncompress and extract individual files in current directory). There is also a companion compressed tar file, v3.0pics.tar.Z that has sample TIFF image files. These are mostly useful in testing the software if/when you port it to an unsupported system. ivtools-1.2.11a1/src/TIFF/README000066400000000000000000000507261214471147700157360ustar00rootroot00000000000000NOTE: The file CHANGES-v3.0 has a list of changes between v2.4.2 and this software. TIFF Software "Release" 3.00 ---------------------------- This is Version 3.00 of my public domain TIFF support software. Included is a library, libtiff, for reading and writing TIFF files. The library, along with associated tool programs, should handle most of your needs for reading and writing files that follow the 5.0 TIFF spec for Classes B, G, P, and R. There is also considerable support for proposed additions that are to appear in the 6.0 TIFF spec. o core requirements both "MM" and "II" byte orders are handled multiple subfiles can be read and written editing is NOT supported in that related subfiles (e.g. a reduced resolution version of an image) are not automatically updated Tags handled: NewSubfileType, ImageWidth, ImageLength, Rowsperstrip, StripOffsets, StripByteCounts, XResolution, YResolution, ResolutionUnit. o Class B for bilevel images SamplesPerPixel = 1 BitsPerSample = 1 Compression = 1 (none), 2 (CCITT 1D), or 32773 (PackBits) PhotometricInterpretation = 0 (Min-is-White), 1 (Min-is-Black) o Class G for grayscale images SamplesPerPixel = 1 BitsPerSample = 4, 8 Compression = 1 (none) 5 (LZW) PhotometricInterpretation = 0 (Min-is-White), 1 (Min-is-Black) o Class P for palette color images SamplesPerPixel = 1 BitsPerSample = 1-8 Compression = 1 (none) 5 (LZW) PhotometricInterpretation = 3 (Palette RGB) ColorMap o Class R for RGB full color images SamplesPerPixel = 3 BitsPerSample = <8,8,8> PlanarConfiguration = 1, 2 Compression = 1 (none) 5 (LZW) PhotometricInterpretation = 2 (RGB) o Class F for facsimile (proposed appendix to 5.0 spec) (Class B tags plus...) Compression = 3 (CCITT Group 3), 4 (CCITT Group 4) FillOrder = 1 (MSB), 2 (LSB) Group3Options = 1 (2d encoding), 4 (zero fill), 5 (2d+fill) ImageWidth = 1728, 2048, 2482 NewSubFileType = 2 ResolutionUnit = 2 (Inch), 3 (Centimeter) PageNumber, XResolution, YResolution, Software, BadFaxLines, CleanFaxData, ConsecutiveBadFaxLines, DateTime, DocumentName, ImageDescription, Orientation o Class S for separated images (Appendix K to appear in 6.0) SamplesPerPixel = 4 PlanarConfiguration = 1, 2 Compression = 1 (none), 5 (LZW) PhotometricInterpretation = 5 (Separated) InkSet = 1 (CMYK) DotRange, InkNames, DotRange, TargetPrinter o Class Y for JPEG images (Appendix O to appear in 6.0) SamplesPerPixel = 3 BitsPerSample = <8,8,8> PlanarConfiguration = 1, 2 Compression = 1 (none), 5 (LZW), 32865 (JPEG) PhotometricInterpretation = 6 (YCbCr) YCbCrCoefficients, YCbCrSubsampling, YCbCrPositioning (colorimetry info from Appendix H; see below) o Class "JPEG" for JPEG images (Appendix P to appear in 6.0) PhotometricInterpretation = 1 (grayscale), 2 (RGB), 5 (CMYK), 6 (YCbCr) (Class Y tags if YCbCr) (Class S tags if CMYK) Compression = 6 (JPEG) JPEGProc = 0 (baseline) JPEGQTables = ... (offsets to per-channel Q matrices) JPEGDCTables = .... (offsets to per-channel DC tables) JPEGACTables = .... (offsets to per-channel AC tables) JPEGRestartInterval o Tiled Images (Appendix L to appear in 6.0) TileWidth TileLength TileOffsets TileByteCounts o Image Colorimetry Information (Appendix H to appear in 6.0) WhitePoint PrimaryChromaticities TransferFunction ReferenceBlackWhite In addition, the library supports some optional compression algorithms that are, in some cases, of dubious value. Compression = 32766 NeXT 2-bit encoding Compression = 32809 ThunderScan 4-bit encoding [JPEG compression should fit into this library simply by replacing the existing stub JPEG compression module. That is, all YCbCr and JPEG-related tags are supported in this version of the library.] The following tags are recognized and handled by the library (as described in the table). If no use is indicated, then the library reads and writes the tag, but does not use it internally. Tag Name Value R/W Library's Use ----------------------------------------------------- NewSubFileType 254 R/W (called SubFileType) SubFileType 255 R/W (called OSubFileType) ImageWidth 256 R/W lots ImageLength 257 R/W lots BitsPerSample 258 R/W lots Compression 259 R/W choosing compression routines PhotometricInterpretation 262 R/W Group 3 and JPEG code Thresholding 263 R/W CellWidth 264 parsed but ignored CellLength 265 parsed but ignored FillOrder 266 R/W control bit order DocumentName 269 R/W ImageDescription 270 R/W Make 271 R/W Model 272 R/W StripOffsets 273 R/W data i/o Orientation 274 R/W SamplesPerPixel 277 R/W lots RowsPerStrip 278 R/W data i/o StripByteCounts 279 R/W data i/o MinSampleValue 280 R/W MaxSampleValue 281 R/W XResolution 282 R/W YResolution 283 R/W used by Group 3 2d encoding PlanarConfiguration 284 R/W data i/o PageName 285 R/W XPosition 286 R/W YPosition 286 R/W FreeOffsets 288 parsed but ignored FreeByteCounts 289 parsed but ignored GrayResponseUnit 290 parsed but ignored GrayResponseCurve 291 parsed but ignored Group3Options 292 R/W used by Group 3 code Group4Options 293 R/W ResolutionUnit 296 R/W PageNumber 297 R/W ColorResponseUnit 300 parsed but ignored TransferFunction 301 R/W Software 305 R/W DateTime 306 R/W Artist 315 R/W HostComputer 316 R/W Predictor 317 R/W used by LZW code WhitePoint 318 R/W PrimaryChromacities 319 R/W ColorMap 320 R/W TileWidth 322 R/W data i/o TileLength 323 R/W data i/o TileOffsets 324 R/W data i/o TileByteCounts 324 R/W data i/o BadFaxLines 326 R/W CleanFaxData 327 R/W ConsecutiveBadFaxLines 328 R/W InkSet 332 R/W InkNames 333 R/W DotRange 336 R/W TargetPrinter 337 R/W ExtraSamples 338 R/W SampleFormat 339 R/W JPEGProc 512 R/W JPEG code JPEGQRestartInterval 515 R/W JPEG code JPEGQTables 519 R/W JPEG code JPEGDCTables 520 R/W JPEG code JPEGACTables 521 R/W JPEG code YCbCrCoefficients 529 R/W used by TIFFReadRGBAImage YCbCrSubsampling 530 R/W tile/strip size calculations YCbCrPositioning 531 R/W ReferenceBlackWhite 532 R/W Matteing 32995 R DataType 32996 R ImageDepth 32997 R/W tile/strip calculations TileDepth 32998 R/W tile/strip calculations The Matteing and DataType tags have been obsoleted by the 6.0 ExtraSamples and SampleFormat tags. Note that the ExtraSamples tag is only supported as needed to store Associated Alpha data. Consult the documentation on the ExtraSamples tag and Associated Alpha for elaboration. Note however that if you use Associated Alpha, you are expected to save data that is pre-multipled by Alpha. If this means nothing to you, check out Porter & Duff's paper in the '84 SIGGRAPH proceedings: "Compositing Digital Images". The ImageDepth tag is a non-standard, but registered tag that specifies the Z-dimension of volumetric data. The combination of ImageWidth, ImageLength, and ImageDepth, defines a 3D volume of pixels that are further specified by BitsPerSample and SamplesPerPixel. The TileDepth tag (also non-standard, but registered) can be used to specified a subvolume "tiling" of a volume of data. The JPEG, Colorimetry, and CMYK tags are planned additions for TIFF 6.0. Consult the appropriate TIFF appendices for the descriptions of these tags. LIBTIFF ------- Libtiff is the software library that you can use to read and write TIFF files (most all the tools use it to do their work). The library provides two interfaces, one for strip-based images and one for tile-based images. The normal interface is through a simple scanline-based interface that works with images comprised of strips. For example, to read the contents of a file, the following might be used: #include "tiffio.h" TIFF *tif; unsigned long imagelength; char *buf; long row; tif = TIFFOpen("myfile.tif", "r"); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength); buf = malloc(TIFFScanlineSize(tif)); for (row = 0; row < imagelength; row++) TIFFReadScanline(tif, buf, row); (this example assumes samples are packed contiguously.) Similarly, to write a file, something like the following can be used: tif = TIFFOpen("myfile.tif", "w"); TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, imagewidth); TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW); ... row = 0; while (...more scanlines to write...) TIFFWriteScanline(tif, buf, row); TIFFClose(tif); (once again, we assume samples are packed contiguously.) A 2D tile-based interface is also provided as an alternative to the scanline-orientated interfaces. With this interface, an image is broken up into a set of rectangular areas called tiles. All the tiles in an image have the same size, and the tile width and length must each be a multiple of 16 pixels. Tiles are ordered left-to-right and top-to-bottom in an image. As for scanlines, samples can be packed contiguously or separately. When separated, all the tiles for a sample are colocated in the file. That is, all the tiles for sample 0 appear before the tiles for sample 1, etc. Tiles and strips may also be extended in a z dimension to form volumes. Data volumes are organized as "slices". That is, all the data for a slice is colocated. Volumes whose data is organized in tiles can also have a tile depth so that data can be organized in cubes. The interface for tiles is similar to scanlines. To read a tiled image, code of the following sort might be used: unsigned long imageWidth, imageLength; unsigned long tileWidth, tileLength; unsigned long x, y; char *buf; tif = TIFFOpen("myfile.tif", "r"); TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imageWidth); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imageLength); TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tileWidth); TIFFGetField(tif, TIFFTAG_TILELENGTH, &tileLength); buf = malloc(TIFFTileSize(tif)); for (y = 0; y < imageLength; y += tileLength) for (x = 0; x < imageWidth; x += tileWidth) TIFFReadTile(tif, buf, x, y, 0); (once again, we assume samples are packed contiguously.) Note that unlike the stdio library, libtiff only supports reading OR writing of a file. There is also an append mode, but this has not really been tested. TOOLS ----- There are two device-dependent programs: o tiffgt is used to display the contents of a TIFF file on a framebuffer. The version included in this release was written for the Silicon Graphics Graphics Library (GL), although it should be a simple matter to tailor it for other systems. o tiffsv is used to save all or part of a framebuffer in a TIFF file. Once again, the version of tiffsv included here was written for the GL, but should be tailorable to other devices. (Note, tiffsv uses the readdisplay routine that was introduced in IRIX 4.0.) The remaining programs should be device-independent: o tiffinfo formats information about one or more TIFF files o tiffdump displays the verbatim contents of the TIFF directory in a file (it's very useful for debugging bogus files that you may get from someone that claims they support TIFF). o tiffcp is used to copy, concatenate, and convert TIFF images (e.g. switching from Compression=5 to Compression=1). o tiff2ps is a program that converts a TIFF image to PostScript. o tiffcmp can be used to compare the contents of two TIFF files (it does not check all the directory information, but does check all the data). o tiff2bw is a simple program to convert a color image to grayscale. o ras2tiff is a quick hack that converts Sun rasterfile format images to TIFF -- it's less than complete. o rgb2ycbcr converts an RGB, grayscale, or bilevel TIFF image to a YCbCr TIFF image. o gif2tiff is a quick hack that converts GIF 87a format images to TIFF. o ppm2tiff is a quick hack that converts PPM format images to TIFF. o fax2tiff converts raw Group 3 facsimile data to TIFF. o pal2rgb converts a Palette color image to a full color RGB image by applying the colormap. o tiffdither dithers a b&w image into a bilevel image (suitable for use in creating fax files) o tiffsplit creates one or more single-image files from a (possibly) multi-image file o Finally, tiffmedian is a version of Paul Heckbert's median cut program that reads an RGB TIFF image, and creates a TIFF palette file as a result. It's useful for converting full-color RGB images to 8-bit color for your friends that have cheapo 8-bit framebuffers. There is also: o sgi2tiff, a program to convert SGI image files to TIFF. This program is only useful on SGI machines as it uses -limage. Check out the manual pages for details about the above programs. CONTRIBUTED STUFF: ----------------- The directory contrib has contributed software: contrib/dbs an X-based TIFF viewer from Dan & Chris Sears contrib/ras two programs by Patrick Naughton for converting between Sun rasterfile format and TIFF (these require libpixrect.a, as opposed to the one in tools that doesn't) contrib/fax2ps a program that converts TIFF/F images to an encoded form of PostScript that is faster to print than just dumping a full raster contrib/vms scripts and files from Karsten Spang for building the library and tools under VMS contrib/xv patches to XV version 2.00 to make it support TIFF (XV is an X-based viewer from John Bradley) Don't send me mail asking about these programs. Send questions and/or bug reports directly to the authors. DOCUMENTATION: ------------- A copy of the 5.0 spec is included in the doc directory. This document was obtained by Bill Johnston of LBL who retrieved it from simtel20. Beware that the document has been modified slightly from the original version to enhance printability. We've tried to be very careful in making any changes, but there's always the possibility of mistakes being introduced. Another document describes a proposed addition to TIFF 6.0 for Associated Alpha data (i.e. what is now the Matteing tag). TEST IMAGES: ----------- Test images are available for most formats supported by the library. The images are kept in a separate archive that should be located along with this software. If the archive that you retrieve was v3.0.tar.Z, then the images should be in the same directory in an archive named v3.0pics.tar.Z. BUILDING THE SOFTWARE --------------------- The software, as distributed, is setup for building the software on an SGI machine (release 4.0.1 if you care). To configure things for your machine, check for Makefiles in the libtiff and tools directories for your machine: Makefile.aix Makefile for an IBM RS/6000 running AIX Makefile.apollo Makefile for an Apollo Makefile.hpux Makefile for HP machines running HP-UX Makefile.mips Makefile for a MIPS running MIPS OS 2.? Makefile.next Makefile for a NeXT Makefile.sgi Makefile for a VGX, GT, GTX, or Personal Iris Makefile.sun Makefile for a Sun-3 or Sun-4 running SunOS 3.5+ Makefile.tahoe Makefile for a TAHOE running 4.3BSD Makefile.vax Makefile for a VAX running 4.3BSD If your machine is not represented, you'll have to make up a Makefile that is right for you. In libtiff the important things to setup are AR=/usr/bin/ar whatever your library archiver is called RANLIB=/usr/bin/ranlib if you need to ranlib a library IPATH=-I. -I/usr/include/bsd list of directories to search includes CONF=.... configuring optional support To build the library, just cd libtiff; make In the tools directory, you'll want to setup the MACHALL macro, MACHALL=ras2tiff tiffgt tiffsv and add definitions for how to build tiffgt and tiffsv for your machine (if appropriate). Note also that for building the fax2tiff program, the CONF_LIBRARY macro in the Makefile MUST agree with the definition in the Makefile in the libtiff directory! If this is not true, then fax2tiff will not work. To build the tools library, just cd ../tools; make CHECKING OUT THE SOFTWARE ------------------------- Assuming you have working versions of tiffgt and tiffsv, you can just use them to view any of the sample images (the list is given below). Otherwise, you can check out the operation of the library with tiffcp and tiffcmp. For example, tiffcp -lzw cramps.tif x.tif tiffcmp cramps.tif x.tif (tiffcmp should be silent if the files compare correctly). BUGS AND SUCH.... ----------------- This software is free. The only thing that I ask in return is that you tell me when you find a problem or fix a bug. I also gladly accept software contributions, although I hesitate to include such software in my regular stuff if I am personally unable to test it. There is a mailing list associated with the software, tiff@ucbvax.berkeley.edu, that you can join by sending a message to tiff-request@ucbvax.berkeley.edu. You can also reach me directly at sam@sgi.com. ACKNOWLEDGEMENTS ---------------- The LZW algorithm is derived from the compress program (the proper attribution is included in the source code). The Group 3 fax stuff originated as code from Jef Poskanzer, but has since been rewritten several times. The latest version uses an algorithm from Michael Marking -- consult libtiff/mkg3states.c for further information. Many other people have, by now, helped with bug fixes and code. WARNING ------- It appears that Unisys is actively pursuing copyright control on the LZW compression algorithm. In particular, users of the LZW compression within the TIFF framework. For this reason the TIFF 6.0 spec will state that LZW compression is not recommended. It is unclear at this time what compression algorithm will be used in place of it. I have no idea what this means to you or to this library. I make no warranty or guarantees with regard to the LZW support in this library. FILE CONTENTS ------------- At least the following files are included in the distribution: libtiff/prototypes.h stuff for ANSI function prototypes libtiff/tiff.h TIFF spec definitions libtiff/tiffio.h public TIFF library definitions libtiff/tiffioP.h private TIFF library definitions libtiff/tiffcompat.h UNIX-compatibility definitions libtiff/t4.h CCITT Group 3 1d code tables+definitions libtiff/tif_fax3.h CCITT Group 3-related definitions libtiff/tif_aux.c auxilary directory-related functions libtiff/tif_ccittrle.c CCITT 1d Huffman compression libtiff/tif_compat.c OS-related compatibility stuff libtiff/tif_compress.c list of supported compression algorithms libtiff/tif_dir.c directory tag interface code libtiff/tif_dirinfo.c directory known tag support code libtiff/tif_dirread.c directory reading code libtiff/tif_dirwrite.c directory writing code libtiff/tif_dumpmode.c "no" compression algorithm libtiff/tif_fax3.c CCITT Group 3 fax compression libtiff/tif_fax4.c CCITT Group 4 fax compression libtiff/tif_getimage.c code to read an entire image into an RGBA raster libtiff/tif_jpeg.c JPEG compression placeholder libtiff/tif_lzw.c LZW encoding and decoding libtiff/tif_next.c NeXT 2-bit decoding algorithm (no encoding) libtiff/tif_machdep.c machine/architecture-specific code libtiff/tif_open.c open and simply query code libtiff/tif_packbits.c Packbits encoding and decoding libtiff/tif_print.c directory printing support libtiff/tif_swab.c byte and bit swapping support libtiff/tif_strip.c some strip-related code libtiff/tif_thunder.c Thunderscan decoding (no encoding) libtiff/tif_tile.c some tile-related code libtiff/mkg3states.c program to generate G3 decoding state tables libtiff/mkspans.c program to generate black-white span tables tools/getopt.c public domain getopt from Berkeley used by tools tools/fax2tiff.c convert raw facsimile data to TIFF tools/gif2tiff.c convert GIF87 file to TIFF tools/pal2rgb.c convert TIFF Palette image to TIFF RGB tools/ppm2tiff.c convert PPM image file to TIFF tools/ras2tiff.c convert Sun rasterfile format to TIFF (limited) tools/rgb2ybcr.c convert TIFF to YCbCr TIFF tools/sgi2tiff.c convert SGI image file to TIFF tools/sgigt.c TIFF picture get for SGI framebuffer (uses GL) tools/sgisv.c save image on SGI framebuffer in TIFF file tools/tiff2bw.c convert color TIFF file to B&W tools/tiff2ps.c convert TIFF to PostScript tools/tiffcmp.c compare two TIFF files tools/tiffcp.c copy/convert TIFF files (used to change compression) tools/tiffdither.c dither grayscale to bilevel tools/tiffdump.c dump TIFF header and directory tags w/o library tools/tiffinfo.c print info about TIFF file(s) tools/tiffmedian.c median cut RGB -> palette conversion program tools/tiffsplit.c split a multi-page TIFF into single-page TIFFs tools/ycbcr.c RGB->YCbCr->RGB test program doc/5.0spec raw text version of TIFF 5.0 spec doc/ClassF.txt raw text version of current Class F (fax) document doc/alpha.ps PostScript version of proposed TIFF 6.0 appendix doc/extra.ps PostScript version of proposed TIFF 6.0 tag doc/TIFF6.ps PostScript version of 1st draft of TIFF 6.0 spec man/man1 UNIX manual pages for tools man/man3 UNIX manual pages for libtiff functions ivtools-1.2.11a1/src/TIFF/VERSION000066400000000000000000000000051214471147700161070ustar00rootroot000000000000003.00 ivtools-1.2.11a1/src/TIFF/machdep.h000066400000000000000000000167041214471147700166260ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991 Sam Leffler * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _MACHDEP_ #define _MACHDEP_ /* * Machine dependent definitions: * o floating point formats * o byte ordering * * NB, there are lots of assumptions here: * - 32-bit natural integers (sign extension code) * - native float is 4 bytes (floating point conversion) * - native double is 8 bytes (floating point conversion) */ #if defined(sun) || defined(sparc) || defined(stellar) || defined(MIPSEB) || defined(hpux) || defined(apollo) || defined(NeXT) || defined(_IBMR2) #define BIGENDIAN 1 #define IEEEFP #endif /* sun || sparc || stellar || MIPSEB || hpux || apollo || NeXT || _IBMR2 */ /* MIPSEL = MIPS w/ Little Endian byte ordering (e.g. DEC 3100) */ #if defined(MIPSEL) #define BIGENDIAN 0 #define IEEEFP #endif /* MIPSEL */ #ifdef transputer #define BIGENDIAN 0 #define IEEEFP /* IEEE floating point supported */ #endif /* transputer */ #if defined(m386) || defined(M_I86) || defined(i386) || defined(__x64_64__) #define BIGENDIAN 0 #define IEEEFP /* IEEE floating point supported */ #endif /* m386 || M_I86 || i386 */ #ifdef IEEEFP typedef struct ieeedouble nativedouble; typedef struct ieeefloat nativefloat; #define ISFRACTION(e) (1022 - 4 <= (e) && (e) <= 1022 + 15) #define EXTRACTFRACTION(dp, fract) \ ((fract) = ((unsigned long)(1<<31)|((dp)->native.mant<<11)|\ ((dp)->native.mant2>>21)) >> (1022+16-(dp)->native.exp)) #define EXTRACTEXPONENT(dp, exponent) ((exponent) = (dp)->native.exp) #define NATIVE2IEEEFLOAT(fp) #define IEEEFLOAT2NATIVE(fp) #define IEEEDOUBLE2NATIVE(dp) #define TIFFSwabArrayOfFloat(fp,n) TIFFSwabArrayOfLong((unsigned long *)fp,n) #define TIFFSwabArrayOfDouble(dp,n) TIFFSwabArrayOfLong((unsigned long *)dp,2*n) #endif /* IEEEFP */ #ifdef tahoe #define BIGENDIAN 1 typedef struct { unsigned sign:1; unsigned exp:8; unsigned mant:23; unsigned mant2; } nativedouble; typedef struct { unsigned sign:1; unsigned exp:8; unsigned mant:23; } nativefloat; #define ISFRACTION(e) (128 - 4 <= (e) && (e) <= 128 + 15) #define EXTRACTFRACTION(dp, fract) \ ((fract) = ((1<<31)|((dp)->native.mant<<8)|((dp)->native.mant2>>15)) >> \ (128+16-(dp)->native.exp)) #define EXTRACTEXPONENT(dp, exponent) ((exponent) = (dp)->native.exp - 2) /* * Beware, over/under-flow in conversions will * result in garbage values -- handling it would * require a subroutine call or lots more code. */ #define NATIVE2IEEEFLOAT(fp) { \ if ((fp)->native.exp) \ (fp)->ieee.exp = (fp)->native.exp - 129 + 127; /* alter bias */\ } #define IEEEFLOAT2NATIVE(fp) { \ if ((fp)->ieee.exp) \ (fp)->native.exp = (fp)->ieee.exp - 127 + 129; /* alter bias */\ } #define IEEEDOUBLE2NATIVE(dp) { \ if ((dp)->native.exp = (dp)->ieee.exp) \ (dp)->native.exp += -1023 + 129; \ (dp)->native.mant = ((dp)->ieee.mant<<3)|((dp)->native.mant2>>29); \ (dp)->native.mant2 <<= 3; \ } /* the following is to work around a compiler bug... */ #define SIGNEXTEND(a,b) { char ch; ch = (a); (b) = ch; } #define TIFFSwabArrayOfFloat(fp,n) TIFFSwabArrayOfLong((unsigned long *)fp,n) #define TIFFSwabArrayOfDouble(dp,n) TIFFSwabArrayOfLong((unsigned long *)dp,2*n) #endif /* tahoe */ #ifdef vax #define BIGENDIAN 0 typedef struct { unsigned mant1:7; unsigned exp:8; unsigned sign:1; unsigned mant2:16; unsigned mant3; } nativedouble; typedef struct { unsigned mant1:7; unsigned exp:8; unsigned sign:1; unsigned mant2:16; } nativefloat; #define ISFRACTION(e) (128 - 4 <= (e) && (e) <= 128 + 15) #define EXTRACTFRACTION(dp, fract) \ ((fract) = ((1<<31)|((dp)->native.mant1<<16)|(dp)->native.mant2)) >> \ (128+16-(dp)->native.exp)) #define EXTRACTEXPONENT(dp, exponent) ((exponent) = (dp)->native.exp - 2) /* * Beware, these do not handle over/under-flow * during conversion from ieee to native format. */ #define NATIVE2IEEEFLOAT(fp) { \ float_t t; \ if (t.ieee.exp = (fp)->native.exp) \ t.ieee.exp += -129 + 127; \ t.ieee.sign = (fp)->native.sign; \ t.ieee.mant = ((fp)->native.mant1<<16)|(fp)->native.mant2; \ *(fp) = t; \ } #define IEEEFLOAT2NATIVE(fp) { \ float_t t; int v = (fp)->ieee.exp; \ if (v) v += -127 + 129; /* alter bias of exponent */\ t.native.exp = v; /* implicit truncation of exponent */\ t.native.sign = (fp)->ieee.sign; \ v = (fp)->ieee.mant; \ t.native.mant1 = v >> 16; \ t.native.mant2 = v;\ *(fp) = v; \ } #define IEEEDOUBLE2NATIVE(dp) { \ double_t t; int v = (dp)->ieee.exp; \ if (v) v += -1023 + 129; /* if can alter bias of exponent */\ t.native.exp = v; /* implicit truncation of exponent */\ v = (dp)->ieee.mant; \ t.native.sign = (dp)->ieee.sign; \ t.native.mant1 = v >> 16; \ t.native.mant2 = v;\ t.native.mant3 = (dp)->mant2; \ *(dp) = t; \ } #define TIFFSwabArrayOfFloat(fp,n) TIFFSwabArrayOfLong((unsigned long *)fp,n) #define TIFFSwabArrayOfDouble(dp,n) TIFFSwabArrayOfLong((unsigned long *)dp,2*n) #endif /* vax */ /* * These unions are used during floating point * conversions. The macros given above define * the conversion operations. */ typedef struct ieeedouble { #if BIGENDIAN == 1 #if !defined(_IBMR2) unsigned sign:1; unsigned exp:11; unsigned long mant:20; unsigned mant2; #else /* _IBMR2 */ unsigned sign:1; unsigned exp:11; unsigned mant:20; unsigned mant2; #endif /* _IBMR2 */ #else #if !defined(vax) #ifdef INT_16_BIT /* MSDOS C compilers */ unsigned long mant2; unsigned long mant:20; unsigned long exp:11; unsigned long sign:1; #else /* 32 bit ints */ unsigned mant2; unsigned long mant:20; unsigned exp:11; unsigned sign:1; #endif /* 32 bit ints */ #else unsigned long mant:20; unsigned exp:11; unsigned sign:1; unsigned mant2; #endif /* !vax */ #endif } ieeedouble; typedef struct ieeefloat { #if BIGENDIAN == 1 #if !defined(_IBMR2) unsigned sign:1; unsigned exp:8; unsigned long mant:23; #else /* _IBMR2 */ unsigned sign:1; unsigned exp:8; unsigned mant:23; #endif /* _IBMR2 */ #else #ifdef INT_16_BIT /* MSDOS C compilers */ unsigned long mant:23; unsigned long exp:8; unsigned long sign:1; #else /* 32 bit ints */ unsigned long mant:23; unsigned exp:8; unsigned sign:1; #endif /* 32 bit ints */ #endif } ieeefloat; typedef union { ieeedouble ieee; nativedouble native; char b[8]; double d; } double_t; typedef union { ieeefloat ieee; nativefloat native; char b[4]; float f; } float_t; #endif /* _MACHDEP_ */ ivtools-1.2.11a1/src/TIFF/mkg3states.c000066400000000000000000000575231214471147700173110ustar00rootroot00000000000000/* * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Program to construct Group 3 & Group 4 decoding tables. * * This code is derived from code by Michael P. Marking. In * particular, the algorithms to generate the null_mode and * horiz_mode state tables are his. See the comments below * for more information. * * BEGIN (from the original source) LEGAL * Copyright 1989, 1990 Michael P. Marking, Post Office Box 8039, * Scottsdale, Arizona 85252-8039. All rights reserved. * * License is granted by the copyright holder to distribute and use this * code without payment of royalties or the necessity of notification as * long as this notice (all the text under "LEGAL") is included. * * This program is offered without any warranty of any kind. It includes * no warranty of merchantability or fitness for any purpose. Testing and * suitability for any use are the sole responsibility of the user. * INFORMATION * Although there is no support offered with this program, the author will * endeavor to correct errors. Updates will also be made available from * time to time. * * Contact: Michael P. Marking, Post Office Box 8039, Scottsdale, Arizona * 85252-8039 USA. Replies are not guaranteed to be swift. Beginning * July 1990, e-mail may be sent to uunet!ipel!marking. * * Also beginning in July 1990, this code will be archived at the * ipel!phoenix BBS in file g3g4.zoo. The 24-hour telephone number * for 300/1200/2400 is (602)274-0462. When logging in, specify user * "public", system "bbs", and password "public". * * This code is also available from the C Users Group in volume 317. * * END (from the original source) */ #include #include #include "prototypes.h" #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #define WHITE 0 #define BLACK 1 /* * G3 2D and G4 decoding modes. Note that * the vertical modes are ordered so that * (mode - MODE_VERT_V0) gives the vertical * adjustment for the b1 parameter. */ #define MODE_NULL 0 #define MODE_PASS 1 #define MODE_HORIZ 2 #define MODE_VERT_VL3 3 #define MODE_VERT_VL2 4 #define MODE_VERT_VL1 5 #define MODE_VERT_V0 6 #define MODE_VERT_VR1 7 #define MODE_VERT_VR2 8 #define MODE_VERT_VR3 9 #define MODE_UNCOMP 10 #define MODE_ERROR 11 #define MODE_ERROR_1 12 unsigned long DECLARE1(append_0, unsigned long, prefix) { return (prefix + (1L<<16)); } unsigned long DECLARE1(append_1, unsigned long, prefix) { static unsigned short prefix_bit[16] = { 0x8000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0400, 0x0200, 0x0100, 0x0080, 0x0040, 0x0020, 0x0010, 0x0008, 0x0004, 0x0002, 0x0001 }; unsigned char len = (prefix >> 16) & 0xf; return (append_0(prefix) + prefix_bit[len]); } #define G3CODES #include "t4.h" short #if defined(__STDC__) || defined(__EXTENDED__) || USE_CONST DECLARE3(search_table, unsigned long, prefix, tableentry const*, tab, int, n) #else DECLARE3(search_table, unsigned long, prefix, tableentry*, tab, int, n) #endif { unsigned short len = (prefix >> 16) & 0xf; unsigned short code = (prefix & 0xffff) >> (16 - len); while (n-- > 0) { if (tab->length == len && tab->code == code) return ((short) tab->runlen); tab++; } return (G3CODE_INCOMP); } #define NCODES(a) (sizeof (a) / sizeof (a[0])) short DECLARE1(white_run_length, unsigned long, prefix) { return (search_table(prefix, TIFFFaxWhiteCodes, NCODES(TIFFFaxWhiteCodes))); } short DECLARE1(black_run_length, unsigned long, prefix) { return (search_table(prefix, TIFFFaxBlackCodes, NCODES(TIFFFaxBlackCodes))); } #undef NCODES #define MAX_NULLPREFIX 200 /* max # of null-mode prefixes */ typedef unsigned char NullModeTable[MAX_NULLPREFIX][256]; #define MAX_HORIZPREFIX 250 /* max # of incomplete 1-D prefixes */ typedef unsigned char HorizModeTable[MAX_HORIZPREFIX][256]; /* the bit string corresponding to this row of the decoding table */ long null_mode_prefix[MAX_NULLPREFIX]; NullModeTable null_mode; /* MODE_*, indexed by bit and byte */ NullModeTable null_mode_next_state; /* next row of decoding tables to use */ /* number of prefixes or rows in the G4 decoding tables */ short null_mode_prefix_count = 0; /* * 2D uncompressed mode codes. Note * that two groups of codes are arranged * so that the decoder can caluclate the * length of the run by subtracting the * code from a known base value. */ #define UNCOMP_INCOMP 0 /* runs of [0]*1 */ #define UNCOMP_RUN0 1 #define UNCOMP_RUN1 2 #define UNCOMP_RUN2 3 #define UNCOMP_RUN3 4 #define UNCOMP_RUN4 5 #define UNCOMP_RUN5 6 #define UNCOMP_RUN6 7 /* runs of [0]* w/ terminating color */ #define UNCOMP_TRUN0 8 #define UNCOMP_TRUN1 9 #define UNCOMP_TRUN2 10 #define UNCOMP_TRUN3 11 #define UNCOMP_TRUN4 12 /* special code for unexpected EOF */ #define UNCOMP_EOF 13 /* invalid code encountered */ #define UNCOMP_INVALID 14 long uncomp_mode_prefix[MAX_NULLPREFIX]; NullModeTable uncomp_mode; NullModeTable uncomp_mode_next_state; short uncomp_mode_prefix_count = 0; /* * Decoding action values for horiz_mode. */ #define ACT_INCOMP 0 /* incompletely decoded code */ #define ACT_INVALID 1 /* invalide code */ #define ACT_WRUNT 2 /* terminating white run code */ #define ACT_WRUN 65 /* non-terminating white run code */ #define ACT_BRUNT 106 /* terminating black run code */ #define ACT_BRUN 169 /* non-terminating black run code */ #define ACT_EOL 210 /* end-of-line code */ HorizModeTable horiz_mode; short DECLARE1(horiz_mode_code_black, short, runlen) { return (runlen < 64 ? runlen + ACT_BRUNT : (runlen / 64) + ACT_BRUN); } short DECLARE1(horiz_mode_code_white, short, runlen) { return (runlen < 64 ? runlen + ACT_WRUNT : (runlen / 64) + ACT_WRUN); } /* * If the corresponding horiz_mode entry is ACT_INCOMP * this entry is a row number for decoding the next byte; * otherwise, it is the bit number with which to continue * decoding the next codeword. */ HorizModeTable horiz_mode_next_state; /* prefixes corresponding to the rows of the decoding table */ long horiz_mode_prefix[MAX_HORIZPREFIX]; /* color of next run, BLACK or WHITE */ char horiz_mode_color[MAX_HORIZPREFIX]; short horiz_mode_prefix_count = 0; static unsigned char bit_mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; #if USE_PROTOTYPES void build_null_mode_tables(void); short find_horiz_mode_prefix(long, char); short find_null_mode_prefix(long); short null_mode_type(long); void build_horiz_mode_tables(void); short horiz_mode_code_black(short); short horiz_mode_code_white(short); void build_uncomp_mode_tables(void); void write_tables(FILE*); #else void build_null_mode_tables(); short find_horiz_mode_prefix(); short find_null_mode_prefix(); short null_mode_type(); void build_horiz_mode_tables(); short horiz_mode_code_black(); short horiz_mode_code_white(); void build_uncomp_mode_tables(); void write_tables(); #endif int verbose = FALSE; char *storage_class = ""; int DECLARE2(main, int, argc, char**, argv) { while (argc > 1 && argv[1][0] == '-') { if (strcmp(argv[1], "-v") == 0) { verbose = TRUE; argc--, argv++; } else if (strcmp(argv[1], "-c") == 0) { storage_class = "const "; argc--, argv++; } } build_null_mode_tables(); /* null mode decoding tables */ if (verbose) { fprintf(stderr, "%d null mode prefixes defined\n", (int) null_mode_prefix_count); fprintf(stderr, "building uncompressed mode scripts...\n"); } build_uncomp_mode_tables(); /* uncompressed mode decoding tables */ if (verbose) { fprintf(stderr, "%d uncompressed mode prefixes defined\n", (int) uncomp_mode_prefix_count); fprintf(stderr, "building 1D scripts...\n"); } build_horiz_mode_tables(); /* 1D decoding tables */ if (verbose) fprintf(stderr, "%d incomplete prefixes defined\n", (int) horiz_mode_prefix_count); write_tables(stdout); exit(0); } void DECLARE3(write_null_mode_table, FILE*, fd, NullModeTable, table, char*, name) { int i, j; char* outersep; char* sep; fprintf(fd, "%su_char\t%s[%d][256] = {", storage_class, name, (int) null_mode_prefix_count); outersep = ""; for (i = 0; i < null_mode_prefix_count; i++) { fprintf(fd, "%s\n/* prefix %d */ {\n", outersep, i); sep = " "; for (j = 0; j < 256; j++) { fprintf(fd, "%s%2d", sep, (int) table[i][j]); if (((j+1) % 16) == 0) { fprintf(fd, ", /* %3d-%3d */\n", j-15, j); sep = " "; } else sep = ","; } fprintf(fd, "}"); outersep = ","; } fprintf(fd, "\n};\n"); } void DECLARE3(write_horiz_mode_table, FILE*, fd, HorizModeTable, table, char*, name) { int i, j; char* outersep; char* sep; fprintf(fd, "%s u_char\t%s[%d][256] = {", storage_class, name, (int) horiz_mode_prefix_count); outersep = ""; for (i = 0; i < horiz_mode_prefix_count; i++) { fprintf(fd, "%s\n/* prefix %d */ {\n", outersep, i); sep = " "; for (j = 0; j < 256; j++) { fprintf(fd, "%s%3d", sep, (int) table[i][j]); if (((j+1) % 14) == 0) { fprintf(fd, ", /* %3d-%3d */\n", j-13, j); sep = " "; } else sep = ","; } fprintf(fd, "\n}"); outersep = ","; } fprintf(fd, "\n};\n"); } void write_define(fd, name, value, comment) FILE *fd; char *name; int value; char *comment; { fprintf(fd, "#define\t%s\t%d", name, value); if (comment) fprintf(fd, "\t/* %s */", comment); fprintf(fd, "\n"); } void write_preamble(fd) FILE *fd; { fprintf(fd, "%s\n", "/* DO NOT EDIT THIS FILE, IT WAS AUTOMATICALLY CREATED BY mkg3state */"); write_define(fd, "ACT_INCOMP", ACT_INCOMP, "incompletely decoded code"); write_define(fd, "ACT_INVALID", ACT_INVALID, "invalide code"); write_define(fd, "ACT_WRUNT", ACT_WRUNT, "terminating white run code"); write_define(fd, "ACT_WRUN", ACT_WRUN, "non-terminating white run code"); write_define(fd, "ACT_BRUNT", ACT_BRUNT, "terminating black run code"); write_define(fd, "ACT_BRUN", ACT_BRUN, "non-terminating black run code"); write_define(fd, "ACT_EOL", ACT_EOL, "end-of-line code"); fprintf(fd, "\n"); fprintf(fd, "/* modes that the decoder can be in */\n"); write_define(fd, "MODE_NULL", MODE_NULL, NULL); write_define(fd, "MODE_PASS", MODE_PASS, NULL); write_define(fd, "MODE_HORIZ", MODE_HORIZ, NULL); write_define(fd, "MODE_VERT_V0", MODE_VERT_V0, NULL); write_define(fd, "MODE_VERT_VR1", MODE_VERT_VR1, NULL); write_define(fd, "MODE_VERT_VR2", MODE_VERT_VR2, NULL); write_define(fd, "MODE_VERT_VR3", MODE_VERT_VR3, NULL); write_define(fd, "MODE_VERT_VL1", MODE_VERT_VL1, NULL); write_define(fd, "MODE_VERT_VL2", MODE_VERT_VL2, NULL); write_define(fd, "MODE_VERT_VL3", MODE_VERT_VL3, NULL); write_define(fd, "MODE_UNCOMP", MODE_UNCOMP, NULL); write_define(fd, "MODE_ERROR", MODE_ERROR, NULL); write_define(fd, "MODE_ERROR_1", MODE_ERROR_1, NULL); fprintf(fd, "\n"); fprintf(fd, "#define\tRUNLENGTH(ix) (TIFFFaxWhiteCodes[ix].runlen)\n"); fprintf(fd, "\n"); write_define(fd, "UNCOMP_INCOMP", UNCOMP_INCOMP, NULL); fprintf(fd, "/* runs of [0]*1 */\n"); write_define(fd, "UNCOMP_RUN0", UNCOMP_RUN0, NULL); write_define(fd, "UNCOMP_RUN1", UNCOMP_RUN1, NULL); write_define(fd, "UNCOMP_RUN2", UNCOMP_RUN2, NULL); write_define(fd, "UNCOMP_RUN3", UNCOMP_RUN3, NULL); write_define(fd, "UNCOMP_RUN4", UNCOMP_RUN4, NULL); write_define(fd, "UNCOMP_RUN5", UNCOMP_RUN5, NULL); write_define(fd, "UNCOMP_RUN6", UNCOMP_RUN6, NULL); fprintf(fd, "/* runs of [0]* w/ terminating color */\n"); write_define(fd, "UNCOMP_TRUN0", UNCOMP_TRUN0, NULL); write_define(fd, "UNCOMP_TRUN1", UNCOMP_TRUN1, NULL); write_define(fd, "UNCOMP_TRUN2", UNCOMP_TRUN2, NULL); write_define(fd, "UNCOMP_TRUN3", UNCOMP_TRUN3, NULL); write_define(fd, "UNCOMP_TRUN4", UNCOMP_TRUN4, NULL); fprintf(fd, "/* special code for unexpected EOF */\n"); write_define(fd, "UNCOMP_EOF", UNCOMP_EOF, NULL); fprintf(fd, "/* invalid code encountered */\n"); write_define(fd, "UNCOMP_INVALID", UNCOMP_INVALID, NULL); fprintf(fd, "/* codes >= terminate uncompress mode */\n"); fprintf(fd, "#define\tUNCOMP_EXIT UNCOMP_TRUN0\n"); fprintf(fd, "\n"); } void extern_table(fd, name) FILE* fd; char* name; { fprintf(fd, "extern\t%su_char %s[][256];\n", storage_class, name); } void write_tables(fd) FILE* fd; { write_preamble(fd); fprintf(fd, "#ifdef G3STATES\n"); write_null_mode_table(fd, null_mode, "TIFFFax2DMode"); write_null_mode_table(fd, null_mode_next_state, "TIFFFax2DNextState"); write_null_mode_table(fd, uncomp_mode, "TIFFFaxUncompAction"); write_null_mode_table(fd, uncomp_mode_next_state, "TIFFFaxUncompNextState"); write_horiz_mode_table(fd, horiz_mode, "TIFFFax1DAction"); write_horiz_mode_table(fd, horiz_mode_next_state, "TIFFFax1DNextState"); fprintf(fd, "#else\n"); extern_table(fd, "TIFFFax2DMode"); extern_table(fd, "TIFFFax2DNextState"); extern_table(fd, "TIFFFaxUncompAction"); extern_table(fd, "TIFFFaxUncompNextState"); extern_table(fd, "TIFFFax1DAction"); extern_table(fd, "TIFFFax1DNextState"); fprintf(fd, "#endif\n"); } short DECLARE1(find_null_mode_prefix, long, prefix) { short j1; if (prefix == 0L) return (0); for (j1 = 8; j1 < null_mode_prefix_count; j1++) if (prefix == null_mode_prefix[j1]) return (j1); if (null_mode_prefix_count == MAX_NULLPREFIX) { fprintf(stderr, "ERROR: null mode prefix table overflow\n"); exit(1); } if (verbose) fprintf(stderr, "adding null mode prefix[%d] 0x%lx\n", (int) null_mode_prefix_count, prefix); null_mode_prefix[null_mode_prefix_count++] = prefix; return (null_mode_prefix_count-1); } short DECLARE2(find_horiz_mode_prefix, long, prefix, char, color) { short j1; for (j1 = 0; j1 < horiz_mode_prefix_count; j1++) if (prefix == horiz_mode_prefix[j1] && horiz_mode_color[j1] == color) return (j1); /* * It wasn't found, so add it to the tables, but first, is there room? */ if (horiz_mode_prefix_count == MAX_HORIZPREFIX) { fprintf(stderr, "ERROR: 1D prefix table overflow\n"); exit(1); } /* OK, there's room... */ if (verbose) fprintf(stderr, "\nhoriz mode prefix %d, color %c = 0x%lx ", (int) horiz_mode_prefix_count, "WB"[color], prefix); horiz_mode_prefix[horiz_mode_prefix_count] = prefix; horiz_mode_color[horiz_mode_prefix_count] = color; horiz_mode_prefix_count++; return (horiz_mode_prefix_count - 1); } short DECLARE1(find_uncomp_mode_prefix, long, prefix) { short j1; if (prefix == 0L) return (0); for (j1 = 8; j1 < uncomp_mode_prefix_count; j1++) if (prefix == uncomp_mode_prefix[j1]) return (j1); if (uncomp_mode_prefix_count == MAX_NULLPREFIX) { fprintf(stderr, "ERROR: uncomp mode prefix table overflow\n"); exit(1); } if (verbose) fprintf(stderr, "adding uncomp mode prefix[%d] 0x%lx\n", (int) uncomp_mode_prefix_count, prefix); uncomp_mode_prefix[uncomp_mode_prefix_count++] = prefix; return (uncomp_mode_prefix_count-1); } short DECLARE1(null_mode_type, long, prefix) { switch (prefix) { case 0x18000L: return (MODE_VERT_V0); /* 1 */ case 0x36000L: return (MODE_VERT_VR1); /* 011 */ case 0x34000L: return (MODE_VERT_VL1); /* 010 */ case 0x32000L: return (MODE_HORIZ); /* 001 */ case 0x41000L: return (MODE_PASS); /* 0001 */ case 0x60C00L: return (MODE_VERT_VR2); /* 0000 11 */ case 0x60800L: return (MODE_VERT_VL2); /* 0000 10 */ case 0x70600L: return (MODE_VERT_VR3); /* 0000 011 */ case 0x70400L: return (MODE_VERT_VL3); /* 0000 010 */ case 0x80200L: return (MODE_ERROR); /* 0000 0010 */ case 0x90300L: return (MODE_ERROR); /* 0000 0011 0 */ case 0xA0380L: return (MODE_ERROR); /* 0000 0011 10 */ case 0xA03C0L: return (MODE_UNCOMP); /* 0000 0011 11 */ /* * Under the assumption that there are no * errors in the file, then this bit string * can only be the beginning of an EOL code. */ case 0x70000L: return (MODE_ERROR_1); /* 0000 000 */ } return (-1); } short DECLARE1(uncomp_mode_type, long, prefix) { short code; short len; switch (prefix) { case 0x18000L: return (UNCOMP_RUN1); /* 1 */ case 0x24000L: return (UNCOMP_RUN2); /* 01 */ case 0x32000L: return (UNCOMP_RUN3); /* 001 */ case 0x41000L: return (UNCOMP_RUN4); /* 0001 */ case 0x50800L: return (UNCOMP_RUN5); /* 0000 1 */ case 0x60400L: return (UNCOMP_RUN6); /* 0000 01 */ case 0x70200L: return (UNCOMP_TRUN0); /* 0000 001 */ case 0x80100L: return (UNCOMP_TRUN1); /* 0000 0001 */ case 0x90080L: return (UNCOMP_TRUN2); /* 0000 0000 1 */ case 0xA0040L: return (UNCOMP_TRUN3); /* 0000 0000 01 */ case 0xB0020L: return (UNCOMP_TRUN4); /* 0000 0000 001 */ } code = prefix & 0xffffL; len = (prefix >> 16) & 0xf; return ((code || len > 10) ? UNCOMP_INVALID : -1); } #define BASESTATE(b) ((unsigned char) ((b) & 0x7)) void build_null_mode_tables() { short prefix; /* * Note: the first eight entries correspond to * a null prefix and starting bit numbers 0-7. */ null_mode_prefix_count = 8; for (prefix = 0; prefix < null_mode_prefix_count; prefix++) { short byte; for (byte = 0; byte < 256; byte++) { short firstbit; short bit; long curprefix; char found_code = FALSE; if (prefix < 8) { curprefix = 0L; firstbit = prefix; } else { curprefix = null_mode_prefix[prefix]; firstbit = 0; } for (bit = firstbit; bit < 8 && !found_code; bit++) { short mode; if (bit_mask[bit] & byte) curprefix = append_1(curprefix); else curprefix = append_0(curprefix); switch (mode = null_mode_type(curprefix)) { case MODE_PASS: case MODE_HORIZ: case MODE_VERT_V0: case MODE_VERT_VR1: case MODE_VERT_VR2: case MODE_VERT_VR3: case MODE_VERT_VL1: case MODE_VERT_VL2: case MODE_VERT_VL3: case MODE_UNCOMP: case MODE_ERROR: case MODE_ERROR_1: /* * NOTE: if the bit number is 8, then the table * entry will be zero, which indicates a new byte * is to be fetched during the decoding process */ found_code = TRUE; null_mode[prefix][byte] = (unsigned char) mode; null_mode_next_state[prefix][byte] = BASESTATE(bit+1); break; } } if (!found_code) { null_mode_next_state[prefix][byte] = (unsigned char) find_null_mode_prefix(curprefix); /* * This indicates to the decoder that * no valid code has yet been identified. */ null_mode[prefix][byte] = MODE_NULL; } } } } void build_horiz_mode_tables() { unsigned short byte; short prefix; /* * The first 8 are for white, * the second 8 are for black, * beginning with bits 0-7. */ horiz_mode_prefix_count = 16; for (prefix = 0; prefix < horiz_mode_prefix_count; prefix++) for (byte = 0; byte < 256; byte++) { short bits_digested = 0; short bit; short firstbit; char color; unsigned long curprefix; if (prefix < 8) { color = WHITE; curprefix = 0L; firstbit = prefix; } else if (prefix < 16) { color = BLACK; curprefix = 0L; firstbit = prefix - 8; } else { color = horiz_mode_color[prefix]; curprefix = horiz_mode_prefix[prefix]; firstbit = 0; } for (bit = firstbit; bit < 8 && !bits_digested; bit++) { if (bit_mask[bit] & byte) curprefix = append_1(curprefix); else curprefix = append_0(curprefix); /* * The following conversion allows for arbitrary strings of * zeroes to precede the end-of-line code 0000 0000 0001. * It assumes no errors in the data, and is based on * the assumption that the code replaced (12 consecutive * zeroes) can only be "legally" encountered before the * end-of-line code. This assumption is valid only for * a Group 3 image; the combination will never occur * in horizontal mode in a proper Group 4 image. */ if (curprefix == 0xC0000L) curprefix = 0xB0000L; if (color == WHITE) { short runlength = white_run_length(curprefix); if (runlength == G3CODE_INVALID) { horiz_mode[prefix][byte] = (unsigned char) ACT_INVALID; horiz_mode_next_state[prefix][byte] = (unsigned char) bit; bits_digested = bit + 1; } else if (runlength == G3CODE_EOL) { /* Group 3 only */ horiz_mode[prefix][byte] = (unsigned char) ACT_EOL; horiz_mode_next_state[prefix][byte] = BASESTATE(bit+1); bits_digested = bit + 1; } else if (runlength != G3CODE_INCOMP) { horiz_mode[prefix][byte] = (unsigned char) horiz_mode_code_white(runlength); horiz_mode_next_state[prefix][byte] = BASESTATE(bit+1); bits_digested = bit + 1; } } else { /* color == BLACK */ short runlength = black_run_length(curprefix); if (runlength == G3CODE_INVALID) { horiz_mode[prefix][byte] = (unsigned char) ACT_INVALID; horiz_mode_next_state[prefix][byte] = (unsigned char) (bit+8); bits_digested = bit + 1; } else if (runlength == G3CODE_EOL) { /* Group 3 only */ horiz_mode[prefix][byte] = (unsigned char) ACT_EOL; horiz_mode_next_state[prefix][byte] = BASESTATE(bit+1); bits_digested = bit + 1; } else if (runlength != G3CODE_INCOMP) { horiz_mode[prefix][byte] = (unsigned char) horiz_mode_code_black(runlength); horiz_mode_next_state[prefix][byte] = BASESTATE(bit+1); bits_digested = bit + 1; } } } if (!bits_digested) { /* no codewords after examining byte */ horiz_mode[prefix][byte] = (unsigned char) ACT_INCOMP; horiz_mode_next_state[prefix][byte] = (unsigned char) find_horiz_mode_prefix(curprefix, color); } } } void build_uncomp_mode_tables() { short prefix; /* * Note: the first eight entries correspond to * a null prefix and starting bit numbers 0-7. */ uncomp_mode_prefix_count = 8; for (prefix = 0; prefix < uncomp_mode_prefix_count; prefix++) { short byte; for (byte = 0; byte < 256; byte++) { short firstbit; short bit; long curprefix; char found_code = FALSE; if (prefix < 8) { curprefix = 0L; firstbit = prefix; } else { curprefix = uncomp_mode_prefix[prefix]; firstbit = 0; } for (bit = firstbit; bit < 8 && !found_code; bit++) { short mode; if (bit_mask[bit] & byte) curprefix = append_1(curprefix); else curprefix = append_0(curprefix); mode = uncomp_mode_type(curprefix); if (mode != -1) { /* * NOTE: if the bit number is 8, then the table * entry will be zero, which indicates a new byte * is to be fetched during the decoding process */ found_code = TRUE; uncomp_mode[prefix][byte] = (unsigned char) mode; uncomp_mode_next_state[prefix][byte] = BASESTATE(bit+1); break; } } if (!found_code) { uncomp_mode_next_state[prefix][byte] = (unsigned char) find_uncomp_mode_prefix(curprefix); /* * This indicates to the decoder that * no valid code has yet been identified. */ uncomp_mode[prefix][byte] = UNCOMP_INCOMP; } } } } ivtools-1.2.11a1/src/TIFF/mkspans.c000066400000000000000000000016501214471147700166660ustar00rootroot00000000000000#include "tiffcompat.h" /* * Hack program to construct tables used to find * runs of zeros and ones in Group 3 Fax encoding. */ dumparray(name, runs) char *name; unsigned char runs[256]; { register int i; register char *sep; printf("static u_char %s[256] = {\n", name); sep = " "; for (i = 0; i < 256; i++) { printf("%s%d", sep, runs[i]); if (((i + 1) % 16) == 0) { printf(", /* 0x%02x - 0x%02x */\n", i-15, i); sep = " "; } else sep = ", "; } printf("\n};\n"); } main() { unsigned char runs[2][256]; bzero(runs[0], 256*sizeof (char)); bzero(runs[1], 256*sizeof (char)); { register int run, runlen, i; runlen = 1; for (run = 0x80; run != 0xff; run = (run>>1)|0x80) { for (i = run-1; i >= 0; i--) { runs[1][run|i] = runlen; runs[0][(~(run|i)) & 0xff] = runlen; } runlen++; } runs[1][0xff] = runs[0][0] = 8; } dumparray("bruns", runs[0]); dumparray("wruns", runs[1]); } ivtools-1.2.11a1/src/TIFF/prototypes.h000066400000000000000000000051541214471147700174520ustar00rootroot00000000000000/* * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #if USE_PROTOTYPES #define DECLARE1(f,t1,a1) f(t1 a1) #define DECLARE2(f,t1,a1,t2,a2) f(t1 a1, t2 a2) #define DECLARE3(f,t1,a1,t2,a2,t3,a3) f(t1 a1, t2 a2, t3 a3) #define DECLARE4(f,t1,a1,t2,a2,t3,a3,t4,a4)\ f(t1 a1, t2 a2, t3 a3, t4 a4) #define DECLARE5(f,t1,a1,t2,a2,t3,a3,t4,a4,t5,a5)\ f(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) #define DECLARE6(f,t1,a1,t2,a2,t3,a3,t4,a4,t5,a5,t6,a6)\ f(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) #define DECLARE1V(f,t1,a1) f(t1 a1 ...) #define DECLARE2V(f,t1,a1,t2,a2) f(t1 a1, t2 a2, ...) #define DECLARE3V(f,t1,a1,t2,a2,t3,a3) f(t1 a1, t2 a2, t3 a3, ...) #else #define DECLARE1(f,t1,a1) f(a1) t1 a1; #define DECLARE2(f,t1,a1,t2,a2) f(a1,a2) t1 a1; t2 a2; #define DECLARE3(f,t1,a1,t2,a2,t3,a3) f(a1, a2, a3) t1 a1; t2 a2; t3 a3; #define DECLARE4(f,t1,a1,t2,a2,t3,a3,t4,a4) \ f(a1, a2, a3, a4) t1 a1; t2 a2; t3 a3; t4 a4; #define DECLARE5(f,t1,a1,t2,a2,t3,a3,t4,a4,t5,a5)\ f(a1, a2, a3, a4, a5) t1 a1; t2 a2; t3 a3; t4 a4; t5 a5; #define DECLARE6(f,t1,a1,t2,a2,t3,a3,t4,a4,t5,a5,t6,a6)\ f(a1, a2, a3, a4, a5, a6) t1 a1; t2 a2; t3 a3; t4 a4; t5 a5; t6 a6; #if USE_VARARGS #define DECLARE1V(f,t1,a1) \ f(a1, va_alist) t1 a1; va_dcl #define DECLARE2V(f,t1,a1,t2,a2) \ f(a1, a2, va_alist) t1 a1; t2 a2; va_dcl #define DECLARE3V(f,t1,a1,t2,a2,t3,a3) \ f(a1, a2, a3, va_alist) t1 a1; t2 a2; t3 a3; va_dcl #else /* "Help, I don't know how to handle this case: !USE_PROTOTYPES and !USE_VARARGS?" */ #endif #endif ivtools-1.2.11a1/src/TIFF/t4.h000066400000000000000000000264061214471147700155540ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _T4_ #define _T4_ /* * CCITT T.4 1D Huffman runlength codes and * related definitions. Given the small sizes * of these tables it might does not seem * worthwhile to make code & length 8 bits. */ typedef struct tableentry { unsigned short length; /* bit length of g3 code */ unsigned short code; /* g3 code */ short runlen; /* run length in bits */ } tableentry; #define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */ /* status values returned instead of a run length */ #define G3CODE_INVALID -1 #define G3CODE_INCOMP -2 #define G3CODE_EOL -3 #define G3CODE_EOF -4 /* * Note that these tables are ordered such that the * index into the table is known to be either the * run length, or (run length / 64) + a fixed offset. * * NB: The G3CODE_INVALID entries are only used * during state generation (see mkg3states.c). */ #ifdef G3CODES #if defined(__STDC__) || defined(__EXTENDED__) || USE_CONST const tableentry TIFFFaxWhiteCodes[] = { #else tableentry TIFFFaxWhiteCodes[] = { #endif { 8, 0x35, 0 }, /* 0011 0101 */ { 6, 0x7, 1 }, /* 0001 11 */ { 4, 0x7, 2 }, /* 0111 */ { 4, 0x8, 3 }, /* 1000 */ { 4, 0xB, 4 }, /* 1011 */ { 4, 0xC, 5 }, /* 1100 */ { 4, 0xE, 6 }, /* 1110 */ { 4, 0xF, 7 }, /* 1111 */ { 5, 0x13, 8 }, /* 1001 1 */ { 5, 0x14, 9 }, /* 1010 0 */ { 5, 0x7, 10 }, /* 0011 1 */ { 5, 0x8, 11 }, /* 0100 0 */ { 6, 0x8, 12 }, /* 0010 00 */ { 6, 0x3, 13 }, /* 0000 11 */ { 6, 0x34, 14 }, /* 1101 00 */ { 6, 0x35, 15 }, /* 1101 01 */ { 6, 0x2A, 16 }, /* 1010 10 */ { 6, 0x2B, 17 }, /* 1010 11 */ { 7, 0x27, 18 }, /* 0100 111 */ { 7, 0xC, 19 }, /* 0001 100 */ { 7, 0x8, 20 }, /* 0001 000 */ { 7, 0x17, 21 }, /* 0010 111 */ { 7, 0x3, 22 }, /* 0000 011 */ { 7, 0x4, 23 }, /* 0000 100 */ { 7, 0x28, 24 }, /* 0101 000 */ { 7, 0x2B, 25 }, /* 0101 011 */ { 7, 0x13, 26 }, /* 0010 011 */ { 7, 0x24, 27 }, /* 0100 100 */ { 7, 0x18, 28 }, /* 0011 000 */ { 8, 0x2, 29 }, /* 0000 0010 */ { 8, 0x3, 30 }, /* 0000 0011 */ { 8, 0x1A, 31 }, /* 0001 1010 */ { 8, 0x1B, 32 }, /* 0001 1011 */ { 8, 0x12, 33 }, /* 0001 0010 */ { 8, 0x13, 34 }, /* 0001 0011 */ { 8, 0x14, 35 }, /* 0001 0100 */ { 8, 0x15, 36 }, /* 0001 0101 */ { 8, 0x16, 37 }, /* 0001 0110 */ { 8, 0x17, 38 }, /* 0001 0111 */ { 8, 0x28, 39 }, /* 0010 1000 */ { 8, 0x29, 40 }, /* 0010 1001 */ { 8, 0x2A, 41 }, /* 0010 1010 */ { 8, 0x2B, 42 }, /* 0010 1011 */ { 8, 0x2C, 43 }, /* 0010 1100 */ { 8, 0x2D, 44 }, /* 0010 1101 */ { 8, 0x4, 45 }, /* 0000 0100 */ { 8, 0x5, 46 }, /* 0000 0101 */ { 8, 0xA, 47 }, /* 0000 1010 */ { 8, 0xB, 48 }, /* 0000 1011 */ { 8, 0x52, 49 }, /* 0101 0010 */ { 8, 0x53, 50 }, /* 0101 0011 */ { 8, 0x54, 51 }, /* 0101 0100 */ { 8, 0x55, 52 }, /* 0101 0101 */ { 8, 0x24, 53 }, /* 0010 0100 */ { 8, 0x25, 54 }, /* 0010 0101 */ { 8, 0x58, 55 }, /* 0101 1000 */ { 8, 0x59, 56 }, /* 0101 1001 */ { 8, 0x5A, 57 }, /* 0101 1010 */ { 8, 0x5B, 58 }, /* 0101 1011 */ { 8, 0x4A, 59 }, /* 0100 1010 */ { 8, 0x4B, 60 }, /* 0100 1011 */ { 8, 0x32, 61 }, /* 0011 0010 */ { 8, 0x33, 62 }, /* 0011 0011 */ { 8, 0x34, 63 }, /* 0011 0100 */ { 5, 0x1B, 64 }, /* 1101 1 */ { 5, 0x12, 128 }, /* 1001 0 */ { 6, 0x17, 192 }, /* 0101 11 */ { 7, 0x37, 256 }, /* 0110 111 */ { 8, 0x36, 320 }, /* 0011 0110 */ { 8, 0x37, 384 }, /* 0011 0111 */ { 8, 0x64, 448 }, /* 0110 0100 */ { 8, 0x65, 512 }, /* 0110 0101 */ { 8, 0x68, 576 }, /* 0110 1000 */ { 8, 0x67, 640 }, /* 0110 0111 */ { 9, 0xCC, 704 }, /* 0110 0110 0 */ { 9, 0xCD, 768 }, /* 0110 0110 1 */ { 9, 0xD2, 832 }, /* 0110 1001 0 */ { 9, 0xD3, 896 }, /* 0110 1001 1 */ { 9, 0xD4, 960 }, /* 0110 1010 0 */ { 9, 0xD5, 1024 }, /* 0110 1010 1 */ { 9, 0xD6, 1088 }, /* 0110 1011 0 */ { 9, 0xD7, 1152 }, /* 0110 1011 1 */ { 9, 0xD8, 1216 }, /* 0110 1100 0 */ { 9, 0xD9, 1280 }, /* 0110 1100 1 */ { 9, 0xDA, 1344 }, /* 0110 1101 0 */ { 9, 0xDB, 1408 }, /* 0110 1101 1 */ { 9, 0x98, 1472 }, /* 0100 1100 0 */ { 9, 0x99, 1536 }, /* 0100 1100 1 */ { 9, 0x9A, 1600 }, /* 0100 1101 0 */ { 6, 0x18, 1664 }, /* 0110 00 */ { 9, 0x9B, 1728 }, /* 0100 1101 1 */ { 11, 0x8, 1792 }, /* 0000 0001 000 */ { 11, 0xC, 1856 }, /* 0000 0001 100 */ { 11, 0xD, 1920 }, /* 0000 0001 101 */ { 12, 0x12, 1984 }, /* 0000 0001 0010 */ { 12, 0x13, 2048 }, /* 0000 0001 0011 */ { 12, 0x14, 2112 }, /* 0000 0001 0100 */ { 12, 0x15, 2176 }, /* 0000 0001 0101 */ { 12, 0x16, 2240 }, /* 0000 0001 0110 */ { 12, 0x17, 2304 }, /* 0000 0001 0111 */ { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ }; #if defined(__STDC__) || defined(__EXTENDED__) || USE_CONST const tableentry TIFFFaxBlackCodes[] = { #else tableentry TIFFFaxBlackCodes[] = { #endif { 10, 0x37, 0 }, /* 0000 1101 11 */ { 3, 0x2, 1 }, /* 010 */ { 2, 0x3, 2 }, /* 11 */ { 2, 0x2, 3 }, /* 10 */ { 3, 0x3, 4 }, /* 011 */ { 4, 0x3, 5 }, /* 0011 */ { 4, 0x2, 6 }, /* 0010 */ { 5, 0x3, 7 }, /* 0001 1 */ { 6, 0x5, 8 }, /* 0001 01 */ { 6, 0x4, 9 }, /* 0001 00 */ { 7, 0x4, 10 }, /* 0000 100 */ { 7, 0x5, 11 }, /* 0000 101 */ { 7, 0x7, 12 }, /* 0000 111 */ { 8, 0x4, 13 }, /* 0000 0100 */ { 8, 0x7, 14 }, /* 0000 0111 */ { 9, 0x18, 15 }, /* 0000 1100 0 */ { 10, 0x17, 16 }, /* 0000 0101 11 */ { 10, 0x18, 17 }, /* 0000 0110 00 */ { 10, 0x8, 18 }, /* 0000 0010 00 */ { 11, 0x67, 19 }, /* 0000 1100 111 */ { 11, 0x68, 20 }, /* 0000 1101 000 */ { 11, 0x6C, 21 }, /* 0000 1101 100 */ { 11, 0x37, 22 }, /* 0000 0110 111 */ { 11, 0x28, 23 }, /* 0000 0101 000 */ { 11, 0x17, 24 }, /* 0000 0010 111 */ { 11, 0x18, 25 }, /* 0000 0011 000 */ { 12, 0xCA, 26 }, /* 0000 1100 1010 */ { 12, 0xCB, 27 }, /* 0000 1100 1011 */ { 12, 0xCC, 28 }, /* 0000 1100 1100 */ { 12, 0xCD, 29 }, /* 0000 1100 1101 */ { 12, 0x68, 30 }, /* 0000 0110 1000 */ { 12, 0x69, 31 }, /* 0000 0110 1001 */ { 12, 0x6A, 32 }, /* 0000 0110 1010 */ { 12, 0x6B, 33 }, /* 0000 0110 1011 */ { 12, 0xD2, 34 }, /* 0000 1101 0010 */ { 12, 0xD3, 35 }, /* 0000 1101 0011 */ { 12, 0xD4, 36 }, /* 0000 1101 0100 */ { 12, 0xD5, 37 }, /* 0000 1101 0101 */ { 12, 0xD6, 38 }, /* 0000 1101 0110 */ { 12, 0xD7, 39 }, /* 0000 1101 0111 */ { 12, 0x6C, 40 }, /* 0000 0110 1100 */ { 12, 0x6D, 41 }, /* 0000 0110 1101 */ { 12, 0xDA, 42 }, /* 0000 1101 1010 */ { 12, 0xDB, 43 }, /* 0000 1101 1011 */ { 12, 0x54, 44 }, /* 0000 0101 0100 */ { 12, 0x55, 45 }, /* 0000 0101 0101 */ { 12, 0x56, 46 }, /* 0000 0101 0110 */ { 12, 0x57, 47 }, /* 0000 0101 0111 */ { 12, 0x64, 48 }, /* 0000 0110 0100 */ { 12, 0x65, 49 }, /* 0000 0110 0101 */ { 12, 0x52, 50 }, /* 0000 0101 0010 */ { 12, 0x53, 51 }, /* 0000 0101 0011 */ { 12, 0x24, 52 }, /* 0000 0010 0100 */ { 12, 0x37, 53 }, /* 0000 0011 0111 */ { 12, 0x38, 54 }, /* 0000 0011 1000 */ { 12, 0x27, 55 }, /* 0000 0010 0111 */ { 12, 0x28, 56 }, /* 0000 0010 1000 */ { 12, 0x58, 57 }, /* 0000 0101 1000 */ { 12, 0x59, 58 }, /* 0000 0101 1001 */ { 12, 0x2B, 59 }, /* 0000 0010 1011 */ { 12, 0x2C, 60 }, /* 0000 0010 1100 */ { 12, 0x5A, 61 }, /* 0000 0101 1010 */ { 12, 0x66, 62 }, /* 0000 0110 0110 */ { 12, 0x67, 63 }, /* 0000 0110 0111 */ { 10, 0xF, 64 }, /* 0000 0011 11 */ { 12, 0xC8, 128 }, /* 0000 1100 1000 */ { 12, 0xC9, 192 }, /* 0000 1100 1001 */ { 12, 0x5B, 256 }, /* 0000 0101 1011 */ { 12, 0x33, 320 }, /* 0000 0011 0011 */ { 12, 0x34, 384 }, /* 0000 0011 0100 */ { 12, 0x35, 448 }, /* 0000 0011 0101 */ { 13, 0x6C, 512 }, /* 0000 0011 0110 0 */ { 13, 0x6D, 576 }, /* 0000 0011 0110 1 */ { 13, 0x4A, 640 }, /* 0000 0010 0101 0 */ { 13, 0x4B, 704 }, /* 0000 0010 0101 1 */ { 13, 0x4C, 768 }, /* 0000 0010 0110 0 */ { 13, 0x4D, 832 }, /* 0000 0010 0110 1 */ { 13, 0x72, 896 }, /* 0000 0011 1001 0 */ { 13, 0x73, 960 }, /* 0000 0011 1001 1 */ { 13, 0x74, 1024 }, /* 0000 0011 1010 0 */ { 13, 0x75, 1088 }, /* 0000 0011 1010 1 */ { 13, 0x76, 1152 }, /* 0000 0011 1011 0 */ { 13, 0x77, 1216 }, /* 0000 0011 1011 1 */ { 13, 0x52, 1280 }, /* 0000 0010 1001 0 */ { 13, 0x53, 1344 }, /* 0000 0010 1001 1 */ { 13, 0x54, 1408 }, /* 0000 0010 1010 0 */ { 13, 0x55, 1472 }, /* 0000 0010 1010 1 */ { 13, 0x5A, 1536 }, /* 0000 0010 1101 0 */ { 13, 0x5B, 1600 }, /* 0000 0010 1101 1 */ { 13, 0x64, 1664 }, /* 0000 0011 0010 0 */ { 13, 0x65, 1728 }, /* 0000 0011 0010 1 */ { 11, 0x8, 1792 }, /* 0000 0001 000 */ { 11, 0xC, 1856 }, /* 0000 0001 100 */ { 11, 0xD, 1920 }, /* 0000 0001 101 */ { 12, 0x12, 1984 }, /* 0000 0001 0010 */ { 12, 0x13, 2048 }, /* 0000 0001 0011 */ { 12, 0x14, 2112 }, /* 0000 0001 0100 */ { 12, 0x15, 2176 }, /* 0000 0001 0101 */ { 12, 0x16, 2240 }, /* 0000 0001 0110 */ { 12, 0x17, 2304 }, /* 0000 0001 0111 */ { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ }; #else #if defined(__STDC__) || defined(__EXTENDED__) || USE_CONST extern const tableentry TIFFFaxWhiteCodes[]; extern const tableentry TIFFFaxBlackCodes[]; #else extern tableentry TIFFFaxWhiteCodes[]; extern tableentry TIFFFaxBlackCodes[]; #endif /* !__STDC__ */ #endif #endif /* _T4_ */ ivtools-1.2.11a1/src/TIFF/tif_aux.c000066400000000000000000000124111214471147700166460ustar00rootroot00000000000000/* * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * Auxiliary Support Routines. */ #include "tiffioP.h" #include "prototypes.h" #include /* * Like TIFFGetField, but return any default * value if the tag is not present in the directory. * * NB: We use the value in the directory, rather than * explcit values so that defaults exist only one * place in the library -- in TIFFDefaultDirectory. */ TIFFVGetFieldDefaulted(tif, tag, ap) TIFF *tif; int tag; va_list ap; { TIFFDirectory *td = &tif->tif_dir; int i; if (TIFFVGetField(tif, tag, ap)) return (1); switch (tag) { case TIFFTAG_SUBFILETYPE: *va_arg(ap, u_short *) = td->td_subfiletype; return (1); case TIFFTAG_BITSPERSAMPLE: *va_arg(ap, u_short *) = td->td_bitspersample; return (1); case TIFFTAG_THRESHHOLDING: *va_arg(ap, u_short *) = td->td_threshholding; return (1); case TIFFTAG_FILLORDER: *va_arg(ap, u_short *) = td->td_fillorder; return (1); case TIFFTAG_ORIENTATION: *va_arg(ap, u_short *) = td->td_orientation; return (1); case TIFFTAG_SAMPLESPERPIXEL: *va_arg(ap, u_short *) = td->td_samplesperpixel; return (1); case TIFFTAG_ROWSPERSTRIP: *va_arg(ap, u_long *) = td->td_rowsperstrip; return (1); case TIFFTAG_MINSAMPLEVALUE: *va_arg(ap, u_short *) = td->td_minsamplevalue; return (1); case TIFFTAG_MAXSAMPLEVALUE: *va_arg(ap, u_short *) = td->td_maxsamplevalue; return (1); case TIFFTAG_PLANARCONFIG: *va_arg(ap, u_short *) = td->td_planarconfig; return (1); case TIFFTAG_GROUP4OPTIONS: *va_arg(ap, u_long *) = td->td_group4options; return (1); case TIFFTAG_RESOLUTIONUNIT: *va_arg(ap, u_short *) = td->td_resolutionunit; return (1); case TIFFTAG_PREDICTOR: *va_arg(ap, u_short *) = td->td_predictor; return (1); #ifdef CMYK_SUPPORT case TIFFTAG_DOTRANGE: *va_arg(ap, u_short *) = 0; *va_arg(ap, u_short *) = (1<td_bitspersample)-1; return (1); case TIFFTAG_INKSET: *va_arg(ap, u_short *) = td->td_inkset; return (1); #endif case TIFFTAG_TILEDEPTH: *va_arg(ap, u_long *) = td->td_tiledepth; return (1); case TIFFTAG_DATATYPE: *va_arg(ap, u_short *) = td->td_sampleformat-1; return (1); case TIFFTAG_IMAGEDEPTH: *va_arg(ap, u_short *) = td->td_imagedepth; return (1); #ifdef YCBCR_SUPPORT case TIFFTAG_YCBCRCOEFFICIENTS: if (!td->td_ycbcrcoeffs) { td->td_ycbcrcoeffs = (float *)malloc(3*sizeof (float)); /* defaults are from CCIR Recommendation 601-1 */ td->td_ycbcrcoeffs[0] = .299; td->td_ycbcrcoeffs[1] = .587; td->td_ycbcrcoeffs[2] = .114; } *va_arg(ap, float **) = td->td_ycbcrcoeffs; return (1); case TIFFTAG_YCBCRSUBSAMPLING: *va_arg(ap, u_short *) = td->td_ycbcrsubsampling[0]; *va_arg(ap, u_short *) = td->td_ycbcrsubsampling[1]; return (1); case TIFFTAG_YCBCRPOSITIONING: *va_arg(ap, u_short *) = td->td_ycbcrpositioning; return (1); #endif #ifdef COLORIMETRY_SUPPORT case TIFFTAG_TRANSFERFUNCTION: if (!td->td_transferfunction[0]) { u_short **tf = td->td_transferfunction; int n = 1<td_bitspersample; tf[0] = (u_short *)malloc(n * sizeof (u_short)); tf[0][0] = 0; for (i = 1; i < n; i++) tf[0][i] = (u_short) floor(65535.*pow(i/(n-1.), 2.2) + .5); for (i = 1; i < td->td_samplesperpixel; i++) { tf[i] = (u_short *)malloc(n * sizeof (u_short)); bcopy(tf[0], tf[i], n * sizeof (u_short)); } } for (i = 0; i < td->td_samplesperpixel; i++) *va_arg(ap, u_short **) = td->td_transferfunction[i]; return (1); case TIFFTAG_REFERENCEBLACKWHITE: if (!td->td_refblackwhite) { td->td_refblackwhite = (float *) malloc(2*td->td_samplesperpixel * sizeof (float)); for (i = 0; i < td->td_samplesperpixel; i++) { td->td_refblackwhite[2*i+0] = 0; td->td_refblackwhite[2*i+1] = 1L<td_bitspersample; } } *va_arg(ap, float **) = td->td_refblackwhite; return (1); #endif } return (0); } /* * Like TIFFGetField, but return any default * value if the tag is not present in the directory. */ /*VARARGS2*/ DECLARE2V(TIFFGetFieldDefaulted, TIFF*, tif, int, tag) { int ok; va_list ap; VA_START(ap, tag); ok = TIFFVGetFieldDefaulted(tif, tag, ap); va_end(ap); return (ok); } ivtools-1.2.11a1/src/TIFF/tif_ccittrle.c000066400000000000000000000046701214471147700176720ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * CCITT Group 3 1-D Modified Huffman * Run Length Encoding Compression Support */ #include "tiffioP.h" #include "tif_fax3.h" TIFFInitCCITTRLE(tif) TIFF *tif; { TIFFInitCCITTFax3(tif); /* reuse G3 compression */ tif->tif_preencode = NULL; tif->tif_postencode = NULL; tif->tif_encoderow = TIFFNoRowEncode; tif->tif_encodestrip = TIFFNoStripEncode; tif->tif_encodetile = TIFFNoTileEncode; tif->tif_close = NULL; /* * This magic causes the regular G3 decompression * code to not skip to the EOL mark at the end of * a row, and to flush input data to a byte boundary * at the end of each row. */ tif->tif_options |= FAX3_NOEOL|FAX3_BYTEALIGN; return (1); } TIFFInitCCITTRLEW(tif) TIFF *tif; { TIFFInitCCITTFax3(tif); /* reuse G3 compression */ tif->tif_preencode = NULL; tif->tif_postencode = NULL; tif->tif_encoderow = TIFFNoRowEncode; tif->tif_encodestrip = TIFFNoStripEncode; tif->tif_encodetile = TIFFNoTileEncode; tif->tif_close = NULL; /* * This magic causes the regular G3 decompression * code to not skip to the EOL mark at the end of * a row, and to flush input data to a byte boundary * at the end of each row. */ tif->tif_options |= FAX3_NOEOL|FAX3_WORDALIGN; return (1); } ivtools-1.2.11a1/src/TIFF/tif_close.c000066400000000000000000000034611214471147700171630ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. */ #include "tiffioP.h" #if USE_PROTOTYPES extern int TIFFFreeDirectory(TIFF*); #else extern int TIFFFreeDirectory(); #endif void TIFFClose(tif) TIFF *tif; { if (tif->tif_mode != O_RDONLY) /* * Flush buffered data and directory (if dirty). */ TIFFFlush(tif); if (tif->tif_cleanup) (*tif->tif_cleanup)(tif); TIFFFreeDirectory(tif); if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER)) free(tif->tif_rawdata); #ifdef MMAP_SUPPORT if (isMapped(tif)) TIFFUnmapFileContents(tif->tif_base, tif->tif_size); #endif (void) close(tif->tif_fd); free((char *)tif); } ivtools-1.2.11a1/src/TIFF/tif_compat.c000066400000000000000000000134231214471147700173400ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library Compatibility Routines. */ #include "tiffioP.h" #if defined(unix) || defined(__unix) || defined(MSDOS) || defined(VMS) || defined(AIXV3) || defined(__CYGWIN__) || defined(__NetBSD__) || defined(__APPLE__) #include long TIFFGetFileSize(fd) int fd; { struct stat sb; return (fstat(fd, &sb) < 0 ? 0 : sb.st_size); } #endif #if (defined(unix) || defined(__unix)) && defined(MMAP_SUPPORT) #include int TIFFMapFileContents(fd, pbase, psize) int fd; char **pbase; long *psize; { long size = TIFFGetFileSize(fd); if (size != -1) { *pbase = (char *) mmap(0, size, PROT_READ, MAP_SHARED, fd, 0); if (*pbase != (char *)-1) { *psize = size; return (1); } } return (0); } void TIFFUnmapFileContents(base, size) char *base; long size; { (void) munmap(base, size); } #endif /* (defined(unix) || defined(__unix)) && defined(MMAP_SUPPORT) */ #if defined(VMS) && defined(MMAP_SUPPORT) #include #include /* * Table for storing information on current open sections. * (You may want to substitute a linked list...) */ #define MAX_MAPPED 100 static int no_mapped = 0; static struct { void *base; void *top; unsigned channel; } map_table[MAX_MAPPED]; /* * This routine maps a file into a private section. Note that this * method of accessing a file is by far the fastest under VMS. * The routine may fail (i.e. return 0) for several reasons, for * example: * - There is no more room for storing the info on sections. * - The process is out of open file quota, channels, ... * - fd does not describe an opened file. * - The file is already opened for write access by this process * or another process * - There is no free "hole" in virtual memory that fits the * size of the file */ int TIFFMapFileContents(fd, pbase, psize) int fd; char **pbase; long *psize; { char name[256]; struct FAB fab; unsigned short channel; void *inadr[2], *retadr[2]; unsigned long status; long size; if (no_mapped >= MAX_MAPPED) return(0); /* * We cannot use a file descriptor, we * must open the file once more. */ if (getname(fd, name, 1) == NULL) return(0); /* prepare the FAB for a user file open */ fab = cc$rms_fab; fab.fab$v_ufo = 1; fab.fab$b_fac = FAB$M_GET; fab.fab$b_shr = FAB$M_SHRGET; fab.fab$l_fna = name; fab.fab$b_fns = strlen(name); status = sys$open(&fab); /* open file & get channel number */ if ((status&1) == 0) return(0); channel = (unsigned short)fab.fab$l_stv; inadr[0] = inadr[1] = &channel; /* just an address in P0 space */ /* * Map the blocks of the file up to * the EOF block into virtual memory. */ size = TIFFGetFileSize(fd); status = sys$crmpsc(inadr, retadr, 0, SEC$M_EXPREG, 0,0,0, channel, howmany(size,512), 0,0,0); if ((status&1) == 0) return(0); *pbase = retadr[0]; /* starting virtual address */ /* * Use the size of the file up to the * EOF mark for UNIX compatibility. */ *psize = size; /* Record the section in the table */ map_table[no_mapped].base = retadr[0]; map_table[no_mapped].top = retadr[1]; map_table[no_mapped].channel = channel; no_mapped++; return(1); } /* * This routine unmaps a section from the virtual address space of * the process, but only if the base was the one returned from a * call to TIFFMapFileContents. */ void TIFFUnmapFileContents(base, size) char *base; long size; { void *inadr[2]; int i, j; /* Find the section in the table */ for (i = 0;i < no_mapped; i++) { if (map_table[i].base == base) { /* Unmap the section */ inadr[1] = base; inadr[0] = map_table[i].top; sys$deltva(inadr, 0, 0); sys$dassgn(map_table[i].channel); /* Remove this section from the list */ for (j = i+1; j < no_mapped; j++) map_table[j-1] = map_table[j]; no_mapped--; return; } } } #endif /* defined(VMS) && defined(MMAP_SUPPORT) */ #if defined(THINK_C) || defined(applec) long TIFFGetFileSize(int fd) { long pos, eof; pos = lseek(fd, 0, SEEK_CUR); eof = lseek(fd, 0, SEEK_END); lseek(fd, pos, SEEK_SET); return(eof); } #endif /* THINK_C || applec */ #if defined(applec) #include #include #undef lseek long mpw_lseek(int fd, long offset, int whence) { long filepos, filesize, newpos; short macfd; if ((filepos = lseek(fd, 0, SEEK_CUR)) < 0 || (filesize = lseek(fd, 0, SEEK_END)) < 0) return (EOF); newpos = offset + (whence == SEEK_SET ? 0 : whence == SEEK_CUR ? filepos : filesize); if (newpos > filesize) if (ioctl(fd, FIOREFNUM, &macfd) == -1 || SetEOF(macfd, newpos) != 0) return (EOF); return (lseek(fd, newpos, SEEK_SET)); } #endif /* applec */ ivtools-1.2.11a1/src/TIFF/tif_compress.c000066400000000000000000000125321214471147700177100ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library * * Compression Scheme Configuration Support. */ #include "tiffioP.h" #if USE_PROTOTYPES extern int TIFFInitDumpMode(TIFF*); #ifdef PACKBITS_SUPPORT extern int TIFFInitPackBits(TIFF*); #endif #ifdef CCITT_SUPPORT extern int TIFFInitCCITTRLE(TIFF*), TIFFInitCCITTRLEW(TIFF*); extern int TIFFInitCCITTFax3(TIFF*), TIFFInitCCITTFax4(TIFF*); #endif #ifdef THUNDER_SUPPORT extern int TIFFInitThunderScan(TIFF*); #endif #ifdef NEXT_SUPPORT extern int TIFFInitNeXT(TIFF*); #endif #ifdef LZW_SUPPORT extern int TIFFInitLZW(TIFF*); #endif #ifdef JPEG_SUPPORT extern int TIFFInitJPEG(TIFF*); #endif #else extern int TIFFInitDumpMode(); #ifdef PACKBITS_SUPPORT extern int TIFFInitPackBits(); #endif #ifdef CCITT_SUPPORT extern int TIFFInitCCITTRLE(), TIFFInitCCITTRLEW(); extern int TIFFInitCCITTFax3(), TIFFInitCCITTFax4(); #endif #ifdef THUNDER_SUPPORT extern int TIFFInitThunderScan(); #endif #ifdef NEXT_SUPPORT extern int TIFFInitNeXT(); #endif #ifdef LZW_SUPPORT extern int TIFFInitLZW(); #endif #ifdef JPEG_SUPPORT extern int TIFFInitJPEG(); #endif #endif struct cscheme { char* name; int scheme; int (*init)(); }; static const struct cscheme CompressionSchemes[] = { { "Null", COMPRESSION_NONE, TIFFInitDumpMode }, #ifdef LZW_SUPPORT { "LZW", COMPRESSION_LZW, TIFFInitLZW }, #endif #ifdef PACKBITS_SUPPORT { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits }, #endif #ifdef THUNDER_SUPPORT { "ThunderScan", COMPRESSION_THUNDERSCAN,TIFFInitThunderScan }, #endif #ifdef NEXT_SUPPORT { "NeXT", COMPRESSION_NEXT, TIFFInitNeXT }, #endif #ifdef JPEG_SUPPORT { "JPEG", COMPRESSION_JPEG, TIFFInitJPEG }, #endif #ifdef CCITT_SUPPORT { "CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE }, { "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW }, { "CCITT Group3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 }, { "CCITT Group4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 }, #endif }; #define NSCHEMES (sizeof (CompressionSchemes) / sizeof (CompressionSchemes[0])) static struct cscheme const * findScheme(scheme) int scheme; { register struct cscheme const *c; for (c = CompressionSchemes; c < &CompressionSchemes[NSCHEMES]; c++) if (c->scheme == scheme) return (c); return ((struct cscheme const *)0); } static int TIFFNoEncode(tif, method) TIFF *tif; char *method; { struct cscheme const *c = findScheme(tif->tif_dir.td_compression); TIFFError(tif->tif_name, "%s %s encoding is not implemented", c->name, method); return (-1); } int TIFFNoRowEncode(tif, pp, cc, s) TIFF *tif; u_char *pp; int cc; u_int s; { return (TIFFNoEncode(tif, "scanline")); } int TIFFNoStripEncode(tif, pp, cc, s) TIFF *tif; u_char *pp; int cc; u_int s; { return (TIFFNoEncode(tif, "strip")); } int TIFFNoTileEncode(tif, pp, cc, s) TIFF *tif; u_char *pp; int cc; u_int s; { return (TIFFNoEncode(tif, "tile")); } int TIFFNoDecode(tif, method) TIFF *tif; char *method; { struct cscheme const *c = findScheme(tif->tif_dir.td_compression); TIFFError(tif->tif_name, "%s %s decoding is not implemented", c->name, method); return (-1); } int TIFFNoRowDecode(tif, pp, cc, s) TIFF *tif; u_char *pp; int cc; u_int s; { return (TIFFNoDecode(tif, "scanline")); } int TIFFNoStripDecode(tif, pp, cc, s) TIFF *tif; u_char *pp; int cc; u_int s; { return (TIFFNoDecode(tif, "strip")); } int TIFFNoTileDecode(tif, pp, cc, s) TIFF *tif; u_char *pp; int cc; u_int s; { return (TIFFNoDecode(tif, "tile")); } TIFFSetCompressionScheme(tif, scheme) TIFF *tif; int scheme; { struct cscheme const *c = findScheme(scheme); if (!c) { TIFFError(tif->tif_name, "Unknown data compression algorithm %u (0x%x)", scheme, scheme); return (0); } tif->tif_predecode = NULL; tif->tif_decoderow = TIFFNoRowDecode; tif->tif_decodestrip = TIFFNoStripDecode; tif->tif_decodetile = TIFFNoTileDecode; tif->tif_preencode = NULL; tif->tif_postencode = NULL; tif->tif_encoderow = TIFFNoRowEncode; tif->tif_encodestrip = TIFFNoStripEncode; tif->tif_encodetile = TIFFNoTileEncode; tif->tif_close = NULL; tif->tif_seek = NULL; tif->tif_cleanup = NULL; tif->tif_flags &= ~TIFF_NOBITREV; tif->tif_options = 0; return ((*c->init)(tif)); } ivtools-1.2.11a1/src/TIFF/tif_dir.c000066400000000000000000000613171214471147700166400ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * Directory Tag Get & Set Routines. * (and also some miscellaneous stuff) * * NB: Beware of the varargs declarations for routines in * this file. The names and types of variables has been * carefully chosen to make things work with compilers that * are busted in one way or another (e.g. SGI/MIPS). */ #include "tiffioP.h" #include "prototypes.h" static DECLARE2(setString, char**, cpp, char*, cp) { if (*cpp) free(*cpp), *cpp = 0; if (cp) { int len = strlen(cp)+1; if (*cpp = malloc(len)) bcopy(cp, *cpp, len); } } static DECLARE3(setShortArray, u_short**, wpp, u_short*, wp, long, n) { if (*wpp) free((char *)*wpp), *wpp = 0; n *= sizeof (u_short); if (wp && (*wpp = (u_short *)malloc(n))) bcopy(wp, *wpp, n); } static DECLARE3(setLongArray, u_long**, wpp, u_long*, wp, long, n) { if (*wpp) free((char *)*wpp), *wpp = 0; n *= sizeof (u_long); if (wp && (*wpp = (u_long *)malloc(n))) bcopy(wp, *wpp, n); } static DECLARE3(setFloatArray, float**, wpp, float*, wp, long, n) { if (*wpp) free((char *)*wpp), *wpp = 0; n *= sizeof (float); if (wp && (*wpp = (float *)malloc(n))) bcopy(wp, *wpp, n); } #ifdef JPEG_SUPPORT /* * Install a JPEG Quantization table. * Note that we reorder the elements * of the array in the zig-zag order * that is expected by the compression code * and that is to be stored in the file. */ static DECLARE3(setJPEGQTable, u_char***, wpp, u_char**, wp, int, nc) { static u_char zigzag[64] = { 0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63 }; char *tab; int i, j; if (*wpp) free((char *)*wpp), *wpp = 0; *wpp = (u_char **) malloc(nc * (sizeof (u_char *) + 64*sizeof (u_char))); tab = (((char *)*wpp) + nc*sizeof (u_short *)); for (i = 0; i < nc; i++) { (*wpp)[i] = (u_char *)tab; for (j = 0; j < 64; j++) tab[zigzag[j]] = wp[i][j]; tab += 64*sizeof (u_char); } } /* * Install a JPEG Coefficient table. */ static DECLARE3(setJPEGCTable, u_char***, cpp, u_char**, cp, int, nc) { u_char *tab; int i, j, nw; if (*cpp) free(*cpp), *cpp = 0; /* * Calculate the size of the table by counting * the number of codes specified in the bits array. */ nw = 0; for (i = 0; i < nc; i++) { nw += 16; /* 16 bytes for bits array */ for (j = 0; j < 16; j++)/* sum up count of codes */ nw += cp[i][j]; } *cpp = (u_char **)malloc(nc*sizeof (u_char *) + nw); tab = ((u_char *)*cpp) + nc*sizeof (u_char *); /* * Setup internal array and copy user data. */ for (i = 0; i < nc; i++) { (*cpp)[i] = tab; for (nw = 16, j = 0; j < 16; j++) nw += cp[i][j]; bcopy(cp[i], tab, nw); tab += nw; } } #endif static TIFFSetField1(tif, tag, ap) TIFF *tif; int tag; va_list ap; { TIFFDirectory *td = &tif->tif_dir; int i, status = 1; long v; switch (tag) { case TIFFTAG_SUBFILETYPE: td->td_subfiletype = va_arg(ap, u_long); break; case TIFFTAG_IMAGEWIDTH: td->td_imagewidth = va_arg(ap, u_long); break; case TIFFTAG_IMAGELENGTH: td->td_imagelength = va_arg(ap, u_long); break; case TIFFTAG_BITSPERSAMPLE: td->td_bitspersample = va_arg(ap, int); break; case TIFFTAG_COMPRESSION: v = va_arg(ap, int) & 0xffff; /* * If we're changing the compression scheme, * the notify the previous module so that it * can cleanup any state it's setup. */ if (TIFFFieldSet(tif, FIELD_COMPRESSION)) { if (td->td_compression == v) break; if (tif->tif_cleanup) (*tif->tif_cleanup)(tif); } /* * Setup new compression routine state. */ if (status = TIFFSetCompressionScheme(tif, v)) td->td_compression = v; break; case TIFFTAG_PHOTOMETRIC: td->td_photometric = va_arg(ap, int); break; case TIFFTAG_THRESHHOLDING: td->td_threshholding = va_arg(ap, int); break; case TIFFTAG_FILLORDER: v = va_arg(ap, int); if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB) goto badvalue; td->td_fillorder = v; break; case TIFFTAG_DOCUMENTNAME: setString(&td->td_documentname, va_arg(ap, char *)); break; case TIFFTAG_ARTIST: setString(&td->td_artist, va_arg(ap, char *)); break; case TIFFTAG_DATETIME: setString(&td->td_datetime, va_arg(ap, char *)); break; case TIFFTAG_HOSTCOMPUTER: setString(&td->td_hostcomputer, va_arg(ap, char *)); break; case TIFFTAG_IMAGEDESCRIPTION: setString(&td->td_imagedescription, va_arg(ap, char *)); break; case TIFFTAG_MAKE: setString(&td->td_make, va_arg(ap, char *)); break; case TIFFTAG_MODEL: setString(&td->td_model, va_arg(ap, char *)); break; case TIFFTAG_SOFTWARE: setString(&td->td_software, va_arg(ap, char *)); break; case TIFFTAG_ORIENTATION: v = va_arg(ap, int); if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) { TIFFWarning(tif->tif_name, "Bad value %ld for \"%s\" tag ignored", v, TIFFFieldWithTag(tag)->field_name); } else td->td_orientation = v; break; case TIFFTAG_SAMPLESPERPIXEL: /* XXX should cross check -- e.g. if pallette, then 1 */ v = va_arg(ap, int); if (v == 0) goto badvalue; if (v > 4) { TIFFError(tif->tif_name, "Cannot handle %ld-channel data", v); status = 0; } else td->td_samplesperpixel = v; break; case TIFFTAG_ROWSPERSTRIP: v = va_arg(ap, u_long); if (v == 0) goto badvalue; td->td_rowsperstrip = v; if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { td->td_tilelength = v; td->td_tilewidth = td->td_imagewidth; } break; case TIFFTAG_MINSAMPLEVALUE: td->td_minsamplevalue = va_arg(ap, int) & 0xffff; break; case TIFFTAG_MAXSAMPLEVALUE: td->td_maxsamplevalue = va_arg(ap, int) & 0xffff; break; case TIFFTAG_XRESOLUTION: td->td_xresolution = va_arg(ap, dblparam_t); break; case TIFFTAG_YRESOLUTION: td->td_yresolution = va_arg(ap, dblparam_t); break; case TIFFTAG_PLANARCONFIG: v = va_arg(ap, int); if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE) goto badvalue; td->td_planarconfig = v; break; case TIFFTAG_PAGENAME: setString(&td->td_pagename, va_arg(ap, char *)); break; case TIFFTAG_XPOSITION: td->td_xposition = va_arg(ap, dblparam_t); break; case TIFFTAG_YPOSITION: td->td_yposition = va_arg(ap, dblparam_t); break; case TIFFTAG_GROUP3OPTIONS: td->td_group3options = va_arg(ap, u_long); break; case TIFFTAG_GROUP4OPTIONS: td->td_group4options = va_arg(ap, u_long); break; case TIFFTAG_RESOLUTIONUNIT: v = va_arg(ap, int); if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v) goto badvalue; td->td_resolutionunit = v; break; case TIFFTAG_PAGENUMBER: td->td_pagenumber[0] = va_arg(ap, int); td->td_pagenumber[1] = va_arg(ap, int); break; case TIFFTAG_HALFTONEHINTS: td->td_halftonehints[0] = va_arg(ap, int); td->td_halftonehints[1] = va_arg(ap, int); break; case TIFFTAG_COLORMAP: v = 1L<td_bitspersample; setShortArray(&td->td_colormap[0], va_arg(ap, u_short *), v); setShortArray(&td->td_colormap[1], va_arg(ap, u_short *), v); setShortArray(&td->td_colormap[2], va_arg(ap, u_short *), v); break; case TIFFTAG_PREDICTOR: td->td_predictor = va_arg(ap, int); break; case TIFFTAG_EXTRASAMPLES: v = va_arg(ap, int); if (v > td->td_samplesperpixel) goto badvalue; if (v != 1) /* XXX */ goto badvalue; /* XXX */ v = va_arg(ap, int); if (v != EXTRASAMPLE_ASSOCALPHA)/* XXX */ goto badvalue; /* XXX */ td->td_matteing = 1; break; case TIFFTAG_MATTEING: td->td_matteing = va_arg(ap, int); break; case TIFFTAG_BADFAXLINES: td->td_badfaxlines = va_arg(ap, u_long); break; case TIFFTAG_CLEANFAXDATA: td->td_cleanfaxdata = va_arg(ap, int); break; case TIFFTAG_CONSECUTIVEBADFAXLINES: td->td_badfaxrun = va_arg(ap, u_long); break; case TIFFTAG_TILEWIDTH: v = va_arg(ap, u_long); if (v % 8) goto badvalue; td->td_tilewidth = v; tif->tif_flags |= TIFF_ISTILED; break; case TIFFTAG_TILELENGTH: v = va_arg(ap, u_long); if (v % 8) goto badvalue; td->td_tilelength = v; tif->tif_flags |= TIFF_ISTILED; break; case TIFFTAG_TILEDEPTH: v = va_arg(ap, u_long); if (v == 0) goto badvalue; td->td_tiledepth = v; break; case TIFFTAG_DATATYPE: case TIFFTAG_SAMPLEFORMAT: v = va_arg(ap, int); if (tag == TIFFTAG_DATATYPE && v == 0) v = SAMPLEFORMAT_VOID; if (v < SAMPLEFORMAT_INT || SAMPLEFORMAT_VOID < v) goto badvalue; td->td_sampleformat = v; break; case TIFFTAG_IMAGEDEPTH: td->td_imagedepth = va_arg(ap, u_long); break; #ifdef YCBCR_SUPPORT case TIFFTAG_YCBCRCOEFFICIENTS: setFloatArray(&td->td_ycbcrcoeffs, va_arg(ap, float *), 3); break; case TIFFTAG_YCBCRPOSITIONING: td->td_ycbcrpositioning = va_arg(ap, int); break; case TIFFTAG_YCBCRSUBSAMPLING: td->td_ycbcrsubsampling[0] = va_arg(ap, int); td->td_ycbcrsubsampling[1] = va_arg(ap, int); break; #endif #ifdef JPEG_SUPPORT case TIFFTAG_JPEGPROC: td->td_jpegproc = va_arg(ap, int); break; case TIFFTAG_JPEGRESTARTINTERVAL: td->td_jpegrestartinterval = va_arg(ap, int); break; case TIFFTAG_JPEGQTABLES: setJPEGQTable(&td->td_qtab, va_arg(ap, u_char **), td->td_samplesperpixel); break; case TIFFTAG_JPEGDCTABLES: setJPEGCTable(&td->td_dctab, va_arg(ap, u_char **), td->td_samplesperpixel); break; case TIFFTAG_JPEGACTABLES: setJPEGCTable(&td->td_actab, va_arg(ap, u_char **), td->td_samplesperpixel); break; #endif #ifdef COLORIMETRY_SUPPORT case TIFFTAG_WHITEPOINT: setFloatArray(&td->td_whitepoint, va_arg(ap, float *), 2); break; case TIFFTAG_PRIMARYCHROMATICITIES: setFloatArray(&td->td_primarychromas, va_arg(ap, float *), 6); break; case TIFFTAG_TRANSFERFUNCTION: for (i = 0; i < td->td_samplesperpixel; i++) setShortArray(&td->td_transferfunction[i], va_arg(ap, u_short *), 1L<td_bitspersample); break; case TIFFTAG_REFERENCEBLACKWHITE: /* XXX should check for null range */ v = 2 * td->td_samplesperpixel; setFloatArray(&td->td_refblackwhite, va_arg(ap, float *), v); break; #endif #ifdef CMYK_SUPPORT case TIFFTAG_INKSET: td->td_inkset = va_arg(ap, int); break; case TIFFTAG_DOTRANGE: /* XXX should check for null range */ td->td_dotrange[0] = va_arg(ap, int); td->td_dotrange[1] = va_arg(ap, int); break; case TIFFTAG_INKNAMES: setString(&td->td_inknames, va_arg(ap, char *)); break; case TIFFTAG_TARGETPRINTER: setString(&td->td_targetprinter, va_arg(ap, char *)); break; #endif default: TIFFError(tif->tif_name, "Internal error, tag value botch, tag \"%s\"", TIFFFieldWithTag(tag)->field_name); status = 0; break; } if (status) { TIFFSetFieldBit(tif, TIFFFieldWithTag(tag)->field_bit); tif->tif_flags |= TIFF_DIRTYDIRECT; } va_end(ap); return (status); badvalue: TIFFError(tif->tif_name, "%ld: Bad value for \"%s\"", v, TIFFFieldWithTag(tag)->field_name); va_end(ap); return (0); } /* * Return 1/0 according to whether or not * it is permissible to set the tag's value. * Note that we allow ImageLength to be changed * so that we can append and extend to images. * Any other tag may not be altered once writing * has commenced, unless its value has no effect * on the format of the data that is written. */ static OkToChangeTag(tif, tag) TIFF *tif; int tag; { if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING)) { TIFFFieldInfo const *fip = TIFFFindFieldInfo(tag, TIFF_ANY); /* * Consult info table to see if tag can be changed * after we've started writing. We only allow changes * to those tags that don't/shouldn't affect the * compression and/or format of the data. */ if (fip && !fip->field_oktochange) return (0); } return (1); } /* * Record the value of a field in the * internal directory structure. The * field will be written to the file * when/if the directory structure is * updated. */ /*VARARGS2*/ DECLARE2V(TIFFSetField, TIFF*, tif, int, tag) { int status = 0; if (OkToChangeTag(tif, tag)) { va_list ap; VA_START(ap, tag); status = TIFFSetField1(tif, tag, ap); va_end(ap); } else { TIFFFieldInfo const *fip = TIFFFindFieldInfo(tag, TIFF_ANY); if (fip) TIFFError("TIFFSetField", "%s: Cannot modify tag \"%s\" while writing", tif->tif_name, fip->field_name); } return (status); } /* * Like TIFFSetField, but taking a varargs * parameter list. This routine is useful * for building higher-level interfaces on * top of the library. */ TIFFVSetField(tif, tag, ap) TIFF *tif; int tag; va_list ap; { int status = 0; if (!OkToChangeTag(tif, tag)) { TIFFFieldInfo const *fip = TIFFFindFieldInfo(tag, TIFF_ANY); if (fip) TIFFError("TIFFVSetField", "%s: Cannot modify tag \"%s\" while writing", tif->tif_name, fip->field_name); } else status = TIFFSetField1(tif, tag, ap); return (status); } static TIFFGetField1(td, tag, ap) TIFFDirectory *td; int tag; va_list ap; { switch (tag) { case TIFFTAG_SUBFILETYPE: *va_arg(ap, u_long *) = td->td_subfiletype; break; case TIFFTAG_IMAGEWIDTH: *va_arg(ap, u_long *) = td->td_imagewidth; break; case TIFFTAG_IMAGELENGTH: *va_arg(ap, u_long *) = td->td_imagelength; break; case TIFFTAG_BITSPERSAMPLE: *va_arg(ap, u_short *) = td->td_bitspersample; break; case TIFFTAG_COMPRESSION: *va_arg(ap, u_short *) = td->td_compression; break; case TIFFTAG_PHOTOMETRIC: *va_arg(ap, u_short *) = td->td_photometric; break; case TIFFTAG_THRESHHOLDING: *va_arg(ap, u_short *) = td->td_threshholding; break; case TIFFTAG_FILLORDER: *va_arg(ap, u_short *) = td->td_fillorder; break; case TIFFTAG_DOCUMENTNAME: *va_arg(ap, char **) = td->td_documentname; break; case TIFFTAG_ARTIST: *va_arg(ap, char **) = td->td_artist; break; case TIFFTAG_DATETIME: *va_arg(ap, char **) = td->td_datetime; break; case TIFFTAG_HOSTCOMPUTER: *va_arg(ap, char **) = td->td_hostcomputer; break; case TIFFTAG_IMAGEDESCRIPTION: *va_arg(ap, char **) = td->td_imagedescription; break; case TIFFTAG_MAKE: *va_arg(ap, char **) = td->td_make; break; case TIFFTAG_MODEL: *va_arg(ap, char **) = td->td_model; break; case TIFFTAG_SOFTWARE: *va_arg(ap, char **) = td->td_software; break; case TIFFTAG_ORIENTATION: *va_arg(ap, u_short *) = td->td_orientation; break; case TIFFTAG_SAMPLESPERPIXEL: *va_arg(ap, u_short *) = td->td_samplesperpixel; break; case TIFFTAG_ROWSPERSTRIP: *va_arg(ap, u_long *) = td->td_rowsperstrip; break; case TIFFTAG_MINSAMPLEVALUE: *va_arg(ap, u_short *) = td->td_minsamplevalue; break; case TIFFTAG_MAXSAMPLEVALUE: *va_arg(ap, u_short *) = td->td_maxsamplevalue; break; case TIFFTAG_XRESOLUTION: *va_arg(ap, float *) = td->td_xresolution; break; case TIFFTAG_YRESOLUTION: *va_arg(ap, float *) = td->td_yresolution; break; case TIFFTAG_PLANARCONFIG: *va_arg(ap, u_short *) = td->td_planarconfig; break; case TIFFTAG_XPOSITION: *va_arg(ap, float *) = td->td_xposition; break; case TIFFTAG_YPOSITION: *va_arg(ap, float *) = td->td_yposition; break; case TIFFTAG_PAGENAME: *va_arg(ap, char **) = td->td_pagename; break; case TIFFTAG_GROUP3OPTIONS: *va_arg(ap, u_long *) = td->td_group3options; break; case TIFFTAG_GROUP4OPTIONS: *va_arg(ap, u_long *) = td->td_group4options; break; case TIFFTAG_RESOLUTIONUNIT: *va_arg(ap, u_short *) = td->td_resolutionunit; break; case TIFFTAG_PAGENUMBER: *va_arg(ap, u_short *) = td->td_pagenumber[0]; *va_arg(ap, u_short *) = td->td_pagenumber[1]; break; case TIFFTAG_HALFTONEHINTS: *va_arg(ap, u_short *) = td->td_halftonehints[0]; *va_arg(ap, u_short *) = td->td_halftonehints[1]; break; case TIFFTAG_COLORMAP: *va_arg(ap, u_short **) = td->td_colormap[0]; *va_arg(ap, u_short **) = td->td_colormap[1]; *va_arg(ap, u_short **) = td->td_colormap[2]; break; case TIFFTAG_PREDICTOR: *va_arg(ap, u_short *) = td->td_predictor; break; case TIFFTAG_STRIPOFFSETS: case TIFFTAG_TILEOFFSETS: *va_arg(ap, u_long **) = td->td_stripoffset; break; case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_TILEBYTECOUNTS: *va_arg(ap, u_long **) = td->td_stripbytecount; break; case TIFFTAG_MATTEING: *va_arg(ap, u_short *) = td->td_matteing; break; case TIFFTAG_EXTRASAMPLES: *va_arg(ap, u_short *) = td->td_matteing; *va_arg(ap, u_short **) = &td->td_matteing; break; case TIFFTAG_BADFAXLINES: *va_arg(ap, u_long *) = td->td_badfaxlines; break; case TIFFTAG_CLEANFAXDATA: *va_arg(ap, u_short *) = td->td_cleanfaxdata; break; case TIFFTAG_CONSECUTIVEBADFAXLINES: *va_arg(ap, u_long *) = td->td_badfaxrun; break; case TIFFTAG_TILEWIDTH: *va_arg(ap, u_long *) = td->td_tilewidth; break; case TIFFTAG_TILELENGTH: *va_arg(ap, u_long *) = td->td_tilelength; break; case TIFFTAG_TILEDEPTH: *va_arg(ap, u_long *) = td->td_tiledepth; break; case TIFFTAG_DATATYPE: *va_arg(ap, u_short *) = (td->td_sampleformat == SAMPLEFORMAT_VOID ? 0 : td->td_sampleformat); break; case TIFFTAG_SAMPLEFORMAT: *va_arg(ap, u_short *) = td->td_sampleformat; break; case TIFFTAG_IMAGEDEPTH: *va_arg(ap, u_long *) = td->td_imagedepth; break; #ifdef YCBCR_SUPPORT case TIFFTAG_YCBCRCOEFFICIENTS: *va_arg(ap, float **) = td->td_ycbcrcoeffs; break; case TIFFTAG_YCBCRPOSITIONING: *va_arg(ap, u_short *) = td->td_ycbcrpositioning; break; case TIFFTAG_YCBCRSUBSAMPLING: *va_arg(ap, u_short *) = td->td_ycbcrsubsampling[0]; *va_arg(ap, u_short *) = td->td_ycbcrsubsampling[1]; break; #endif #ifdef JPEG_SUPPORT case TIFFTAG_JPEGPROC: *va_arg(ap, u_short *) = td->td_jpegproc; break; case TIFFTAG_JPEGRESTARTINTERVAL: *va_arg(ap, u_short *) = td->td_jpegrestartinterval; break; case TIFFTAG_JPEGQTABLES: *va_arg(ap, u_char ***) = td->td_qtab; break; case TIFFTAG_JPEGDCTABLES: *va_arg(ap, u_char ***) = td->td_dctab; break; case TIFFTAG_JPEGACTABLES: *va_arg(ap, u_char ***) = td->td_actab; break; #endif #ifdef COLORIMETRY_SUPPORT case TIFFTAG_WHITEPOINT: *va_arg(ap, float **) = td->td_whitepoint; break; case TIFFTAG_PRIMARYCHROMATICITIES: *va_arg(ap, float **) = td->td_primarychromas; break; case TIFFTAG_TRANSFERFUNCTION: { int i; for (i = 0; i < td->td_samplesperpixel; i++) *va_arg(ap, u_short **) = td->td_transferfunction[i]; break; } case TIFFTAG_REFERENCEBLACKWHITE: *va_arg(ap, float **) = td->td_refblackwhite; break; #endif #ifdef CMYK_SUPPORT case TIFFTAG_INKSET: *va_arg(ap, u_short *) = td->td_inkset; break; case TIFFTAG_DOTRANGE: *va_arg(ap, u_short *) = td->td_dotrange[0]; *va_arg(ap, u_short *) = td->td_dotrange[1]; break; case TIFFTAG_INKNAMES: *va_arg(ap, char **) = td->td_inknames; break; case TIFFTAG_TARGETPRINTER: *va_arg(ap, char **) = td->td_targetprinter; break; #endif default: TIFFError("TIFFGetField1", "Internal error, no value returned for tag \"%s\"", TIFFFieldWithTag(tag)->field_name); break; } va_end(ap); } /* * Return the value of a field in the * internal directory structure. */ /*VARARGS2*/ DECLARE2V(TIFFGetField, TIFF*, tif, int, tag) { TIFFFieldInfo const *fip = TIFFFindFieldInfo(tag, TIFF_ANY); if (fip) { u_short bit = fip->field_bit; if (bit != FIELD_IGNORE && TIFFFieldSet(tif, bit)) { va_list ap; VA_START(ap, tag); (void) TIFFGetField1(&tif->tif_dir, tag, ap); va_end(ap); return (1); } } else TIFFError("TIFFGetField", "Unknown field, tag 0x%x", tag); return (0); } /* * Like TIFFGetField, but taking a varargs * parameter list. This routine is useful * for building higher-level interfaces on * top of the library. */ TIFFVGetField(tif, tag, ap) TIFF *tif; int tag; va_list ap; { TIFFFieldInfo const *fip = TIFFFindFieldInfo(tag, TIFF_ANY); if (fip) { u_short bit = fip->field_bit; if (bit != FIELD_IGNORE && TIFFFieldSet(tif, bit)) { (void) TIFFGetField1(&tif->tif_dir, tag, ap); return (1); } } else TIFFError("TIFFGetField", "Unknown field, tag 0x%x", tag); return (0); } /* * Internal interface to TIFFGetField... */ int /*VARARGS2*/ DECLARE2V(_TIFFgetfield, TIFFDirectory*, td, int, tag) { va_list ap; VA_START(ap, tag); (void) TIFFGetField1(td, tag, ap); va_end(ap); } #define CleanupField(member) { \ if (td->member) { \ free((char *)td->member); \ td->member = 0; \ } \ } /* * Release storage associated with a directory. */ TIFFFreeDirectory(tif) TIFF *tif; { register TIFFDirectory *td = &tif->tif_dir; CleanupField(td_colormap[0]); CleanupField(td_colormap[1]); CleanupField(td_colormap[2]); CleanupField(td_documentname); CleanupField(td_artist); CleanupField(td_datetime); CleanupField(td_hostcomputer); CleanupField(td_imagedescription); CleanupField(td_make); CleanupField(td_model); CleanupField(td_software); CleanupField(td_pagename); #ifdef YCBCR_SUPPORT CleanupField(td_ycbcrcoeffs); #endif #ifdef JPEG_SUPPORT CleanupField(td_qtab); CleanupField(td_dctab); CleanupField(td_actab); #endif #ifdef CMYK_SUPPORT CleanupField(td_inknames); CleanupField(td_targetprinter); #endif #ifdef COLORIMETRY_SUPPORT CleanupField(td_whitepoint); CleanupField(td_primarychromas); CleanupField(td_refblackwhite); CleanupField(td_transferfunction[0]); CleanupField(td_transferfunction[1]); CleanupField(td_transferfunction[2]); CleanupField(td_transferfunction[3]); #endif CleanupField(td_stripoffset); CleanupField(td_stripbytecount); } #undef CleanupField /* * Setup a default directory structure. */ TIFFDefaultDirectory(tif) TIFF *tif; { register TIFFDirectory *td = &tif->tif_dir; bzero((char *)td, sizeof (*td)); td->td_fillorder = FILLORDER_MSB2LSB; td->td_bitspersample = 1; td->td_threshholding = THRESHHOLD_BILEVEL; td->td_orientation = ORIENTATION_TOPLEFT; td->td_samplesperpixel = 1; td->td_predictor = 1; td->td_rowsperstrip = 0xffffffff; td->td_tilewidth = 0xffffffff; td->td_tilelength = 0xffffffff; td->td_tiledepth = 1; td->td_resolutionunit = RESUNIT_INCH; td->td_sampleformat = SAMPLEFORMAT_VOID; td->td_imagedepth = 1; #ifdef YCBCR_SUPPORT td->td_ycbcrsubsampling[0] = 2; td->td_ycbcrsubsampling[1] = 2; td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED; #endif #ifdef CMYK_SUPPORT td->td_inkset = INKSET_CMYK; #endif (void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); /* * NB: The directory is marked dirty as a result of setting * up the default compression scheme. However, this really * isn't correct -- we want TIFF_DIRTYDIRECT to be set only * if the user does something. We could just do the setup * by hand, but it seems better to use the normal mechanism * (i.e. TIFFSetField). */ tif->tif_flags &= ~TIFF_DIRTYDIRECT; return (1); } /* * Set the n-th directory as the current directory. * NB: Directories are numbered starting at 0. */ TIFFSetDirectory(tif, dirn) register TIFF *tif; int dirn; { static char module[] = "TIFFSetDirectory"; u_short dircount; long nextdir; int n; nextdir = tif->tif_header.tiff_diroff; for (n = dirn; n > 0 && nextdir != 0; n--) { if (!SeekOK(tif->tif_fd, nextdir) || !ReadOK(tif->tif_fd, &dircount, sizeof (dircount))) { TIFFError(module, "%s: Error fetching directory count", tif->tif_name); return (0); } if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount); lseek(tif->tif_fd, dircount*sizeof (TIFFDirEntry), L_INCR); if (!ReadOK(tif->tif_fd, &nextdir, sizeof (nextdir))) { TIFFError(module, "%s: Error fetching directory link", tif->tif_name); return (0); } if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong((u_long *)&nextdir); } tif->tif_nextdiroff = nextdir; /* * Set curdir to the actual directory index. The * -1 is because TIFFReadDirectory will increment * tif_curdir after successfully reading the directory. */ tif->tif_curdir = (dirn - n) - 1; return (TIFFReadDirectory(tif)); } ivtools-1.2.11a1/src/TIFF/tif_dirinfo.c000066400000000000000000000275441214471147700175200ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * Known Directory Tag Support. */ #include "tiffioP.h" #include "prototypes.h" #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif /* * NB: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG. * Also, if a tag can have both LONG and SHORT types * then the LONG must be placed before the SHORT for * writing to work properly. */ const TIFFFieldInfo tiffFieldInfo[] = { { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, FIELD_SUBFILETYPE, TRUE, "SubfileType" }, /* XXX SHORT for compatibility w/ old versions of the library */ { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_SHORT, FIELD_SUBFILETYPE, TRUE, "SubfileType" }, { TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, FIELD_SUBFILETYPE, TRUE, "OldSubfileType" }, { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, FIELD_IMAGEDIMENSIONS, FALSE, "ImageWidth" }, { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDIMENSIONS, FALSE, "ImageWidth" }, { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, FIELD_IMAGEDIMENSIONS, TRUE, "ImageLength" }, { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDIMENSIONS, TRUE, "ImageLength" }, { TIFFTAG_BITSPERSAMPLE, -1,-1, TIFF_SHORT, FIELD_BITSPERSAMPLE, FALSE, "BitsPerSample" }, { TIFFTAG_COMPRESSION, -1, 1, TIFF_SHORT, FIELD_COMPRESSION, FALSE, "Compression" }, { TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, FIELD_PHOTOMETRIC, FALSE, "PhotometricInterpretation" }, { TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, FIELD_THRESHHOLDING, TRUE, "Threshholding" }, { TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, FIELD_IGNORE, TRUE, "CellWidth" }, { TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, FIELD_IGNORE, TRUE, "CellLength" }, { TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, FIELD_FILLORDER, FALSE, "FillOrder" }, { TIFFTAG_DOCUMENTNAME, -1,-1, TIFF_ASCII, FIELD_DOCUMENTNAME, TRUE, "DocumentName" }, { TIFFTAG_IMAGEDESCRIPTION, -1,-1, TIFF_ASCII, FIELD_IMAGEDESCRIPTION, TRUE, "ImageDescription" }, { TIFFTAG_MAKE, -1,-1, TIFF_ASCII, FIELD_MAKE, TRUE, "Make" }, { TIFFTAG_MODEL, -1,-1, TIFF_ASCII, FIELD_MODEL, TRUE, "Model" }, { TIFFTAG_STRIPOFFSETS, -1,-1, TIFF_LONG, FIELD_STRIPOFFSETS, FALSE, "StripOffsets" }, { TIFFTAG_STRIPOFFSETS, -1,-1, TIFF_SHORT, FIELD_STRIPOFFSETS, FALSE, "StripOffsets" }, { TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, FIELD_ORIENTATION, FALSE, "Orientation" }, { TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, FIELD_SAMPLESPERPIXEL, FALSE, "SamplesPerPixel" }, { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, FIELD_ROWSPERSTRIP, FALSE, "RowsPerStrip" }, { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_SHORT, FIELD_ROWSPERSTRIP, FALSE, "RowsPerStrip" }, { TIFFTAG_STRIPBYTECOUNTS, -1,-1, TIFF_LONG, FIELD_STRIPBYTECOUNTS, FALSE, "StripByteCounts" }, { TIFFTAG_STRIPBYTECOUNTS, -1,-1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS, FALSE, "StripByteCounts" }, { TIFFTAG_MINSAMPLEVALUE, -2,-1, TIFF_SHORT, FIELD_MINSAMPLEVALUE, TRUE, "MinSampleValue" }, { TIFFTAG_MAXSAMPLEVALUE, -2,-1, TIFF_SHORT, FIELD_MAXSAMPLEVALUE, TRUE, "MaxSampleValue" }, { TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_RESOLUTION, FALSE, "XResolution" }, { TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_RESOLUTION, FALSE, "YResolution" }, { TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, FIELD_PLANARCONFIG, FALSE, "PlanarConfiguration" }, { TIFFTAG_PAGENAME, -1,-1, TIFF_ASCII, FIELD_PAGENAME, TRUE, "PageName" }, { TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, FIELD_POSITION, TRUE, "XPosition" }, { TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, FIELD_POSITION, TRUE, "YPosition" }, { TIFFTAG_FREEOFFSETS, -1,-1, TIFF_LONG, FIELD_IGNORE, FALSE, "FreeOffsets" }, { TIFFTAG_FREEBYTECOUNTS, -1,-1, TIFF_LONG, FIELD_IGNORE, FALSE, "FreeByteCounts" }, { TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE, TRUE, "GrayResponseUnit" }, { TIFFTAG_GRAYRESPONSECURVE,-1,-1, TIFF_SHORT, FIELD_IGNORE, TRUE, "GrayResponseCurve" }, { TIFFTAG_GROUP3OPTIONS, 1, 1, TIFF_LONG, FIELD_GROUP3OPTIONS, FALSE, "Group3Options" }, { TIFFTAG_GROUP4OPTIONS, 1, 1, TIFF_LONG, FIELD_GROUP4OPTIONS, FALSE, "Group4Options" }, { TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, FIELD_RESOLUTIONUNIT, FALSE, "ResolutionUnit" }, { TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, FIELD_PAGENUMBER, TRUE, "PageNumber" }, { TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE, TRUE, "ColorResponseUnit" }, #ifdef COLORIMETRY_SUPPORT { TIFFTAG_TRANSFERFUNCTION, -1,-1, TIFF_SHORT, FIELD_TRANSFERFUNCTION, TRUE, "TransferFunction" }, #endif { TIFFTAG_SOFTWARE, -1,-1, TIFF_ASCII, FIELD_SOFTWARE, TRUE, "Software" }, { TIFFTAG_DATETIME, 20,20, TIFF_ASCII, FIELD_DATETIME, TRUE, "DateTime" }, { TIFFTAG_ARTIST, -1,-1, TIFF_ASCII, FIELD_ARTIST, TRUE, "Artist" }, { TIFFTAG_HOSTCOMPUTER, -1,-1, TIFF_ASCII, FIELD_HOSTCOMPUTER, TRUE, "HostComputer" }, { TIFFTAG_PREDICTOR, 1, 1, TIFF_SHORT, FIELD_PREDICTOR, FALSE, "Predictor" }, #ifdef COLORIMETRY_SUPPORT { TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL,FIELD_WHITEPOINT, TRUE, "WhitePoint" }, { TIFFTAG_PRIMARYCHROMATICITIES,6,6,TIFF_RATIONAL,FIELD_PRIMARYCHROMAS, TRUE, "PrimaryChromaticities" }, #endif { TIFFTAG_COLORMAP, -1,-1, TIFF_SHORT, FIELD_COLORMAP, TRUE, "ColorMap" }, { TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, FIELD_HALFTONEHINTS, TRUE, "HalftoneHints" }, { TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, FIELD_TILEDIMENSIONS, FALSE, "TileWidth" }, { TIFFTAG_TILEWIDTH, 1, 1, TIFF_SHORT, FIELD_TILEDIMENSIONS, FALSE, "TileWidth" }, { TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, FIELD_TILEDIMENSIONS, FALSE, "TileLength" }, { TIFFTAG_TILELENGTH, 1, 1, TIFF_SHORT, FIELD_TILEDIMENSIONS, FALSE, "TileLength" }, { TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG, FIELD_STRIPOFFSETS, FALSE, "TileOffsets" }, { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG, FIELD_STRIPBYTECOUNTS, FALSE, "TileByteCounts" }, { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS, FALSE, "TileByteCounts" }, { TIFFTAG_BADFAXLINES, 1, 1, TIFF_LONG, FIELD_BADFAXLINES, TRUE, "BadFaxLines" }, { TIFFTAG_BADFAXLINES, 1, 1, TIFF_SHORT, FIELD_BADFAXLINES, TRUE, "BadFaxLines" }, { TIFFTAG_CLEANFAXDATA, 1, 1, TIFF_SHORT, FIELD_CLEANFAXDATA, TRUE, "CleanFaxData" }, { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_LONG,FIELD_BADFAXRUN, TRUE, "ConsecutiveBadFaxLines" }, { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_SHORT,FIELD_BADFAXRUN, TRUE, "ConsecutiveBadFaxLines" }, #ifdef CMYK_SUPPORT /* 6.0 CMYK tags */ { TIFFTAG_INKSET, 1, 1, TIFF_SHORT, FIELD_INKSET, FALSE, "InkSet" }, { TIFFTAG_INKNAMES, -1,-1, TIFF_ASCII, FIELD_INKNAMES, TRUE, "InkNames" }, { TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, FIELD_DOTRANGE, FALSE, "DotRange" }, { TIFFTAG_DOTRANGE, 2, 2, TIFF_BYTE, FIELD_DOTRANGE, FALSE, "DotRange" }, { TIFFTAG_TARGETPRINTER, -1,-1, TIFF_ASCII, FIELD_TARGETPRINTER, TRUE, "TargetPrinter" }, #endif { TIFFTAG_EXTRASAMPLES, -1,-1, TIFF_SHORT, FIELD_MATTEING, FALSE, "ExtraSamples" }, { TIFFTAG_SAMPLEFORMAT, -1,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, FALSE, "SampleFormat" }, #ifdef notdef { TIFFTAG_SMINSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMINSAMPLEVALUE, TRUE, "SMinSampleValue" }, { TIFFTAG_SMAXSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMAXSAMPLEVALUE, TRUE, "SMaxSampleValue" }, #endif #ifdef JPEG_SUPPORT /* 6.0 JPEG tags */ { TIFFTAG_JPEGPROC, 1, 1, TIFF_SHORT, FIELD_JPEGPROC, FALSE, "JPEGProc" }, { TIFFTAG_JPEGIFOFFSET, 1, 1, TIFF_LONG, FIELD_IGNORE, FALSE, "JPEGInterchangeFormat" }, { TIFFTAG_JPEGIFBYTECOUNT, 1, 1, TIFF_LONG, FIELD_IGNORE, FALSE, "JPEGInterchangeFormatLength" }, { TIFFTAG_JPEGRESTARTINTERVAL,1,1, TIFF_SHORT,FIELD_JPEGRESTARTINTERVAL, FALSE, "JPEGRestartInterval" }, { TIFFTAG_JPEGQTABLES, -2,-1, TIFF_LONG, FIELD_JPEGQTABLES, FALSE, "JPEGQTables" }, { TIFFTAG_JPEGDCTABLES, -2,-1, TIFF_LONG, FIELD_JPEGDCTABLES, FALSE, "JPEGDCTables" }, { TIFFTAG_JPEGACTABLES, -2,-1, TIFF_LONG, FIELD_JPEGACTABLES, FALSE, "JPEGACTables" }, #endif #ifdef YCBCR_SUPPORT /* 6.0 YCbCr tags */ { TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, FIELD_YCBCRCOEFFICIENTS, FALSE, "YCbCrCoefficients" }, { TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, FIELD_YCBCRSUBSAMPLING, FALSE, "YCbCrSubsampling" }, { TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, FIELD_YCBCRPOSITIONING, FALSE, "YCbCrPositioning" }, #endif #ifdef COLORIMETRY_SUPPORT { TIFFTAG_REFERENCEBLACKWHITE,-1,-1,TIFF_RATIONAL, FIELD_REFBLACKWHITE, FALSE, "ReferenceBlackWhite" }, /* XXX temporarily accept LONG for backwards compatibility */ { TIFFTAG_REFERENCEBLACKWHITE,-1,-1,TIFF_LONG, FIELD_REFBLACKWHITE, FALSE, "ReferenceBlackWhite" }, #endif /* begin SGI tags */ { TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, FIELD_MATTEING, FALSE, "Matteing" }, { TIFFTAG_DATATYPE, -2,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, FALSE, "DataType" }, { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, FIELD_IMAGEDEPTH, FALSE, "ImageDepth" }, { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDEPTH, FALSE, "ImageDepth" }, { TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, FIELD_TILEDEPTH, FALSE, "TileDepth" }, { TIFFTAG_TILEDEPTH, 1, 1, TIFF_SHORT, FIELD_TILEDEPTH, FALSE, "TileDepth" }, /* end SGI tags */ { 0 } }; const int tiffDataWidth[] = { 1, /* nothing */ 1, /* TIFF_BYTE */ 1, /* TIFF_ASCII */ 2, /* TIFF_SHORT */ 4, /* TIFF_LONG */ 8, /* TIFF_RATIONAL */ 1, /* TIFF_SBYTE */ 1, /* TIFF_UNDEFINED */ 2, /* TIFF_SSHORT */ 4, /* TIFF_SLONG */ 8, /* TIFF_SRATIONAL */ 4, /* TIFF_FLOAT */ 8, /* TIFF_DOUBLE */ }; TIFFFieldInfo const * DECLARE2(TIFFFindFieldInfo, u_short, tag, TIFFDataType, dt) { static TIFFFieldInfo const *last = NULL; register TIFFFieldInfo const *fip; if (last && last->field_tag == tag && (dt == TIFF_ANY || dt == last->field_type)) return (last); /* NB: if table gets big, use sorted search (e.g. binary search) */ for (fip = tiffFieldInfo; fip->field_tag; fip++) if (fip->field_tag == tag && (dt == TIFF_ANY || fip->field_type == dt)) return (last = fip); return ((TIFFFieldInfo *)0); } TIFFFieldInfo const * DECLARE1(TIFFFieldWithTag, u_short, tag) { TIFFFieldInfo const *fip = TIFFFindFieldInfo(tag, TIFF_ANY); if (fip) return (fip); TIFFError("TIFFFieldWithTag", "Internal error, unknown tag 0x%x", tag); exit(-1); /*NOTREACHED*/ } ivtools-1.2.11a1/src/TIFF/tif_dirread.c000066400000000000000000000760531214471147700174770ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * Directory Read Support Routines. * * NB: Beware of the varargs declarations for routines in * this file. The names and types of variables has been * carefully chosen to make things work with compilers that * are busted in one way or another (e.g. SGI/MIPS). */ #include "tiffioP.h" #define IGNORE 0 /* tag placeholder used below */ #if HAVE_IEEEFP #define TIFFCvtIEEEFloatToNative(tif, n, fp) #endif #include "prototypes.h" #if USE_PROTOTYPES static EstimateStripByteCounts(TIFF *, TIFFDirEntry *, u_int); static MissingRequired(TIFF *, char *); static CheckDirCount(TIFF *, TIFFDirEntry *, u_long); static TIFFFetchData(TIFF *, TIFFDirEntry *, char *); static TIFFFetchString(TIFF *, TIFFDirEntry *, char *); static float TIFFFetchRational(TIFF *, TIFFDirEntry *); static TIFFFetchNormalTag(TIFF *, TIFFDirEntry *); static TIFFFetchPerSampleShorts(TIFF *, TIFFDirEntry *, long *); static TIFFFetchShortArray(TIFF *, TIFFDirEntry *, u_short []); static TIFFFetchStripThing(TIFF *, TIFFDirEntry *, long, u_long **); static TIFFFetchRefBlackWhite(TIFF *, TIFFDirEntry *); static TIFFFetchJPEGQTables(TIFF *, TIFFDirEntry *); static TIFFFetchJPEGCTables(TIFF *, TIFFDirEntry *, u_char ***); static TIFFFetchExtraSamples(TIFF *, TIFFDirEntry *); static float TIFFFetchFloat(TIFF *, TIFFDirEntry *); static int TIFFFetchFloatArray(TIFF *, TIFFDirEntry *, float *); extern int TIFFSetCompressionScheme(TIFF *, int); extern int TIFFDefaultDirectory(TIFF*); extern int TIFFFreeDirectory(TIFF*); #else static EstimateStripByteCounts(); static MissingRequired(); static CheckDirCount(); static TIFFFetchData(); static TIFFFetchString(); static float TIFFFetchRational(); static TIFFFetchNormalTag(); static TIFFFetchPerSampleShorts(); static TIFFFetchShortArray(); static TIFFFetchStripThing(); static TIFFFetchRefBlackWhite(); static TIFFFetchJPEGQTables(); static TIFFFetchJPEGCTables(); static TIFFFetchExtraSamples(); static float TIFFFetchFloat(); static int TIFFFetchFloatArray(); extern int TIFFSetCompressionScheme(); extern int TIFFDefaultDirectory(); extern int TIFFFreeDirectory(); #endif static char * CheckMalloc(tif, n, what) TIFF *tif; int n; char *what; { char *cp = malloc(n); if (cp == NULL) TIFFError(tif->tif_name, "No space %s", what); return (cp); } /* * Read the next TIFF directory from a file * and convert it to the internal format. * We read directories sequentially. */ TIFFReadDirectory(tif) TIFF *tif; { register TIFFDirEntry *dp; register int n; register TIFFDirectory *td; TIFFDirEntry *dir; long v; const TIFFFieldInfo *fip; u_short dircount; char *cp; int diroutoforderwarning = 0; tif->tif_diroff = tif->tif_nextdiroff; if (tif->tif_diroff == 0) /* no more directories */ return (0); tif->tif_curdir++; if (!isMapped(tif)) { if (!SeekOK(tif->tif_fd, tif->tif_diroff)) { TIFFError(tif->tif_name, "Seek error accessing TIFF directory"); return (0); } if (!ReadOK(tif->tif_fd, &dircount, sizeof (short))) { TIFFError(tif->tif_name, "Can not read TIFF directory count"); return (0); } if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount); dir = (TIFFDirEntry *)CheckMalloc(tif, dircount * sizeof (TIFFDirEntry), "to read TIFF directory"); if (dir == NULL) return (0); if (!ReadOK(tif->tif_fd, dir, dircount*sizeof (TIFFDirEntry))) { TIFFError(tif->tif_name, "Can not read TIFF directory"); goto bad; } /* * Read offset to next directory for sequential scans. */ if (!ReadOK(tif->tif_fd, &tif->tif_nextdiroff, sizeof (long))) tif->tif_nextdiroff = 0; #ifdef MMAP_SUPPORT } else { off_t off = tif->tif_diroff; if (off + sizeof (short) > tif->tif_size) { TIFFError(tif->tif_name, "Can not read TIFF directory count"); return (0); } else bcopy(tif->tif_base + off, &dircount, sizeof (short)); off += sizeof (short); if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount); dir = (TIFFDirEntry *)CheckMalloc(tif, dircount * sizeof (TIFFDirEntry), "to read TIFF directory"); if (dir == NULL) return (0); if (off + dircount*sizeof (TIFFDirEntry) > tif->tif_size) { TIFFError(tif->tif_name, "Can not read TIFF directory"); goto bad; } else bcopy(tif->tif_base + off, dir, dircount*sizeof (TIFFDirEntry)); off += dircount* sizeof (TIFFDirEntry); if (off + sizeof (long) < tif->tif_size) bcopy(tif->tif_base + off, &tif->tif_nextdiroff, sizeof (long)); else tif->tif_nextdiroff = 0; #endif } if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong((u_long *)&tif->tif_nextdiroff); tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ /* * Setup default value and then make a pass over * the fields to check type and tag information, * and to extract info required to size data * structures. A second pass is made afterwards * to read in everthing not taken in the first pass. */ td = &tif->tif_dir; /* free any old stuff and reinit */ TIFFFreeDirectory(tif); TIFFDefaultDirectory(tif); /* * Electronic Arts writes gray-scale TIFF files * without a PlanarConfiguration directory entry. * Thus we setup a default value here, even though * the TIFF spec says there is no default value. */ TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); for (fip = tiffFieldInfo, dp = dir, n = dircount; n > 0; n--, dp++) { if (tif->tif_flags & TIFF_SWAB) { TIFFSwabArrayOfShort(&dp->tdir_tag, 2); TIFFSwabArrayOfLong(&dp->tdir_count, 2); } /* * Find the field information entry for this tag. */ /* * Silicon Beach (at least) writes unordered * directory tags (violating the spec). Handle * it here, but be obnoxious (maybe they'll fix it?). */ if (dp->tdir_tag < fip->field_tag) { if (!diroutoforderwarning) { TIFFWarning(tif->tif_name, "invalid TIFF directory; tags are not sorted in ascending order"); diroutoforderwarning = 1; } fip = tiffFieldInfo; /* O(n^2) */ } while (fip->field_tag && fip->field_tag < dp->tdir_tag) fip++; if (!fip->field_tag || fip->field_tag != dp->tdir_tag) { TIFFWarning(tif->tif_name, "unknown field with tag %d (0x%x) ignored", dp->tdir_tag, dp->tdir_tag); dp->tdir_tag = IGNORE; fip = tiffFieldInfo; /* restart search */ continue; } /* * Null out old tags that we ignore. */ if (fip->field_bit == FIELD_IGNORE) { ignore: dp->tdir_tag = IGNORE; continue; } /* * Check data type. */ while (dp->tdir_type != (u_short)fip->field_type) { if (fip->field_type == TIFF_ANY) /* wildcard */ break; fip++; if (!fip->field_tag || fip->field_tag != dp->tdir_tag) { TIFFWarning(tif->tif_name, "wrong data type %d for \"%s\"; tag ignored", dp->tdir_type, fip[-1].field_name); goto ignore; } } /* * Check count if known in advance. */ if (fip->field_readcount != TIFF_VARIABLE) { u_long expected = (fip->field_readcount == TIFF_SPP) ? (u_long) td->td_samplesperpixel : (u_long) fip->field_readcount; if (!CheckDirCount(tif, dp, expected)) goto ignore; } switch (dp->tdir_tag) { case TIFFTAG_STRIPOFFSETS: case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_TILEOFFSETS: case TIFFTAG_TILEBYTECOUNTS: TIFFSetFieldBit(tif, fip->field_bit); break; case TIFFTAG_IMAGEWIDTH: case TIFFTAG_IMAGELENGTH: case TIFFTAG_IMAGEDEPTH: case TIFFTAG_TILELENGTH: case TIFFTAG_TILEWIDTH: case TIFFTAG_TILEDEPTH: case TIFFTAG_PLANARCONFIG: case TIFFTAG_SAMPLESPERPIXEL: case TIFFTAG_ROWSPERSTRIP: if (!TIFFFetchNormalTag(tif, dp)) goto bad; break; } } /* * Allocate directory structure and setup defaults. */ if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { MissingRequired(tif, "ImageLength"); goto bad; } if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { MissingRequired(tif, "PlanarConfiguration"); goto bad; } /* * Setup appropriate structures (by strip or by tile) */ if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { td->td_stripsperimage = (td->td_rowsperstrip == 0xffffffff ? (td->td_imagelength != 0 ? 1 : 0) : howmany(td->td_imagelength, td->td_rowsperstrip)); td->td_tilewidth = td->td_imagewidth; td->td_tilelength = td->td_rowsperstrip; td->td_tiledepth = td->td_imagedepth; tif->tif_flags &= ~TIFF_ISTILED; } else { td->td_stripsperimage = TIFFNumberOfTiles(tif); tif->tif_flags |= TIFF_ISTILED; } td->td_nstrips = td->td_stripsperimage; if (td->td_planarconfig == PLANARCONFIG_SEPARATE) td->td_nstrips *= td->td_samplesperpixel; if (td->td_nstrips > 0 && !TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) { MissingRequired(tif, isTiled(tif) ? "TileOffsets" : "StripOffsets"); goto bad; } /* * Second pass: extract other information. */ for (dp = dir, n = dircount; n > 0; n--, dp++) { if (dp->tdir_tag == IGNORE) continue; switch (dp->tdir_tag) { case TIFFTAG_COMPRESSION: case TIFFTAG_MINSAMPLEVALUE: case TIFFTAG_MAXSAMPLEVALUE: case TIFFTAG_BITSPERSAMPLE: /* * The 5.0 spec says the Compression tag has * one value, while earlier specs say it has * one value per sample. Because of this, we * accept the tag if one value is supplied. * * The MinSampleValue, MaxSampleValue and * BitsPerSample tags are supposed to be written * as one value/sample, but some vendors incorrectly * write one value only -- so we accept that * as well (yech). */ if (dp->tdir_count == 1) { v = TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); if (!TIFFSetField(tif, dp->tdir_tag, (int)v)) goto bad; break; } /* fall thru... */ case TIFFTAG_DATATYPE: case TIFFTAG_SAMPLEFORMAT: if (!TIFFFetchPerSampleShorts(tif, dp, &v) || !TIFFSetField(tif, dp->tdir_tag, (int)v)) goto bad; break; case TIFFTAG_STRIPOFFSETS: case TIFFTAG_TILEOFFSETS: if (!TIFFFetchStripThing(tif, dp, td->td_nstrips, &td->td_stripoffset)) goto bad; break; case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_TILEBYTECOUNTS: if (!TIFFFetchStripThing(tif, dp, td->td_nstrips, &td->td_stripbytecount)) goto bad; break; case TIFFTAG_IMAGELENGTH: case TIFFTAG_ROWSPERSTRIP: case TIFFTAG_TILELENGTH: case TIFFTAG_TILEWIDTH: case TIFFTAG_TILEDEPTH: case TIFFTAG_SAMPLESPERPIXEL: case TIFFTAG_PLANARCONFIG: /* handled in first pass above */ break; case TIFFTAG_COLORMAP: if (!CheckDirCount(tif,dp,3*(1L<td_bitspersample))) break; /* fall thru... */ case TIFFTAG_TRANSFERFUNCTION: v = (1L<td_bitspersample) * sizeof (u_short); cp = CheckMalloc(tif, dp->tdir_count * sizeof (u_short), "to read \"TransferFunction\" tag"); if (cp != NULL) { if (TIFFFetchData(tif, dp, cp)) { /* * This deals with there being only * one array to apply to all samples. */ if (dp->tdir_count == 1L<td_bitspersample) v = 0; /* NB: we assume samples/pixel <= 4 */ TIFFSetField(tif, dp->tdir_tag, cp, cp+v, cp+2*v, cp+3*v); } free(cp); } break; case TIFFTAG_PAGENUMBER: if (TIFFFetchShortArray(tif, dp, td->td_pagenumber)) TIFFSetFieldBit(tif, FIELD_PAGENUMBER); break; case TIFFTAG_HALFTONEHINTS: if (TIFFFetchShortArray(tif, dp, td->td_halftonehints)) TIFFSetFieldBit(tif, FIELD_HALFTONEHINTS); break; #ifdef COLORIMETRY_SUPPORT case TIFFTAG_REFERENCEBLACKWHITE: (void) TIFFFetchRefBlackWhite(tif, dp); break; #endif #ifdef YCBCR_SUPPORT case TIFFTAG_YCBCRSUBSAMPLING: if (TIFFFetchShortArray(tif, dp, td->td_ycbcrsubsampling)) TIFFSetFieldBit(tif, FIELD_YCBCRSUBSAMPLING); break; #endif #ifdef CMYK_SUPPORT case TIFFTAG_DOTRANGE: if (TIFFFetchShortArray(tif, dp, td->td_dotrange)) TIFFSetFieldBit(tif, FIELD_DOTRANGE); break; #endif #ifdef JPEG_SUPPORT case TIFFTAG_JPEGQTABLES: if (TIFFFetchJPEGQTables(tif, dp)) TIFFSetFieldBit(tif, FIELD_JPEGQTABLES); break; case TIFFTAG_JPEGDCTABLES: if (TIFFFetchJPEGCTables(tif, dp, &td->td_dctab)) TIFFSetFieldBit(tif, FIELD_JPEGDCTABLES); break; case TIFFTAG_JPEGACTABLES: if (TIFFFetchJPEGCTables(tif, dp, &td->td_actab)) TIFFSetFieldBit(tif, FIELD_JPEGACTABLES); break; #endif case TIFFTAG_EXTRASAMPLES: (void) TIFFFetchExtraSamples(tif, dp); break; /* BEGIN REV 4.0 COMPATIBILITY */ case TIFFTAG_OSUBFILETYPE: v = 0; switch (TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset)) { case OFILETYPE_REDUCEDIMAGE: v = FILETYPE_REDUCEDIMAGE; break; case OFILETYPE_PAGE: v = FILETYPE_PAGE; break; } if (v) (void) TIFFSetField(tif, TIFFTAG_SUBFILETYPE, (int)v); break; /* END REV 4.0 COMPATIBILITY */ default: (void) TIFFFetchNormalTag(tif, dp); break; } } /* * Verify Palette image has a Colormap. */ if (td->td_photometric == PHOTOMETRIC_PALETTE && !TIFFFieldSet(tif, FIELD_COLORMAP)) { MissingRequired(tif, "Colormap"); goto bad; } /* * Attempt to deal with a missing StripByteCounts tag. */ if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) { /* * Some manufacturers violate the spec by not giving * the size of the strips. In this case, assume there * is one uncompressed strip of data. */ if (td->td_nstrips > 1) { MissingRequired(tif, "StripByteCounts"); goto bad; } TIFFWarning(tif->tif_name, "TIFF directory is missing required \"%s\" field, calculating from imagelength", TIFFFieldWithTag(TIFFTAG_STRIPBYTECOUNTS)->field_name); EstimateStripByteCounts(tif, dir, dircount); } else if (td->td_nstrips == 1 && td->td_stripbytecount[0] == 0) { /* * Plexus (and others) sometimes give a value * of zero for a tag when they don't know what * the correct value is! Try and handle the * simple case of estimating the size of a one * strip image. */ TIFFWarning(tif->tif_name, "Bogus \"%s\" field, ignoring and calculating from imagelength", TIFFFieldWithTag(TIFFTAG_STRIPBYTECOUNTS)->field_name); EstimateStripByteCounts(tif, dir, dircount); } if (dir) free((char *)dir); if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) td->td_maxsamplevalue = (1L<td_bitspersample)-1; /* * Setup default compression scheme. */ if (!TIFFFieldSet(tif, FIELD_COMPRESSION)) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); /* * Reinitialize i/o since we are starting on a new directory. */ tif->tif_row = -1; tif->tif_curstrip = -1; tif->tif_col = -1; tif->tif_curtile = -1; tif->tif_tilesize = TIFFTileSize(tif); tif->tif_scanlinesize = TIFFScanlineSize(tif); return (1); bad: if (dir) free((char *)dir); return (0); } static EstimateStripByteCounts(tif, dir, dircount) TIFF *tif; TIFFDirEntry *dir; u_int dircount; { register TIFFDirEntry *dp; register TIFFDirectory *td = &tif->tif_dir; register int n; td->td_stripbytecount = (u_long *) CheckMalloc(tif, sizeof (u_long), "for \"StripByteCounts\" array"); if (td->td_compression != COMPRESSION_NONE) { u_long space = sizeof (TIFFHeader) + sizeof (short) + (dircount * sizeof (TIFFDirEntry)) + sizeof (long); long filesize = TIFFGetFileSize(tif->tif_fd); /* calculate amount of space used by indirect values */ for (dp = dir, n = dircount; n > 0; n--, dp++) { int cc = dp->tdir_count * tiffDataWidth[dp->tdir_type]; if (cc > sizeof (long)) space += cc; } td->td_stripbytecount[0] = filesize - space; /* * This gross hack handles the case were the offset to * the strip is past the place where we think the strip * should begin. Since a strip of data must be contiguous, * it's safe to assume that we've overestimated the amount * of data in the strip and trim this number back accordingly. */ if (td->td_stripoffset[0] + td->td_stripbytecount[0] > filesize) td->td_stripbytecount[0] = filesize - td->td_stripoffset[0]; } else { u_long rowbytes = howmany(td->td_bitspersample * td->td_samplesperpixel * td->td_imagewidth, 8); td->td_stripbytecount[0] = td->td_imagelength * rowbytes; } TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) td->td_rowsperstrip = td->td_imagelength; } static MissingRequired(tif, tagname) TIFF *tif; char *tagname; { TIFFError(tif->tif_name, "TIFF directory is missing required \"%s\" field", tagname); } /* * Check the count field of a directory * entry against a known value. The caller * is expected to skip/ignore the tag if * there is a mismatch. */ static CheckDirCount(tif, dir, count) TIFF *tif; TIFFDirEntry *dir; u_long count; { if (count != dir->tdir_count) { TIFFWarning(tif->tif_name, "incorrect count for field \"%s\" (%lu, expecting %lu); tag ignored", TIFFFieldWithTag(dir->tdir_tag)->field_name, dir->tdir_count, count); return (0); } return (1); } /* * Fetch a contiguous directory item. */ static TIFFFetchData(tif, dir, cp) TIFF *tif; TIFFDirEntry *dir; char *cp; { int cc, w; w = tiffDataWidth[dir->tdir_type]; cc = dir->tdir_count * w; if (!isMapped(tif)) { if (!SeekOK(tif->tif_fd, dir->tdir_offset)) goto bad; if (!ReadOK(tif->tif_fd, cp, cc)) goto bad; #ifdef MMAP_SUPPORT } else { if (dir->tdir_offset + cc > tif->tif_size) goto bad; bcopy(tif->tif_base + dir->tdir_offset, cp, cc); #endif } if (tif->tif_flags & TIFF_SWAB) { switch (dir->tdir_type) { case TIFF_SHORT: case TIFF_SSHORT: TIFFSwabArrayOfShort((u_short *)cp, dir->tdir_count); break; case TIFF_LONG: case TIFF_SLONG: case TIFF_FLOAT: TIFFSwabArrayOfLong((u_long *)cp, dir->tdir_count); break; case TIFF_RATIONAL: case TIFF_SRATIONAL: TIFFSwabArrayOfLong((u_long *)cp, 2*dir->tdir_count); break; } } return (cc); bad: TIFFError(tif->tif_name, "Error fetching data for field \"%s\"", TIFFFieldWithTag(dir->tdir_tag)->field_name); return (0); } /* * Fetch an ASCII item from the file. */ static TIFFFetchString(tif, dir, cp) TIFF *tif; TIFFDirEntry *dir; char *cp; { if (dir->tdir_count <= 4) { u_long l = dir->tdir_offset; if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(&l); bcopy(&l, cp, dir->tdir_count); return (1); } return (TIFFFetchData(tif, dir, cp)); } /* * Convert numerator+denominator to float. */ static int cvtRational(tif, dir, num, denom, rv) TIFF *tif; TIFFDirEntry *dir; u_long num, denom; float *rv; { if (denom == 0) { TIFFError(tif->tif_name, "%s: Rational with zero denominator (num = %lu)", TIFFFieldWithTag(dir->tdir_tag)->field_name, num); return (0); } else { if (dir->tdir_type == TIFF_RATIONAL) *rv = ((float)num / (float)denom); else *rv = ((float)(long)num / (float)(long)denom); return (1); } } /* * Fetch a rational item from the file * at offset off and return the value * as a floating point number. */ static float TIFFFetchRational(tif, dir) TIFF *tif; TIFFDirEntry *dir; { u_long l[2]; float v; return (!TIFFFetchData(tif, dir, (char *)l) || !cvtRational(tif, dir, l[0], l[1], &v) ? 1. : v); } /* * Fetch a single floating point value * from the offset field and return it * as a native float. */ static float TIFFFetchFloat(tif, dir) TIFF *tif; TIFFDirEntry *dir; { float v = (float) TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset); TIFFCvtIEEEFloatToNative(tif, 1, &v); return (v); } /* * Fetch an array of BYTE or SBYTE values. */ static TIFFFetchByteArray(tif, dir, v) TIFF *tif; TIFFDirEntry *dir; u_short v[]; { if (dir->tdir_count <= 4) { /* * Extract data from offset field. */ if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { switch (dir->tdir_count) { case 4: v[3] = dir->tdir_offset & 0xff; case 3: v[2] = (dir->tdir_offset >> 8) & 0xff; case 2: v[1] = (dir->tdir_offset >> 16) & 0xff; case 1: v[0] = dir->tdir_offset >> 24; } } else { switch (dir->tdir_count) { case 4: v[3] = dir->tdir_offset >> 24; case 3: v[2] = (dir->tdir_offset >> 16) & 0xff; case 2: v[1] = (dir->tdir_offset >> 8) & 0xff; case 1: v[0] = dir->tdir_offset & 0xff; } } return (1); } else return (TIFFFetchData(tif, dir, (char *)v)); /* XXX */ } /* * Fetch an array of SHORT or SSHORT values. */ static TIFFFetchShortArray(tif, dir, v) TIFF *tif; TIFFDirEntry *dir; u_short v[]; { if (dir->tdir_count <= 2) { if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { switch (dir->tdir_count) { case 2: v[1] = dir->tdir_offset & 0xffff; case 1: v[0] = dir->tdir_offset >> 16; } } else { switch (dir->tdir_count) { case 2: v[1] = dir->tdir_offset >> 16; case 1: v[0] = dir->tdir_offset & 0xffff; } } return (1); } else return (TIFFFetchData(tif, dir, (char *)v)); } /* * Fetch an array of LONG or SLONG values. */ static TIFFFetchLongArray(tif, dir, v) TIFF *tif; TIFFDirEntry *dir; u_long v[]; { if (dir->tdir_count == 1) { v[0] = dir->tdir_offset; return (1); } else return (TIFFFetchData(tif, dir, (char *)v)); } /* * Fetch an array of RATIONAL or SRATIONAL values. */ static TIFFFetchRationalArray(tif, dir, v) TIFF *tif; TIFFDirEntry *dir; float v[]; { int ok = 0; u_long *l; l = (u_long *)CheckMalloc(tif, dir->tdir_count*tiffDataWidth[dir->tdir_type], "to fetch array of rationals"); if (l) { if (TIFFFetchData(tif, dir, (char *)l)) { u_long i; for (i = 0; i < dir->tdir_count; i++) { ok = cvtRational(tif, dir, l[2*i+0], l[2*i+1], &v[i]); if (!ok) break; } } free((char *)l); } return (ok); } /* * Fetch an array of FLOAT values. */ static TIFFFetchFloatArray(tif, dir, v) TIFF *tif; TIFFDirEntry *dir; float v[]; { if (TIFFFetchData(tif, dir, (char *)v)) { TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); return (1); } else return (0); } /* * Fetch a tag that is not handled by special case code. * * NB: DOUBLE and UNDEFINED types are not handled. */ static TIFFFetchNormalTag(tif, dp) TIFF *tif; TIFFDirEntry *dp; { static char mesg[] = "to fetch tag value"; int ok = 0; if (dp->tdir_count > 1) { /* array of values */ char *cp = NULL; switch (dp->tdir_type) { case TIFF_BYTE: case TIFF_SBYTE: /* NB: always expand BYTE values to shorts */ cp = CheckMalloc(tif, dp->tdir_count * sizeof (u_short), mesg); ok = cp && TIFFFetchByteArray(tif, dp, (u_short *)cp); break; case TIFF_SHORT: case TIFF_SSHORT: cp = CheckMalloc(tif, dp->tdir_count * sizeof (u_short), mesg); ok = cp && TIFFFetchShortArray(tif, dp, (u_short *)cp); break; case TIFF_LONG: case TIFF_SLONG: cp = CheckMalloc(tif, dp->tdir_count * sizeof (u_long), mesg); ok = cp && TIFFFetchLongArray(tif, dp, (u_long *)cp); break; case TIFF_RATIONAL: case TIFF_SRATIONAL: cp = CheckMalloc(tif, dp->tdir_count * sizeof (float), mesg); ok = cp && TIFFFetchRationalArray(tif, dp, (float *)cp); break; case TIFF_FLOAT: cp = CheckMalloc(tif, dp->tdir_count * sizeof (float), mesg); ok = cp && TIFFFetchFloatArray(tif, dp, (float *)cp); break; case TIFF_ASCII: /* * Some vendors write strings w/o the trailing * NULL byte, so always append one just in case. */ cp = CheckMalloc(tif, dp->tdir_count+1, mesg); if (ok = (cp && TIFFFetchString(tif, dp, cp))) cp[dp->tdir_count] = '\0'; /* XXX */ break; } if (ok) ok = TIFFSetField(tif, dp->tdir_tag, cp); if (cp != NULL) free(cp); } else if (CheckDirCount(tif, dp, 1)) { /* singleton value */ char c[2]; switch (dp->tdir_type) { case TIFF_BYTE: case TIFF_SBYTE: case TIFF_SHORT: case TIFF_SSHORT: ok = TIFFSetField(tif, dp->tdir_tag, (int) TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset)); break; case TIFF_LONG: case TIFF_SLONG: ok = TIFFSetField(tif, dp->tdir_tag, (u_long) TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset)); break; case TIFF_RATIONAL: case TIFF_SRATIONAL: ok = TIFFSetField(tif, dp->tdir_tag, TIFFFetchRational(tif, dp)); break; case TIFF_FLOAT: ok = TIFFSetField(tif, dp->tdir_tag, TIFFFetchFloat(tif, dp)); break; case TIFF_ASCII: if (ok = (TIFFFetchString(tif, dp, c))) { c[1] = '\0'; /* XXX paranoid */ ok = TIFFSetField(tif, dp->tdir_tag, c); } break; } } return (ok); } /* * Fetch samples/pixel short values for * the specified tag and verify that * all values are the same. */ static TIFFFetchPerSampleShorts(tif, dir, pl) TIFF *tif; TIFFDirEntry *dir; long *pl; { u_short v[4]; int samples = tif->tif_dir.td_samplesperpixel; if (CheckDirCount(tif, dir, (u_long)samples) && TIFFFetchShortArray(tif, dir, v)) { int i; for (i = 1; i < samples; i++) if (v[i] != v[0]) { TIFFError(tif->tif_name, "Cannot handle different per-sample values for field \"%s\"", TIFFFieldWithTag(dir->tdir_tag)->field_name); return (0); } *pl = v[0]; return (1); } return (0); } /* * Fetch a set of offsets or lengths. * While this routine says "strips", * in fact it's also used for tiles. */ static TIFFFetchStripThing(tif, dir, nstrips, lpp) TIFF *tif; TIFFDirEntry *dir; long nstrips; u_long **lpp; { register u_long *lp; int status; if (!CheckDirCount(tif, dir, nstrips)) return (0); /* * Allocate space for strip information. */ if (*lpp == NULL && (*lpp = (u_long *)CheckMalloc(tif, nstrips * sizeof (u_long), "for strip array")) == NULL) return (0); lp = *lpp; if (dir->tdir_type == (int)TIFF_SHORT) { /* * Handle short->long expansion. */ u_short *dp = (u_short *)CheckMalloc(tif, dir->tdir_count* sizeof (u_short), "to fetch strip tag"); if (dp == NULL) return (0); if (status = TIFFFetchShortArray(tif, dir, dp)) { register u_short *wp = dp; while (nstrips-- > 0) *lp++ = *wp++; } free((char *)dp); } else status = TIFFFetchLongArray(tif, dir, lp); return (status); } #ifdef COLORIMETRY_SUPPORT static TIFFFetchRefBlackWhite(tif, dir) TIFF *tif; TIFFDirEntry *dir; { static char mesg[] = "for \"ReferenceBlackWhite\" array"; char *cp; int ok; if (!CheckDirCount(tif, dir, 2*tif->tif_dir.td_samplesperpixel)) return (0); if (dir->tdir_type == TIFF_RATIONAL) return (TIFFFetchNormalTag(tif, dir)); /* * Handle LONG's for backward compatibility. */ cp = CheckMalloc(tif, dir->tdir_count * sizeof (u_long), mesg); if (ok = (cp && TIFFFetchLongArray(tif, dir, (u_long *)cp))) { float *fp = (float *) CheckMalloc(tif, dir->tdir_count * sizeof (float), mesg); if (ok = (fp != NULL)) { int i; for (i = 0; i < dir->tdir_count; i++) fp[i] = (float)((u_long *)cp)[i]; ok = TIFFSetField(tif, dir->tdir_tag, fp); free((char *)fp); } } if (cp) free(cp); return (ok); } #endif #ifdef JPEG_SUPPORT /* * Fetch the JPEG Quantization tables * for the specified directory entry. * Storage for the td_qtab array is * allocated as a side effect. */ static TIFFFetchJPEGQTables(tif, dir) TIFF *tif; TIFFDirEntry *dir; { TIFFDirectory *td = &tif->tif_dir; long off[4]; int i, j; TIFFDirEntry tdir; char *qmat; if (dir->tdir_count > 1) { /* XXX verify count <= 4 */ if (!TIFFFetchData(tif, dir, (char *)off)) return (0); } else off[0] = dir->tdir_offset; /* * We don't share per-component q matrices because * (besides complicating this logic even more), it * would make it very painful if the user does a ``set''. */ td->td_qtab = (u_char **)CheckMalloc(tif, dir->tdir_count*(sizeof (u_char *) + 64*sizeof (u_char)), "for JPEG Q table"); if (td->td_qtab == NULL) return (0); tdir.tdir_type = TIFF_BYTE; tdir.tdir_count = 64; qmat = (((char *)td->td_qtab) + dir->tdir_count*sizeof (u_char *)); for (i = 0; i < dir->tdir_count; i++) { td->td_qtab[i] = (u_char *)qmat; tdir.tdir_offset = off[i]; if (!TIFFFetchData(tif, &tdir, qmat)) return (0); qmat += 64*sizeof (u_char); } return (1); } /* * Fetch JPEG Huffman code tables for the * specified directory entry. Storage for * the tables are allocated as a side effect. */ static TIFFFetchJPEGCTables(tif, dir, ptab) TIFF *tif; TIFFDirEntry *dir; u_char ***ptab; { long off[4]; int i, j, ncodes; TIFFDirEntry tdir; char *tab; if (dir->tdir_count > 1) { /* XXX verify count <= 4 */ if (!TIFFFetchData(tif, dir, (char *)off)) return (0); } else off[0] = dir->tdir_offset; /* * We don't share per-component tables because * (besides complicating this logic even more), it * would make it very painful if the user does a * ``set''. Note also that we don't try to optimize * storage of the tables -- we just allocate enough * space to hold the largest possible. All this * stuff is so complicated 'cuz the tag is defined * to be compatible with the JPEG table format, * rather than something that fits well into the * structure of TIFF -- argh! */ *ptab = (u_char **)CheckMalloc(tif, dir->tdir_count* (sizeof (u_char *) + (16+256)*sizeof (u_char)), "for JPEG Huffman table"); if (*ptab == NULL) return (0); tdir.tdir_type = TIFF_BYTE; tab = (((char *)*ptab) + dir->tdir_count*sizeof (u_char *)); for (i = 0; i < dir->tdir_count; i++) { (*ptab)[i] = (u_char *)tab; tdir.tdir_offset = off[i]; tdir.tdir_count = 16; /* * We must fetch the array that holds the * count of codes for each bit length first * and the count up the number of codes that * are in the variable length table. This * information is implicit in the JPEG format * 'cuz it's preceded by a length field. */ if (!TIFFFetchData(tif, &tdir, tab)) /* count array */ return (0); for (ncodes = 0, j = 0; j < 16; j++) ncodes += tab[j]; /* * Adjust offsets and fetch codes separately. */ tdir.tdir_offset += 16; tdir.tdir_count = ncodes; tab += 16; if (!TIFFFetchData(tif, &tdir, tab)) return (0); tab += ncodes; } return (1); } #endif /* * Accept matteing-only ExtraSamples tag. */ static TIFFFetchExtraSamples(tif, dp) TIFF *tif; TIFFDirEntry *dp; { int type; if (dp->tdir_count != 1) { TIFFError(tif->tif_name, "Can not handle more than 1 extra sample/pixel"); return (0); } type = TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); if (type != EXTRASAMPLE_ASSOCALPHA) { TIFFError(tif->tif_name, "Can only handle associated-alpha extra samples"); return (0); } return (TIFFSetField(tif, TIFFTAG_MATTEING, 1)); } ivtools-1.2.11a1/src/TIFF/tif_dirwrite.c000066400000000000000000000525601214471147700177130ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * Directory Write Support Routines. * * NB: Beware of the varargs declarations for routines in * this file. The names and types of variables has been * carefully chosen to make things work with compilers that * are busted in one way or another (e.g. SGI/MIPS). */ #include "tiffioP.h" #include "prototypes.h" #if HAVE_IEEEFP #define TIFFCvtNativeToIEEEFloat(tif, n, fp) #endif #if USE_PROTOTYPES static TIFFWriteNormalTag(TIFF*, TIFFDirEntry*, TIFFFieldInfo*); static TIFFSetupShortLong(TIFF *, u_short, TIFFDirEntry *, u_long); static TIFFSetupShortPair(TIFF *, u_short, TIFFDirEntry *); static TIFFWriteRational(TIFF *, TIFFDataType, u_short, TIFFDirEntry *, float); static TIFFWritePerSampleShorts(TIFF *, u_short, TIFFDirEntry *); static TIFFWriteShortTable(TIFF *, u_short, TIFFDirEntry *, int, u_short **); static TIFFWriteShortArray(TIFF *, TIFFDataType, u_short, TIFFDirEntry *, int, u_short *); static TIFFWriteLongArray(TIFF *, TIFFDataType, u_short, TIFFDirEntry *, int, u_long *); static TIFFWriteRationalArray(TIFF *, TIFFDataType, u_short, TIFFDirEntry *, int, float *); static TIFFWriteFloatArray(TIFF *, TIFFDataType, u_short, TIFFDirEntry *, int, float *); static TIFFWriteString(TIFF *, u_short, TIFFDirEntry *, char *); #ifdef JPEG_SUPPORT static TIFFWriteJPEGQTables(TIFF *, TIFFDirEntry *); static TIFFWriteJPEGCTables(TIFF *, u_short, TIFFDirEntry *, u_char **); #endif #ifdef COLORIMETRY_SUPPORT static TIFFWriteTransferFunction(TIFF*, TIFFDirEntry*); #endif static TIFFWriteData(TIFF *, TIFFDirEntry *, char *); static TIFFLinkDirectory(TIFF *); #else static TIFFWriteNormalTag(); static TIFFSetupShortLong(); static TIFFSetupShortPair(); static TIFFWriteRational(); static TIFFWritePerSampleShorts(); static TIFFWriteShortTable(); static TIFFWriteShortArray(); static TIFFWriteLongArray(); static TIFFWriteRationalArray(); static TIFFWriteFloatArray(); static TIFFWriteString(); #ifdef JPEG_SUPPORT static TIFFWriteJPEGQTables(); static TIFFWriteJPEGCTables(); #endif static TIFFWriteData(); static TIFFLinkDirectory(); #endif #define WriteRationalPair(type, tag1, v1, tag2, v2) { \ if (!TIFFWriteRational(tif, type, tag1, dir, v1)) \ goto bad; \ if (!TIFFWriteRational(tif, type, tag2, dir+1, v2)) \ goto bad; \ dir++; \ } static long dataoff; /* * Write the contents of the current directory * to the specified file. This routine doesn't * handle overwriting a directory with auxiliary * storage that's been changed. */ TIFFWriteDirectory(tif) TIFF *tif; { short dircount, tag; int nfields, dirsize; char *data; const TIFFFieldInfo *fip; TIFFDirEntry *dir; TIFFDirectory *td; u_long b, fields[sizeof (td->td_fieldsset) / sizeof (u_long)]; if (tif->tif_mode == O_RDONLY) return (1); /* * Clear write state so that subsequent images with * different characteristics get the right buffers * setup for them. */ if (tif->tif_flags & TIFF_POSTENCODE) { tif->tif_flags &= ~TIFF_POSTENCODE; if (tif->tif_postencode && !(*tif->tif_postencode)(tif)) { TIFFError(tif->tif_name, "Error post-encoding before directory write"); return (0); } } if (tif->tif_close) (*tif->tif_close)(tif); if (tif->tif_cleanup) (*tif->tif_cleanup)(tif); /* * Flush any data that might have been written * by the compression close+cleanup routines. */ if (tif->tif_rawcc > 0 && !TIFFFlushData1(tif)) { TIFFError(tif->tif_name, "Error flushing data before directory write"); return (0); } if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { free(tif->tif_rawdata); tif->tif_rawdata = NULL; tif->tif_rawcc = 0; } tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP); td = &tif->tif_dir; /* * Size the directory so that we can calculate * offsets for the data items that aren't kept * in-place in each field. */ nfields = 0; for (b = 0; b <= FIELD_LAST; b++) if (TIFFFieldSet(tif, b)) nfields += (b < FIELD_SUBFILETYPE ? 2 : 1); dirsize = nfields * sizeof (TIFFDirEntry); data = malloc(dirsize); if (data == NULL) { TIFFError(tif->tif_name, "Cannot write directory, out of space"); return (0); } /* * Directory hasn't been placed yet, put * it at the end of the file and link it * into the existing directory structure. */ if (tif->tif_diroff == 0 && !TIFFLinkDirectory(tif)) return (0); dataoff = tif->tif_diroff + sizeof (short) + dirsize + sizeof (long); if (dataoff & 1) dataoff++; (void) lseek(tif->tif_fd, dataoff, L_SET); tif->tif_curdir++; dir = (TIFFDirEntry *)data; /* * Setup external form of directory * entries and write data items. */ bcopy(td->td_fieldsset, fields, sizeof (fields)); /*BEGIN XXX*/ /* * Write out ExtraSamples tag only if Matteing would * be set to 1 (i.e. Associated Alpha data is present). */ if (FieldSet(fields, FIELD_MATTEING) && !td->td_matteing) { /*XXX*/ ResetFieldBit(fields, FIELD_MATTEING); /*XXX*/ nfields--; /*XXX*/ dirsize -= sizeof (TIFFDirEntry); /*XXX*/ } /*XXX*/ /*END XXX*/ for (fip = tiffFieldInfo; fip->field_tag; fip++) { if (fip->field_bit == FIELD_IGNORE || !FieldSet(fields, fip->field_bit)) continue; switch (fip->field_bit) { case FIELD_STRIPOFFSETS: /* * We use one field bit for both strip and tile * offsets, and so must be careful in selecting * the appropriate field descriptor (so that tags * are written in sorted order). */ tag = isTiled(tif) ? TIFFTAG_TILEOFFSETS : TIFFTAG_STRIPOFFSETS; if (tag != fip->field_tag) continue; if (!TIFFWriteLongArray(tif, TIFF_LONG, tag, dir, (int) td->td_nstrips, td->td_stripoffset)) goto bad; break; case FIELD_STRIPBYTECOUNTS: /* * We use one field bit for both strip and tile * byte counts, and so must be careful in selecting * the appropriate field descriptor (so that tags * are written in sorted order). */ tag = isTiled(tif) ? TIFFTAG_TILEBYTECOUNTS : TIFFTAG_STRIPBYTECOUNTS; if (tag != fip->field_tag) continue; if (!TIFFWriteLongArray(tif, TIFF_LONG, tag, dir, (int) td->td_nstrips, td->td_stripbytecount)) goto bad; break; case FIELD_COLORMAP: if (!TIFFWriteShortTable(tif, TIFFTAG_COLORMAP, dir, 3, td->td_colormap)) goto bad; break; case FIELD_IMAGEDIMENSIONS: TIFFSetupShortLong(tif, TIFFTAG_IMAGEWIDTH, dir++, td->td_imagewidth); TIFFSetupShortLong(tif, TIFFTAG_IMAGELENGTH, dir, td->td_imagelength); break; case FIELD_TILEDIMENSIONS: TIFFSetupShortLong(tif, TIFFTAG_TILEWIDTH, dir++, td->td_tilewidth); TIFFSetupShortLong(tif, TIFFTAG_TILELENGTH, dir, td->td_tilelength); break; case FIELD_POSITION: WriteRationalPair(TIFF_RATIONAL, TIFFTAG_XPOSITION, td->td_xposition, TIFFTAG_YPOSITION, td->td_yposition); break; case FIELD_RESOLUTION: WriteRationalPair(TIFF_RATIONAL, TIFFTAG_XRESOLUTION, td->td_xresolution, TIFFTAG_YRESOLUTION, td->td_yresolution); break; case FIELD_BITSPERSAMPLE: case FIELD_MINSAMPLEVALUE: case FIELD_MAXSAMPLEVALUE: case FIELD_SAMPLEFORMAT: if (!TIFFWritePerSampleShorts(tif, fip->field_tag, dir)) goto bad; break; case FIELD_PAGENUMBER: case FIELD_HALFTONEHINTS: #ifdef YCBCR_SUPPORT case FIELD_YCBCRSUBSAMPLING: #endif #ifdef CMYK_SUPPORT case FIELD_DOTRANGE: #endif TIFFSetupShortPair(tif, fip->field_tag, dir); break; #ifdef JPEG_SUPPORT case FIELD_JPEGQTABLES: if (!TIFFWriteJPEGQTables(tif, dir)) goto bad; break; case FIELD_JPEGDCTABLES: if (!TIFFWriteJPEGCTables(tif, TIFFTAG_JPEGDCTABLES, dir, td->td_dctab)) goto bad; break; case FIELD_JPEGACTABLES: if (!TIFFWriteJPEGCTables(tif, TIFFTAG_JPEGACTABLES, dir, td->td_actab)) goto bad; break; #endif #ifdef COLORIMETRY_SUPPORT case FIELD_REFBLACKWHITE: if (!TIFFWriteRationalArray(tif, TIFF_RATIONAL, TIFFTAG_REFERENCEBLACKWHITE, dir, 2*td->td_samplesperpixel, td->td_refblackwhite)) goto bad; break; case FIELD_TRANSFERFUNCTION: if (!TIFFWriteTransferFunction(tif, dir)) goto bad; break; #endif default: if (!TIFFWriteNormalTag(tif, dir, (TIFFFieldInfo*)fip)) goto bad; break; } dir++; ResetFieldBit(fields, fip->field_bit); } /* * Write directory. */ (void) lseek(tif->tif_fd, tif->tif_diroff, L_SET); dircount = nfields; if (!WriteOK(tif->tif_fd, &dircount, sizeof (short))) { TIFFError(tif->tif_name, "Error writing directory count"); goto bad; } if (!WriteOK(tif->tif_fd, data, dirsize)) { TIFFError(tif->tif_name, "Error writing directory contents"); goto bad; } if (!WriteOK(tif->tif_fd, &tif->tif_nextdiroff, sizeof (long))) { TIFFError(tif->tif_name, "Error writing directory link"); goto bad; } TIFFFreeDirectory(tif); free(data); tif->tif_flags &= ~TIFF_DIRTYDIRECT; /* * Reset directory-related state for subsequent * directories. */ TIFFDefaultDirectory(tif); tif->tif_diroff = 0; tif->tif_curoff = 0; tif->tif_row = -1; tif->tif_curstrip = -1; return (1); bad: free(data); return (0); } #undef WriteRationalPair /* * Process tags that are not special cased. */ static DECLARE3(TIFFWriteNormalTag, TIFF*, tif, TIFFDirEntry*, dir, TIFFFieldInfo*, fip) { TIFFDirectory* td = &tif->tif_dir; u_short wc = (u_short) fip->field_writecount; dir->tdir_tag = fip->field_tag; dir->tdir_type = (u_short)fip->field_type; dir->tdir_count = wc; #define WRITE(x,y) x(tif, fip->field_type, fip->field_tag, dir, wc, y) switch (fip->field_type) { case TIFF_SHORT: case TIFF_SSHORT: if (wc > 1) { u_short *wp; if (wc == (u_short) TIFF_VARIABLE) { _TIFFgetfield(td, fip->field_tag, &wc, &wp); dir->tdir_count = wc; } else _TIFFgetfield(td, fip->field_tag, &wp); if (!WRITE(TIFFWriteShortArray, wp)) return (0); } else { u_short sv; _TIFFgetfield(td, fip->field_tag, &sv); dir->tdir_offset = TIFFInsertData(tif, dir->tdir_type, sv); } break; case TIFF_LONG: case TIFF_SLONG: if (wc > 1) { u_long *lp; if (wc == (u_short) TIFF_VARIABLE) { _TIFFgetfield(td, fip->field_tag, &wc, &lp); dir->tdir_count = wc; } else _TIFFgetfield(td, fip->field_tag, &lp); if (!WRITE(TIFFWriteLongArray, lp)) return (0); } else { /* XXX handle LONG->SHORT conversion */ _TIFFgetfield(td, fip->field_tag, &dir->tdir_offset); } break; case TIFF_RATIONAL: case TIFF_SRATIONAL: if (wc > 1) { float *fp; if (wc == (u_short) TIFF_VARIABLE) { _TIFFgetfield(td, fip->field_tag, &wc, &fp); dir->tdir_count = wc; } else _TIFFgetfield(td, fip->field_tag, &fp); if (!WRITE(TIFFWriteRationalArray, fp)) return (0); } else { float fv; _TIFFgetfield(td, fip->field_tag, &fv); if (!TIFFWriteRational(tif, fip->field_type, fip->field_tag, dir, fv)) return (0); } break; case TIFF_FLOAT: if (wc > 1) { float *fp; if (wc == (u_short) TIFF_VARIABLE) { _TIFFgetfield(td, fip->field_tag, &wc, &fp); dir->tdir_count = wc; } else _TIFFgetfield(td, fip->field_tag, &fp); if (!WRITE(TIFFWriteFloatArray, fp)) return (0); } else { float fv; _TIFFgetfield(td, fip->field_tag, &fv); TIFFCvtNativeToIEEEFloat(tif, 1, &fv); /* XXX assumes sizeof (long) == sizeof (float) */ dir->tdir_offset = *(u_long *)&fv; /* XXX */ } break; case TIFF_ASCII: { char *cp; _TIFFgetfield(td, fip->field_tag, &cp); if (!TIFFWriteString(tif, fip->field_tag, dir, cp)) return (0); break; } } return (1); } #undef WRITE /* * Setup a directory entry with either a SHORT * or LONG type according to the value. */ static DECLARE4(TIFFSetupShortLong, TIFF*, tif, u_short, tag, TIFFDirEntry*, dir, u_long, v) { dir->tdir_tag = tag; dir->tdir_count = 1; if (v > 0xffffL) { dir->tdir_type = (short)TIFF_LONG; dir->tdir_offset = v; } else { dir->tdir_type = (short)TIFF_SHORT; dir->tdir_offset = TIFFInsertData(tif, (int)TIFF_SHORT, v); } } #undef MakeShortDirent /* * Setup a RATIONAL directory entry and * write the associated indirect value. */ static DECLARE5(TIFFWriteRational, TIFF*, tif, TIFFDataType, type, u_short, tag, TIFFDirEntry*, dir, float, v) { u_long t[2]; dir->tdir_tag = tag; dir->tdir_type = (short)type; dir->tdir_count = 1; if (type == TIFF_RATIONAL && v < 0) TIFFWarning(tif->tif_name, "\"%s\": Information lost writing value (%g) as (unsigned) RATIONAL", TIFFFieldWithTag(tag)->field_name, v); /* need algorithm to convert ... XXX */ t[0] = v*10000.0 + 0.5; t[1] = 10000; return (TIFFWriteData(tif, dir, (char *)t)); } /* * Setup a directory entry that references a * samples/pixel array of SHORT values and * (potentially) write the associated indirect * values. */ static DECLARE3(TIFFWritePerSampleShorts, TIFF*, tif, u_short, tag, TIFFDirEntry*, dir) { u_short w[4], v; int i, samplesperpixel = tif->tif_dir.td_samplesperpixel; _TIFFgetfield(&tif->tif_dir, tag, &v); for (i = 0; i < samplesperpixel; i++) w[i] = v; return (TIFFWriteShortArray( tif, TIFF_SHORT, tag, dir, samplesperpixel, w)); } /* * Setup a pair of shorts that are returned by * value, rather than as a reference to an array. */ static DECLARE3(TIFFSetupShortPair, TIFF*, tif, u_short, tag, TIFFDirEntry*, dir) { u_short v[2]; _TIFFgetfield(&tif->tif_dir, tag, &v[0], &v[1]); return (TIFFWriteShortArray(tif, TIFF_SHORT, tag, dir, 2, v)); } /* * Setup a directory entry for an NxM table of shorts, * where M is known to be 2**bitspersample, and write * the associated indirect data. */ static DECLARE5(TIFFWriteShortTable, TIFF*, tif, u_short, tag, TIFFDirEntry*, dir, int, n, u_short**, table) { u_long off; int i; dir->tdir_tag = tag; dir->tdir_type = (short)TIFF_SHORT; /* XXX -- yech, fool TIFFWriteData */ dir->tdir_count = 1L<tif_dir.td_bitspersample; off = dataoff; for (i = 0; i < n; i++) if (!TIFFWriteData(tif, dir, (char *)table[i])) return (0); dir->tdir_count *= n; dir->tdir_offset = off; return (1); } /* * Setup a directory entry of an ASCII string * and write any associated indirect value. */ static DECLARE4(TIFFWriteString, TIFF*, tif, u_short, tag, TIFFDirEntry*, dir, char*, cp) { dir->tdir_tag = tag; dir->tdir_type = (short)TIFF_ASCII; dir->tdir_count = strlen(cp) + 1; /* includes \0 byte */ if (dir->tdir_count > 4) { if (!TIFFWriteData(tif, dir, cp)) return (0); } else bcopy(cp, &dir->tdir_offset, dir->tdir_count); return (1); } /* * Setup a directory entry of an array of SHORT * or SSHORT and write the associated indirect values. */ static DECLARE6(TIFFWriteShortArray, TIFF*, tif, TIFFDataType, type, u_short, tag, TIFFDirEntry*, dir, int, n, u_short*, v) { dir->tdir_tag = tag; dir->tdir_type = (short)type; dir->tdir_count = n; if (n <= 2) { if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { dir->tdir_offset = (long)v[0] << 16; if (n == 2) dir->tdir_offset |= v[1] & 0xffff; } else { dir->tdir_offset = v[0] & 0xffff; if (n == 2) dir->tdir_offset |= (long)v[1] << 16; } return (1); } else return (TIFFWriteData(tif, dir, (char *)v)); } /* * Setup a directory entry of an array of LONG * or SLONG and write the associated indirect values. */ static DECLARE6(TIFFWriteLongArray, TIFF*, tif, TIFFDataType, type, u_short, tag, TIFFDirEntry*, dir, int, n, u_long*, v) { dir->tdir_tag = tag; dir->tdir_type = (short)type; dir->tdir_count = n; if (n == 1) { dir->tdir_offset = v[0]; return (1); } else return (TIFFWriteData(tif, dir, (char *)v)); } /* * Setup a directory entry of an array of RATIONAL * or SRATIONAL and write the associated indirect values. */ static DECLARE6(TIFFWriteRationalArray, TIFF*, tif, TIFFDataType, type, u_short, tag, TIFFDirEntry*, dir, int, n, float*, v) { int i, status; u_long *t; dir->tdir_tag = tag; dir->tdir_type = (short)type; dir->tdir_count = n; t = (u_long *)malloc(2*n * sizeof (long)); for (i = 0; i < n; i++) { /* need algorithm to convert ... XXX */ t[2*i+0] = v[i]*10000.0 + 0.5; t[2*i+1] = 10000; } status = TIFFWriteData(tif, dir, (char *)t); free((char *)t); return (status); } static DECLARE6(TIFFWriteFloatArray, TIFF *, tif, TIFFDataType, type, u_short, tag, TIFFDirEntry *, dir, int, n, float *, v) { dir->tdir_tag = tag; dir->tdir_type = (short)type; dir->tdir_count = n; TIFFCvtNativeToIEEEFloat(tif, n, v); if (n == 1) { dir->tdir_offset = *(u_long *)&v[0]; return (1); } else return (TIFFWriteData(tif, dir, (char *)v)); } #ifdef JPEG_SUPPORT /* * Setup a directory entry for JPEG Quantization * tables and write the associated indirect values. */ static DECLARE2(TIFFWriteJPEGQTables, TIFF*, tif, TIFFDirEntry*, dir) { TIFFDirectory *td = &tif->tif_dir; TIFFDirEntry tdir; u_long off[4]; int i; tdir.tdir_tag = TIFFTAG_JPEGQTABLES; /* for diagnostics */ tdir.tdir_type = (short)TIFF_BYTE; tdir.tdir_count = 64; for (i = 0; i < td->td_samplesperpixel; i++) { if (!TIFFWriteData(tif, &tdir, (char *)td->td_qtab[i])) return (0); off[i] = tdir.tdir_offset; } return (TIFFWriteLongArray(tif, TIFF_LONG, TIFFTAG_JPEGQTABLES, dir, td->td_samplesperpixel, off)); } /* * Setup a directory entry for JPEG Coefficient * tables and write the associated indirect values. */ static DECLARE4(TIFFWriteJPEGCTables, TIFF*, tif, u_short, tag, TIFFDirEntry*, dir, u_char **, tab) { TIFFDirectory *td = &tif->tif_dir; TIFFDirEntry tdir; u_long off[4]; int i, j, ncodes; tdir.tdir_tag = tag; /* for diagnostics */ tdir.tdir_type = (short)TIFF_BYTE; for (i = 0; i < td->td_samplesperpixel; i++) { for (ncodes = 0, j = 0; j < 16; j++) ncodes += tab[i][j]; tdir.tdir_count = 16+ncodes; if (!TIFFWriteData(tif, &tdir, (char *)tab[i])) return (0); off[i] = tdir.tdir_offset; } return (TIFFWriteLongArray(tif, TIFF_LONG, tag, dir, td->td_samplesperpixel, off)); } #endif #ifdef COLORIMETRY_SUPPORT static DECLARE2(TIFFWriteTransferFunction, TIFF*, tif, TIFFDirEntry*, dir) { TIFFDirectory *td = &tif->tif_dir; int j, ncols; u_long n; u_short **tf = td->td_transferfunction; /* * Check if the table can be written as a single column. */ n = (1L<td_bitspersample) * sizeof (u_short); ncols = 1; /* assume only one column is needed */ for (j = 1; j < td->td_samplesperpixel; j++) if (bcmp(tf[0], tf[j], n)) { ncols = td->td_samplesperpixel; break; } return (TIFFWriteShortTable(tif, TIFFTAG_TRANSFERFUNCTION, dir, ncols, tf)); } #endif /* * Write a contiguous directory item. */ static TIFFWriteData(tif, dir, cp) TIFF *tif; TIFFDirEntry *dir; char *cp; { int cc; dir->tdir_offset = dataoff; cc = dir->tdir_count * tiffDataWidth[dir->tdir_type]; if (SeekOK(tif->tif_fd, dir->tdir_offset) && WriteOK(tif->tif_fd, cp, cc)) { dataoff += (cc + 1) & ~1; return (1); } TIFFError(tif->tif_name, "Error writing data for field \"%s\"", TIFFFieldWithTag(dir->tdir_tag)->field_name); return (0); } /* * Link the current directory into the * directory chain for the file. */ static TIFFLinkDirectory(tif) register TIFF *tif; { static char module[] = "TIFFLinkDirectory"; u_short dircount; long nextdir; tif->tif_diroff = (lseek(tif->tif_fd, 0L, L_XTND)+1) &~ 1L; if (tif->tif_header.tiff_diroff == 0) { /* * First directory, overwrite header. */ tif->tif_header.tiff_diroff = tif->tif_diroff; (void) lseek(tif->tif_fd, 0L, L_SET); if (!WriteOK(tif->tif_fd, &tif->tif_header, sizeof (tif->tif_header))) { TIFFError(tif->tif_name, "Error writing TIFF header"); return (0); } return (1); } /* * Not the first directory, search to the last and append. */ nextdir = tif->tif_header.tiff_diroff; do { if (!SeekOK(tif->tif_fd, nextdir) || !ReadOK(tif->tif_fd, &dircount, sizeof (dircount))) { TIFFError(module, "Error fetching directory count"); return (0); } if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount); lseek(tif->tif_fd, dircount * sizeof (TIFFDirEntry), L_INCR); if (!ReadOK(tif->tif_fd, &nextdir, sizeof (nextdir))) { TIFFError(module, "Error fetching directory link"); return (0); } if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong((u_long *)&nextdir); } while (nextdir != 0); (void) lseek(tif->tif_fd, -sizeof (nextdir), L_INCR); if (!WriteOK(tif->tif_fd, &tif->tif_diroff, sizeof (tif->tif_diroff))) { TIFFError(module, "Error writing directory link"); return (0); } return (1); } ivtools-1.2.11a1/src/TIFF/tif_dumpmode.c000066400000000000000000000076031214471147700176720ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * "Null" Compression Algorithm Support. */ #include "tiffioP.h" #include #include #if USE_PROTOTYPES static int DumpModeEncode(TIFF *, u_char *, int, u_int); static int DumpModeDecode(TIFF *, u_char *, int, u_int); static int DumpModeSeek(TIFF *, int); #else static int DumpModeEncode(), DumpModeDecode(), DumpModeSeek(); #endif /* * Initialize dump mode. */ TIFFInitDumpMode(tif) register TIFF *tif; { tif->tif_decoderow = DumpModeDecode; tif->tif_decodestrip = DumpModeDecode; tif->tif_decodetile = DumpModeDecode; tif->tif_encoderow = DumpModeEncode; tif->tif_encodestrip = DumpModeEncode; tif->tif_encodetile = DumpModeEncode; tif->tif_seek = DumpModeSeek; return (1); } /* * Encode a hunk of pixels. */ static int DumpModeEncode(tif, pp, cc, s) register TIFF *tif; u_char *pp; int cc; u_int s; { /* * This may be overzealous, but avoids having to * worry about byte alignment for the (potential) * byte-swapping work below. */ if (tif->tif_rawcc + cc > tif->tif_rawdatasize) if (!TIFFFlushData1(tif)) return (-1); while (cc > 0) { int n; if ((n = cc) > tif->tif_rawdatasize) n = tif->tif_rawdatasize; bcopy(pp, tif->tif_rawcp, n); if (tif->tif_flags & TIFF_SWAB) { switch (tif->tif_dir.td_bitspersample) { case 16: assert((n & 3) == 0); TIFFSwabArrayOfShort((u_short *)tif->tif_rawcp, n/2); break; case 32: assert((n & 15) == 0); TIFFSwabArrayOfLong((u_long *)tif->tif_rawcp, n/4); break; } } tif->tif_rawcp += n; tif->tif_rawcc += n; pp += n; cc -= n; if (tif->tif_rawcc >= tif->tif_rawdatasize && !TIFFFlushData1(tif)) return (-1); } return (1); } /* * Decode a hunk of pixels. */ static int DumpModeDecode(tif, buf, cc, s) register TIFF *tif; u_char *buf; int cc; u_int s; { if (tif->tif_rawcc < cc) { TIFFError(tif->tif_name, "DumpModeDecode: Not enough data for scanline %d", tif->tif_row); return (0); } /* * Avoid copy if client has setup raw * data buffer to avoid extra copy. */ if (tif->tif_rawcp != (char*) buf) bcopy(tif->tif_rawcp, buf, cc); if (tif->tif_flags & TIFF_SWAB) { switch (tif->tif_dir.td_bitspersample) { case 16: assert((cc & 3) == 0); TIFFSwabArrayOfShort((u_short *)buf, cc/2); break; case 32: assert((cc & 15) == 0); TIFFSwabArrayOfLong((u_long *)buf, cc/4); break; } } tif->tif_rawcp += cc; tif->tif_rawcc -= cc; return (1); } /* * Seek forwards nrows in the current strip. */ static int DumpModeSeek(tif, nrows) register TIFF *tif; int nrows; { tif->tif_rawcp += nrows * tif->tif_scanlinesize; tif->tif_rawcc -= nrows * tif->tif_scanlinesize; return (1); } ivtools-1.2.11a1/src/TIFF/tif_error.c000066400000000000000000000037271214471147700172140ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. */ #include #include "tiffioP.h" #include "prototypes.h" static void DECLARE3(defaultHandler, char*, module, char*, fmt, va_list, ap) { if (module != NULL) fprintf(stderr, "%s: ", module); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } static TIFFErrorHandler _errorHandler = defaultHandler; TIFFErrorHandler DECLARE1(TIFFSetErrorHandler, TIFFErrorHandler, handler) { TIFFErrorHandler prev = _errorHandler; _errorHandler = handler; return (prev); } void #if USE_PROTOTYPES TIFFError(char *module, char *fmt, ...) #else /*VARARGS2*/ TIFFError(module, fmt, va_alist) char *module; char *fmt; va_dcl #endif { if (_errorHandler) { va_list ap; VA_START(ap, fmt); (*_errorHandler)(module, fmt, ap); va_end(ap); } } ivtools-1.2.11a1/src/TIFF/tif_fax3.c000066400000000000000000000706431214471147700167250ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * CCITT Group 3 and Group 4 Compression Support. */ #include "tiffioP.h" #include #include #include "tif_fax3.h" #define G3CODES #include "t4.h" #define G3STATES #include "g3states.h" typedef struct { Fax3BaseState b; } Fax3DecodeState; typedef struct { Fax3BaseState b; const u_char *wruns; const u_char *bruns; short k; /* #rows left that can be 2d encoded */ short maxk; /* max #rows that can be 2d encoded */ } Fax3EncodeState; #if USE_PROTOTYPES static Fax3PreDecode(TIFF *); static Fax3Decode(TIFF*, u_char *, int, u_int); static int Fax3Decode1DRow(TIFF*, u_char *, int); static Fax3PreEncode(TIFF *); static Fax3PostEncode(TIFF *); static Fax3Encode(TIFF*, u_char *, int, u_int); static int Fax3Encode1DRow(TIFF *, u_char *, int); static Fax3Close(TIFF *); static Fax3Cleanup(TIFF *); static void *Fax3SetupState(TIFF *, int); static void fillspan(char *, int, int); static int findspan(u_char **, int, int, u_char const *); static int finddiff(u_char *, int, int, int); static void skiptoeol(TIFF *, int); static void putbits(TIFF *, u_int, u_int); static void putcode(TIFF *, tableentry const *); static void putspan(TIFF *, int, tableentry const *); extern int TIFFFlushData1(TIFF *); #else static int Fax3PreEncode(), Fax3Encode(), Fax3PostEncode(); static int Fax3Encode1DRow(); static int Fax3Decode(), Fax3PreDecode(); static int Fax3Decode1DRow(); static int Fax3Close(), Fax3Cleanup(); static void *Fax3SetupState(); static void fillspan(); static int findspan(); static int finddiff(); static void skiptoeol(); static void putbits(); static void putcode(); static void putspan(); extern int TIFFFlushData1(); #endif TIFFInitCCITTFax3(tif) TIFF *tif; { tif->tif_predecode = Fax3PreDecode; tif->tif_decoderow = Fax3Decode; tif->tif_decodestrip = Fax3Decode; tif->tif_decodetile = Fax3Decode; tif->tif_preencode = Fax3PreEncode; tif->tif_postencode = Fax3PostEncode; tif->tif_encoderow = Fax3Encode; tif->tif_encodestrip = Fax3Encode; tif->tif_encodetile = Fax3Encode; tif->tif_close = Fax3Close; tif->tif_cleanup = Fax3Cleanup; tif->tif_options |= FAX3_CLASSF; /* default */ tif->tif_flags |= TIFF_NOBITREV; /* we handle bit reversal */ return (1); } TIFFModeCCITTFax3(tif, isClassF) TIFF *tif; int isClassF; { if (isClassF) tif->tif_options |= FAX3_CLASSF; else tif->tif_options &= ~FAX3_CLASSF; } static u_char bitMask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; #define isBitSet(sp) ((sp)->b.data & bitMask[(sp)->b.bit]) #define is2DEncoding(tif) \ (tif->tif_dir.td_group3options & GROUP3OPT_2DENCODING) #define fetchByte(tif, sp) \ ((tif)->tif_rawcc--, (sp)->b.bitmap[*(u_char *)(tif)->tif_rawcp++]) #define BITCASE(b) \ case b: \ code <<= 1; \ if (data & (1<<(7-b))) code |= 1;\ len++; \ if (code > 0) { bit = b+1; break; } /* * Skip over input until an EOL code is found. The * value of len is passed as 0 except during error * recovery when decoding 2D data. Note also that * we don't use the optimized state tables to locate * an EOL because we can't assume much of anything * about our state (e.g. bit position). */ static void skiptoeol(tif, len) TIFF *tif; int len; { Fax3DecodeState *sp = (Fax3DecodeState *)tif->tif_data; register int bit = sp->b.bit; register int data = sp->b.data; int code = 0; /* * Our handling of ``bit'' is painful because * the rest of the code does not maintain it as * exactly the bit offset in the current data * byte (bit == 0 means refill the data byte). * Thus we have to be careful on entry and * exit to insure that we maintain a value that's * understandable elsewhere in the decoding logic. */ if (bit == 0) /* force refill */ bit = 8; for (;;) { switch (bit) { again: BITCASE(0); BITCASE(1); BITCASE(2); BITCASE(3); BITCASE(4); BITCASE(5); BITCASE(6); BITCASE(7); default: if (tif->tif_rawcc <= 0) return; data = fetchByte(tif, sp); goto again; } if (len >= 12 && code == EOL) break; code = len = 0; } sp->b.bit = bit > 7 ? 0 : bit; /* force refill */ sp->b.data = data; } /* * Return the next bit in the input stream. This is * used to extract 2D tag values and the color tag * at the end of a terminating uncompressed data code. */ static int nextbit(tif) TIFF *tif; { Fax3DecodeState *sp = (Fax3DecodeState *)tif->tif_data; int bit; if (sp->b.bit == 0 && tif->tif_rawcc > 0) sp->b.data = fetchByte(tif, sp); bit = isBitSet(sp); if (++(sp->b.bit) > 7) sp->b.bit = 0; return (bit); } static void bset(cp, n, v) register unsigned char *cp; register int n; register int v; { while (n-- > 0) *cp++ = v; } /* * Setup G3-related compression/decompression * state before data is processed. This routine * is called once per image -- it sets up different * state based on whether or not 2D encoding is used. */ static void * Fax3SetupState(tif, space) TIFF *tif; int space; { TIFFDirectory *td = &tif->tif_dir; Fax3BaseState *sp; int cc = space; long rowbytes, rowpixels; if (td->td_bitspersample != 1) { TIFFError(tif->tif_name, "Bits/sample must be 1 for Group 3/4 encoding/decoding"); return (0); } /* * Calculate the scanline/tile widths. */ if (isTiled(tif)) { rowbytes = TIFFTileRowSize(tif); rowpixels = tif->tif_dir.td_tilewidth; } else { rowbytes = TIFFScanlineSize(tif); rowpixels = tif->tif_dir.td_imagewidth; } if (is2DEncoding(tif) || td->td_compression == COMPRESSION_CCITTFAX4) cc += rowbytes+1; tif->tif_data = malloc(cc); if (tif->tif_data == NULL) { TIFFError("Fax3SetupState", "%s: No space for Fax3 state block", tif->tif_name); return (0); } sp = (Fax3BaseState *)tif->tif_data; sp->rowbytes = rowbytes; sp->rowpixels = rowpixels; sp->bitmap = (tif->tif_fillorder != td->td_fillorder ? TIFFBitRevTable : TIFFNoBitRevTable); sp->white = (td->td_photometric == PHOTOMETRIC_MINISBLACK); if (is2DEncoding(tif) || td->td_compression == COMPRESSION_CCITTFAX4) { /* * 2d encoding/decoding requires a scanline * buffer for the ``reference line''; the * scanline against which delta encoding * is referenced. The reference line must * be initialized to be ``white'' (done elsewhere). */ sp->refline = (u_char *)tif->tif_data + space + 1; /* * Initialize pixel just to the left of the * reference line to white. This extra pixel * simplifies the edge-condition logic. */ sp->refline[-1] = sp->white ? 0xff : 0x00; } else sp->refline = 0; return (sp); } /* * Setup state for decoding a strip. */ static Fax3PreDecode(tif) TIFF *tif; { Fax3DecodeState *sp = (Fax3DecodeState *)tif->tif_data; if (sp == NULL) { sp = (Fax3DecodeState *)Fax3SetupState(tif, sizeof (*sp)); if (!sp) return (0); } sp->b.bit = 0; /* force initial read */ sp->b.data = 0; sp->b.tag = G3_1D; if (sp->b.refline) bset(sp->b.refline, sp->b.rowbytes, sp->b.white ? 0xff : 0x00); /* * If image has EOL codes, they precede each line * of data. We skip over the first one here so that * when we decode rows, we can use an EOL to signal * that less than the expected number of pixels are * present for the scanline. */ if ((tif->tif_options & FAX3_NOEOL) == 0) { skiptoeol(tif, 0); if (is2DEncoding(tif)) /* tag should always be 1D! */ sp->b.tag = nextbit(tif) ? G3_1D : G3_2D; } return (1); } /* * Fill a span with ones. */ static void fillspan(cp, x, count) register char *cp; register int x, count; { static const unsigned char masks[] = { 0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; if (count <= 0) return; cp += x>>3; if (x &= 7) { /* align to byte boundary */ if (count < 8 - x) { *cp++ |= masks[count] >> x; return; } *cp++ |= 0xff >> x; count -= 8 - x; } while (count >= 8) { *cp++ = 0xff; count -= 8; } *cp |= masks[count]; } /* * Decode the requested amount of data. */ static Fax3Decode(tif, buf, occ, s) TIFF *tif; u_char *buf; int occ; u_int s; { Fax3DecodeState *sp = (Fax3DecodeState *)tif->tif_data; bzero(buf, occ); /* decoding only sets non-zero bits */ while (occ > 0) { if (sp->b.tag == G3_1D) { if (!Fax3Decode1DRow(tif, buf, sp->b.rowpixels)) return (0); } else { if (!Fax3Decode2DRow(tif, buf, sp->b.rowpixels)) return (0); } if (is2DEncoding(tif)) { /* * Fetch the tag bit that indicates * whether the next row is 1d or 2d * encoded. If 2d-encoded, then setup * the reference line from the decoded * scanline just completed. */ sp->b.tag = nextbit(tif) ? G3_1D : G3_2D; if (sp->b.tag == G3_2D) bcopy(buf, sp->b.refline, sp->b.rowbytes); } buf += sp->b.rowbytes; occ -= sp->b.rowbytes; } return (1); } /* * Decode a run of white. */ static int decode_white_run(tif) TIFF *tif; { Fax3DecodeState *sp = (Fax3DecodeState *)tif->tif_data; short state = sp->b.bit; short action; int runlen = 0; for (;;) { if (sp->b.bit == 0) { nextbyte: if (tif->tif_rawcc <= 0) return (G3CODE_EOF); sp->b.data = fetchByte(tif, sp); } action = TIFFFax1DAction[state][sp->b.data]; state = TIFFFax1DNextState[state][sp->b.data]; if (action == ACT_INCOMP) goto nextbyte; if (action == ACT_INVALID) return (G3CODE_INVALID); if (action == ACT_EOL) return (G3CODE_EOL); sp->b.bit = state; action = RUNLENGTH(action - ACT_WRUNT); runlen += action; if (action < 64) return (runlen); } /*NOTREACHED*/ } /* * Decode a run of black. */ static int decode_black_run(tif) TIFF *tif; { Fax3DecodeState *sp = (Fax3DecodeState *)tif->tif_data; short state = sp->b.bit + 8; short action; int runlen = 0; for (;;) { if (sp->b.bit == 0) { nextbyte: if (tif->tif_rawcc <= 0) return (G3CODE_EOF); sp->b.data = fetchByte(tif, sp); } action = TIFFFax1DAction[state][sp->b.data]; state = TIFFFax1DNextState[state][sp->b.data]; if (action == ACT_INCOMP) goto nextbyte; if (action == ACT_INVALID) return (G3CODE_INVALID); if (action == ACT_EOL) return (G3CODE_EOL); sp->b.bit = state; action = RUNLENGTH(action - ACT_BRUNT); runlen += action; if (action < 64) return (runlen); state += 8; } /*NOTREACHED*/ } /* * Process one row of 1d Huffman-encoded data. */ static int Fax3Decode1DRow(tif, buf, npels) TIFF *tif; u_char *buf; int npels; { Fax3DecodeState *sp = (Fax3DecodeState *)tif->tif_data; int x = 0; int runlen; short action; short color = sp->b.white; static char module[] = "Fax3Decode1D"; for (;;) { if (color == sp->b.white) runlen = decode_white_run(tif); else runlen = decode_black_run(tif); switch (runlen) { case G3CODE_EOF: TIFFError(module, "%s: Premature EOF at scanline %d (x %d)", tif->tif_name, tif->tif_row, x); return (0); case G3CODE_INVALID: /* invalid code */ /* * An invalid code was encountered. * Flush the remainder of the line * and allow the caller to decide whether * or not to continue. Note that this * only works if we have a G3 image * with EOL markers. */ TIFFError(module, "%s: Bad code word at scanline %d (x %d)", tif->tif_name, tif->tif_row, x); goto done; case G3CODE_EOL: /* premature end-of-line code */ TIFFWarning(module, "%s: Premature EOL at scanline %d (x %d)", tif->tif_name, tif->tif_row, x); return (1); /* try to resynchronize... */ } if (x+runlen > npels) runlen = npels-x; if (runlen > 0) { if (color) fillspan((char *)buf, x, runlen); x += runlen; if (x >= npels) break; } color = !color; } done: /* * Cleanup at the end of the row. This convoluted * logic is merely so that we can reuse the code with * two other related compression algorithms (2 & 32771). * * Note also that our handling of word alignment assumes * that the buffer is at least word aligned. This is * the case for most all versions of malloc (typically * the buffer is returned longword aligned). */ if ((tif->tif_options & FAX3_NOEOL) == 0) skiptoeol(tif, 0); if (tif->tif_options & FAX3_BYTEALIGN) sp->b.bit = 0; if ((tif->tif_options & FAX3_WORDALIGN) && ((long)tif->tif_rawcp & 1)) (void) fetchByte(tif, sp); return (x == npels); } /* * Group 3 2d Decoding support. */ /* * Return the next uncompressed mode code word. */ static int decode_uncomp_code(tif) TIFF *tif; { Fax3DecodeState *sp = (Fax3DecodeState *)tif->tif_data; short code; do { if (sp->b.bit == 0 || sp->b.bit > 7) { if (tif->tif_rawcc <= 0) return (UNCOMP_EOF); sp->b.data = fetchByte(tif, sp); } code = TIFFFaxUncompAction[sp->b.bit][sp->b.data]; sp->b.bit = TIFFFaxUncompNextState[sp->b.bit][sp->b.data]; } while (code == ACT_INCOMP); return (code); } /* * Process one row of 2d encoded data. */ int Fax3Decode2DRow(tif, buf, npels) TIFF *tif; u_char *buf; int npels; { #define PIXEL(buf,ix) ((((buf)[(ix)>>3]) >> (7-((ix)&7))) & 1) Fax3DecodeState *sp = (Fax3DecodeState *)tif->tif_data; int a0 = -1; int b1, b2; int run1, run2; /* for horizontal mode */ short mode; short color = sp->b.white; static char module[] = "Fax3Decode2D"; do { if (sp->b.bit == 0 || sp->b.bit > 7) { if (tif->tif_rawcc <= 0) { TIFFError(module, "%s: Premature EOF at scanline %d", tif->tif_name, tif->tif_row); return (0); } sp->b.data = fetchByte(tif, sp); } mode = TIFFFax2DMode[sp->b.bit][sp->b.data]; sp->b.bit = TIFFFax2DNextState[sp->b.bit][sp->b.data]; switch (mode) { case MODE_NULL: break; case MODE_PASS: b2 = finddiff(sp->b.refline, a0, npels, !color); b1 = finddiff(sp->b.refline, b2, npels, color); b2 = finddiff(sp->b.refline, b1, npels, !color); if (color) { if (a0 < 0) a0 = 0; fillspan((char *)buf, a0, b2 - a0); } a0 = b2; break; case MODE_HORIZ: if (color == sp->b.white) { run1 = decode_white_run(tif); run2 = decode_black_run(tif); } else { run1 = decode_black_run(tif); run2 = decode_white_run(tif); } /* * Do the appropriate fill. Note that we exit * this logic with the same color that we enter * with since we do 2 fills. This explains the * somewhat obscure logic below. */ if (a0 < 0) a0 = 0; if (a0 + run1 > npels) run1 = npels - a0; if (color) fillspan((char *)buf, a0, run1); a0 += run1; if (a0 + run2 > npels) run2 = npels - a0; if (!color) fillspan((char *)buf, a0, run2); a0 += run2; break; case MODE_VERT_V0: case MODE_VERT_VR1: case MODE_VERT_VR2: case MODE_VERT_VR3: case MODE_VERT_VL1: case MODE_VERT_VL2: case MODE_VERT_VL3: b2 = finddiff(sp->b.refline, a0, npels, !color); b1 = finddiff(sp->b.refline, b2, npels, color); b1 += mode - MODE_VERT_V0; if (color) { if (a0 < 0) a0 = 0; fillspan((char *)buf, a0, b1 - a0); } color = !color; a0 = b1; break; case MODE_UNCOMP: /* * Uncompressed mode: select from the * special set of code words. */ if (a0 < 0) a0 = 0; do { mode = decode_uncomp_code(tif); switch (mode) { case UNCOMP_RUN1: case UNCOMP_RUN2: case UNCOMP_RUN3: case UNCOMP_RUN4: case UNCOMP_RUN5: run1 = mode - UNCOMP_RUN0; fillspan((char *)buf, a0+run1-1, 1); a0 += run1; break; case UNCOMP_RUN6: a0 += 5; break; case UNCOMP_TRUN0: case UNCOMP_TRUN1: case UNCOMP_TRUN2: case UNCOMP_TRUN3: case UNCOMP_TRUN4: run1 = mode - UNCOMP_TRUN0; a0 += run1; color = nextbit(tif) ? !sp->b.white : sp->b.white; break; case UNCOMP_INVALID: TIFFError(module, "%s: Bad uncompressed code word at scanline %d", tif->tif_name, tif->tif_row); goto bad; case UNCOMP_EOF: TIFFError(module, "%s: Premature EOF at scanline %d", tif->tif_name, tif->tif_row); return (0); } } while (mode < UNCOMP_EXIT); break; case MODE_ERROR_1: if ((tif->tif_options & FAX3_NOEOL) == 0) { TIFFWarning(module, "%s: Premature EOL at scanline %d (x %d)", tif->tif_name, tif->tif_row, a0); skiptoeol(tif, 7); /* seen 7 0's already */ return (1); /* try to synchronize */ } /* fall thru... */ case MODE_ERROR: TIFFError(module, "%s: Bad 2D code word at scanline %d", tif->tif_name, tif->tif_row); goto bad; default: TIFFError(module, "%s: Panic, bad decoding state at scanline %d", tif->tif_name, tif->tif_row); return (0); } } while (a0 < npels); bad: /* * Cleanup at the end of row. We check for * EOL separately so that this code can be * reused by the Group 4 decoding routine. */ if ((tif->tif_options & FAX3_NOEOL) == 0) skiptoeol(tif, 0); return (a0 >= npels); #undef PIXEL } /* * CCITT Group 3 FAX Encoding. */ /* * Write a variable-length bit-value to * the output stream. Values are * assumed to be at most 16 bits. */ static void putbits(tif, bits, length) TIFF *tif; u_int bits, length; { Fax3BaseState *sp = (Fax3BaseState *)tif->tif_data; static const int mask[9] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff }; while (length > sp->bit) { sp->data |= bits >> (length - sp->bit); length -= sp->bit; Fax3FlushBits(tif, sp); } sp->data |= (bits & mask[length]) << (sp->bit - length); sp->bit -= length; if (sp->bit == 0) Fax3FlushBits(tif, sp); } /* * Write a code to the output stream. */ static void putcode(tif, te) TIFF *tif; tableentry const *te; { putbits(tif, te->code, te->length); } /* * Write the sequence of codes that describes * the specified span of zero's or one's. The * appropriate table that holds the make-up and * terminating codes is supplied. */ static void putspan(tif, span, tab) TIFF *tif; int span; tableentry const *tab; { while (span >= 2624) { tableentry const *te = &tab[63 + (2560>>6)]; putcode(tif, te); span -= te->runlen; } if (span >= 64) { tableentry const *te = &tab[63 + (span>>6)]; assert(te->runlen == 64*(span>>6)); putcode(tif, te); span -= te->runlen; } putcode(tif, &tab[span]); } /* * Write an EOL code to the output stream. The zero-fill * logic for byte-aligning encoded scanlines is handled * here. We also handle writing the tag bit for the next * scanline when doing 2d encoding. */ void Fax3PutEOL(tif) TIFF *tif; { Fax3BaseState *sp = (Fax3BaseState *)tif->tif_data; if (tif->tif_dir.td_group3options & GROUP3OPT_FILLBITS) { /* * Force bit alignment so EOL will terminate on * a byte boundary. That is, force the bit alignment * to 16-12 = 4 before putting out the EOL code. */ int align = 8 - 4; if (align != sp->bit) { if (align > sp->bit) align = sp->bit + (8 - align); else align = sp->bit - align; putbits(tif, 0, align); } } putbits(tif, EOL, 12); if (is2DEncoding(tif)) putbits(tif, sp->tag == G3_1D, 1); } static const u_char zeroruns[256] = { 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, /* 0x00 - 0x0f */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x10 - 0x1f */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x20 - 0x2f */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x30 - 0x3f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 - 0x4f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 - 0x5f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 - 0x6f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x70 - 0x7f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 - 0xaf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 - 0xbf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 - 0xcf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 - 0xdf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 - 0xef */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xf0 - 0xff */ }; static const u_char oneruns[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 - 0x0f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 - 0x1f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 - 0x2f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 - 0x3f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x4f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 - 0x5f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x6f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x7f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 - 0x8f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 - 0x9f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xa0 - 0xaf */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xb0 - 0xbf */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xc0 - 0xcf */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xd0 - 0xdf */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xe0 - 0xef */ 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, /* 0xf0 - 0xff */ }; /* * Reset encoding state at the start of a strip. */ static Fax3PreEncode(tif) TIFF *tif; { Fax3EncodeState *sp = (Fax3EncodeState *)tif->tif_data; if (sp == NULL) { sp = (Fax3EncodeState *)Fax3SetupState(tif, sizeof (*sp)); if (!sp) return (0); if (sp->b.white == 0) { sp->wruns = zeroruns; sp->bruns = oneruns; } else { sp->wruns = oneruns; sp->bruns = zeroruns; } } sp->b.bit = 8; sp->b.data = 0; sp->b.tag = G3_1D; /* * This is necessary for Group 4; otherwise it isn't * needed because the first scanline of each strip ends * up being copied into the refline. */ if (sp->b.refline) bset(sp->b.refline, sp->b.rowbytes, sp->b.white ? 0xff : 0x00); if (is2DEncoding(tif)) { float res = tif->tif_dir.td_yresolution; /* * The CCITT spec says that when doing 2d encoding, you * should only do it on K consecutive scanlines, where K * depends on the resolution of the image being encoded * (2 for <= 200 lpi, 4 for > 200 lpi). Since the directory * code initializes td_yresolution to 0, this code will * select a K of 2 unless the YResolution tag is set * appropriately. (Note also that we fudge a little here * and use 150 lpi to avoid problems with units conversion.) */ if (tif->tif_dir.td_resolutionunit == RESUNIT_CENTIMETER) res = (res * .3937) / 2.54; /* convert to inches */ sp->maxk = (res > 150 ? 4 : 2); sp->k = sp->maxk-1; } else sp->k = sp->maxk = 0; return (1); } /* * 1d-encode a row of pixels. The encoding is * a sequence of all-white or all-black spans * of pixels encoded with Huffman codes. */ static int Fax3Encode1DRow(tif, bp, bits) TIFF *tif; u_char *bp; int bits; { Fax3EncodeState *sp = (Fax3EncodeState *)tif->tif_data; int bs = 0, span; for (;;) { span = findspan(&bp, bs, bits, sp->wruns); /* white span */ putspan(tif, span, TIFFFaxWhiteCodes); bs += span; if (bs >= bits) break; span = findspan(&bp, bs, bits, sp->bruns); /* black span */ putspan(tif, span, TIFFFaxBlackCodes); bs += span; if (bs >= bits) break; } return (1); } static const tableentry horizcode = { 3, 0x1 }; /* 001 */ static const tableentry passcode = { 4, 0x1 }; /* 0001 */ static const tableentry vcodes[7] = { { 7, 0x03 }, /* 0000 011 */ { 6, 0x03 }, /* 0000 11 */ { 3, 0x03 }, /* 011 */ { 1, 0x1 }, /* 1 */ { 3, 0x2 }, /* 010 */ { 6, 0x02 }, /* 0000 10 */ { 7, 0x02 } /* 0000 010 */ }; /* * 2d-encode a row of pixels. Consult the CCITT * documentation for the algorithm. */ int Fax3Encode2DRow(tif, bp, rp, bits) TIFF *tif; u_char *bp, *rp; int bits; { #define PIXEL(buf,ix) ((((buf)[(ix)>>3]) >> (7-((ix)&7))) & 1) short white = ((Fax3BaseState *)tif->tif_data)->white; int a0 = 0; int a1 = (PIXEL(bp, 0) != white ? 0 : finddiff(bp, 0, bits, white)); int b1 = (PIXEL(rp, 0) != white ? 0 : finddiff(rp, 0, bits, white)); int a2, b2; for (;;) { b2 = finddiff(rp, b1, bits, PIXEL(rp,b1)); if (b2 >= a1) { int d = b1 - a1; if (!(-3 <= d && d <= 3)) { /* horizontal mode */ a2 = finddiff(bp, a1, bits, PIXEL(bp,a1)); putcode(tif, &horizcode); if (a0+a1 == 0 || PIXEL(bp, a0) == white) { putspan(tif, a1-a0, TIFFFaxWhiteCodes); putspan(tif, a2-a1, TIFFFaxBlackCodes); } else { putspan(tif, a1-a0, TIFFFaxBlackCodes); putspan(tif, a2-a1, TIFFFaxWhiteCodes); } a0 = a2; } else { /* vertical mode */ putcode(tif, &vcodes[d+3]); a0 = a1; } } else { /* pass mode */ putcode(tif, &passcode); a0 = b2; } if (a0 >= bits) break; a1 = finddiff(bp, a0, bits, PIXEL(bp,a0)); b1 = finddiff(rp, a0, bits, !PIXEL(bp,a0)); b1 = finddiff(rp, b1, bits, PIXEL(bp,a0)); } return (1); #undef PIXEL } /* * Encode a buffer of pixels. */ static int Fax3Encode(tif, bp, cc, s) TIFF *tif; u_char *bp; int cc; u_int s; { Fax3EncodeState *sp = (Fax3EncodeState *)tif->tif_data; while (cc > 0) { Fax3PutEOL(tif); if (is2DEncoding(tif)) { if (sp->b.tag == G3_1D) { if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) return (0); sp->b.tag = G3_2D; } else { if (!Fax3Encode2DRow(tif, bp, sp->b.refline, sp->b.rowpixels)) return (0); sp->k--; } if (sp->k == 0) { sp->b.tag = G3_1D; sp->k = sp->maxk-1; } else bcopy(bp, sp->b.refline, sp->b.rowbytes); } else { if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) return (0); } bp += sp->b.rowbytes; cc -= sp->b.rowbytes; } return (1); } static int Fax3PostEncode(tif) TIFF *tif; { Fax3BaseState *sp = (Fax3BaseState *)tif->tif_data; if (sp->bit != 8) Fax3FlushBits(tif, sp); return (1); } static Fax3Close(tif) TIFF *tif; { if ((tif->tif_options & FAX3_CLASSF) == 0) { /* append RTC */ int i; for (i = 0; i < 6; i++) Fax3PutEOL(tif); (void) Fax3PostEncode(tif); } } static Fax3Cleanup(tif) TIFF *tif; { if (tif->tif_data) { free(tif->tif_data); tif->tif_data = NULL; } } /* * Bit handling utilities. */ /* * Find a span of ones or zeros using the supplied * table. The byte-aligned start of the bit string * is supplied along with the start+end bit indices. * The table gives the number of consecutive ones or * zeros starting from the msb and is indexed by byte * value. */ static int findspan(bpp, bs, be, tab) u_char **bpp; int bs, be; register u_char const *tab; { register u_char *bp = *bpp; register int bits = be - bs; register int n, span; /* * Check partial byte on lhs. */ if (bits > 0 && (n = (bs & 7))) { span = tab[(*bp << n) & 0xff]; if (span > 8-n) /* table value too generous */ span = 8-n; if (span > bits) /* constrain span to bit range */ span = bits; if (n+span < 8) /* doesn't extend to edge of byte */ goto done; bits -= span; bp++; } else span = 0; /* * Scan full bytes for all 1's or all 0's. */ while (bits >= 8) { n = tab[*bp]; span += n; bits -= n; if (n < 8) /* end of run */ goto done; bp++; } /* * Check partial byte on rhs. */ if (bits > 0) { n = tab[*bp]; span += (n > bits ? bits : n); } done: *bpp = bp; return (span); } /* * Return the offset of the next bit in the range * [bs..be] that is different from the specified * color. The end, be, is returned if no such bit * exists. */ static int finddiff(cp, bs, be, color) u_char *cp; int bs, be, color; { cp += bs >> 3; /* adjust byte offset */ return (bs + findspan(&cp, bs, be, color ? oneruns : zeroruns)); } ivtools-1.2.11a1/src/TIFF/tif_fax3.h000066400000000000000000000056061214471147700167270ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _FAX3_ #define _FAX3_ /* * CCITT Group 3 compression/decompression definitions. */ #define FAX3_CLASSF TIFF_OPT0 /* use Class F protocol */ /* the following are for use by Compression=2, 32771, and 4 (T.6) algorithms */ #define FAX3_NOEOL TIFF_OPT1 /* no EOL code at end of row */ #define FAX3_BYTEALIGN TIFF_OPT2 /* force byte alignment at end of row */ #define FAX3_WORDALIGN TIFF_OPT3 /* force word alignment at end of row */ /* * Compression+decompression state blocks are * derived from this ``base state'' block. */ typedef struct { short data; /* current i/o byte */ short bit; /* current i/o bit in byte */ short white; /* value of the color ``white'' */ u_long rowbytes; /* XXX maybe should be a long? */ u_long rowpixels; /* XXX maybe should be a long? */ enum { /* decoding/encoding mode */ G3_1D, /* basic 1-d mode */ G3_2D /* optional 2-d mode */ } tag; #if defined(__STDC__) || defined(__EXTENDED__) || USE_CONST u_char const *bitmap; /* bit reversal table */ #else u_char *bitmap; /* bit reversal table */ #endif u_char *refline; /* reference line for 2d decoding */ } Fax3BaseState; /* these routines are used for Group 4 (T.6) */ #if USE_PROTOTYPES extern int Fax3Decode2DRow(TIFF*, u_char *, int); extern int Fax3Encode2DRow(TIFF*, u_char *, u_char *, int); extern void Fax3PutEOL(TIFF*); #else extern int Fax3Decode2DRow(); extern int Fax3Encode2DRow(); extern void Fax3PutEOL(); #endif #define Fax3FlushBits(tif, sp) { \ if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ (void) TIFFFlushData1(tif); \ *(tif)->tif_rawcp++ = (sp)->bitmap[(sp)->data]; \ (tif)->tif_rawcc++; \ (sp)->data = 0; \ (sp)->bit = 8; \ } #endif /* _FAX3_ */ ivtools-1.2.11a1/src/TIFF/tif_fax4.c000066400000000000000000000063031214471147700167160ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * CCITT Group 4 Facsimile-compatible * Compression Scheme Support. */ #include "tiffioP.h" #include "tif_fax3.h" #if USE_PROTOTYPES static int Fax4Decode(TIFF*, u_char *, int, u_int); static int Fax4Encode(TIFF*, u_char *, int, u_int); static int Fax4PostEncode(TIFF*); #else static int Fax4Decode(); static int Fax4Encode(); static int Fax4PostEncode(); #endif TIFFInitCCITTFax4(tif) TIFF *tif; { TIFFInitCCITTFax3(tif); /* reuse G3 compression */ tif->tif_decoderow = Fax4Decode; tif->tif_decodestrip = Fax4Decode; tif->tif_decodetile = Fax4Decode; tif->tif_encoderow = Fax4Encode; tif->tif_encodestrip = Fax4Encode; tif->tif_encodetile = Fax4Encode; tif->tif_postencode = Fax4PostEncode; /* * FAX3_NOEOL causes the regular G3 decompression * code to not skip to the EOL mark at the end of * a row (during normal decoding). FAX3_CLASSF * suppresses RTC generation at the end of an image. */ tif->tif_options = FAX3_NOEOL|FAX3_CLASSF; return (1); } /* * Decode the requested amount of data. */ static int Fax4Decode(tif, buf, occ, s) TIFF *tif; u_char *buf; int occ; u_int s; { Fax3BaseState *sp = (Fax3BaseState *)tif->tif_data; bzero(buf, occ); /* decoding only sets non-zero bits */ while (occ > 0) { if (!Fax3Decode2DRow(tif, buf, sp->rowpixels)) return (0); bcopy(buf, sp->refline, sp->rowbytes); buf += sp->rowbytes; occ -= sp->rowbytes; } return (1); } /* * Encode the requested amount of data. */ static int Fax4Encode(tif, bp, cc, s) TIFF *tif; u_char *bp; int cc; u_int s; { Fax3BaseState *sp = (Fax3BaseState *)tif->tif_data; while (cc > 0) { if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->rowpixels)) return (0); bcopy(bp, sp->refline, sp->rowbytes); bp += sp->rowbytes; cc -= sp->rowbytes; } return (1); } static Fax4PostEncode(tif) TIFF *tif; { Fax3BaseState *sp = (Fax3BaseState *)tif->tif_data; /* terminate strip w/ EOFB */ Fax3PutEOL(tif); Fax3PutEOL(tif); if (sp->bit != 8) Fax3FlushBits(tif, sp); return (1); } ivtools-1.2.11a1/src/TIFF/tif_flush.c000066400000000000000000000034411214471147700171750ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. */ #include "tiffioP.h" TIFFFlush(tif) TIFF *tif; { if (tif->tif_mode != O_RDONLY) { if (!TIFFFlushData(tif)) return (0); if ((tif->tif_flags & TIFF_DIRTYDIRECT) && !TIFFWriteDirectory(tif)) return (0); } return (1); } /* * Flush buffered data to the file. */ TIFFFlushData(tif) TIFF *tif; { if ((tif->tif_flags & TIFF_BEENWRITING) == 0) return (0); if (tif->tif_flags & TIFF_POSTENCODE) { tif->tif_flags &= ~TIFF_POSTENCODE; if (tif->tif_postencode && !(*tif->tif_postencode)(tif)) return (0); } return (TIFFFlushData1(tif)); } ivtools-1.2.11a1/src/TIFF/tif_getimage.c000066400000000000000000000636311214471147700176450ustar00rootroot00000000000000/* * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library * * Read and return a packed RGBA image. */ #include "tiffio.h" #include "tiffcompat.h" #include "prototypes.h" typedef u_char RGBvalue; static u_long width, height; /* image width & height */ static u_short bitspersample; static u_short samplesperpixel; static u_short photometric; static u_short orientation; /* colormap for pallete images */ static u_short *redcmap, *greencmap, *bluecmap; static int stoponerr; /* stop on read error */ static char *filename; /* YCbCr support */ static u_short YCbCrHorizSampling; static u_short YCbCrVertSampling; static float *YCbCrCoeffs; static float *refBlackWhite; static u_long **BWmap; static u_long **PALmap; static int gt(); TIFFReadRGBAImage(tif, rwidth, rheight, raster, stop) TIFF *tif; u_long rwidth, rheight; u_long *raster; int stop; { int ok; u_long width, height; TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample); switch (bitspersample) { case 1: case 2: case 4: case 8: case 16: break; default: TIFFError(TIFFFileName(tif), "Sorry, can not handle %d-bit pictures", bitspersample); return (0); } TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); switch (samplesperpixel) { case 1: case 3: case 4: break; default: TIFFError(TIFFFileName(tif), "Sorry, can not handle %d-channel images", samplesperpixel); return (0); } if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) { switch (samplesperpixel) { case 1: photometric = PHOTOMETRIC_MINISBLACK; break; case 3: case 4: photometric = PHOTOMETRIC_RGB; break; default: TIFFError(TIFFFileName(tif), "Missing needed \"PhotometricInterpretation\" tag"); return (0); } TIFFError(TIFFFileName(tif), "No \"PhotometricInterpretation\" tag, assuming %s\n", photometric == PHOTOMETRIC_RGB ? "RGB" : "min-is-black"); } /* XXX maybe should check photometric? */ TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height); /* XXX verify rwidth and rheight against width and height */ stoponerr = stop; BWmap = NULL; PALmap = NULL; ok = gt(tif, rwidth, height, raster + (rheight-height)*rwidth); if (BWmap) free((char *)BWmap); if (PALmap) free((char *)PALmap); return (ok); } static int checkcmap(n, r, g, b) int n; u_short *r, *g, *b; { while (n-- > 0) if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) return (16); TIFFWarning(filename, "Assuming 8-bit colormap"); return (8); } static gtTileContig(); static gtTileSeparate(); static gtStripContig(); static gtStripSeparate(); static void initYCbCrConversion(); static gt(tif, w, h, raster) TIFF *tif; int w, h; u_long *raster; { u_short minsamplevalue, maxsamplevalue, planarconfig; RGBvalue *Map; int e; TIFFGetFieldDefaulted(tif, TIFFTAG_MINSAMPLEVALUE, &minsamplevalue); TIFFGetFieldDefaulted(tif, TIFFTAG_MAXSAMPLEVALUE, &maxsamplevalue); Map = NULL; switch (photometric) { case PHOTOMETRIC_YCBCR: TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS, &YCbCrCoeffs); TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &YCbCrHorizSampling, &YCbCrVertSampling); TIFFGetFieldDefaulted(tif, TIFFTAG_REFERENCEBLACKWHITE, &refBlackWhite); initYCbCrConversion(); /* fall thru... */ case PHOTOMETRIC_RGB: if (minsamplevalue == 0 && maxsamplevalue == 255) break; /* fall thru... */ case PHOTOMETRIC_MINISBLACK: case PHOTOMETRIC_MINISWHITE: { register int x, range; range = maxsamplevalue - minsamplevalue; Map = (RGBvalue *)malloc((range + 1) * sizeof (RGBvalue)); if (Map == NULL) { TIFFError(filename, "No space for photometric conversion table"); return (0); } if (photometric == PHOTOMETRIC_MINISWHITE) { for (x = 0; x <= range; x++) Map[x] = ((range - x) * 255) / range; } else { for (x = 0; x <= range; x++) Map[x] = (x * 255) / range; } if (photometric != PHOTOMETRIC_RGB && bitspersample <= 8) { /* * Use photometric mapping table to construct * unpacking tables for samples <= 8 bits. */ if (!makebwmap(Map)) return (0); /* no longer need Map, free it */ free((char *)Map); Map = NULL; } break; } case PHOTOMETRIC_PALETTE: if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &redcmap, &greencmap, &bluecmap)) { TIFFError(filename, "Missing required \"Colormap\" tag"); return (0); } /* * Convert 16-bit colormap to 8-bit (unless it looks * like an old-style 8-bit colormap). */ if (checkcmap(1< 0; i--) { #define CVT(x) (((x) * 255) / ((1L<<16)-1)) redcmap[i] = CVT(redcmap[i]); greencmap[i] = CVT(greencmap[i]); bluecmap[i] = CVT(bluecmap[i]); } } if (bitspersample <= 8) { /* * Use mapping table and colormap to construct * unpacking tables for samples < 8 bits. */ if (!makecmap(redcmap, greencmap, bluecmap)) return (0); } break; } TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planarconfig); if (planarconfig == PLANARCONFIG_SEPARATE && samplesperpixel > 1) { e = TIFFIsTiled(tif) ? gtTileSeparate(tif, raster, Map, h, w) : gtStripSeparate(tif, raster, Map, h, w); } else { e = TIFFIsTiled(tif) ? gtTileContig(tif, raster, Map, h, w) : gtStripContig(tif, raster, Map, h, w); } if (Map) free((char *)Map); return (e); } u_long setorientation(tif, h) TIFF *tif; u_long h; { u_long y; TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &orientation); switch (orientation) { case ORIENTATION_BOTRIGHT: case ORIENTATION_RIGHTBOT: /* XXX */ case ORIENTATION_LEFTBOT: /* XXX */ TIFFWarning(filename, "using bottom-left orientation"); orientation = ORIENTATION_BOTLEFT; /* fall thru... */ case ORIENTATION_BOTLEFT: y = 0; break; case ORIENTATION_TOPRIGHT: case ORIENTATION_RIGHTTOP: /* XXX */ case ORIENTATION_LEFTTOP: /* XXX */ default: TIFFWarning(filename, "using top-left orientation"); orientation = ORIENTATION_TOPLEFT; /* fall thru... */ case ORIENTATION_TOPLEFT: y = h-1; break; } return (y); } #if USE_PROTOTYPES typedef void (*tileContigRoutine) (u_long*, u_char*, RGBvalue*, u_long, u_long, int, int); static tileContigRoutine pickTileContigCase(RGBvalue*); #else typedef void (*tileContigRoutine)(); static tileContigRoutine pickTileContigCase(); #endif /* * Get an tile-organized image that has * PlanarConfiguration contiguous if SamplesPerPixel > 1 * or * SamplesPerPixel == 1 */ static gtTileContig(tif, raster, Map, h, w) TIFF *tif; u_long *raster; RGBvalue *Map; u_long h, w; { u_long col, row, y; u_long tw, th; u_char *buf; int fromskew, toskew; u_int nrow; tileContigRoutine put; put = pickTileContigCase(Map); if (put == 0) return (0); buf = (u_char *)malloc(TIFFTileSize(tif)); if (buf == 0) { TIFFError(filename, "No space for tile buffer"); return (0); } TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); y = setorientation(tif, h); toskew = (orientation == ORIENTATION_TOPLEFT ? -tw + -w : -tw + w); for (row = 0; row < h; row += th) { nrow = (row + th > h ? h - row : th); for (col = 0; col < w; col += tw) { if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0 && stoponerr) break; if (col + tw > w) { /* * Tile is clipped horizontally. Calculate * visible portion and skewing factors. */ u_long npix = w - col; fromskew = tw - npix; (*put)(raster + y*w + col, buf, Map, npix, nrow, fromskew, toskew + fromskew); } else (*put)(raster + y*w + col, buf, Map, tw, nrow, 0, toskew); } y += (orientation == ORIENTATION_TOPLEFT ? -nrow : nrow); } free(buf); return (1); } #if USE_PROTOTYPES typedef void (*tileSeparateRoutine) (u_long*, u_char*, u_char*, u_char*, RGBvalue*, u_long, u_long, int, int); static tileSeparateRoutine pickTileSeparateCase(RGBvalue*); #else typedef void (*tileSeparateRoutine)(); static tileSeparateRoutine pickTileSeparateCase(); #endif /* * Get an tile-organized image that has * SamplesPerPixel > 1 * PlanarConfiguration separated * We assume that all such images are RGB. */ static gtTileSeparate(tif, raster, Map, h, w) TIFF *tif; u_long *raster; RGBvalue *Map; u_long h, w; { u_long col, row, y; u_long tw, th; u_char *buf; u_char *r, *g, *b; int tilesize; int fromskew, toskew; u_int nrow; tileSeparateRoutine put; put = pickTileSeparateCase(Map); if (put == 0) return (0); tilesize = TIFFTileSize(tif); buf = (u_char *)malloc(3*tilesize); if (buf == 0) { TIFFError(filename, "No space for tile buffer"); return (0); } r = buf; g = r + tilesize; b = g + tilesize; TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); y = setorientation(tif, h); toskew = (orientation == ORIENTATION_TOPLEFT ? -tw + -w : -tw + w); for (row = 0; row < h; row += th) { nrow = (row + th > h ? h - row : th); for (col = 0; col < w; col += tw) { if (TIFFReadTile(tif, r, col, row,0,0) < 0 && stoponerr) break; if (TIFFReadTile(tif, g, col, row,0,1) < 0 && stoponerr) break; if (TIFFReadTile(tif, b, col, row,0,2) < 0 && stoponerr) break; if (col + tw > w) { /* * Tile is clipped horizontally. Calculate * visible portion and skewing factors. */ u_long npix = w - col; fromskew = tw - npix; (*put)(raster + y*w + col, r, g, b, Map, npix, nrow, fromskew, toskew + fromskew); } else (*put)(raster + y*w + col, r, g, b, Map, tw, nrow, 0, toskew); } y += (orientation == ORIENTATION_TOPLEFT ? -nrow : nrow); } free(buf); return (1); } /* * Get a strip-organized image that has * PlanarConfiguration contiguous if SamplesPerPixel > 1 * or * SamplesPerPixel == 1 */ static gtStripContig(tif, raster, Map, h, w) TIFF *tif; u_long *raster; RGBvalue *Map; u_long h, w; { u_long row, y, nrow; u_char *buf; tileContigRoutine put; u_long rowsperstrip; u_long imagewidth; int scanline; int fromskew, toskew; put = pickTileContigCase(Map); if (put == 0) return (0); buf = (u_char *)malloc(TIFFStripSize(tif)); if (buf == 0) { TIFFError(filename, "No space for strip buffer"); return (0); } y = setorientation(tif, h); toskew = (orientation == ORIENTATION_TOPLEFT ? -w + -w : -w + w); TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imagewidth); scanline = TIFFScanlineSize(tif); fromskew = (w < imagewidth ? imagewidth - w : 0); for (row = 0; row < h; row += rowsperstrip) { nrow = (row + rowsperstrip > h ? h - row : rowsperstrip); if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0), buf, nrow*scanline) < 0 && stoponerr) break; (*put)(raster + y*w, buf, Map, w, nrow, fromskew, toskew); y += (orientation == ORIENTATION_TOPLEFT ? -nrow : nrow); } free(buf); return (1); } /* * Get a strip-organized image with * SamplesPerPixel > 1 * PlanarConfiguration separated * We assume that all such images are RGB. */ static gtStripSeparate(tif, raster, Map, h, w) TIFF *tif; u_long *raster; register RGBvalue *Map; u_long h, w; { u_char *buf; u_char *r, *g, *b; u_long row, y, nrow; int scanline; tileSeparateRoutine put; u_long rowsperstrip; u_long imagewidth; u_int stripsize; int fromskew, toskew; stripsize = TIFFStripSize(tif); r = buf = (u_char *)malloc(3*stripsize); if (buf == 0) return (0); g = r + stripsize; b = g + stripsize; put = pickTileSeparateCase(Map); if (put == 0) { TIFFError(filename, "Can not handle format"); return (0); } y = setorientation(tif, h); toskew = (orientation == ORIENTATION_TOPLEFT ? -w + -w : -w + w); TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imagewidth); scanline = TIFFScanlineSize(tif); fromskew = (w < imagewidth ? imagewidth - w : 0); for (row = 0; row < h; row += rowsperstrip) { nrow = (row + rowsperstrip > h ? h - row : rowsperstrip); if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0), r, nrow*scanline) < 0 && stoponerr) break; if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 1), g, nrow*scanline) < 0 && stoponerr) break; if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 2), b, nrow*scanline) < 0 && stoponerr) break; (*put)(raster + y*w, r, g, b, Map, w, nrow, fromskew, toskew); y += (orientation == ORIENTATION_TOPLEFT ? -nrow : nrow); } free(buf); return (1); } #define PACK(r,g,b) ((u_long)(r)|((u_long)(g)<<8)|((u_long)(b)<<16)) /* * Greyscale images with less than 8 bits/sample are handled * with a table to avoid lots of shifts and masks. The table * is setup so that put*bwtile (below) can retrieve 8/bitspersample * pixel values simply by indexing into the table with one * number. */ makebwmap(Map) RGBvalue *Map; { register int i; int nsamples = 8 / bitspersample; register u_long *p; BWmap = (u_long **)malloc( 256*sizeof (u_long *)+(256*nsamples*sizeof(u_long))); if (BWmap == NULL) { TIFFError(filename, "No space for B&W mapping table"); return (0); } p = (u_long *)(BWmap + 256); for (i = 0; i < 256; i++) { BWmap[i] = p; switch (bitspersample) { register RGBvalue c; #define GREY(x) c = Map[x]; *p++ = PACK(c,c,c); case 1: GREY(i>>7); GREY((i>>6)&1); GREY((i>>5)&1); GREY((i>>4)&1); GREY((i>>3)&1); GREY((i>>2)&1); GREY((i>>1)&1); GREY(i&1); break; case 2: GREY(i>>6); GREY((i>>4)&3); GREY((i>>2)&3); GREY(i&3); break; case 4: GREY(i>>4); GREY(i&0xf); break; case 8: GREY(i); break; } #undef GREY } return (1); } /* * Palette images with <= 8 bits/sample are handled * with a table to avoid lots of shifts and masks. The table * is setup so that put*cmaptile (below) can retrieve 8/bitspersample * pixel values simply by indexing into the table with one * number. */ makecmap(rmap, gmap, bmap) u_short *rmap, *gmap, *bmap; { register int i; int nsamples = 8 / bitspersample; register u_long *p; PALmap = (u_long **)malloc( 256*sizeof (u_long *)+(256*nsamples*sizeof(u_long))); if (PALmap == NULL) { TIFFError(filename, "No space for Palette mapping table"); return (0); } p = (u_long *)(PALmap + 256); for (i = 0; i < 256; i++) { PALmap[i] = p; #define CMAP(x) \ c = x; *p++ = PACK(rmap[c]&0xff, gmap[c]&0xff, bmap[c]&0xff); switch (bitspersample) { register RGBvalue c; case 1: CMAP(i>>7); CMAP((i>>6)&1); CMAP((i>>5)&1); CMAP((i>>4)&1); CMAP((i>>3)&1); CMAP((i>>2)&1); CMAP((i>>1)&1); CMAP(i&1); break; case 2: CMAP(i>>6); CMAP((i>>4)&3); CMAP((i>>2)&3); CMAP(i&3); break; case 4: CMAP(i>>4); CMAP(i&0xf); break; case 8: CMAP(i); break; } #undef CMAP } return (1); } /* * The following routines move decoded data returned * from the TIFF library into rasters filled with packed * ABGR pixels (i.e. suitable for passing to lrecwrite.) * * The routines have been created according to the most * important cases and optimized. pickTileContigCase and * pickTileSeparateCase analyze the parameters and select * the appropriate "put" routine to use. */ #define REPEAT8(op) REPEAT4(op); REPEAT4(op) #define REPEAT4(op) REPEAT2(op); REPEAT2(op) #define REPEAT2(op) op; op #define CASE8(x,op) \ switch (x) { \ case 7: op; case 6: op; case 5: op; \ case 4: op; case 3: op; case 2: op; \ case 1: op; \ } #define CASE4(x,op) switch (x) { case 3: op; case 2: op; case 1: op; } #define UNROLL8(w, op1, op2) { \ register u_long x; \ for (x = w; x >= 8; x -= 8) { \ op1; \ REPEAT8(op2); \ } \ if (x > 0) { \ op1; \ CASE8(x,op2); \ } \ } #define UNROLL4(w, op1, op2) { \ register u_long x; \ for (x = w; x >= 4; x -= 4) { \ op1; \ REPEAT4(op2); \ } \ if (x > 0) { \ op1; \ CASE4(x,op2); \ } \ } #define UNROLL2(w, op1, op2) { \ register u_long x; \ for (x = w; x >= 2; x -= 2) { \ op1; \ REPEAT2(op2); \ } \ if (x) { \ op1; \ op2; \ } \ } #define SKEW(r,g,b,skew) { r += skew; g += skew; b += skew; } /* * 8-bit palette => colormap/RGB */ static void put8bitcmaptile(cp, pp, Map, w, h, fromskew, toskew) register u_long *cp; register u_char *pp; RGBvalue *Map; u_long w, h; int fromskew, toskew; { while (h-- > 0) { UNROLL8(w,, *cp++ = PALmap[*pp++][0]); cp += toskew; pp += fromskew; } } /* * 4-bit palette => colormap/RGB */ static void put4bitcmaptile(cp, pp, Map, w, h, fromskew, toskew) register u_long *cp; register u_char *pp; register RGBvalue *Map; u_long w, h; int fromskew, toskew; { register u_long *bw; fromskew /= 2; while (h-- > 0) { UNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; } } /* * 2-bit palette => colormap/RGB */ static void put2bitcmaptile(cp, pp, Map, w, h, fromskew, toskew) register u_long *cp; register u_char *pp; register RGBvalue *Map; u_long w, h; int fromskew, toskew; { register u_long *bw; fromskew /= 4; while (h-- > 0) { UNROLL4(w, bw = PALmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; } } /* * 1-bit palette => colormap/RGB */ static void put1bitcmaptile(cp, pp, Map, w, h, fromskew, toskew) register u_long *cp; register u_char *pp; register RGBvalue *Map; u_long w, h; int fromskew, toskew; { register u_long *bw; fromskew /= 8; while (h-- > 0) { UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; } } /* * 8-bit greyscale => colormap/RGB */ static void putgreytile(cp, pp, Map, w, h, fromskew, toskew) register u_long *cp; register u_char *pp; RGBvalue *Map; u_long w, h; int fromskew, toskew; { while (h-- > 0) { register u_long x; for (x = w; x-- > 0;) *cp++ = BWmap[*pp++][0]; cp += toskew; pp += fromskew; } } /* * 1-bit bilevel => colormap/RGB */ static void put1bitbwtile(cp, pp, Map, w, h, fromskew, toskew) u_long *cp; u_char *pp; RGBvalue *Map; u_long w, h; int fromskew, toskew; { register u_long *bw; fromskew /= 8; while (h-- > 0) { UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; } } /* * 2-bit greyscale => colormap/RGB */ static void put2bitbwtile(cp, pp, Map, w, h, fromskew, toskew) u_long *cp; u_char *pp; RGBvalue *Map; u_long w, h; int fromskew, toskew; { register u_long *bw; fromskew /= 4; while (h-- > 0) { UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; } } /* * 4-bit greyscale => colormap/RGB */ static void put4bitbwtile(cp, pp, Map, w, h, fromskew, toskew) u_long *cp; u_char *pp; RGBvalue *Map; u_long w, h; int fromskew, toskew; { register u_long *bw; fromskew /= 2; while (h-- > 0) { UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; } } /* * 8-bit packed samples => RGB */ static void putRGBcontig8bittile(cp, pp, Map, w, h, fromskew, toskew) register u_long *cp; register u_char *pp; register RGBvalue *Map; u_long w, h; int fromskew, toskew; { fromskew *= samplesperpixel; if (Map) { while (h-- > 0) { register u_long x; for (x = w; x-- > 0;) { *cp++ = PACK(Map[pp[0]], Map[pp[1]], Map[pp[2]]); pp += samplesperpixel; } pp += fromskew; cp += toskew; } } else { while (h-- > 0) { UNROLL8(w,, *cp++ = PACK(pp[0], pp[1], pp[2]); pp += samplesperpixel); cp += toskew; pp += fromskew; } } } /* * 16-bit packed samples => RGB */ static void putRGBcontig16bittile(cp, pp, Map, w, h, fromskew, toskew) register u_long *cp; u_char *pp; register RGBvalue *Map; u_long w, h; int fromskew, toskew; { register u_short *wp = (u_short *)pp; register u_int x; fromskew *= samplesperpixel; if (Map) { while (h-- > 0) { for (x = w; x-- > 0;) { *cp++ = PACK(Map[wp[0]], Map[wp[1]], Map[wp[2]]); wp += samplesperpixel; } cp += toskew; wp += fromskew; } } else { while (h-- > 0) { for (x = w; x-- > 0;) { *cp++ = PACK(wp[0], wp[1], wp[2]); wp += samplesperpixel; } cp += toskew; wp += fromskew; } } } /* * 8-bit unpacked samples => RGB */ static void putRGBseparate8bittile(cp, r, g, b, Map, w, h, fromskew, toskew) register u_long *cp; register u_char *r, *g, *b; register RGBvalue *Map; u_long w, h; int fromskew, toskew; { if (Map) { while (h-- > 0) { register u_long x; for (x = w; x > 0; x--) *cp++ = PACK(Map[*r++], Map[*g++], Map[*b++]); SKEW(r, g, b, fromskew); cp += toskew; } } else { while (h-- > 0) { UNROLL8(w,, *cp++ = PACK(*r++, *g++, *b++)); SKEW(r, g, b, fromskew); cp += toskew; } } } /* * 16-bit unpacked samples => RGB */ static void putRGBseparate16bittile(cp, br, bg, bb, Map, w, h, fromskew, toskew) register u_long *cp; u_char *br, *bg, *bb; register RGBvalue *Map; u_long w, h; int fromskew, toskew; { register u_short *r = (u_short *)br; register u_short *g = (u_short *)bg; register u_short *b = (u_short *)bb; register u_long x; if (Map) { while (h-- > 0) { for (x = w; x > 0; x--) *cp++ = PACK(Map[*r++], Map[*g++], Map[*b++]); SKEW(r, g, b, fromskew); cp += toskew; } } else { while (h-- > 0) { for (x = 0; x < w; x++) *cp++ = PACK(*r++, *g++, *b++); SKEW(r, g, b, fromskew); cp += toskew; } } } #define Code2V(c, RB, RW, CR) ((((c)-RB)*(float)CR)/(float)(RW-RB)) #define CLAMP(f,min,max) \ (int)((f)+.5 < (min) ? (min) : (f)+.5 > (max) ? (max) : (f)+.5) #define LumaRed YCbCrCoeffs[0] #define LumaGreen YCbCrCoeffs[1] #define LumaBlue YCbCrCoeffs[2] static float D1, D2; static float D3, D4; static void initYCbCrConversion() { D1 = 2 - 2*LumaRed; D2 = D1*LumaRed / LumaGreen; D3 = 2 - 2*LumaBlue; D4 = D2*LumaBlue / LumaGreen; } static void putRGBContigYCbCrClump(cp, pp, cw, ch, w, n, fromskew, toskew) register u_long *cp; register u_char *pp; int cw, ch; u_long w; int n, fromskew, toskew; { float Cb, Cr; int j, k; Cb = Code2V(pp[n], refBlackWhite[2], refBlackWhite[3], 127); Cr = Code2V(pp[n+1], refBlackWhite[4], refBlackWhite[5], 127); for (j = 0; j < ch; j++) { for (k = 0; k < cw; k++) { float Y, R, G, B; Y = Code2V(*pp++, refBlackWhite[0], refBlackWhite[1], 255); R = Y + Cr*D1; B = Y + Cb*D3; G = Y - Cb*D4 - Cr*D2; cp[k] = PACK(CLAMP(R,0,255), CLAMP(G,0,255), CLAMP(B,0,255)); } cp += w+toskew; pp += fromskew; } } #undef LumaBlue #undef LumaGreen #undef LumaRed #undef CLAMP #undef Code2V /* * 8-bit packed YCbCr samples => RGB */ static void putcontig8bitYCbCrtile(cp, pp, Map, w, h, fromskew, toskew) register u_long *cp; register u_char *pp; register RGBvalue *Map; u_long w, h; int fromskew, toskew; { u_int Coff = YCbCrVertSampling * YCbCrHorizSampling; u_long *tp; u_long x; /* XXX adjust fromskew */ while (h >= YCbCrVertSampling) { tp = cp; for (x = w; x >= YCbCrHorizSampling; x -= YCbCrHorizSampling) { putRGBContigYCbCrClump(tp, pp, YCbCrHorizSampling, YCbCrVertSampling, w, Coff, 0, toskew); tp += YCbCrHorizSampling; pp += Coff+2; } if (x > 0) { putRGBContigYCbCrClump(tp, pp, x, YCbCrVertSampling, w, Coff, YCbCrHorizSampling - x, toskew); pp += Coff+2; } cp += YCbCrVertSampling*(w + toskew); pp += fromskew; h -= YCbCrVertSampling; } if (h > 0) { tp = cp; for (x = w; x >= YCbCrHorizSampling; x -= YCbCrHorizSampling) { putRGBContigYCbCrClump(tp, pp, YCbCrHorizSampling, h, w, Coff, 0, toskew); tp += YCbCrHorizSampling; pp += Coff+2; } if (x > 0) putRGBContigYCbCrClump(tp, pp, x, h, w, Coff, YCbCrHorizSampling - x, toskew); } } /* * Select the appropriate conversion routine for packed data. */ static tileContigRoutine DECLARE1(pickTileContigCase, RGBvalue*, Map) { tileContigRoutine put = 0; switch (photometric) { case PHOTOMETRIC_RGB: put = (bitspersample == 8 ? putRGBcontig8bittile : putRGBcontig16bittile); break; case PHOTOMETRIC_PALETTE: switch (bitspersample) { case 8: put = put8bitcmaptile; break; case 4: put = put4bitcmaptile; break; case 2: put = put2bitcmaptile; break; case 1: put = put1bitcmaptile; break; } break; case PHOTOMETRIC_MINISWHITE: case PHOTOMETRIC_MINISBLACK: switch (bitspersample) { case 8: put = putgreytile; break; case 4: put = put4bitbwtile; break; case 2: put = put2bitbwtile; break; case 1: put = put1bitbwtile; break; } break; case PHOTOMETRIC_YCBCR: switch (bitspersample) { case 8: put = putcontig8bitYCbCrtile; break; } break; } if (put == 0) TIFFError(filename, "Can not handle format"); return (put); } /* * Select the appropriate conversion routine for unpacked data. * * NB: we assume that unpacked single channel data is directed * to the "packed routines. */ static tileSeparateRoutine DECLARE1(pickTileSeparateCase, RGBvalue*, Map) { tileSeparateRoutine put = 0; switch (photometric) { case PHOTOMETRIC_RGB: put = (bitspersample == 8 ? putRGBseparate8bittile : putRGBseparate16bittile); break; } if (put == 0) TIFFError(filename, "Can not handle format"); return (put); } ivtools-1.2.11a1/src/TIFF/tif_jpeg.c000066400000000000000000000025411214471147700170010ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * Baseline JPEG Compression Algorithm Support. */ #include "tiffioP.h" TIFFInitJPEG(tif) register TIFF *tif; { return (1); } ivtools-1.2.11a1/src/TIFF/tif_lzw.c000066400000000000000000000757021214471147700167010ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * Rev 5.0 Lempel-Ziv & Welch Compression Support * * This code is derived from the compress program whose code is * derived from software contributed to Berkeley by James A. Woods, * derived from original work by Spencer Thomas and Joseph Orost. * * The original Berkeley copyright notice appears below in its entirety. */ #include "tiffioP.h" #include #include #include "prototypes.h" /* * NB: The 5.0 spec describes a different algorithm than Aldus * implements. Specifically, Aldus does code length transitions * one code earlier than should be done (for real LZW). * Earlier versions of this library implemented the correct * LZW algorithm, but emitted codes in a bit order opposite * to the TIFF spec. Thus, to maintain compatibility w/ Aldus * we interpret MSB-LSB ordered codes to be images written w/ * old versions of this library, but otherwise adhere to the * Aldus "off by one" algorithm. * * Future revisions to the TIFF spec are expected to "clarify this issue". */ #define LZW_COMPAT /* include backwards compatibility code */ /* * Each strip of data is supposed to be terminated by a CODE_EOI. * If the following #define is included, the decoder will also * check for end-of-strip w/o seeing this code. This makes the * library more robust, but also slower. */ #define LZW_CHECKEOS /* include checks for strips w/o EOI code */ #define MAXCODE(n) ((1<<(n))-1) /* * The TIFF spec specifies that encoded bit * strings range from 9 to 12 bits. */ #define BITS_MIN 9 /* start with 9 bits */ #define BITS_MAX 12 /* max of 12 bit strings */ /* predefined codes */ #define CODE_CLEAR 256 /* code to clear string table */ #define CODE_EOI 257 /* end-of-information code */ #define CODE_FIRST 258 /* first free code entry */ #define CODE_MAX MAXCODE(BITS_MAX) #define HSIZE 9001 /* 91% occupancy */ #define HSHIFT (13-8) #ifdef LZW_COMPAT /* NB: +1024 is for compatibility with old files */ #define CSIZE (MAXCODE(BITS_MAX)+1024) #else #define CSIZE (MAXCODE(BITS_MAX)+1) #endif #if USE_PROTOTYPES typedef void (*predictorFunc)(char* data, int nbytes, int stride); #else typedef void (*predictorFunc)(); #endif /* * State block for each open TIFF * file using LZW compression/decompression. */ typedef struct { predictorFunc hordiff; /* horizontal differencing method */ long rowsize; /* width of tile/strip/row */ u_short stride; /* horizontal diferencing stride */ u_short nbits; /* # of bits/code */ u_short maxcode; /* maximum code for lzw_nbits */ u_short free_ent; /* next free entry in hash table */ long nextdata; /* next bits of i/o */ long nextbits; /* # of valid bits in lzw_nextdata */ } LZWState; #define lzw_hordiff base.hordiff #define lzw_rowsize base.rowsize #define lzw_stride base.stride #define lzw_nbits base.nbits #define lzw_maxcode base.maxcode #define lzw_free_ent base.free_ent #define lzw_nextdata base.nextdata #define lzw_nextbits base.nextbits /* * Decoding-specific state. */ typedef struct code_ent { struct code_ent *next; u_short length; /* string len, including this token */ u_char value; /* data value */ u_char firstchar; /* first token of string */ } code_t; #if USE_PROTOTYPES typedef int (*decodeFunc)(TIFF*, u_char*, int, u_int); #else typedef int (*decodeFunc)(); #endif typedef struct { LZWState base; long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */ long dec_restart; /* restart count */ #ifdef LZW_CHECKEOS long dec_bitsleft; /* available bits in raw data */ #endif decodeFunc dec_decode; /* regular or backwards compatible */ code_t *dec_codep; /* current recognized code */ code_t *dec_oldcodep; /* previously recognized code */ code_t *dec_free_entp; /* next free entry */ code_t *dec_maxcodep; /* max available entry */ code_t dec_codetab[CSIZE]; } LZWDecodeState; /* * Encoding-specific state. */ typedef struct { long hash; long code; } hash_t; typedef struct { LZWState base; int enc_oldcode; /* last code encountered */ long enc_checkpoint; /* point at which to clear table */ #define CHECK_GAP 10000 /* enc_ratio check interval */ long enc_ratio; /* current compression ratio */ long enc_incount; /* (input) data bytes encoded */ long enc_outcount; /* encoded (output) bytes */ char *enc_rawlimit; /* bound on tif_rawdata buffer */ hash_t enc_hashtab[HSIZE]; } LZWEncodeState; #if USE_PROTOTYPES static int LZWPreEncode(TIFF*); static int LZWEncode(TIFF*, u_char*, int, u_int); static int LZWEncodePredRow(TIFF*, u_char*, int, u_int); static int LZWEncodePredTile(TIFF*, u_char*, int, u_int); static int LZWPostEncode(TIFF*); static int LZWDecode(TIFF*, u_char*, int, u_int); #ifdef LZW_COMPAT static int LZWDecodeCompat(TIFF*, u_char*, int, u_int); #endif static int LZWDecodePredRow(TIFF*, u_char*, int, u_int); static int LZWDecodePredTile(TIFF*, u_char*, int, u_int); static int LZWPreDecode(TIFF*); static int LZWCleanup(TIFF*); static void cl_hash(LZWEncodeState*); extern int TIFFFlushData1(TIFF *); #else static int LZWPreEncode(), LZWEncode(), LZWPostEncode(); static int LZWEncodePredRow(), LZWEncodePredTile(); static int LZWPreDecode(), LZWDecode(); #ifdef LZW_COMPAT static int LZWDecodeCompat(); #endif static int LZWDecodePredRow(), LZWDecodePredTile(); static int LZWCleanup(); static void cl_hash(); extern int TIFFFlushData1(); #endif TIFFInitLZW(tif) TIFF *tif; { tif->tif_predecode = LZWPreDecode; tif->tif_decoderow = LZWDecode; tif->tif_decodestrip = LZWDecode; tif->tif_decodetile = LZWDecode; tif->tif_preencode = LZWPreEncode; tif->tif_postencode = LZWPostEncode; tif->tif_encoderow = LZWEncode; tif->tif_encodestrip = LZWEncode; tif->tif_encodetile = LZWEncode; tif->tif_cleanup = LZWCleanup; return (1); } static DECLARE4(LZWCheckPredictor, TIFF*, tif, LZWState*, sp, predictorFunc, pred8bit, predictorFunc, pred16bit ) { TIFFDirectory *td = &tif->tif_dir; sp->hordiff = NULL; switch (td->td_predictor) { case 1: break; case 2: sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel : 1); switch (td->td_bitspersample) { case 8: sp->hordiff = pred8bit; break; case 16: sp->hordiff = pred16bit; break; default: TIFFError(tif->tif_name, "Horizontal differencing \"Predictor\" not supported with %d-bit samples", td->td_bitspersample); return (0); } break; default: TIFFError(tif->tif_name, "\"Predictor\" value %d not supported", td->td_predictor); return (0); } if (sp->hordiff != NULL) { /* * Calculate the scanline/tile-width size in bytes. */ if (isTiled(tif)) sp->rowsize = TIFFTileRowSize(tif); else sp->rowsize = TIFFScanlineSize(tif); } else sp->rowsize = 0; return (1); } /* * LZW Decoder. */ #ifdef LZW_CHECKEOS /* * This check shouldn't be necessary because each * strip is suppose to be terminated with CODE_EOI. */ #define NextCode(tif, sp, bp, code, get) { \ if ((sp)->dec_bitsleft < nbits) { \ TIFFWarning(tif->tif_name, \ "LZWDecode: Strip %d not terminated with EOI code", \ tif->tif_curstrip); \ code = CODE_EOI; \ } else { \ get(sp, bp, code); \ (sp)->dec_bitsleft -= nbits; \ } \ } #else #define NextCode(tif, sp, bp, code, get) get(sp, bp, code) #endif #define REPEAT4(n, op) \ switch (n) { \ default: { int i; for (i = n-4; i > 0; i--) { op; } } \ case 4: op; \ case 3: op; \ case 2: op; \ case 1: op; \ case 0: ; \ } #define XREPEAT4(n, op) \ switch (n) { \ default: { int i; for (i = n-4; i > 0; i--) { op; } } \ case 2: op; \ case 1: op; \ case 0: ; \ } static void DECLARE3(horizontalAccumulate8, register char*, cp, register int, cc, register int, stride ) { if (cc > stride) { cc -= stride; /* * Pipeline the most common cases. */ if (stride == 3) { u_int cr = cp[0]; u_int cg = cp[1]; u_int cb = cp[2]; do { cc -= 3, cp += 3; cp[0] = (cr += cp[0]); cp[1] = (cg += cp[1]); cp[2] = (cb += cp[2]); } while (cc > 0); } else if (stride == 4) { u_int cr = cp[0]; u_int cg = cp[1]; u_int cb = cp[2]; u_int ca = cp[3]; do { cc -= 4, cp += 4; cp[0] = (cr += cp[0]); cp[1] = (cg += cp[1]); cp[2] = (cb += cp[2]); cp[3] = (ca += cp[3]); } while (cc > 0); } else { do { XREPEAT4(stride, cp[stride] += *cp; cp++) cc -= stride; } while (cc > 0); } } } static void DECLARE3(horizontalAccumulate16, char*, cp, int, cc, register int, stride ) { register short* wp = (short *)cp; register int wc = cc / 2; if (wc > stride) { wc -= stride; do { REPEAT4(stride, wp[stride] += wp[0]; wp++) wc -= stride; } while (wc > 0); } } /* * Setup state for decoding a strip. */ static LZWPreDecode(tif) TIFF *tif; { register LZWDecodeState *sp = (LZWDecodeState *)tif->tif_data; if (sp == NULL) { tif->tif_data = malloc(sizeof (LZWDecodeState)); if (tif->tif_data == NULL) { TIFFError("LZWPreDecode", "No space for LZW state block"); return (0); } sp = (LZWDecodeState *)tif->tif_data; sp->dec_decode = NULL; if (!LZWCheckPredictor(tif, &sp->base, horizontalAccumulate8, horizontalAccumulate16)) return (0); if (sp->lzw_hordiff) { /* * Override default decoding method with * one that does the predictor stuff. */ tif->tif_decoderow = LZWDecodePredRow; tif->tif_decodestrip = LZWDecodePredTile; tif->tif_decodetile = LZWDecodePredTile; } /* * Pre-load the table. */ { int code; for (code = 255; code >= 0; code--) { sp->dec_codetab[code].value = code; sp->dec_codetab[code].firstchar = code; sp->dec_codetab[code].length = 1; sp->dec_codetab[code].next = NULL; } } } /* * Check for old bit-reversed codes. */ if (tif->tif_rawdata[0] == 0 && (tif->tif_rawdata[1] & 0x1)) { #ifdef LZW_COMPAT if (!sp->dec_decode) { if (sp->lzw_hordiff == NULL) { /* * Override default decoding methods with * ones that deal with the old coding. * Otherwise the predictor versions set * above will call the compatibility routines * through the dec_decode method. */ tif->tif_decoderow = LZWDecodeCompat; tif->tif_decodestrip = LZWDecodeCompat; tif->tif_decodetile = LZWDecodeCompat; } TIFFWarning(tif->tif_name, "Old-style LZW codes, convert file"); } sp->lzw_maxcode = MAXCODE(BITS_MIN); sp->dec_decode = LZWDecodeCompat; #else /* !LZW_COMPAT */ if (!sp->dec_decode) { TIFFError(tif->tif_name, "Old-style LZW codes not supported"); sp->dec_decode = LZWDecode; } return (0); #endif/* !LZW_COMPAT */ } else { sp->lzw_maxcode = MAXCODE(BITS_MIN)-1; sp->dec_decode = LZWDecode; } sp->lzw_nbits = BITS_MIN; sp->lzw_nextbits = 0; sp->lzw_nextdata = 0; sp->dec_restart = 0; sp->dec_nbitsmask = MAXCODE(BITS_MIN); #ifdef LZW_CHECKEOS sp->dec_bitsleft = tif->tif_rawdatasize << 3; #endif sp->dec_free_entp = sp->dec_codetab + CODE_FIRST; sp->dec_oldcodep = &sp->dec_codetab[-1]; sp->dec_maxcodep = &sp->dec_codetab[sp->dec_nbitsmask-1]; return (1); } /* * Decode a "hunk of data". */ #define GetNextCode(sp, bp, code) { \ nextdata = (nextdata<<8) | *(bp)++; \ nextbits += 8; \ if (nextbits < nbits) { \ nextdata = (nextdata<<8) | *(bp)++; \ nextbits += 8; \ } \ code = (nextdata >> (nextbits-nbits)) & nbitsmask; \ nextbits -= nbits; \ } static LZWDecode(tif, op0, occ0, s) TIFF *tif; u_char *op0; u_int s; { LZWDecodeState *sp = (LZWDecodeState *)tif->tif_data; char *op = (char *)op0; int occ = occ0; char *tp; u_char *bp; int code, nbits, nextbits; long nextdata, nbitsmask; code_t *codep, *free_entp, *maxcodep, *oldcodep; assert(sp != NULL); /* * Restart interrupted output operation. */ if (sp->dec_restart) { int residue; codep = sp->dec_codep; residue = codep->length - sp->dec_restart; if (residue > occ) { /* * Residue from previous decode is sufficient * to satisfy decode request. Skip to the * start of the decoded string, place decoded * values in the output buffer, and return. */ sp->dec_restart += occ; do { codep = codep->next; } while (--residue > occ); tp = op + occ; do { *--tp = codep->value; codep = codep->next; } while (--occ); return (1); } /* * Residue satisfies only part of the decode request. */ op += residue, occ -= residue; tp = op; do { int t; --tp; t = codep->value; codep = codep->next; *tp = t; } while (--residue); sp->dec_restart = 0; } bp = (u_char *)tif->tif_rawcp; nbits = sp->lzw_nbits; nextdata = sp->lzw_nextdata; nextbits = sp->lzw_nextbits; nbitsmask = sp->dec_nbitsmask; oldcodep = sp->dec_oldcodep; free_entp = sp->dec_free_entp; maxcodep = sp->dec_maxcodep; while (occ > 0) { NextCode(tif, sp, bp, code, GetNextCode); if (code == CODE_EOI) break; if (code == CODE_CLEAR) { free_entp = sp->dec_codetab + CODE_FIRST; nbits = BITS_MIN; nbitsmask = MAXCODE(BITS_MIN); maxcodep = sp->dec_codetab + nbitsmask-1; NextCode(tif, sp, bp, code, GetNextCode); if (code == CODE_EOI) break; *op++ = code, occ--; oldcodep = sp->dec_codetab + code; continue; } codep = sp->dec_codetab + code; /* * Add the new entry to the code table. */ assert(&sp->dec_codetab[0] <= free_entp && free_entp < &sp->dec_codetab[CSIZE]); free_entp->next = oldcodep; free_entp->firstchar = free_entp->next->firstchar; free_entp->length = free_entp->next->length+1; free_entp->value = (codep < free_entp) ? codep->firstchar : free_entp->firstchar; if (++free_entp > maxcodep) { if (++nbits > BITS_MAX) /* should not happen */ nbits = BITS_MAX; nbitsmask = MAXCODE(nbits); maxcodep = sp->dec_codetab + nbitsmask-1; } oldcodep = codep; if (code >= 256) { /* * Code maps to a string, copy string * value to output (written in reverse). */ if (codep->length > occ) { /* * String is too long for decode buffer, * locate portion that will fit, copy to * the decode buffer, and setup restart * logic for the next decoding call. */ sp->dec_codep = codep; do { codep = codep->next; } while (codep->length > occ); sp->dec_restart = occ; tp = op + occ; do { *--tp = codep->value; codep = codep->next; } while (--occ); break; } op += codep->length, occ -= codep->length; tp = op; do { int t; --tp; t = codep->value; codep = codep->next; *tp = t; } while (codep); } else *op++ = code, occ--; } tif->tif_rawcp = (char *)bp; sp->lzw_nbits = nbits; sp->lzw_nextdata = nextdata; sp->lzw_nextbits = nextbits; sp->dec_nbitsmask = nbitsmask; sp->dec_oldcodep = oldcodep; sp->dec_free_entp = free_entp; sp->dec_maxcodep = maxcodep; if (occ > 0) { TIFFError(tif->tif_name, "LZWDecode: Not enough data at scanline %d (short %d bytes)", tif->tif_row, occ); return (0); } return (1); } #ifdef LZW_COMPAT /* * Decode a "hunk of data" for old images. */ #define GetNextCodeCompat(sp, bp, code) { \ nextdata |= *(bp)++ << nextbits; \ nextbits += 8; \ if (nextbits < nbits) { \ nextdata |= *(bp)++ << nextbits; \ nextbits += 8; \ } \ code = nextdata & nbitsmask; \ nextdata >>= nbits; \ nextbits -= nbits; \ } static LZWDecodeCompat(tif, op0, occ0, s) TIFF *tif; u_char *op0; u_int s; { LZWDecodeState *sp = (LZWDecodeState *)tif->tif_data; char *op = (char *)op0; int occ = occ0; char *tp; u_char *bp; int code, nbits, nextbits; long nextdata, nbitsmask; code_t *codep, *free_entp, *maxcodep, *oldcodep; assert(sp != NULL); /* * Restart interrupted output operation. */ if (sp->dec_restart) { int residue; codep = sp->dec_codep; residue = codep->length - sp->dec_restart; if (residue > occ) { /* * Residue from previous decode is sufficient * to satisfy decode request. Skip to the * start of the decoded string, place decoded * values in the output buffer, and return. */ sp->dec_restart += occ; do { codep = codep->next; } while (--residue > occ); tp = op + occ; do { *--tp = codep->value; codep = codep->next; } while (--occ); return (1); } /* * Residue satisfies only part of the decode request. */ op += residue, occ -= residue; tp = op; do { *--tp = codep->value; codep = codep->next; } while (--residue); sp->dec_restart = 0; } bp = (u_char *)tif->tif_rawcp; nbits = sp->lzw_nbits; nextdata = sp->lzw_nextdata; nextbits = sp->lzw_nextbits; nbitsmask = sp->dec_nbitsmask; oldcodep = sp->dec_oldcodep; free_entp = sp->dec_free_entp; maxcodep = sp->dec_maxcodep; while (occ > 0) { NextCode(tif, sp, bp, code, GetNextCodeCompat); if (code == CODE_EOI) break; if (code == CODE_CLEAR) { free_entp = sp->dec_codetab + CODE_FIRST; nbits = BITS_MIN; nbitsmask = MAXCODE(BITS_MIN); maxcodep = sp->dec_codetab + nbitsmask; NextCode(tif, sp, bp, code, GetNextCodeCompat); if (code == CODE_EOI) break; *op++ = code, occ--; oldcodep = sp->dec_codetab + code; continue; } codep = sp->dec_codetab + code; /* * Add the new entry to the code table. */ assert(&sp->dec_codetab[0] <= free_entp && free_entp < &sp->dec_codetab[CSIZE]); free_entp->next = oldcodep; free_entp->firstchar = free_entp->next->firstchar; free_entp->length = free_entp->next->length+1; free_entp->value = (codep < free_entp) ? codep->firstchar : free_entp->firstchar; if (++free_entp > maxcodep) { if (++nbits > BITS_MAX) /* should not happen */ nbits = BITS_MAX; nbitsmask = MAXCODE(nbits); maxcodep = sp->dec_codetab + nbitsmask; } oldcodep = codep; if (code >= 256) { /* * Code maps to a string, copy string * value to output (written in reverse). */ if (codep->length > occ) { /* * String is too long for decode buffer, * locate portion that will fit, copy to * the decode buffer, and setup restart * logic for the next decoding call. */ sp->dec_codep = codep; do { codep = codep->next; } while (codep->length > occ); sp->dec_restart = occ; tp = op + occ; do { *--tp = codep->value; codep = codep->next; } while (--occ); break; } op += codep->length, occ -= codep->length; tp = op; do { *--tp = codep->value; } while (codep = codep->next); } else *op++ = code, occ--; } tif->tif_rawcp = (char *)bp; sp->lzw_nbits = nbits; sp->lzw_nextdata = nextdata; sp->lzw_nextbits = nextbits; sp->dec_nbitsmask = nbitsmask; sp->dec_oldcodep = oldcodep; sp->dec_free_entp = free_entp; sp->dec_maxcodep = maxcodep; if (occ > 0) { TIFFError(tif->tif_name, "LZWDecodeCompat: Not enough data at scanline %d (short %d bytes)", tif->tif_row, occ); return (0); } return (1); } #endif /* LZW_COMPAT */ /* * Decode a scanline and apply the predictor routine. */ static LZWDecodePredRow(tif, op0, occ0, s) TIFF *tif; u_char *op0; u_int s; { LZWDecodeState *sp = (LZWDecodeState *)tif->tif_data; assert(sp != NULL); assert(sp->dec_decode != NULL); if ((*sp->dec_decode)(tif, op0, occ0, s)) { (*sp->lzw_hordiff)((char *)op0, occ0, sp->lzw_stride); return (1); } else return (0); } /* * Decode a tile/strip and apply the predictor routine. * Note that horizontal differencing must be done on a * row-by-row basis. The width of a "row" has already * been calculated at pre-decode time according to the * strip/tile dimensions. */ static LZWDecodePredTile(tif, op0, occ0, s) TIFF *tif; u_char *op0; u_int s; { LZWDecodeState *sp = (LZWDecodeState *)tif->tif_data; int rowsize; assert(sp != NULL); assert(sp->dec_decode != NULL); if (!(*sp->dec_decode)(tif, op0, occ0, s)) return (0); rowsize = sp->lzw_rowsize; assert(rowsize > 0); while (occ0 > 0) { (*sp->lzw_hordiff)((char *)op0, rowsize, sp->lzw_stride); occ0 -= rowsize; op0 += rowsize; } return (1); } /* * LZW Encoding. */ static void DECLARE3(horizontalDifference8, register char*, cp, register int, cc, register int, stride ) { if (cc > stride) { cc -= stride; /* * Pipeline the most common cases. */ if (stride == 3) { int r1, g1, b1; int r2 = cp[0]; int g2 = cp[1]; int b2 = cp[2]; do { r1 = cp[3]; cp[3] = r1-r2; r2 = r1; g1 = cp[4]; cp[4] = g1-g2; g2 = g1; b1 = cp[5]; cp[5] = b1-b2; b2 = b1; cp += 3; } while ((cc -= 3) > 0); } else if (stride == 4) { int r1, g1, b1, a1; int r2 = cp[0]; int g2 = cp[1]; int b2 = cp[2]; int a2 = cp[3]; do { r1 = cp[4]; cp[4] = r1-r2; r2 = r1; g1 = cp[5]; cp[5] = g1-g2; g2 = g1; b1 = cp[6]; cp[6] = b1-b2; b2 = b1; a1 = cp[7]; cp[7] = a1-a2; a2 = a1; cp += 4; } while ((cc -= 4) > 0); } else { cp += cc - 1; do { REPEAT4(stride, cp[stride] -= cp[0]; cp--) } while ((cc -= stride) > 0); } } } static void DECLARE3(horizontalDifference16, char*, cp, int, cc, register int, stride ) { register short *wp = (short *)cp; register int wc = cc/2; if (wc > stride) { wc -= stride; wp += wc - 1; do { REPEAT4(stride, wp[stride] -= wp[0]; wp--) wc -= stride; } while (wc > 0); } } /* * Reset encoding state at the start of a strip. */ static LZWPreEncode(tif) TIFF *tif; { register LZWEncodeState *sp = (LZWEncodeState *)tif->tif_data; if (sp == NULL) { tif->tif_data = malloc(sizeof (LZWEncodeState)); if (tif->tif_data == NULL) { TIFFError("LZWPreEncode", "No space for LZW state block"); return (0); } sp = (LZWEncodeState *)tif->tif_data; if (!LZWCheckPredictor(tif, &sp->base, horizontalDifference8, horizontalDifference16)) return (0); if (sp->lzw_hordiff != NULL) { tif->tif_encoderow = LZWEncodePredRow; tif->tif_encodestrip = LZWEncodePredTile; tif->tif_encodetile = LZWEncodePredTile; } } sp->lzw_nbits = BITS_MIN; sp->lzw_maxcode = MAXCODE(BITS_MIN); sp->lzw_free_ent = CODE_FIRST; sp->lzw_nextbits = 0; sp->lzw_nextdata = 0; sp->enc_checkpoint = CHECK_GAP; sp->enc_ratio = 0; sp->enc_incount = 0; sp->enc_outcount = 0; /* * The 4 here insures there is space for 2 max-sized * codes in LZWEncode and LZWPostDecode. */ sp->enc_rawlimit = tif->tif_rawdata + tif->tif_rawdatasize-1 - 4; cl_hash(sp); /* clear hash table */ sp->enc_oldcode = -1; /* generates CODE_CLEAR in LZWEncode */ return (1); } #define CALCRATIO(sp, rat) { \ if (incount > 0x007fffff) { /* NB: shift will overflow */\ rat = outcount >> 8; \ rat = (rat == 0 ? 0x7fffffff : incount/rat); \ } else \ rat = (incount<<8) / outcount; \ } #define PutNextCode(op, c) { \ nextdata = (nextdata << nbits) | c; \ nextbits += nbits; \ *op++ = nextdata >> (nextbits-8); \ nextbits -= 8; \ if (nextbits >= 8) { \ *op++ = nextdata >> (nextbits-8); \ nextbits -= 8; \ } \ outcount += nbits; \ } /* * Encode a chunk of pixels. * * Uses an open addressing double hashing (no chaining) on the * prefix code/next character combination. We do a variant of * Knuth's algorithm D (vol. 3, sec. 6.4) along with G. Knott's * relatively-prime secondary probe. Here, the modular division * first probe is gives way to a faster exclusive-or manipulation. * Also do block compression with an adaptive reset, whereby the * code table is cleared when the compression ratio decreases, * but after the table fills. The variable-length output codes * are re-sized at this point, and a CODE_CLEAR is generated * for the decoder. */ static LZWEncode(tif, bp, cc, s) TIFF *tif; u_char *bp; int cc; u_int s; { static char module[] = "LZWEncode"; register LZWEncodeState *sp = (LZWEncodeState *)tif->tif_data; register long fcode; register hash_t *hp; register int h, c, ent, disp; long incount, outcount, checkpoint; long nextdata, nextbits; int free_ent, maxcode, nbits; char *op, *limit; if (sp == NULL) return (0); /* * Load local state. */ incount = sp->enc_incount; outcount = sp->enc_outcount; checkpoint = sp->enc_checkpoint; nextdata = sp->lzw_nextdata; nextbits = sp->lzw_nextbits; free_ent = sp->lzw_free_ent; maxcode = sp->lzw_maxcode; nbits = sp->lzw_nbits; op = tif->tif_rawcp; limit = sp->enc_rawlimit; ent = sp->enc_oldcode; if (ent == -1 && cc > 0) { /* * NB: This is safe because it can only happen * at the start of a strip where we know there * is space in the data buffer. */ PutNextCode(op, CODE_CLEAR); ent = *bp++; cc--; incount++; } while (cc > 0) { c = *bp++; cc--; incount++; fcode = ((long)c << BITS_MAX) + ent; h = (c << HSHIFT) ^ ent; /* xor hashing */ hp = &sp->enc_hashtab[h]; if (hp->hash == fcode) { ent = hp->code; continue; } if (hp->hash >= 0) { /* * Primary hash failed, check secondary hash. */ disp = HSIZE - h; if (h == 0) disp = 1; do { if ((hp -= disp) < sp->enc_hashtab) hp += HSIZE; if (hp->hash == fcode) { ent = hp->code; goto hit; } } while (hp->hash >= 0); } /* * New entry, emit code and add to table. */ /* * Verify there is space in the buffer for the code * and any potential Clear code that might be emitted * below. The value of limit is setup so that there * are at least 4 bytes free--room for 2 codes. */ if (op > limit) { tif->tif_rawcc = op - tif->tif_rawdata; TIFFFlushData1(tif); op = tif->tif_rawdata; } PutNextCode(op, ent); ent = c; hp->code = free_ent++; hp->hash = fcode; if (free_ent == CODE_MAX-1) { /* table is full, emit clear code and reset */ cl_hash(sp); sp->enc_ratio = 0; incount = 0; outcount = 0; free_ent = CODE_FIRST; PutNextCode(op, CODE_CLEAR); nbits = BITS_MIN; maxcode = MAXCODE(BITS_MIN); } else { /* * If the next entry is going to be too big for * the code size, then increase it, if possible. */ if (free_ent > maxcode) { nbits++; assert(nbits <= BITS_MAX); maxcode = MAXCODE(nbits); } else if (incount >= checkpoint) { long rat; /* * Check compression ratio and, if things seem * to be slipping, clear the hash table and * reset state. The compression ratio is a * 24+8-bit fractional number. */ checkpoint = incount+CHECK_GAP; CALCRATIO(sp, rat); if (rat <= sp->enc_ratio) { cl_hash(sp); sp->enc_ratio = 0; incount = 0; outcount = 0; free_ent = CODE_FIRST; PutNextCode(op, CODE_CLEAR); nbits = BITS_MIN; maxcode = MAXCODE(BITS_MIN); } else sp->enc_ratio = rat; } } hit: ; } /* * Restore global state. */ sp->enc_incount = incount; sp->enc_outcount = outcount; sp->enc_checkpoint = checkpoint; sp->enc_oldcode = ent; sp->lzw_nextdata = nextdata; sp->lzw_nextbits = nextbits; sp->lzw_free_ent = free_ent; sp->lzw_maxcode = maxcode; sp->lzw_nbits = nbits; /* XXX not needed if TIFFWriteScanline is patched properly */ tif->tif_rawcc = op - tif->tif_rawdata; tif->tif_rawcp = op; return (1); } static LZWEncodePredRow(tif, bp, cc, s) TIFF *tif; u_char *bp; int cc; u_int s; { LZWEncodeState *sp = (LZWEncodeState *)tif->tif_data; assert(sp != NULL); assert(sp->lzw_hordiff != NULL); /* XXX horizontal differencing alters user's data XXX */ (*sp->lzw_hordiff)((char *)bp, cc, sp->lzw_stride); return (LZWEncode(tif, bp, cc, s)); } static LZWEncodePredTile(tif, bp0, cc0, s) TIFF *tif; u_char *bp0; int cc0; u_int s; { LZWEncodeState *sp = (LZWEncodeState *)tif->tif_data; int cc = cc0, rowsize; u_char *bp = bp0; assert(sp != NULL); assert(sp->lzw_hordiff != NULL); rowsize = sp->lzw_rowsize; assert(rowsize > 0); while (cc > 0) { (*sp->lzw_hordiff)((char *)bp, rowsize, sp->lzw_stride); cc -= rowsize; bp += rowsize; } return (LZWEncode(tif, bp0, cc0, s)); } /* * Finish off an encoded strip by flushing the last * string and tacking on an End Of Information code. */ static LZWPostEncode(tif) TIFF *tif; { register LZWEncodeState *sp = (LZWEncodeState *)tif->tif_data; char *op = tif->tif_rawcp; long nextbits = sp->lzw_nextbits; long nextdata = sp->lzw_nextdata; long outcount = sp->enc_outcount; int nbits = sp->lzw_nbits; if (op > sp->enc_rawlimit) { tif->tif_rawcc = op - tif->tif_rawdata; TIFFFlushData1(tif); op = tif->tif_rawdata; } if (sp->enc_oldcode != -1) { PutNextCode(op, sp->enc_oldcode); sp->enc_oldcode = -1; } PutNextCode(op, CODE_EOI); if (nextbits > 0) *op++ = nextdata << (8-nextbits); tif->tif_rawcc = op - tif->tif_rawdata; return (1); } /* * Reset encoding hash table. */ static void cl_hash(sp) LZWEncodeState *sp; { register hash_t *hp = &sp->enc_hashtab[HSIZE-1]; register long i = HSIZE-8; do { i -= 8; hp[-7].hash = -1; hp[-6].hash = -1; hp[-5].hash = -1; hp[-4].hash = -1; hp[-3].hash = -1; hp[-2].hash = -1; hp[-1].hash = -1; hp[ 0].hash = -1; hp -= 8; } while (i >= 0); for (i += 8; i > 0; i--, hp--) hp->hash = -1; } static LZWCleanup(tif) TIFF *tif; { if (tif->tif_data) { free(tif->tif_data); tif->tif_data = NULL; } } /* * Copyright (c) 1985, 1986 The Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * James A. Woods, derived from original work by Spencer Thomas * and Joseph Orost. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ ivtools-1.2.11a1/src/TIFF/tif_machdep.c000066400000000000000000000110331214471147700174510ustar00rootroot00000000000000/* * Copyright (c) 1992 Sam Leffler * Copyright (c) 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library Machine Dependent Routines. */ #include "tiffioP.h" #ifdef tahoe typedef struct ieeedouble { u_long sign : 1, exp : 11, mant : 20; u_long mant2; } ieeedouble; typedef struct ieeefloat { u_long sign : 1, exp : 8, mant : 23; } ieeefloat; typedef struct { u_long sign : 1, exp : 8, mant : 23; u_long mant2; } nativedouble; typedef struct { u_long sign : 1, exp : 8, mant : 23; } nativefloat; /* * Beware, over/under-flow in conversions will * result in garbage values -- handling it would * require a subroutine call or lots more code. */ #define NATIVE2IEEEFLOAT(fp) { \ if ((fp)->native.exp) \ (fp)->ieee.exp = (fp)->native.exp - 129 + 127; /* alter bias */\ } #define IEEEFLOAT2NATIVE(fp) { \ if ((fp)->ieee.exp) \ (fp)->native.exp = (fp)->ieee.exp - 127 + 129; /* alter bias */\ } #define IEEEDOUBLE2NATIVE(dp) { \ if ((dp)->native.exp = (dp)->ieee.exp) \ (dp)->native.exp += -1023 + 129; \ (dp)->native.mant = ((dp)->ieee.mant<<3)|((dp)->native.mant2>>29); \ (dp)->native.mant2 <<= 3; \ } #endif /* tahoe */ #ifdef vax typedef struct ieeedouble { u_long mant : 20, exp : 11, sign : 1; u_long mant2; } ieeedouble; typedef struct ieeefloat { u_long mant : 23, exp : 8, sign : 1; } ieeefloat; typedef struct { u_long mant1 : 7, exp : 8, sign : 1, mant2 : 16; u_long mant3; } nativedouble; typedef struct { u_long mant1 : 7, exp : 8, sign : 1, mant2 : 16; } nativefloat; /* * Beware, these do not handle over/under-flow * during conversion from ieee to native format. */ #define NATIVE2IEEEFLOAT(fp) { \ float_t t; \ if (t.ieee.exp = (fp)->native.exp) \ t.ieee.exp += -129 + 127; \ t.ieee.sign = (fp)->native.sign; \ t.ieee.mant = ((fp)->native.mant1<<16)|(fp)->native.mant2; \ *(fp) = t; \ } #define IEEEFLOAT2NATIVE(fp) { \ float_t t; int v = (fp)->ieee.exp; \ if (v) v += -127 + 129; /* alter bias of exponent */\ t.native.exp = v; /* implicit truncation of exponent */\ t.native.sign = (fp)->ieee.sign; \ v = (fp)->ieee.mant; \ t.native.mant1 = v >> 16; \ t.native.mant2 = v;\ *(fp) = t; \ } #define IEEEDOUBLE2NATIVE(dp) { \ double_t t; int v = (dp)->ieee.exp; \ if (v) v += -1023 + 129; /* if can alter bias of exponent */\ t.native.exp = v; /* implicit truncation of exponent */\ v = (dp)->ieee.mant; \ t.native.sign = (dp)->ieee.sign; \ t.native.mant1 = v >> 16; \ t.native.mant2 = v;\ t.native.mant3 = (dp)->mant2; \ *(dp) = t; \ } #endif /* vax */ #if !HAVE_IEEEFP #if !defined(IEEEFLOAT2NATIVE) || !defined(NATIVE2IEEEFLOAT) /* "Help, you've configured the library to not have IEEE floating point,\ but not defined how to convert between IEEE and native formats!" */ #endif /* * These unions are used during floating point * conversions. The above macros define the * conversion operations. */ typedef union { ieeedouble ieee; nativedouble native; char b[8]; double d; } double_t; typedef union { ieeefloat ieee; nativefloat native; char b[4]; float f; } float_t; TIFFCvtIEEEFloatToNative(tif, n, f) TIFF *tif; u_int n; float *f; { float_t *fp = (float_t *)f; while (n-- > 0) { IEEEFLOAT2NATIVE(fp); fp++; } } TIFFCvtNativeToIEEEFloat(tif, n, f) TIFF *tif; u_int n; float *f; { float_t *fp = (float_t *)f; while (n-- > 0) { NATIVE2IEEEFLOAT(fp); fp++; } } #endif ivtools-1.2.11a1/src/TIFF/tif_next.c000066400000000000000000000071101214471147700170270ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * NeXT 2-bit Grey Scale Compression Algorithm Support */ #include "tiffioP.h" #if USE_PROTOTYPES static int NeXTDecode(TIFF *, u_char *, int, u_int); #else static int NeXTDecode(); #endif TIFFInitNeXT(tif) TIFF *tif; { tif->tif_decoderow = NeXTDecode; tif->tif_decodestrip = NeXTDecode; tif->tif_decodetile = NeXTDecode; return (1); } #define SETPIXEL(op, v) { \ switch (npixels++ & 3) { \ case 0: op[0] = (v) << 6; break; \ case 1: op[0] |= (v) << 4; break; \ case 2: op[0] |= (v) << 2; break; \ case 3: *op++ |= (v); break; \ } \ } #define LITERALROW 0x00 #define LITERALSPAN 0x40 #define WHITE ((1<<2)-1) static int NeXTDecode(tif, buf, occ, s) TIFF *tif; u_char *buf; int occ; u_int s; { register u_char *bp, *op; register int cc, n; u_char *row; int scanline; /* * Each scanline is assumed to start off as all * white (we assume a PhotometricInterpretation * of ``min-is-black''). */ for (op = buf, cc = occ; cc-- > 0;) *op++ = 0xff; bp = (u_char *)tif->tif_rawcp; cc = tif->tif_rawcc; scanline = tif->tif_scanlinesize; for (row = buf; occ > 0; occ -= scanline, row += scanline) { n = *bp++, cc--; switch (n) { case LITERALROW: /* * The entire scanline is given as literal values. */ if (cc < scanline) goto bad; bcopy(bp, row, scanline); bp += scanline; cc -= scanline; break; case LITERALSPAN: { int off; /* * The scanline has a literal span * that begins at some offset. */ off = (bp[0] * 256) + bp[1]; n = (bp[2] * 256) + bp[3]; if (cc < 4+n) goto bad; bcopy(bp+4, row+off, n); bp += 4+n; cc -= 4+n; break; } default: { register int npixels = 0, grey; int imagewidth = tif->tif_dir.td_imagewidth; /* * The scanline is composed of a sequence * of constant color ``runs''. We shift * into ``run mode'' and interpret bytes * as codes of the form * until we've filled the scanline. */ op = row; for (;;) { grey = (n>>6) & 0x3; n &= 0x3f; while (n-- > 0) SETPIXEL(op, grey); if (npixels >= imagewidth) break; if (cc == 0) goto bad; n = *bp++, cc--; } break; } } } tif->tif_rawcp = (char *)bp; tif->tif_rawcc = cc; return (1); bad: TIFFError(tif->tif_name, "NeXTDecode: Not enough data for scanline %d", tif->tif_row); return (0); } ivtools-1.2.11a1/src/TIFF/tif_open.c000066400000000000000000000207261214471147700170220ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. */ #include "tiffioP.h" #include "prototypes.h" #if USE_PROTOTYPES extern int TIFFDefaultDirectory(TIFF*); #else extern int TIFFDefaultDirectory(); #endif static const long typemask[13] = { 0, /* TIFF_NOTYPE */ 0x000000ff, /* TIFF_BYTE */ 0xffffffff, /* TIFF_ASCII */ 0x0000ffff, /* TIFF_SHORT */ 0xffffffff, /* TIFF_LONG */ 0xffffffff, /* TIFF_RATIONAL */ 0x000000ff, /* TIFF_SBYTE */ 0x000000ff, /* TIFF_UNDEFINED */ 0x0000ffff, /* TIFF_SSHORT */ 0xffffffff, /* TIFF_SLONG */ 0xffffffff, /* TIFF_SRATIONAL */ 0xffffffff, /* TIFF_FLOAT */ 0xffffffff, /* TIFF_DOUBLE */ }; static const int bigTypeshift[13] = { 0, /* TIFF_NOTYPE */ 24, /* TIFF_BYTE */ 0, /* TIFF_ASCII */ 16, /* TIFF_SHORT */ 0, /* TIFF_LONG */ 0, /* TIFF_RATIONAL */ 16, /* TIFF_SBYTE */ 16, /* TIFF_UNDEFINED */ 24, /* TIFF_SSHORT */ 0, /* TIFF_SLONG */ 0, /* TIFF_SRATIONAL */ 0, /* TIFF_FLOAT */ 0, /* TIFF_DOUBLE */ }; static const int litTypeshift[13] = { 0, /* TIFF_NOTYPE */ 0, /* TIFF_BYTE */ 0, /* TIFF_ASCII */ 0, /* TIFF_SHORT */ 0, /* TIFF_LONG */ 0, /* TIFF_RATIONAL */ 0, /* TIFF_SBYTE */ 0, /* TIFF_UNDEFINED */ 0, /* TIFF_SSHORT */ 0, /* TIFF_SLONG */ 0, /* TIFF_SRATIONAL */ 0, /* TIFF_FLOAT */ 0, /* TIFF_DOUBLE */ }; /* * Initialize the bit fill order, the * shift & mask tables, and the byte * swapping state according to the file * contents and the machine architecture. */ static DECLARE3(TIFFInitOrder, register TIFF*, tif, int, magic, int, bigendian) { /* XXX how can we deduce this dynamically? */ tif->tif_fillorder = FILLORDER_MSB2LSB; tif->tif_typemask = typemask; if (magic == TIFF_BIGENDIAN) { tif->tif_typeshift = bigTypeshift; if (!bigendian) tif->tif_flags |= TIFF_SWAB; } else { tif->tif_typeshift = litTypeshift; if (bigendian) tif->tif_flags |= TIFF_SWAB; } } static int DECLARE2(getMode, char*, mode, char*, module) { int m = -1; switch (mode[0]) { case 'r': m = O_RDONLY; if (mode[1] == '+') m = O_RDWR; break; case 'w': case 'a': m = O_RDWR|O_CREAT; if (mode[0] == 'w') m |= O_TRUNC; break; default: TIFFError(module, "\"%s\": Bad mode", mode); break; } return (m); } /* * Open a TIFF file for read/writing. */ TIFF * TIFFOpen(name, mode) char *name, *mode; { static char module[] = "TIFFOpen"; int m, fd; m = getMode(mode, module); if (m == -1) return ((TIFF *)0); fd = TIFFOpenFile(name, m, 0666); if (fd < 0) { TIFFError(module, "%s: Cannot open", name); return ((TIFF *)0); } return (TIFFFdOpen(fd, name, mode)); } /* * Open a TIFF file descriptor for read/writing. */ TIFF * TIFFFdOpen(fd, name, mode) int fd; char *name, *mode; { static char module[] = "TIFFFdOpen"; TIFF *tif; int m, bigendian; m = getMode(mode, module); if (m == -1) goto bad2; tif = (TIFF *)malloc(sizeof (TIFF) + strlen(name) + 1); if (tif == NULL) { TIFFError(module, "%s: Out of memory (TIFF structure)", name); goto bad2; } bzero((char *)tif, sizeof (*tif)); tif->tif_name = (char *)tif + sizeof (TIFF); strcpy(tif->tif_name, name); tif->tif_fd = fd; tif->tif_mode = m &~ (O_CREAT|O_TRUNC); tif->tif_curdir = -1; /* non-existent directory */ tif->tif_curoff = 0; tif->tif_curstrip = -1; /* invalid strip */ tif->tif_row = -1; /* read/write pre-increment */ { int one = 1; bigendian = (*(char *)&one == 0); } /* * Read in TIFF header. */ if (!ReadOK(fd, &tif->tif_header, sizeof (TIFFHeader))) { if (tif->tif_mode == O_RDONLY) { TIFFError(name, "Cannot read TIFF header"); goto bad; } /* * Setup header and write. */ tif->tif_header.tiff_magic = bigendian ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN; tif->tif_header.tiff_version = TIFF_VERSION; tif->tif_header.tiff_diroff = 0; /* filled in later */ if (!WriteOK(fd, &tif->tif_header, sizeof (TIFFHeader))) { TIFFError(name, "Error writing TIFF header"); goto bad; } /* * Setup the byte order handling. */ TIFFInitOrder(tif, tif->tif_header.tiff_magic, bigendian); /* * Setup default directory. */ if (!TIFFDefaultDirectory(tif)) goto bad; tif->tif_diroff = 0; return (tif); } /* * Setup the byte order handling. */ if (tif->tif_header.tiff_magic != TIFF_BIGENDIAN && tif->tif_header.tiff_magic != TIFF_LITTLEENDIAN) { TIFFError(name, "Not a TIFF file, bad magic number %d (0x%x)", tif->tif_header.tiff_magic, tif->tif_header.tiff_magic); goto bad; } TIFFInitOrder(tif, tif->tif_header.tiff_magic, bigendian); /* * Swap header if required. */ if (tif->tif_flags & TIFF_SWAB) { TIFFSwabShort(&tif->tif_header.tiff_version); TIFFSwabLong(&tif->tif_header.tiff_diroff); } /* * Now check version (if needed, it's been byte-swapped). * Note that this isn't actually a version number, it's a * magic number that doesn't change (stupid). */ if (tif->tif_header.tiff_version != TIFF_VERSION) { TIFFError(name, "Not a TIFF file, bad version number %d (0x%x)", tif->tif_header.tiff_version, tif->tif_header.tiff_version); goto bad; } tif->tif_flags |= TIFF_MYBUFFER; tif->tif_rawcp = tif->tif_rawdata = 0; tif->tif_rawdatasize = 0; /* * Setup initial directory. */ switch (mode[0]) { case 'r': tif->tif_nextdiroff = tif->tif_header.tiff_diroff; #ifdef MMAP_SUPPORT if (TIFFMapFileContents(fd, &tif->tif_base, &tif->tif_size)) tif->tif_flags |= TIFF_MAPPED; #endif if (TIFFReadDirectory(tif)) { tif->tif_rawcc = -1; tif->tif_flags |= TIFF_BUFFERSETUP; return (tif); } break; case 'a': /* * Don't append to file that has information * byte swapped -- we will write data that is * in the opposite order. */ if (tif->tif_flags & TIFF_SWAB) { TIFFError(name, "Cannot append to file that has opposite byte ordering"); goto bad; } /* * New directories are automatically append * to the end of the directory chain when they * are written out (see TIFFWriteDirectory). */ if (!TIFFDefaultDirectory(tif)) goto bad; return (tif); } bad: tif->tif_mode = O_RDONLY; /* XXX avoid flush */ TIFFClose(tif); return ((TIFF *)0); bad2: (void) close(fd); return ((TIFF *)0); } TIFFScanlineSize(tif) TIFF *tif; { TIFFDirectory *td = &tif->tif_dir; long scanline; scanline = td->td_bitspersample * td->td_imagewidth; if (td->td_planarconfig == PLANARCONFIG_CONTIG) scanline *= td->td_samplesperpixel; return (howmany(scanline, 8)); } /* * Query functions to access private data. */ /* * Return open file's name. */ char * TIFFFileName(tif) TIFF *tif; { return (tif->tif_name); } /* * Return open file's I/O descriptor. */ int TIFFFileno(tif) TIFF *tif; { return (tif->tif_fd); } /* * Return read/write mode. */ int TIFFGetMode(tif) TIFF *tif; { return (tif->tif_mode); } /* * Return nonzero if file is organized in * tiles; zero if organized as strips. */ int TIFFIsTiled(tif) TIFF *tif; { return (isTiled(tif)); } /* * Return current row being read/written. */ long TIFFCurrentRow(tif) TIFF *tif; { return (tif->tif_row); } /* * Return index of the current directory. */ int TIFFCurrentDirectory(tif) TIFF *tif; { return (tif->tif_curdir); } /* * Return current strip. */ int TIFFCurrentStrip(tif) TIFF *tif; { return (tif->tif_curstrip); } /* * Return current tile. */ int TIFFCurrentTile(tif) TIFF *tif; { return (tif->tif_curtile); } ivtools-1.2.11a1/src/TIFF/tif_packbits.c000066400000000000000000000144671214471147700176660ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * PackBits Compression Algorithm Support */ #include "tiffioP.h" #include #include #if USE_PROTOTYPES static int PackBitsPreEncode(TIFF *); static int PackBitsEncode(TIFF *, u_char *, int, u_int); static int PackBitsEncodeChunk(TIFF *, u_char *, int, u_int); static int PackBitsDecode(TIFF *, u_char *, int, u_int); #else static int PackBitsPreEncode(); static int PackBitsEncode(), PackBitsEncodeChunk(); static int PackBitsDecode(); #endif TIFFInitPackBits(tif) TIFF *tif; { tif->tif_decoderow = PackBitsDecode; tif->tif_decodestrip = PackBitsDecode; tif->tif_decodetile = PackBitsDecode; tif->tif_preencode = PackBitsPreEncode; tif->tif_encoderow = PackBitsEncode; tif->tif_encodestrip = PackBitsEncodeChunk; tif->tif_encodetile = PackBitsEncodeChunk; return (1); } static int PackBitsPreEncode(tif) TIFF *tif; { /* * Calculate the scanline/tile-width size in bytes. */ if (isTiled(tif)) tif->tif_data = (char *) TIFFTileRowSize(tif); else tif->tif_data = (char *) (unsigned long) TIFFScanlineSize(tif); return (1); } /* * Encode a rectangular chunk of pixels. We break it up * into row-sized pieces to insure that encoded runs do * not span rows. Otherwise, there can be problems with * the decoder if data is read, for example, by scanlines * when it was encoded by strips. */ static int PackBitsEncodeChunk(tif, bp, cc, s) TIFF *tif; u_char *bp; int cc; u_int s; { int rowsize = (int) (long) tif->tif_data; assert(rowsize > 0); while (cc > 0) { if (PackBitsEncode(tif, bp, rowsize, s) < 0) return (-1); bp += rowsize; cc -= rowsize; } return (1); } /* * Encode a run of pixels. */ static int PackBitsEncode(tif, bp, cc, s) TIFF *tif; u_char *bp; register int cc; u_int s; { register char *op, *lastliteral; register int n, b; enum { BASE, LITERAL, RUN, LITERAL_RUN } state; char *ep; int slop; op = tif->tif_rawcp; ep = tif->tif_rawdata + tif->tif_rawdatasize; state = BASE; lastliteral = 0; while (cc > 0) { /* * Find the longest string of identical bytes. */ b = *bp++, cc--, n = 1; for (; cc > 0 && b == *bp; cc--, bp++) n++; again: if (op + 2 >= ep) { /* insure space for new data */ /* * Be careful about writing the last * literal. Must write up to that point * and then copy the remainder to the * front of the buffer. */ if (state == LITERAL || state == LITERAL_RUN) { slop = op - lastliteral; tif->tif_rawcc += lastliteral - tif->tif_rawcp; if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; for (; slop-- > 0; *op++ = *lastliteral++) ; lastliteral = tif->tif_rawcp; } else { tif->tif_rawcc += op - tif->tif_rawcp; if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; } } switch (state) { case BASE: /* initial state, set run/literal */ if (n > 1) { state = RUN; if (n > 128) { *op++ = -127; *op++ = b; n -= 128; goto again; } *op++ = -(n-1); *op++ = b; } else { lastliteral = op; *op++ = 0; *op++ = b; state = LITERAL; } break; case LITERAL: /* last object was literal string */ if (n > 1) { state = LITERAL_RUN; if (n > 128) { *op++ = -127; *op++ = b; n -= 128; goto again; } *op++ = -(n-1); /* encode run */ *op++ = b; } else { /* extend literal */ if (++(*lastliteral) == 127) state = BASE; *op++ = b; } break; case RUN: /* last object was run */ if (n > 1) { if (n > 128) { *op++ = -127; *op++ = b; n -= 128; goto again; } *op++ = -(n-1); *op++ = b; } else { lastliteral = op; *op++ = 0; *op++ = b; state = LITERAL; } break; case LITERAL_RUN: /* literal followed by a run */ /* * Check to see if previous run should * be converted to a literal, in which * case we convert literal-run-literal * to a single literal. */ if (n == 1 && op[-2] == (char)-1 && *lastliteral < 126) { state = (((*lastliteral) += 2) == 127 ? BASE : LITERAL); op[-2] = op[-1]; /* replicate */ } else state = RUN; goto again; } } tif->tif_rawcc += op - tif->tif_rawcp; tif->tif_rawcp = op; return (1); } static int PackBitsDecode(tif, op, occ, s) TIFF *tif; register u_char *op; register int occ; u_int s; { register char *bp; register int n, b; register int cc; bp = tif->tif_rawcp; cc = tif->tif_rawcc; while (cc > 0 && occ > 0) { n = (int) *bp++; /* * Watch out for compilers that * don't sign extend chars... */ if (n >= 128) n -= 256; if (n < 0) { /* replicate next byte -n+1 times */ cc--; if (n == -128) /* nop */ continue; n = -n + 1; occ -= n; for (b = *bp++; n-- > 0;) *op++ = b; } else { /* copy next n+1 bytes literally */ bcopy(bp, op, ++n); op += n; occ -= n; bp += n; cc -= n; } } tif->tif_rawcp = bp; tif->tif_rawcc = cc; if (occ > 0) { TIFFError(tif->tif_name, "PackBitsDecode: Not enough data for scanline %d", tif->tif_row); return (0); } /* check for buffer overruns? */ return (1); } ivtools-1.2.11a1/src/TIFF/tif_print.c000066400000000000000000000411731214471147700172140ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * Directory Printing Support */ #include #include #include "tiffioP.h" #ifdef JPEG_SUPPORT static JPEGPrintQTable(fd, tab) FILE *fd; u_char tab[64]; { int i, j; char *sep; fputc('\n', fd); for (i = 0; i < 8; i++) { sep = " "; for (j = 0; j < 8; j++) { fprintf(fd, "%s%2u", sep, tab[8*i+j]); sep = ", "; } fputc('\n', fd); } } static JPEGPrintCTable(fd, tab) FILE *fd; u_char *tab; { int i, n, count; char *sep; fprintf(fd, "\n Bits:"); count = 0; for (i = 0; i < 16; i++) { fprintf(fd, " %u", tab[i]); count += tab[i]; } n = 0; for (; count > 0; count--) { if ((n % 8) == 0) { fputc('\n', fd); sep = " "; } fprintf(fd, "%s0x%02x", sep, tab[i++]); sep = ", "; n++; } if (n % 8) fputc('\n', fd); } #endif static const char *photoNames[] = { "min-is-white", /* PHOTOMETRIC_MINISWHITE */ "min-is-black", /* PHOTOMETRIC_MINISBLACK */ "RGB color", /* PHOTOMETRIC_RGB */ "palette color (RGB from colormap)", /* PHOTOMETRIC_PALETTE */ "transparency mask", /* PHOTOMETRIC_MASK */ "separated", /* PHOTOMETRIC_SEPARATED */ "YCbCr", /* PHOTOMETRIC_YCBCR */ "7 (0x7)", "CIE L*a*b*", /* PHOTOMETRIC_CIELAB */ }; #define NPHOTONAMES (sizeof (photoNames) / sizeof (photoNames[0])) static const char *orientNames[] = { "0 (0x0)", "row 0 top, col 0 lhs", /* ORIENTATION_TOPLEFT */ "row 0 top, col 0 rhs", /* ORIENTATION_TOPRIGHT */ "row 0 bottom, col 0 rhs", /* ORIENTATION_BOTRIGHT */ "row 0 bottom, col 0 lhs", /* ORIENTATION_BOTLEFT */ "row 0 lhs, col 0 top", /* ORIENTATION_LEFTTOP */ "row 0 rhs, col 0 top", /* ORIENTATION_RIGHTTOP */ "row 0 rhs, col 0 bottom", /* ORIENTATION_RIGHTBOT */ "row 0 lhs, col 0 bottom", /* ORIENTATION_LEFTBOT */ }; #define NORIENTNAMES (sizeof (orientNames) / sizeof (orientNames[0])) /* * Print the contents of the current directory * to the specified stdio file stream. */ void TIFFPrintDirectory(tif, fd, flags) TIFF *tif; FILE *fd; long flags; { register TIFFDirectory *td; char *sep; int i, j; long n; fprintf(fd, "TIFF Directory at offset 0x%x\n", tif->tif_diroff); td = &tif->tif_dir; if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) { fprintf(fd, " Subfile Type:"); sep = " "; if (td->td_subfiletype & FILETYPE_REDUCEDIMAGE) { fprintf(fd, "%sreduced-resolution image", sep); sep = "/"; } if (td->td_subfiletype & FILETYPE_PAGE) { fprintf(fd, "%smulti-page document", sep); sep = "/"; } if (td->td_subfiletype & FILETYPE_MASK) fprintf(fd, "%stransparency mask", sep); fprintf(fd, " (%u = 0x%x)\n", td->td_subfiletype, td->td_subfiletype); } if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) { fprintf(fd, " Image Width: %lu Image Length: %lu", td->td_imagewidth, td->td_imagelength); if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH)) fprintf(fd, " Image Depth: %lu", td->td_imagedepth); fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) { fprintf(fd, " Tile Width: %lu Tile Length: %lu", td->td_tilewidth, td->td_tilelength); if (TIFFFieldSet(tif,FIELD_TILEDEPTH)) fprintf(fd, " Tile Depth: %lu", td->td_tiledepth); fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_RESOLUTION)) { fprintf(fd, " Resolution: %g, %g", td->td_xresolution, td->td_yresolution); if (TIFFFieldSet(tif,FIELD_RESOLUTIONUNIT)) { switch (td->td_resolutionunit) { case RESUNIT_NONE: fprintf(fd, " (unitless)"); break; case RESUNIT_INCH: fprintf(fd, " pixels/inch"); break; case RESUNIT_CENTIMETER: fprintf(fd, " pixels/cm"); break; default: fprintf(fd, " (unit %u = 0x%x)", td->td_resolutionunit, td->td_resolutionunit); break; } } fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_POSITION)) fprintf(fd, " Position: %g, %g\n", td->td_xposition, td->td_yposition); if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) fprintf(fd, " Bits/Sample: %u\n", td->td_bitspersample); if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) { fprintf(fd, " Sample Format: "); switch (td->td_sampleformat) { case SAMPLEFORMAT_VOID: fprintf(fd, "void\n"); break; case SAMPLEFORMAT_INT: fprintf(fd, "signed integer\n"); break; case SAMPLEFORMAT_UINT: fprintf(fd, "unsigned integer\n"); break; case SAMPLEFORMAT_IEEEFP: fprintf(fd, "IEEE floating point\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_sampleformat, td->td_sampleformat); break; } } if (TIFFFieldSet(tif,FIELD_COMPRESSION)) { fprintf(fd, " Compression Scheme: "); switch (td->td_compression) { case COMPRESSION_NONE: fprintf(fd, "none\n"); break; case COMPRESSION_CCITTRLE: fprintf(fd, "CCITT modified Huffman encoding\n"); break; case COMPRESSION_CCITTFAX3: fprintf(fd, "CCITT Group 3 facsimile encoding\n"); break; case COMPRESSION_CCITTFAX4: fprintf(fd, "CCITT Group 4 facsimile encoding\n"); break; case COMPRESSION_CCITTRLEW: fprintf(fd, "CCITT modified Huffman encoding %s\n", "w/ word alignment"); break; case COMPRESSION_PACKBITS: fprintf(fd, "Macintosh PackBits encoding\n"); break; case COMPRESSION_THUNDERSCAN: fprintf(fd, "ThunderScan 4-bit encoding\n"); break; case COMPRESSION_LZW: fprintf(fd, "Lempel-Ziv & Welch encoding\n"); break; case COMPRESSION_NEXT: fprintf(fd, "NeXT 2-bit encoding\n"); break; case COMPRESSION_JPEG: fprintf(fd, "JPEG encoding\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_compression, td->td_compression); break; } } if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) { fprintf(fd, " Photometric Interpretation: "); if (td->td_photometric < NPHOTONAMES) fprintf(fd, "%s\n", photoNames[td->td_photometric]); else fprintf(fd, "%u (0x%x)\n", td->td_photometric, td->td_photometric); } if (TIFFFieldSet(tif,FIELD_MATTEING)) fprintf(fd, " Matteing: %s\n", td->td_matteing ? "pre-multiplied with alpha channel" : "none"); #ifdef CMYK_SUPPORT if (TIFFFieldSet(tif,FIELD_INKSET)) { fprintf(fd, " Ink Set: "); switch (td->td_inkset) { case INKSET_CMYK: fprintf(fd, "CMYK\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_inkset, td->td_inkset); break; } } if (TIFFFieldSet(tif,FIELD_INKNAMES)) { char *cp; fprintf(fd, " Ink Names: "); i = td->td_samplesperpixel; sep = ""; for (cp = td->td_inknames; i > 0; cp = strchr(cp, '\0')) { fprintf(fd, "%s%s", sep, cp); sep = ", "; } } if (TIFFFieldSet(tif,FIELD_DOTRANGE)) fprintf(fd, " Dot Range: %u-%u\n", td->td_dotrange[0], td->td_dotrange[1]); if (TIFFFieldSet(tif,FIELD_TARGETPRINTER)) fprintf(fd, " Target Printer: %s\n", td->td_targetprinter); #endif if (TIFFFieldSet(tif,FIELD_THRESHHOLDING)) { fprintf(fd, " Thresholding: "); switch (td->td_threshholding) { case THRESHHOLD_BILEVEL: fprintf(fd, "bilevel art scan\n"); break; case THRESHHOLD_HALFTONE: fprintf(fd, "halftone or dithered scan\n"); break; case THRESHHOLD_ERRORDIFFUSE: fprintf(fd, "error diffused\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_threshholding, td->td_threshholding); break; } } if (TIFFFieldSet(tif,FIELD_FILLORDER)) { fprintf(fd, " FillOrder: "); switch (td->td_fillorder) { case FILLORDER_MSB2LSB: fprintf(fd, "msb-to-lsb\n"); break; case FILLORDER_LSB2MSB: fprintf(fd, "lsb-to-msb\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_fillorder, td->td_fillorder); break; } } if (TIFFFieldSet(tif,FIELD_PREDICTOR)) { fprintf(fd, " Predictor: "); switch (td->td_predictor) { case 1: fprintf(fd, "none\n"); break; case 2: fprintf(fd, "horizontal differencing\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_predictor, td->td_predictor); break; } } #ifdef YCBCR_SUPPORT if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) fprintf(fd, " YCbCr Subsampling: %u, %u\n", td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1]); if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) { fprintf(fd, " YCbCr Positioning: "); switch (td->td_ycbcrpositioning) { case YCBCRPOSITION_CENTERED: fprintf(fd, "centered\n"); break; case YCBCRPOSITION_COSITED: fprintf(fd, "cosited\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_ycbcrpositioning, td->td_ycbcrpositioning); break; } } if (TIFFFieldSet(tif,FIELD_YCBCRCOEFFICIENTS)) fprintf(fd, " YCbCr Coefficients: %g, %g, %g\n", td->td_ycbcrcoeffs[0], td->td_ycbcrcoeffs[1], td->td_ycbcrcoeffs[2]); #endif #ifdef JPEG_SUPPORT if (TIFFFieldSet(tif,FIELD_JPEGPROC)) { fprintf(fd, " JPEG Processing Mode: "); switch (td->td_jpegproc) { case JPEGPROC_BASELINE: fprintf(fd, "baseline sequential algorithm\n"); break; case JPEGPROC_LOSSLESS: fprintf(fd, "lossless algorithm with Huffman coding\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_jpegproc, td->td_jpegproc); break; } } if (TIFFFieldSet(tif,FIELD_JPEGRESTARTINTERVAL)) { fprintf(fd, " JPEG Restart Interval: "); if (td->td_jpegrestartinterval) fprintf(fd, "%u\n", td->td_jpegrestartinterval); else fprintf(fd, "(no restart markers)\n"); } if (TIFFFieldSet(tif,FIELD_JPEGQTABLES)) { fprintf(fd, " JPEG Quantization Tables: "); if (flags & TIFFPRINT_JPEGQTABLES) { for (i = 0; i < td->td_samplesperpixel; i++) JPEGPrintQTable(fd, td->td_qtab[i]); } else fprintf(fd, "(present)\n"); } if (TIFFFieldSet(tif,FIELD_JPEGDCTABLES)) { fprintf(fd, " JPEG DC Tables: "); if (flags & TIFFPRINT_JPEGDCTABLES) { for (i = 0; i < td->td_samplesperpixel; i++) JPEGPrintCTable(fd, td->td_dctab[i]); } else fprintf(fd, "(present)\n"); } if (TIFFFieldSet(tif,FIELD_JPEGACTABLES)) { fprintf(fd, " JPEG AC Tables: "); if (flags & TIFFPRINT_JPEGACTABLES) { for (i = 0; i < td->td_samplesperpixel; i++) JPEGPrintCTable(fd, td->td_actab[i]); } else fprintf(fd, "(present)\n"); } #endif if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS)) fprintf(fd, " Halftone Hints: light %u dark %u\n", td->td_halftonehints[0], td->td_halftonehints[1]); if (TIFFFieldSet(tif,FIELD_ARTIST)) fprintf(fd, " Artist: \"%s\"\n", td->td_artist); if (TIFFFieldSet(tif,FIELD_DATETIME)) fprintf(fd, " Date & Time: \"%s\"\n", td->td_datetime); if (TIFFFieldSet(tif,FIELD_HOSTCOMPUTER)) fprintf(fd, " Host Computer: \"%s\"\n", td->td_hostcomputer); if (TIFFFieldSet(tif,FIELD_SOFTWARE)) fprintf(fd, " Software: \"%s\"\n", td->td_software); if (TIFFFieldSet(tif,FIELD_DOCUMENTNAME)) fprintf(fd, " Document Name: \"%s\"\n", td->td_documentname); if (TIFFFieldSet(tif,FIELD_IMAGEDESCRIPTION)) fprintf(fd, " Image Description: \"%s\"\n", td->td_imagedescription); if (TIFFFieldSet(tif,FIELD_MAKE)) fprintf(fd, " Make: \"%s\"\n", td->td_make); if (TIFFFieldSet(tif,FIELD_MODEL)) fprintf(fd, " Model: \"%s\"\n", td->td_model); if (TIFFFieldSet(tif,FIELD_ORIENTATION)) { fprintf(fd, " Orientation: "); if (td->td_orientation < NORIENTNAMES) fprintf(fd, "%s\n", orientNames[td->td_orientation]); else fprintf(fd, "%u (0x%x)\n", td->td_orientation, td->td_orientation); } if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) fprintf(fd, " Samples/Pixel: %u\n", td->td_samplesperpixel); if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) { fprintf(fd, " Rows/Strip: "); if (td->td_rowsperstrip == 0xffffffffL) fprintf(fd, "(infinite)\n"); else fprintf(fd, "%u\n", td->td_rowsperstrip); } if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE)) fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue); if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue); if (TIFFFieldSet(tif,FIELD_PLANARCONFIG)) { fprintf(fd, " Planar Configuration: "); switch (td->td_planarconfig) { case PLANARCONFIG_CONTIG: fprintf(fd, "single image plane\n"); break; case PLANARCONFIG_SEPARATE: fprintf(fd, "separate image planes\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_planarconfig, td->td_planarconfig); break; } } if (TIFFFieldSet(tif,FIELD_PAGENAME)) fprintf(fd, " Page Name: \"%s\"\n", td->td_pagename); if (TIFFFieldSet(tif,FIELD_GROUP3OPTIONS)) { fprintf(fd, " Group 3 Options:"); sep = " "; if (td->td_group3options & GROUP3OPT_2DENCODING) fprintf(fd, "%s2-d encoding", sep), sep = "+"; if (td->td_group3options & GROUP3OPT_FILLBITS) fprintf(fd, "%sEOL padding", sep), sep = "+"; if (td->td_group3options & GROUP3OPT_UNCOMPRESSED) fprintf(fd, "%suncompressed data", sep); fprintf(fd, " (%u = 0x%x)\n", td->td_group3options, td->td_group3options); } if (TIFFFieldSet(tif,FIELD_CLEANFAXDATA)) { fprintf(fd, " Fax Data: "); switch (td->td_cleanfaxdata) { case CLEANFAXDATA_CLEAN: fprintf(fd, "clean\n"); break; case CLEANFAXDATA_REGENERATED: fprintf(fd, "receiver regenerated\n"); break; case CLEANFAXDATA_UNCLEAN: fprintf(fd, "uncorrected errors\n"); break; default: fprintf(fd, "(%u = 0x%x)\n", td->td_cleanfaxdata, td->td_cleanfaxdata); break; } } if (TIFFFieldSet(tif,FIELD_BADFAXLINES)) fprintf(fd, " Bad Fax Lines: %u\n", td->td_badfaxlines); if (TIFFFieldSet(tif,FIELD_BADFAXRUN)) fprintf(fd, " Consecutive Bad Fax Lines: %u\n", td->td_badfaxrun); if (TIFFFieldSet(tif,FIELD_GROUP4OPTIONS)) { fprintf(fd, " Group 4 Options:"); if (td->td_group4options & GROUP4OPT_UNCOMPRESSED) fprintf(fd, "uncompressed data"); fprintf(fd, " (%u = 0x%x)\n", td->td_group4options, td->td_group4options); } if (TIFFFieldSet(tif,FIELD_PAGENUMBER)) fprintf(fd, " Page Number: %u-%u\n", td->td_pagenumber[0], td->td_pagenumber[1]); if (TIFFFieldSet(tif,FIELD_COLORMAP)) { fprintf(fd, " Color Map: "); if (flags & TIFFPRINT_COLORMAP) { fprintf(fd, "\n"); n = 1L<td_bitspersample; for (i = 0; i < n; i++) fprintf(fd, " %5d: %5u %5u %5u\n", i, td->td_colormap[0][i], td->td_colormap[1][i], td->td_colormap[2][i]); } else fprintf(fd, "(present)\n"); } #ifdef COLORIMETRY_SUPPORT if (TIFFFieldSet(tif,FIELD_WHITEPOINT)) fprintf(fd, " White Point: %g-%g\n", td->td_whitepoint[0], td->td_whitepoint[1]); if (TIFFFieldSet(tif,FIELD_PRIMARYCHROMAS)) fprintf(fd, " Primary Chromaticities: %g,%g %g,%g %g,%g\n", td->td_primarychromas[0], td->td_primarychromas[1], td->td_primarychromas[2], td->td_primarychromas[3], td->td_primarychromas[4], td->td_primarychromas[5]); if (TIFFFieldSet(tif,FIELD_REFBLACKWHITE)) { fprintf(fd, " Reference Black/White:\n"); for (i = 0; i < td->td_samplesperpixel; i++) fprintf(fd, " %2d: %5g %5g\n", i, td->td_refblackwhite[2*i+0], td->td_refblackwhite[2*i+1]); } if (TIFFFieldSet(tif,FIELD_TRANSFERFUNCTION)) { fprintf(fd, " Transfer Function: "); if (flags & TIFFPRINT_CURVES) { fprintf(fd, "\n"); n = 1L<td_bitspersample; for (i = 0; i < n; i++) { fprintf(fd, " %2d: %5u", i, td->td_transferfunction[0][i]); for (j = 1; j < td->td_samplesperpixel; j++) fprintf(fd, " %5u", td->td_transferfunction[j][i]); putc('\n', fd); } } else fprintf(fd, "(present)\n"); } #endif if ((flags & TIFFPRINT_STRIPS) && TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) { fprintf(fd, " %u %s:\n", td->td_nstrips, isTiled(tif) ? "Tiles" : "Strips"); for (i = 0; i < td->td_nstrips; i++) fprintf(fd, " %3d: [%8u, %8u]\n", i, td->td_stripoffset[i], td->td_stripbytecount[i]); } } ivtools-1.2.11a1/src/TIFF/tif_read.c000066400000000000000000000367571214471147700170070ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * Scanline-oriented Read Support */ #include "tiffioP.h" #if USE_PROTOTYPES static TIFFSeek(TIFF *, u_int, u_int); static int TIFFReadRawStrip1(TIFF *, u_int, u_char *, u_int, char []); static int TIFFReadRawTile1(TIFF *, u_int, u_char *, u_int, char []); static TIFFFillStrip(TIFF *, u_int); static TIFFFillTile(TIFF *, u_int); static TIFFStartStrip(TIFF *, u_int); static TIFFStartTile(TIFF *, u_int); static TIFFCheckRead(TIFF *, int); #else static TIFFSeek(); static int TIFFReadRawStrip1(); static int TIFFReadRawTile1(); static TIFFFillStrip(); static TIFFFillTile(); static TIFFStartStrip(); static TIFFStartTile(); static TIFFCheckRead(); #endif /*VARARGS3*/ TIFFReadScanline(tif, buf, row, sample) register TIFF *tif; u_char *buf; u_int row, sample; { int e; if (!TIFFCheckRead(tif, 0)) return (-1); if (e = TIFFSeek(tif, row, sample)) { /* * Decompress desired row into user buffer. */ e = (*tif->tif_decoderow)(tif, buf, tif->tif_scanlinesize, sample); tif->tif_row++; } return (e ? 1 : -1); } /* * Seek to a random row+sample in a file. */ static /*VARARGS2*/ TIFFSeek(tif, row, sample) register TIFF *tif; u_int row, sample; { register TIFFDirectory *td = &tif->tif_dir; int strip; if (row >= td->td_imagelength) { /* out of range */ TIFFError(tif->tif_name, "%d: Row out of range, max %d", row, td->td_imagelength); return (0); } if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { if (sample >= td->td_samplesperpixel) { TIFFError(tif->tif_name, "%d: Sample out of range, max %d", sample, td->td_samplesperpixel); return (0); } strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; } else strip = row / td->td_rowsperstrip; if (strip != tif->tif_curstrip) { /* different strip, refill */ if (!TIFFFillStrip(tif, strip)) return (0); } else if (row < tif->tif_row) { /* * Moving backwards within the same strip: backup * to the start and then decode forward (below). * * NB: If you're planning on lots of random access within a * strip, it's better to just read and decode the entire * strip, and then access the decoded data in a random fashion. */ if (!TIFFStartStrip(tif, strip)) return (0); } if (row != tif->tif_row) { if (tif->tif_seek) { /* * Seek forward to the desired row. */ if (!(*tif->tif_seek)(tif, row - tif->tif_row)) return (0); tif->tif_row = row; } else { TIFFError(tif->tif_name, "Compression algorithm does not support random access"); return (0); } } return (1); } /* * Read a strip of data and decompress the specified * amount into the user-supplied buffer. */ TIFFReadEncodedStrip(tif, strip, buf, size) TIFF *tif; u_int strip; u_char *buf; u_int size; { TIFFDirectory *td = &tif->tif_dir; u_int stripsize = TIFFStripSize(tif); if (!TIFFCheckRead(tif, 0)) return (-1); if (strip >= td->td_nstrips) { TIFFError(tif->tif_name, "%d: Strip out of range, max %d", strip, td->td_nstrips); return (-1); } /* * Calculate the strip size according to the number of * rows in the strip (check for truncated last strip). */ if (size == (u_int)-1) size = stripsize; else if (size > stripsize) size = stripsize; return (TIFFFillStrip(tif, strip) && (*tif->tif_decodestrip)(tif, buf, size, strip / td->td_stripsperimage) ? size : -1); } /* * Read a strip of data from the file. */ TIFFReadRawStrip(tif, strip, buf, size) TIFF *tif; u_int strip; u_char *buf; u_int size; { static char module[] = "TIFFReadRawStrip"; TIFFDirectory *td = &tif->tif_dir; u_long bytecount; if (!TIFFCheckRead(tif, 0)) return (-1); if (strip >= td->td_nstrips) { TIFFError(tif->tif_name, "%d: Strip out of range, max %d", strip, td->td_nstrips); return (-1); } bytecount = td->td_stripbytecount[strip]; if (size != (u_int)-1 && size < bytecount) bytecount = size; return (TIFFReadRawStrip1(tif, strip, buf, bytecount, module)); } static int TIFFReadRawStrip1(tif, strip, buf, size, module) TIFF *tif; u_int strip; u_char *buf; u_int size; char module[]; { TIFFDirectory *td = &tif->tif_dir; if (!isMapped(tif)) { if (!SeekOK(tif->tif_fd, td->td_stripoffset[strip])) { TIFFError(module, "%s: Seek error at scanline %d, strip %d", tif->tif_name, tif->tif_row, strip); return (-1); } if (!ReadOK(tif->tif_fd, buf, size)) { TIFFError(module, "%s: Read error at scanline %d", tif->tif_name, tif->tif_row); return (-1); } #ifdef MMAP_SUPPORT } else { if (td->td_stripoffset[strip] + size > tif->tif_size) { TIFFError(module, "%s: Seek error at scanline %d, strip %d", tif->tif_name, tif->tif_row, strip); return (-1); } bcopy(tif->tif_base + td->td_stripoffset[strip], buf, size); #endif } return (size); } /* * Read the specified strip and setup for decoding. * The data buffer is expanded, as necessary, to * hold the strip's data. */ static TIFFFillStrip(tif, strip) TIFF *tif; u_int strip; { static char module[] = "TIFFFillStrip"; TIFFDirectory *td = &tif->tif_dir; u_long bytecount; bytecount = td->td_stripbytecount[strip]; #ifdef MMAP_SUPPORT if (isMapped(tif) && (td->td_fillorder == tif->tif_fillorder || (tif->tif_flags & TIFF_NOBITREV))) { /* * The image is mapped into memory and we either don't * need to flip bits or the compression routine is going * to handle this operation itself. In this case, avoid * copying the raw data and instead just reference the * data from the memory mapped file image. This assumes * that the decompression routines do not modify the * contents of the raw data buffer (if they try to, * the application will get a fault since the file is * mapped read-only). */ if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) free(tif->tif_rawdata); tif->tif_flags &= ~TIFF_MYBUFFER; if (td->td_stripoffset[strip] + bytecount > tif->tif_size) { /* * This error message might seem strange, but it's * what would happen if a read were done instead. */ TIFFError(module, "%s: Read error on strip %d", tif->tif_name, strip); tif->tif_curstrip = -1; /* unknown state */ return (0); } tif->tif_rawdatasize = bytecount; tif->tif_rawdata = tif->tif_base + td->td_stripoffset[strip]; } else { #endif /* * Expand raw data buffer, if needed, to * hold data strip coming from file * (perhaps should set upper bound on * the size of a buffer we'll use?). */ if (bytecount > tif->tif_rawdatasize) { tif->tif_curstrip = -1; /* unknown state */ if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFError(module, "%s: Data buffer too small to hold strip %d", tif->tif_name, strip); return (0); } if (!TIFFReadBufferSetup(tif, 0, roundup(bytecount, 1024))) return (0); } if (TIFFReadRawStrip1(tif, strip, (u_char *)tif->tif_rawdata, bytecount, module) != bytecount) return (0); if (td->td_fillorder != tif->tif_fillorder && (tif->tif_flags & TIFF_NOBITREV) == 0) TIFFReverseBits((u_char *)tif->tif_rawdata, bytecount); #ifdef MMAP_SUPPORT } #endif return (TIFFStartStrip(tif, strip)); } /* * Tile-oriented Read Support * Contributed by Nancy Cam (Silicon Graphics). */ /* * Read and decompress a tile of data. The * tile is selected by the (x,y,z,s) coordinates. */ TIFFReadTile(tif, buf, x, y, z, s) TIFF *tif; u_char *buf; u_long x, y, z; u_int s; { u_int tile; if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) return (-1); tile = TIFFComputeTile(tif, x, y, z, s); if (tile >= tif->tif_dir.td_nstrips) { TIFFError(tif->tif_name, "%d: Tile out of range, max %d", tile, tif->tif_dir.td_nstrips); return (-1); } return (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif, buf, tif->tif_tilesize, s) ? tif->tif_tilesize : -1); } /* * Read a tile of data and decompress the specified * amount into the user-supplied buffer. */ TIFFReadEncodedTile(tif, tile, buf, size) TIFF *tif; u_int tile; u_char *buf; u_int size; { TIFFDirectory *td = &tif->tif_dir; int tilesize = tif->tif_tilesize; if (!TIFFCheckRead(tif, 1)) return (-1); if (tile >= td->td_nstrips) { TIFFError(tif->tif_name, "%d: Tile out of range, max %d", tile, td->td_nstrips); return (-1); } if (size == (u_int)-1) size = tilesize; else if (size > tilesize ) size = tilesize; return (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif, buf, size, tile/td->td_stripsperimage) ? size : -1); } /* * Read a tile of data from the file. */ TIFFReadRawTile(tif, tile, buf, size) TIFF *tif; u_int tile; u_char *buf; u_int size; { static char module[] = "TIFFReadRawTile"; TIFFDirectory *td = &tif->tif_dir; u_long bytecount; if (!TIFFCheckRead(tif, 1)) return (-1); if (tile >= td->td_nstrips) { TIFFError(tif->tif_name, "%d: Tile out of range, max %d", tile, td->td_nstrips); return (-1); } bytecount = td->td_stripbytecount[tile]; if (size != (u_int)-1 && size < bytecount) bytecount = size; return (TIFFReadRawTile1(tif, tile, buf, bytecount, module)); } static int TIFFReadRawTile1(tif, tile, buf, size, module) TIFF *tif; u_int tile; u_char *buf; u_int size; char module[]; { TIFFDirectory *td = &tif->tif_dir; if (!isMapped(tif)) { if (!SeekOK(tif->tif_fd, td->td_stripoffset[tile])) { TIFFError(module, "%s: Seek error at row %d, col %d, tile %d", tif->tif_name, tif->tif_row, tif->tif_col, tile); return (-1); } if (!ReadOK(tif->tif_fd, buf, size)) { TIFFError(module, "%s: Read error at row %d, col %d", tif->tif_name, tif->tif_row, tif->tif_col); return (-1); } #ifdef MMAP_SUPPORT } else { if (td->td_stripoffset[tile] + size > tif->tif_size) { TIFFError(module, "%s: Seek error at row %d, col %d, tile %d", tif->tif_name, tif->tif_row, tif->tif_col, tile); return (-1); } bcopy(tif->tif_base + td->td_stripoffset[tile], buf, size); #endif } return (size); } /* * Read the specified tile and setup for decoding. * The data buffer is expanded, as necessary, to * hold the tile's data. */ static TIFFFillTile(tif, tile) TIFF *tif; u_int tile; { static char module[] = "TIFFFillTile"; TIFFDirectory *td = &tif->tif_dir; u_long bytecount; bytecount = td->td_stripbytecount[tile]; #ifdef MMAP_SUPPORT if (isMapped(tif) && (td->td_fillorder == tif->tif_fillorder || (tif->tif_flags & TIFF_NOBITREV))) { /* * The image is mapped into memory and we either don't * need to flip bits or the compression routine is going * to handle this operation itself. In this case, avoid * copying the raw data and instead just reference the * data from the memory mapped file image. This assumes * that the decompression routines do not modify the * contents of the raw data buffer (if they try to, * the application will get a fault since the file is * mapped read-only). */ if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) free(tif->tif_rawdata); tif->tif_flags &= ~TIFF_MYBUFFER; if (td->td_stripoffset[tile] + bytecount > tif->tif_size) { tif->tif_curtile = -1; /* unknown state */ return (0); } tif->tif_rawdatasize = bytecount; tif->tif_rawdata = tif->tif_base + td->td_stripoffset[tile]; } else { #endif /* * Expand raw data buffer, if needed, to * hold data tile coming from file * (perhaps should set upper bound on * the size of a buffer we'll use?). */ if (bytecount > tif->tif_rawdatasize) { tif->tif_curtile = -1; /* unknown state */ if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFError(module, "%s: Data buffer too small to hold tile %d", tif->tif_name, tile); return (0); } if (!TIFFReadBufferSetup(tif, 0, roundup(bytecount, 1024))) return (0); } if (TIFFReadRawTile1(tif, tile, (u_char *)tif->tif_rawdata, bytecount, module) != bytecount) return (0); if (td->td_fillorder != tif->tif_fillorder && (tif->tif_flags & TIFF_NOBITREV) == 0) TIFFReverseBits((u_char *)tif->tif_rawdata, bytecount); #ifdef MMAP_SUPPORT } #endif return (TIFFStartTile(tif, tile)); } /* * Setup the raw data buffer in preparation for * reading a strip of raw data. If the buffer * is specified as zero, then a buffer of appropriate * size is allocated by the library. Otherwise, * the client must guarantee that the buffer is * large enough to hold any individual strip of * raw data. */ int TIFFReadBufferSetup(tif, bp, size) TIFF *tif; char *bp; u_int size; { static char module[] = "TIFFReadBufferSetup"; if (tif->tif_rawdata) { if (tif->tif_flags & TIFF_MYBUFFER) free(tif->tif_rawdata); tif->tif_rawdata = NULL; } if (bp) { tif->tif_rawdatasize = size; tif->tif_rawdata = bp; tif->tif_flags &= ~TIFF_MYBUFFER; } else { tif->tif_rawdatasize = roundup(size, 1024); tif->tif_rawdata = malloc(tif->tif_rawdatasize); tif->tif_flags |= TIFF_MYBUFFER; } if (tif->tif_rawdata == NULL) { TIFFError(module, "%s: No space for data buffer at scanline %d", tif->tif_name, tif->tif_row); tif->tif_rawdatasize = 0; return (0); } return (1); } /* * Set state to appear as if a * strip has just been read in. */ static TIFFStartStrip(tif, strip) register TIFF *tif; u_int strip; { TIFFDirectory *td = &tif->tif_dir; tif->tif_curstrip = strip; tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; tif->tif_rawcp = tif->tif_rawdata; tif->tif_rawcc = td->td_stripbytecount[strip]; return (tif->tif_predecode == NULL || (*tif->tif_predecode)(tif)); } /* * Set state to appear as if a * tile has just been read in. */ static TIFFStartTile(tif, tile) register TIFF *tif; u_int tile; { TIFFDirectory *td = &tif->tif_dir; tif->tif_curtile = tile; tif->tif_row = (tile % howmany(td->td_imagewidth, td->td_tilewidth)) * td->td_tilelength; tif->tif_col = (tile % howmany(td->td_imagelength, td->td_tilelength)) * td->td_tilewidth; tif->tif_rawcp = tif->tif_rawdata; tif->tif_rawcc = td->td_stripbytecount[tile]; return (tif->tif_predecode == NULL || (*tif->tif_predecode)(tif)); } static TIFFCheckRead(tif, tiles) TIFF *tif; int tiles; { if (tif->tif_mode == O_WRONLY) { TIFFError(tif->tif_name, "File not open for reading"); return (0); } if (tiles ^ isTiled(tif)) { TIFFError(tif->tif_name, tiles ? "Can not read tiles from a stripped image" : "Can not read scanlines from a tiled image"); return (0); } return (1); } ivtools-1.2.11a1/src/TIFF/tif_strip.c000066400000000000000000000064601214471147700172210ustar00rootroot00000000000000/* * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * Strip-organized Image Support Routines. */ #include "tiffioP.h" /* * Compute which strip a (row,sample) value is in. */ u_int TIFFComputeStrip(tif, row, sample) TIFF *tif; u_long row; u_int sample; { TIFFDirectory *td = &tif->tif_dir; u_int strip; strip = row / td->td_rowsperstrip; if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { if (sample >= td->td_samplesperpixel) { TIFFError(tif->tif_name, "%d: Sample out of range, max %d", sample, td->td_samplesperpixel); return (0); } strip += sample*td->td_stripsperimage; } return (strip); } /* * Compute how many strips are in an image. */ u_int TIFFNumberOfStrips(tif) TIFF *tif; { TIFFDirectory *td = &tif->tif_dir; return (td->td_rowsperstrip == 0xffffffff ? (td->td_imagelength != 0 ? 1 : 0) : howmany(td->td_imagelength, td->td_rowsperstrip)); } /* * Compute the # bytes in a variable height, row-aligned strip. */ u_long TIFFVStripSize(tif, nrows) TIFF *tif; u_long nrows; { TIFFDirectory *td = &tif->tif_dir; if (nrows == (u_long)-1) nrows = td->td_imagelength; #ifdef YCBCR_SUPPORT if (td->td_planarconfig == PLANARCONFIG_CONTIG && td->td_photometric == PHOTOMETRIC_YCBCR) { /* * Packed YCbCr data contain one Cb+Cr for every * HorizontalSampling*VerticalSampling Y values. * Must also roundup width and height when calculating * since images that are not a multiple of the * horizontal/vertical subsampling area include * YCbCr data for the extended image. */ u_long w = roundup(td->td_imagewidth, td->td_ycbcrsubsampling[0]); u_long scanline = howmany(w*td->td_bitspersample, 8); u_long samplingarea = td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; nrows = roundup(nrows, td->td_ycbcrsubsampling[1]); /* NB: don't need howmany here 'cuz everything is rounded */ return (nrows*scanline + 2*(nrows*scanline / samplingarea)); } else #endif return (nrows * TIFFScanlineSize(tif)); } /* * Compute the # bytes in a (row-aligned) strip. */ u_long TIFFStripSize(tif) TIFF *tif; { return (TIFFVStripSize(tif, tif->tif_dir.td_rowsperstrip)); } ivtools-1.2.11a1/src/TIFF/tif_swab.c000066400000000000000000000152511214471147700170120ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library Bit & Byte Swapping Support. * * XXX We assume short = 16-bits and long = 32-bits XXX */ #include "tiffio.h" #ifndef TIFFSwabShort TIFFSwabShort(wp) unsigned short *wp; { register unsigned char *cp = (unsigned char *)wp; int t; t = cp[1]; cp[1] = cp[0]; cp[0] = t; } #endif #ifndef TIFFSwabLong TIFFSwabLong(lp) unsigned long *lp; { register unsigned char *cp = (unsigned char *)lp; int t; t = cp[3]; cp[3] = cp[0]; cp[0] = t; t = cp[2]; cp[2] = cp[1]; cp[1] = t; } #endif #ifndef TIFFSwabArrayOfShort TIFFSwabArrayOfShort(wp, n) unsigned short *wp; register int n; { register unsigned char *cp; register int t; /* XXX unroll loop some */ while (n-- > 0) { cp = (unsigned char *)wp; t = cp[1]; cp[1] = cp[0]; cp[0] = t; wp++; } } #endif #ifndef TIFFSwabArrayOfLong TIFFSwabArrayOfLong(lp, n) register unsigned long *lp; register int n; { register unsigned char *cp; register int t; /* XXX unroll loop some */ while (n-- > 0) { cp = (unsigned char *)lp; t = cp[3]; cp[3] = cp[0]; cp[0] = t; t = cp[2]; cp[2] = cp[1]; cp[1] = t; lp++; } } #endif /* * Bit reversal tables. TIFFBitRevTable[] gives * the bit reversed value of . Used in various * places in the library when the FillOrder requires * bit reversal of byte values (e.g. CCITT Fax 3 * encoding/decoding). TIFFNoBitRevTable is provided * for algorithms that want an equivalent table that * do not reverse bit values. */ #if defined(__STDC__) || defined(__EXTENDED__) || USE_CONST const unsigned char TIFFBitRevTable[256] = { #else unsigned char TIFFBitRevTable[256] = { #endif 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff }; #if defined(__STDC__) || defined(__EXTENDED__) || USE_CONST const unsigned char TIFFNoBitRevTable[256] = { #else unsigned char TIFFNoBitRevTable[256] = { #endif 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, }; TIFFReverseBits(cp, n) register unsigned char *cp; register int n; { for (; n > 8; n -= 8) { cp[0] = TIFFBitRevTable[cp[0]]; cp[1] = TIFFBitRevTable[cp[1]]; cp[2] = TIFFBitRevTable[cp[2]]; cp[3] = TIFFBitRevTable[cp[3]]; cp[4] = TIFFBitRevTable[cp[4]]; cp[5] = TIFFBitRevTable[cp[5]]; cp[6] = TIFFBitRevTable[cp[6]]; cp[7] = TIFFBitRevTable[cp[7]]; cp += 8; } while (n-- > 0) *cp = TIFFBitRevTable[*cp], cp++; } ivtools-1.2.11a1/src/TIFF/tif_thunder.c000066400000000000000000000110401214471147700175170ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * ThunderScan 4-bit Compression Algorithm Support */ #include "tiffioP.h" /* * ThunderScan uses an encoding scheme designed for * 4-bit pixel values. Data is encoded in bytes, with * each byte split into a 2-bit code word and a 6-bit * data value. The encoding gives raw data, runs of * pixels, or pixel values encoded as a delta from the * previous pixel value. For the latter, either 2-bit * or 3-bit delta values are used, with the deltas packed * into a single byte. */ #define THUNDER_DATA 0x3f /* mask for 6-bit data */ #define THUNDER_CODE 0xc0 /* mask for 2-bit code word */ /* code values */ #define THUNDER_RUN 0x00 /* run of pixels w/ encoded count */ #define THUNDER_2BITDELTAS 0x40 /* 3 pixels w/ encoded 2-bit deltas */ #define DELTA2_SKIP 2 /* skip code for 2-bit deltas */ #define THUNDER_3BITDELTAS 0x80 /* 2 pixels w/ encoded 3-bit deltas */ #define DELTA3_SKIP 4 /* skip code for 3-bit deltas */ #define THUNDER_RAW 0xc0 /* raw data encoded */ static const int twobitdeltas[4] = { 0, 1, 0, -1 }; static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 }; #define SETPIXEL(op, v) { \ lastpixel = (v) & 0xf; \ if (npixels++ & 1) \ *op++ |= lastpixel; \ else \ op[0] = lastpixel << 4; \ } static int ThunderDecode(tif, op, maxpixels) TIFF *tif; register u_char *op; int maxpixels; { register u_char *bp; register int n, cc, lastpixel, npixels, delta; bp = (u_char *)tif->tif_rawcp; cc = tif->tif_rawcc; lastpixel = npixels = 0; while (cc > 0 && npixels < maxpixels) { n = *bp++, cc--; switch (n & THUNDER_CODE) { case THUNDER_RUN: /* pixel run */ /* * Replicate the last pixel n times, * where n is the lower-order 6 bits. */ if (npixels & 1) { op[0] |= lastpixel; lastpixel = *op++; npixels++; n--; } else lastpixel |= lastpixel << 4; npixels += n; for (; n > 0; n -= 2) *op++ = lastpixel; if (n == -1) *--op &= 0xf0; lastpixel &= 0xf; break; case THUNDER_2BITDELTAS: /* 2-bit deltas */ if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP) SETPIXEL(op, lastpixel + twobitdeltas[delta]); if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP) SETPIXEL(op, lastpixel + twobitdeltas[delta]); if ((delta = (n & 3)) != DELTA2_SKIP) SETPIXEL(op, lastpixel + twobitdeltas[delta]); break; case THUNDER_3BITDELTAS: /* 3-bit deltas */ if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP) SETPIXEL(op, lastpixel + threebitdeltas[delta]); if ((delta = (n & 7)) != DELTA3_SKIP) SETPIXEL(op, lastpixel + threebitdeltas[delta]); break; case THUNDER_RAW: /* raw data */ SETPIXEL(op, n); break; } } tif->tif_rawcp = (char *)bp; tif->tif_rawcc = cc; if (npixels != maxpixels) { TIFFError(tif->tif_name, "ThunderDecode: %s data at scanline %d (%d != %d)", npixels < maxpixels ? "Not enough" : "Too much", tif->tif_row, npixels, maxpixels); return (0); } return (1); } static int ThunderDecodeRow(tif, buf, occ, s) TIFF *tif; u_char *buf; int occ; u_int s; { u_char *row = buf; while (occ > 0) { if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth)) return (0); occ -= tif->tif_scanlinesize; row += tif->tif_scanlinesize; } return (1); } TIFFInitThunderScan(tif) TIFF *tif; { tif->tif_decoderow = ThunderDecodeRow; tif->tif_decodestrip = ThunderDecodeRow; return (1); } ivtools-1.2.11a1/src/TIFF/tif_tile.c000066400000000000000000000122671214471147700170170ustar00rootroot00000000000000/* * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * Tiled Image Support Routines. */ #include "tiffioP.h" /* * Compute which tile an (x,y,z,s) value is in. */ u_int TIFFComputeTile(tif, x, y, s, z) TIFF *tif; u_long x, y, z; u_int s; { TIFFDirectory *td = &tif->tif_dir; u_long dx = td->td_tilewidth; u_long dy = td->td_tilelength; u_long dz = td->td_tiledepth; u_int tile = 1; if (td->td_imagedepth == 1) z = 0; if (dx == (u_long) -1) dx = td->td_imagewidth; if (dy == (u_long) -1) dy = td->td_imagelength; if (dz == (u_long) -1) dz = td->td_imagedepth; if (dx != 0 && dy != 0 && dz != 0) { u_int xpt = howmany(td->td_imagewidth, dx); u_int ypt = howmany(td->td_imagelength, dy); u_int zpt = howmany(td->td_imagedepth, dz); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) tile = (xpt*ypt*zpt)*s + (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx; else tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx + s; } return (tile); } /* * Check an (x,y,z,s) coordinate * against the image bounds. */ TIFFCheckTile(tif, x, y, z, s) TIFF *tif; u_long x, y, z; u_int s; { TIFFDirectory *td = &tif->tif_dir; if (x >= td->td_imagewidth) { TIFFError(tif->tif_name, "Col %d out of range, max %d", x, td->td_imagewidth); return (0); } if (y >= td->td_imagelength) { TIFFError(tif->tif_name, "Row %d out of range, max %d", y, td->td_imagelength); return (0); } if (z >= td->td_imagedepth) { TIFFError(tif->tif_name, "Depth %d out of range, max %d", z, td->td_imagedepth); return (0); } if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s >= td->td_samplesperpixel) { TIFFError(tif->tif_name, "Sample %d out of range, max %d", s, td->td_samplesperpixel); return (0); } return (1); } /* * Compute how many tiles are in an image. */ u_int TIFFNumberOfTiles(tif) TIFF *tif; { TIFFDirectory *td = &tif->tif_dir; u_long dx = td->td_tilewidth; u_long dy = td->td_tilelength; u_long dz = td->td_tiledepth; u_int ntiles; if (dx == (u_long) -1) dx = td->td_imagewidth; if (dy == (u_long) -1) dy = td->td_imagelength; if (dz == (u_long) -1) dz = td->td_imagedepth; ntiles = (dx != 0 && dy != 0 && dz != 0) ? (howmany(td->td_imagewidth, dx) * howmany(td->td_imagelength, dy) * howmany(td->td_imagedepth, dz)) : 0; return (ntiles); } /* * Compute the # bytes in each row of a tile. */ u_long TIFFTileRowSize(tif) TIFF *tif; { TIFFDirectory *td = &tif->tif_dir; u_long rowsize; if (td->td_tilelength == 0 || td->td_tilewidth == 0) return (0); rowsize = td->td_bitspersample * td->td_tilewidth; if (td->td_planarconfig == PLANARCONFIG_CONTIG) rowsize *= td->td_samplesperpixel; return (howmany(rowsize, 8)); } /* * Compute the # bytes in a variable length, row-aligned tile. */ u_long TIFFVTileSize(tif, nrows) TIFF *tif; u_long nrows; { TIFFDirectory *td = &tif->tif_dir; u_long tilesize; if (td->td_tilelength == 0 || td->td_tilewidth == 0 || td->td_tiledepth == 0) return (0); #ifdef YCBCR_SUPPORT if (td->td_planarconfig == PLANARCONFIG_CONTIG && td->td_photometric == PHOTOMETRIC_YCBCR) { /* * Packed YCbCr data contain one Cb+Cr for every * HorizontalSampling*VerticalSampling Y values. * Must also roundup width and height when calculating * since images that are not a multiple of the * horizontal/vertical subsampling area include * YCbCr data for the extended image. */ u_long w = roundup(td->td_tilewidth, td->td_ycbcrsubsampling[0]); u_long rowsize = howmany(w*td->td_bitspersample, 8); u_long samplingarea = td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; nrows = roundup(nrows, td->td_ycbcrsubsampling[1]); /* NB: don't need howmany here 'cuz everything is rounded */ tilesize = nrows*rowsize + 2*(nrows*rowsize / samplingarea); } else #endif tilesize = nrows * TIFFTileRowSize(tif); return (tilesize * td->td_tiledepth); } /* * Compute the # bytes in a row-aligned tile. */ u_long TIFFTileSize(tif) TIFF *tif; { return (TIFFVTileSize(tif, tif->tif_dir.td_tilelength)); } ivtools-1.2.11a1/src/TIFF/tif_version.c000066400000000000000000000025621214471147700175440ustar00rootroot00000000000000/* * Copyright (c) 1992 Sam Leffler * Copyright (c) 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include "tiffcompat.h" const char TIFFVersion[] = "\ LIBTIFF, Version 3.0\n\ Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler\n\ Copyright (c) 1991, 1992 Silicon Graphics, Inc.\ "; ivtools-1.2.11a1/src/TIFF/tif_warning.c000066400000000000000000000040061214471147700175170ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. */ #include #include "tiffioP.h" #include "prototypes.h" static void DECLARE3(defaultHandler, char*, module, char*, fmt, va_list, ap) { if (module != NULL) fprintf(stderr, "%s: ", module); fprintf(stderr, "Warning, "); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } static TIFFErrorHandler _warningHandler = defaultHandler; TIFFErrorHandler DECLARE1(TIFFSetWarningHandler, TIFFErrorHandler, handler) { TIFFErrorHandler prev = _warningHandler; _warningHandler = handler; return (prev); } void #if USE_PROTOTYPES TIFFWarning(char *module, char *fmt, ...) #else /*VARARGS2*/ TIFFWarning(module, fmt, va_alist) char *module; char *fmt; va_dcl #endif { if (_warningHandler) { va_list ap; VA_START(ap, fmt); (*_warningHandler)(module, fmt, ap); va_end(ap); } } ivtools-1.2.11a1/src/TIFF/tif_write.c000066400000000000000000000411261214471147700172100ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. * * Scanline-oriented Write Support */ #include "tiffioP.h" #include #include #define STRIPINCR 20 /* expansion factor on strip array */ #if USE_PROTOTYPES static TIFFWriteCheck(TIFF *, int, char []); static TIFFBufferSetup(TIFF *, char []); static TIFFGrowStrips(TIFF *, int, char []); static TIFFAppendToStrip(TIFF *, u_int, u_char *, u_int); #else static TIFFWriteCheck(); static TIFFBufferSetup(); static TIFFGrowStrips(); static TIFFAppendToStrip(); #endif /*VARARGS3*/ TIFFWriteScanline(tif, buf, row, sample) register TIFF *tif; u_char *buf; u_int row, sample; { static char module[] = "TIFFWriteScanline"; register TIFFDirectory *td; int strip, status, imagegrew = 0; if (!TIFFWriteCheck(tif, 0, module)) return (-1); /* * Handle delayed allocation of data buffer. This * permits it to be sized more intelligently (using * directory information). */ if ((tif->tif_flags & TIFF_BUFFERSETUP) == 0) { if (!TIFFBufferSetup(tif, module)) return (-1); tif->tif_flags |= TIFF_BUFFERSETUP; } td = &tif->tif_dir; /* * Extend image length if needed * (but only for PlanarConfig=1). */ if (row >= td->td_imagelength) { /* extend image */ if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { TIFFError(tif->tif_name, "Can not change \"ImageLength\" when using separate planes"); return (-1); } td->td_imagelength = row+1; imagegrew = 1; } /* * Calculate strip and check for crossings. */ if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { if (sample >= td->td_samplesperpixel) { TIFFError(tif->tif_name, "%d: Sample out of range, max %d", sample, td->td_samplesperpixel); return (-1); } strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; } else strip = row / td->td_rowsperstrip; if (strip != tif->tif_curstrip) { /* * Changing strips -- flush any data present. */ if (tif->tif_rawcc > 0 && !TIFFFlushData(tif)) return (-1); tif->tif_curstrip = strip; /* * Watch out for a growing image. The value of * strips/image will initially be 1 (since it * can't be deduced until the imagelength is known). */ if (strip >= td->td_stripsperimage && imagegrew) td->td_stripsperimage = howmany(td->td_imagelength, td->td_rowsperstrip); tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; if (tif->tif_preencode && !(*tif->tif_preencode)(tif)) return (-1); tif->tif_flags |= TIFF_POSTENCODE; } /* * Check strip array to make sure there's space. * We don't support dynamically growing files that * have data organized in separate bitplanes because * it's too painful. In that case we require that * the imagelength be set properly before the first * write (so that the strips array will be fully * allocated above). */ if (strip >= td->td_nstrips && !TIFFGrowStrips(tif, 1, module)) return (-1); /* * Ensure the write is either sequential or at the * beginning of a strip (or that we can randomly * access the data -- i.e. no encoding). */ if (row != tif->tif_row) { if (tif->tif_seek) { if (row < tif->tif_row) { /* * Moving backwards within the same strip: * backup to the start and then decode * forward (below). */ tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; tif->tif_rawcp = tif->tif_rawdata; } /* * Seek forward to the desired row. */ if (!(*tif->tif_seek)(tif, row - tif->tif_row)) return (-1); tif->tif_row = row; } else { TIFFError(tif->tif_name, "Compression algorithm does not support random access"); return (-1); } } status = (*tif->tif_encoderow)(tif, buf, tif->tif_scanlinesize, sample); tif->tif_row++; return (status); } /* * Encode the supplied data and write it to the * specified strip. There must be space for the * data; we don't check if strips overlap! * * NB: Image length must be setup before writing; this * interface does not support automatically growing * the image on each write (as TIFFWriteScanline does). */ TIFFWriteEncodedStrip(tif, strip, data, cc) TIFF *tif; u_int strip; u_char *data; u_int cc; { static char module[] = "TIFFWriteEncodedStrip"; TIFFDirectory *td = &tif->tif_dir; if (!TIFFWriteCheck(tif, 0, module)) return (-1); if (strip >= td->td_nstrips) { TIFFError(module, "%s: Strip %d out of range, max %d", tif->tif_name, strip, td->td_nstrips); return (-1); } /* * Handle delayed allocation of data buffer. This * permits it to be sized according to the directory * info. */ if ((tif->tif_flags & TIFF_BUFFERSETUP) == 0) { if (!TIFFBufferSetup(tif, module)) return (-1); tif->tif_flags |= TIFF_BUFFERSETUP; } tif->tif_curstrip = strip; tif->tif_flags &= ~TIFF_POSTENCODE; if (tif->tif_preencode && !(*tif->tif_preencode)(tif)) return (-1); if (!(*tif->tif_encodestrip)(tif, data, cc, strip / td->td_stripsperimage)) return (0); if (tif->tif_postencode && !(*tif->tif_postencode)(tif)) return (-1); if (td->td_fillorder != tif->tif_fillorder && (tif->tif_flags & TIFF_NOBITREV) == 0) TIFFReverseBits((u_char *)tif->tif_rawdata, tif->tif_rawcc); if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, strip, (u_char *)tif->tif_rawdata, tif->tif_rawcc)) return (-1); tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; return (cc); } /* * Write the supplied data to the specified strip. * There must be space for the data; we don't check * if strips overlap! * * NB: Image length must be setup before writing; this * interface does not support automatically growing * the image on each write (as TIFFWriteScanline does). */ TIFFWriteRawStrip(tif, strip, data, cc) TIFF *tif; u_int strip; u_char *data; u_int cc; { static char module[] = "TIFFWriteRawStrip"; if (!TIFFWriteCheck(tif, 0, module)) return (-1); if (strip >= tif->tif_dir.td_nstrips) { TIFFError(module, "%s: Strip %d out of range, max %d", tif->tif_name, strip, tif->tif_dir.td_nstrips); return (-1); } return (TIFFAppendToStrip(tif, strip, data, cc) ? cc : -1); } /* * Write and compress a tile of data. The * tile is selected by the (x,y,z,s) coordinates. */ TIFFWriteTile(tif, buf, x, y, z, s) TIFF *tif; u_char *buf; u_long x, y, z; u_int s; { if (!TIFFCheckTile(tif, x, y, z, s)) return (-1); /* * NB: A tile size of -1 is used instead of tif_tilesize knowing * that TIFFWriteEncodedTile will clamp this to the tile size. * This is done because the tile size may not be defined until * after the output buffer is setup in TIFFBufferSetup. */ return (TIFFWriteEncodedTile(tif, TIFFComputeTile(tif, x, y, z, s), buf, (u_int)-1)); } /* * Encode the supplied data and write it to the * specified tile. There must be space for the * data. The function clamps individual writes * to a tile to the tile size, but does not (and * can not) check that multiple writes to the same * tile do not write more than tile size data. * * NB: Image length must be setup before writing; this * interface does not support automatically growing * the image on each write (as TIFFWriteScanline does). */ TIFFWriteEncodedTile(tif, tile, data, cc) TIFF *tif; u_int tile; u_char *data; u_int cc; { static char module[] = "TIFFWriteEncodedTile"; TIFFDirectory *td; if (!TIFFWriteCheck(tif, 1, module)) return (-1); td = &tif->tif_dir; if (tile >= td->td_nstrips) { TIFFError(module, "%s: Tile %d out of range, max %d", tif->tif_name, tile, td->td_nstrips); return (-1); } /* * Handle delayed allocation of data buffer. This * permits it to be sized more intelligently (using * directory information). */ if ((tif->tif_flags & TIFF_BUFFERSETUP) == 0) { if (!TIFFBufferSetup(tif, module)) return (-1); tif->tif_flags |= TIFF_BUFFERSETUP; } tif->tif_curtile = tile; /* * Compute tiles per row & per column to compute * current row and column */ tif->tif_row = (tile % howmany(td->td_imagelength, td->td_tilelength)) * td->td_tilelength; tif->tif_col = (tile % howmany(td->td_imagewidth, td->td_tilewidth)) * td->td_tilewidth; tif->tif_flags &= ~TIFF_POSTENCODE; if (tif->tif_preencode && !(*tif->tif_preencode)(tif)) return (-1); /* * Clamp write amount to the tile size. This is mostly * done so that callers can pass in some large number * (e.g. -1) and have the tile size used instead. */ if (cc > tif->tif_tilesize) cc = tif->tif_tilesize; if (!(*tif->tif_encodetile)(tif, data, cc, tile/td->td_stripsperimage)) return (0); if (tif->tif_postencode && !(*tif->tif_postencode)(tif)) return (-1); if (td->td_fillorder != tif->tif_fillorder && (tif->tif_flags & TIFF_NOBITREV) == 0) TIFFReverseBits((u_char *)tif->tif_rawdata, tif->tif_rawcc); if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile, (u_char *)tif->tif_rawdata, tif->tif_rawcc)) return (-1); tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; return (cc); } /* * Write the supplied data to the specified strip. * There must be space for the data; we don't check * if strips overlap! * * NB: Image length must be setup before writing; this * interface does not support automatically growing * the image on each write (as TIFFWriteScanline does). */ TIFFWriteRawTile(tif, tile, data, cc) TIFF *tif; u_int tile; u_char *data; u_int cc; { static char module[] = "TIFFWriteRawTile"; if (!TIFFWriteCheck(tif, 1, module)) return (-1); if (tile >= tif->tif_dir.td_nstrips) { TIFFError(module, "%s: Tile %d out of range, max %d", tif->tif_name, tile, tif->tif_dir.td_nstrips); return (-1); } return (TIFFAppendToStrip(tif, tile, data, cc) ? cc : -1); } static TIFFSetupStrips(tif) TIFF *tif; { #define isUnspecified(td, v) \ (td->v == 0xffffffff || (td)->td_imagelength == 0) register TIFFDirectory *td = &tif->tif_dir; if (!isTiled(tif)) td->td_stripsperimage = isUnspecified(td, td_rowsperstrip) ? 1 : howmany(td->td_imagelength, td->td_rowsperstrip); else td->td_stripsperimage = isUnspecified(td, td_tilelength) ? 1 : TIFFNumberOfTiles(tif); td->td_nstrips = td->td_stripsperimage; if (td->td_planarconfig == PLANARCONFIG_SEPARATE) td->td_nstrips *= td->td_samplesperpixel; td->td_stripoffset = (u_long *) malloc(td->td_nstrips * sizeof (u_long)); td->td_stripbytecount = (u_long *) malloc(td->td_nstrips * sizeof (u_long)); if (td->td_stripoffset == NULL || td->td_stripbytecount == NULL) return (0); /* * Place data at the end-of-file * (by setting offsets to zero). */ bzero((char *)td->td_stripoffset, td->td_nstrips * sizeof (u_long)); bzero((char *)td->td_stripbytecount, td->td_nstrips * sizeof (u_long)); TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); return (1); #undef isUnspecified } /* * Verify file is writable and that the directory * information is setup properly. In doing the latter * we also "freeze" the state of the directory so * that important information is not changed. */ static TIFFWriteCheck(tif, tiles, module) register TIFF *tif; int tiles; char module[]; { if (tif->tif_mode == O_RDONLY) { TIFFError(module, "%s: File not open for writing", tif->tif_name); return (0); } if (tiles ^ isTiled(tif)) { TIFFError(tif->tif_name, tiles ? "Can not write tiles to a stripped image" : "Can not write scanlines to a tiled image"); return (0); } /* * On the first write verify all the required information * has been setup and initialize any data structures that * had to wait until directory information was set. * Note that a lot of our work is assumed to remain valid * because we disallow any of the important parameters * from changing after we start writing (i.e. once * TIFF_BEENWRITING is set, TIFFSetField will only allow * the image's length to be changed). */ if ((tif->tif_flags & TIFF_BEENWRITING) == 0) { if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { TIFFError(module, "%s: Must set \"ImageWidth\" before writing data", tif->tif_name); return (0); } if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { TIFFError(module, "%s: Must set \"PlanarConfiguration\" before writing data", tif->tif_name); return (0); } if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) { tif->tif_dir.td_nstrips = 0; TIFFError(module, "%s: No space for %s arrays", tif->tif_name, isTiled(tif) ? "tile" : "strip"); return (0); } tif->tif_flags |= TIFF_BEENWRITING; } return (1); } /* * Setup the raw data buffer used for encoding. */ static TIFFBufferSetup(tif, module) register TIFF *tif; char module[]; { int size; if (isTiled(tif)) tif->tif_tilesize = size = TIFFTileSize(tif); else tif->tif_scanlinesize = size = TIFFScanlineSize(tif); /* * Make raw data buffer at least 8K */ if (size < 8*1024) size = 8*1024; tif->tif_rawdata = malloc(size); if (tif->tif_rawdata == NULL) { TIFFError(module, "%s: No space for output buffer", tif->tif_name); return (0); } tif->tif_rawdatasize = size; tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; return (1); } /* * Grow the strip data structures by delta strips. */ static TIFFGrowStrips(tif, delta, module) TIFF *tif; int delta; char module[]; { TIFFDirectory *td = &tif->tif_dir; assert(td->td_planarconfig == PLANARCONFIG_CONTIG); td->td_stripoffset = (u_long *)realloc(td->td_stripoffset, (td->td_nstrips + delta) * sizeof (u_long)); td->td_stripbytecount = (u_long *)realloc(td->td_stripbytecount, (td->td_nstrips + delta) * sizeof (u_long)); if (td->td_stripoffset == NULL || td->td_stripbytecount == NULL) { td->td_nstrips = 0; TIFFError(module, "%s: No space to expand strip arrays", tif->tif_name); return (0); } bzero(td->td_stripoffset+td->td_nstrips, delta*sizeof (u_long)); bzero(td->td_stripbytecount+td->td_nstrips, delta*sizeof (u_long)); td->td_nstrips += delta; return (1); } /* * Append the data to the specified strip. * * NB: We don't check that there's space in the * file (i.e. that strips do not overlap). */ static TIFFAppendToStrip(tif, strip, data, cc) TIFF *tif; u_int strip; u_char *data; u_int cc; { TIFFDirectory *td = &tif->tif_dir; static char module[] = "TIFFAppendToStrip"; if (td->td_stripoffset[strip] == 0 || tif->tif_curoff == 0) { /* * No current offset, set the current strip. */ if (td->td_stripoffset[strip] != 0) { if (!SeekOK(tif->tif_fd, td->td_stripoffset[strip])) { TIFFError(module, "%s: Seek error at scanline %d", tif->tif_name, tif->tif_row); return (0); } } else td->td_stripoffset[strip] = lseek(tif->tif_fd, 0L, L_XTND); tif->tif_curoff = td->td_stripoffset[strip]; } if (!WriteOK(tif->tif_fd, data, cc)) { TIFFError(module, "%s: Write error at scanline %d", tif->tif_name, tif->tif_row); return (0); } tif->tif_curoff += cc; td->td_stripbytecount[strip] += cc; return (1); } /* * Internal version of TIFFFlushData that can be * called by ``encodestrip routines'' w/o concern * for infinite recursion. */ TIFFFlushData1(tif) register TIFF *tif; { if (tif->tif_rawcc > 0) { if (tif->tif_dir.td_fillorder != tif->tif_fillorder && (tif->tif_flags & TIFF_NOBITREV) == 0) TIFFReverseBits((u_char *)tif->tif_rawdata, tif->tif_rawcc); if (!TIFFAppendToStrip(tif, isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip, (u_char *)tif->tif_rawdata, tif->tif_rawcc)) return (0); tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; } return (1); } ivtools-1.2.11a1/src/TIFF/tiffcompat.h000066400000000000000000000126701214471147700173570ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _COMPAT_ #define _COMPAT_ /* * This file contains a hodgepodge of definitions and * declarations that are needed to provide compatibility * between the native system and the base UNIX implementation * that the library assumes (~4BSD). In particular, you * can override the standard i/o interface (read/write/lseek) * by redefining the ReadOK/WriteOK/SeekOK macros to your * liking. * * NB: This file is a mess. */ #if (defined(__STDC__) || defined(__EXTENDED__)) && !defined(USE_PROTOTYPES) #define USE_PROTOTYPES 1 #define USE_CONST 1 #endif #if !USE_CONST && !defined(const) #define const #endif #ifdef THINK_C #include #include #endif #if USE_PROTOTYPES #include #endif #ifndef THINK_C #include #endif #ifdef VMS #include #include #else #include #endif #if defined(THINK_C) || defined(applec) #include #endif /* * Workarounds for BSD lseek definitions. */ #if defined(SYSV) || defined(VMS) #if defined(SYSV) #include #endif #define L_SET SEEK_SET #define L_INCR SEEK_CUR #define L_XTND SEEK_END #endif #ifndef L_SET #define L_SET 0 #define L_INCR 1 #define L_XTND 2 #endif /* * SVID workarounds for BSD bit * string manipulation routines. */ #if defined(SYSV) || defined(THINK_C) || defined(applec) || defined(VMS) #define bzero(dst,len) memset((char *)dst, 0, len) #define bcopy(src,dst,len) memcpy((char *)dst, (char *)src, len) #define bcmp(src, dst, len) memcmp((char *)dst, (char *)src, len) #endif /* * The BSD typedefs are used throughout the library. * If your system doesn't have them in , * then define BSDTYPES in your Makefile. */ #ifdef BSDTYPES typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; #endif /* * Return an open file descriptor or -1. */ #if defined(applec) || defined(THINK_C) #define TIFFOpenFile(name, mode, prot) open(name, mode) #else #if defined(MSDOS) #define TIFFOpenFile(name, mode, prot) open(name, mode|O_BINARY, prot) #else #define TIFFOpenFile(name, mode, prot) open(name, mode, prot) #endif #endif /* * Return the size in bytes of the file * associated with the supplied file descriptor. */ #if USE_PROTOTYPES extern long TIFFGetFileSize(int fd); #else extern long TIFFGetFileSize(); #endif #ifdef MMAP_SUPPORT /* * Mapped file support. * * TIFFMapFileContents must map the entire file into * memory and return the address of the mapped * region and the size of the mapped region. * TIFFUnmapFileContents does the inverse operation. */ #if USE_PROTOTYPES extern int TIFFMapFileContents(int fd, char **paddr, long *psize); extern void TIFFUnmapFileContents(char *addr, long size); #else extern int TIFFMapFileContents(); extern void TIFFUnmapFileContents(); #endif #endif /* * Mac workaround to handle the file * extension semantics of lseek. */ #ifdef applec #define lseek mpw_lseek extern long mpw_lseek(int, long, int); #else #if !defined(__NetBSD__) && !defined(__FreeBSD__) extern long lseek(); #endif #endif /* * Default Read/Seek/Write definitions. */ #ifndef ReadOK #define ReadOK(fd, buf, size) (read(fd, (char *)buf, size) == size) #endif #ifndef SeekOK #define SeekOK(fd, off) (lseek(fd, (long)off, L_SET) == (long)off) #endif #ifndef WriteOK #define WriteOK(fd, buf, size) (write(fd, (char *)buf, size) == size) #endif #if defined(__MACH__) || defined(THINK_C) extern void *malloc(size_t size); extern void *realloc(void *ptr, size_t size); #else /* !__MACH__ && !THINK_C */ #if defined(MSDOS) #include #else /* !MSDOS */ #include #endif /* !MSDOS */ #endif /* !__MACH__ */ /* * dblparam_t is the type that a double precision * floating point value will have on the parameter * stack (when coerced by the compiler). */ #ifdef applec typedef extended dblparam_t; #else typedef double dblparam_t; #endif /* * Varargs parameter list handling...YECH!!!! */ #if defined(__STDC__) && !defined(USE_VARARGS) #define USE_VARARGS 0 #endif #if defined(USE_VARARGS) #if USE_VARARGS #include #define VA_START(ap, parmN) va_start(ap) #else #include #define VA_START(ap, parmN) va_start(ap, parmN) #endif #endif /* defined(USE_VARARGS) */ #include #include #endif /* _COMPAT_ */ ivtools-1.2.11a1/src/TIFF/tiffioP.h000066400000000000000000000265731214471147700166320ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFFIOP_ #define _TIFFIOP_ /* * ``Library-private'' definitions. */ #include "tiffcompat.h" #include "tiff.h" /* * Internal format of a TIFF directory entry. */ typedef struct { u_long td_fieldsset[2]; /* bit vector of fields that are set */ u_long td_imagewidth, td_imagelength, td_imagedepth; u_long td_tilewidth, td_tilelength, td_tiledepth; u_short td_subfiletype; u_short td_bitspersample; u_short td_sampleformat; u_short td_compression; u_short td_photometric; u_short td_threshholding; u_short td_fillorder; u_short td_orientation; u_short td_samplesperpixel; u_short td_predictor; u_long td_rowsperstrip; u_long td_minsamplevalue, td_maxsamplevalue; /* XXX */ float td_xresolution, td_yresolution; u_short td_resolutionunit; u_short td_planarconfig; float td_xposition, td_yposition; u_long td_group3options; u_long td_group4options; u_short td_pagenumber[2]; u_short td_matteing; u_short td_cleanfaxdata; u_short td_badfaxrun; u_long td_badfaxlines; u_short *td_colormap[3]; u_short td_halftonehints[2]; char *td_documentname; char *td_artist; char *td_datetime; char *td_hostcomputer; char *td_imagedescription; char *td_make; char *td_model; char *td_software; char *td_pagename; u_long td_stripsperimage; u_long td_nstrips; /* size of offset & bytecount arrays */ u_long *td_stripoffset; u_long *td_stripbytecount; #ifdef YCBCR_SUPPORT float *td_ycbcrcoeffs; u_short td_ycbcrsubsampling[2]; u_short td_ycbcrpositioning; #endif #ifdef JPEG_SUPPORT u_short td_jpegproc; u_short td_jpegrestartinterval; u_char **td_qtab; u_char **td_dctab; u_char **td_actab; #endif #ifdef COLORIMETRY_SUPPORT float *td_whitepoint; float *td_primarychromas; float *td_refblackwhite; u_short *td_transferfunction[4]; #endif #ifdef CMYK_SUPPORT u_short td_inkset; u_short td_dotrange[2]; char *td_inknames; char *td_targetprinter; #endif } TIFFDirectory; /* * Field flags used to indicate fields that have * been set in a directory, and to reference fields * when manipulating a directory. */ /* multi-entry fields */ #define FIELD_IMAGEDIMENSIONS 0 #define FIELD_TILEDIMENSIONS 1 #define FIELD_CELLDIMENSIONS 2 /* XXX */ #define FIELD_RESOLUTION 3 #define FIELD_POSITION 4 /* single-entry fields */ #define FIELD_SUBFILETYPE 5 #define FIELD_BITSPERSAMPLE 6 #define FIELD_COMPRESSION 7 #define FIELD_PHOTOMETRIC 8 #define FIELD_THRESHHOLDING 9 #define FIELD_FILLORDER 10 #define FIELD_DOCUMENTNAME 11 #define FIELD_IMAGEDESCRIPTION 12 #define FIELD_MAKE 13 #define FIELD_MODEL 14 #define FIELD_ORIENTATION 15 #define FIELD_SAMPLESPERPIXEL 16 #define FIELD_ROWSPERSTRIP 17 #define FIELD_MINSAMPLEVALUE 18 #define FIELD_MAXSAMPLEVALUE 19 #define FIELD_PLANARCONFIG 20 #define FIELD_PAGENAME 21 #define FIELD_GROUP3OPTIONS 22 #define FIELD_GROUP4OPTIONS 23 #define FIELD_RESOLUTIONUNIT 24 #define FIELD_PAGENUMBER 25 #define FIELD_STRIPBYTECOUNTS 26 #define FIELD_STRIPOFFSETS 27 #define FIELD_COLORMAP 28 #define FIELD_PREDICTOR 29 #define FIELD_ARTIST 30 #define FIELD_DATETIME 31 #define FIELD_HOSTCOMPUTER 32 #define FIELD_SOFTWARE 33 #define FIELD_MATTEING 34 #define FIELD_BADFAXLINES 35 #define FIELD_CLEANFAXDATA 36 #define FIELD_BADFAXRUN 37 #define FIELD_SAMPLEFORMAT 38 #define FIELD_SMINSAMPLEVALUE 39 #define FIELD_SMAXSAMPLEVALUE 40 #define FIELD_IMAGEDEPTH 41 #define FIELD_TILEDEPTH 42 #define FIELD_HALFTONEHINTS 43 #ifdef YCBCR_SUPPORT #define FIELD_YCBCRCOEFFICIENTS 44 #define FIELD_YCBCRSUBSAMPLING 45 #define FIELD_YCBCRPOSITIONING 46 #endif #ifdef JPEG_SUPPORT #define FIELD_JPEGPROC 47 #define FIELD_JPEGRESTARTINTERVAL 48 #define FIELD_JPEGQTABLES 49 #define FIELD_JPEGDCTABLES 50 #define FIELD_JPEGACTABLES 51 #endif #ifdef COLORIMETRY_SUPPORT #define FIELD_REFBLACKWHITE 52 #define FIELD_WHITEPOINT 53 #define FIELD_PRIMARYCHROMAS 54 #define FIELD_TRANSFERFUNCTION 55 #endif #ifdef CMYK_SUPPORT #define FIELD_INKSET 56 #define FIELD_INKNAMES 57 #define FIELD_DOTRANGE 58 #define FIELD_TARGETPRINTER 59 #endif #define FIELD_LAST 59 #define TIFFExtractData(tif, type, v) \ ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ ((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \ (v) & (tif)->tif_typemask[type]) #define TIFFInsertData(tif, type, v) \ ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ ((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \ (v) & (tif)->tif_typemask[type]) typedef struct { u_short field_tag; /* field's tag */ short field_readcount; /* read count (-1 for unknown) */ short field_writecount; /* write count (-1 for unknown) */ TIFFDataType field_type; /* type of associated data */ u_short field_bit; /* bit in fieldsset bit vector */ u_short field_oktochange; /* if true, can change while writing */ char *field_name; /* ASCII name */ } TIFFFieldInfo; #define FIELD_IGNORE ((u_short)-1) /* tags processed but ignored */ #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ #define TIFF_VARIABLE -1 /* marker for variable length tags */ #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ extern const TIFFFieldInfo tiffFieldInfo[];/* table of field descriptors */ extern const int tiffDataWidth[]; /* table of tag datatype widths */ #define BITn(n) (((unsigned)1L)<<((n)&0x1f)) #define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32]) #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field)) #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field)) #define FieldSet(fields, f) (fields[(f)/32] & BITn(f)) #define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f)) struct tiff { char *tif_name; /* name of open file */ short tif_fd; /* open file descriptor */ short tif_mode; /* open mode (O_*) */ char tif_fillorder; /* natural bit fill order for machine */ char tif_options; /* compression-specific options */ short tif_flags; #define TIFF_DIRTYHEADER 0x1 /* header must be written on close */ #define TIFF_DIRTYDIRECT 0x2 /* current directory must be written */ #define TIFF_BUFFERSETUP 0x4 /* data buffers setup */ #define TIFF_BEENWRITING 0x8 /* written 1+ scanlines to file */ #define TIFF_SWAB 0x10 /* byte swap file information */ #define TIFF_NOBITREV 0x20 /* inhibit bit reversal logic */ #define TIFF_MYBUFFER 0x40 /* my raw data buffer; free on close */ #define TIFF_ISTILED 0x80 /* file is tile, not strip- based */ #define TIFF_MAPPED 0x100 /* file is mapped into memory */ #define TIFF_POSTENCODE 0x200 /* need call to postencode routine */ long tif_diroff; /* file offset of current directory */ long tif_nextdiroff; /* file offset of following directory */ TIFFDirectory tif_dir; /* internal rep of current directory */ TIFFHeader tif_header; /* file's header block */ int const *tif_typeshift; /* data type shift counts */ long const *tif_typemask; /* data type masks */ long tif_row; /* current scanline */ int tif_curdir; /* current directory (index) */ int tif_curstrip; /* current strip for read/write */ long tif_curoff; /* current offset for read/write */ /* tiling support */ long tif_col; /* current column (offset by row too) */ int tif_curtile; /* current tile for read/write */ long tif_tilesize; /* # of bytes in a tile */ /* compression scheme hooks */ int (*tif_predecode)(); /* pre row/strip/tile decoding */ int (*tif_preencode)(); /* pre row/strip/tile encoding */ int (*tif_postencode)(); /* post row/strip/tile encoding */ int (*tif_decoderow)(); /* scanline decoding routine */ int (*tif_encoderow)(); /* scanline encoding routine */ int (*tif_decodestrip)(); /* strip decoding routine */ int (*tif_encodestrip)(); /* strip encoding routine */ int (*tif_decodetile)(); /* tile decoding routine */ int (*tif_encodetile)(); /* tile encoding routine */ int (*tif_close)(); /* cleanup-on-close routine */ int (*tif_seek)(); /* position within a strip routine */ int (*tif_cleanup)(); /* routine called to cleanup state */ char *tif_data; /* compression scheme private data */ /* input/output buffering */ int tif_scanlinesize; /* # of bytes in a scanline */ int tif_scanlineskew; /* scanline skew for reading strips */ char *tif_rawdata; /* raw data buffer */ long tif_rawdatasize; /* # of bytes in raw data buffer */ char *tif_rawcp; /* current spot in raw buffer */ long tif_rawcc; /* bytes unread from raw buffer */ #ifdef MMAP_SUPPORT char* tif_base; /* base of mapped file */ long tif_size; /* size of mapped file region (bytes) */ #endif }; #define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0) #ifdef MMAP_SUPPORT #define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0) #else #define isMapped(tif) 0 /* force dead code */ #endif /* generic option bit names */ #define TIFF_OPT0 0x1 #define TIFF_OPT1 0x2 #define TIFF_OPT2 0x4 #define TIFF_OPT3 0x8 #define TIFF_OPT4 0x10 #define TIFF_OPT5 0x20 #define TIFF_OPT6 0x40 #define TIFF_OPT7 0x80 #include "tiffio.h" /* NB: the u_int casts are to silence certain ANSI-C compilers */ #ifdef howmany #undef howmany #endif #define howmany(x, y) ((((u_int)(x))+(((u_int)(y))-1))/((u_int)(y))) #ifdef roundup #undef roundup #endif #define roundup(x, y) (howmany(x,y)*((u_int)(y))) #if defined(c_plusplus) || defined(__cplusplus) || defined(__STDC__) || USE_PROTOTYPES #if defined(__cplusplus) extern "C" { #endif extern TIFFFieldInfo const *TIFFFindFieldInfo(u_short, TIFFDataType); extern TIFFFieldInfo const *TIFFFieldWithTag(u_short); extern int _TIFFgetfield(TIFFDirectory*, int, ...); extern int TIFFNoRowEncode(TIFF*, u_char*, int, u_int); extern int TIFFNoStripEncode(TIFF*, u_char*, int, u_int); extern int TIFFNoTileEncode(TIFF*, u_char*, int, u_int); extern int TIFFNoRowDecode(TIFF*, u_char*, int, u_int); extern int TIFFNoStripDecode(TIFF*, u_char*, int, u_int); extern int TIFFNoTileDecode(TIFF*, u_char*, int, u_int); #if defined(__cplusplus) } #endif #else extern TIFFFieldInfo const *TIFFFindFieldInfo(); extern TIFFFieldInfo const *TIFFFieldWithTag(); extern int _TIFFgetfield(); extern int TIFFNoRowEncode(); extern int TIFFNoStripEncode(); extern int TIFFNoTileEncode(); extern int TIFFNoRowDecode(); extern int TIFFNoStripDecode(); extern int TIFFNoTileDecode(); #endif #endif /* _TIFFIOP_ */ ivtools-1.2.11a1/src/Time/000077500000000000000000000000001214471147700152125ustar00rootroot00000000000000ivtools-1.2.11a1/src/Time/Date.cc000066400000000000000000000306641214471147700164070ustar00rootroot00000000000000/* Date.c -- implementation of Gregorian calendar dates THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A "UNITED STATES GOVERNMENT WORK". IT WAS WRITTEN AS A PART OF THE AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE. THIS MEANS IT CANNOT BE COPYRIGHTED. THIS SOFTWARE IS FREELY AVAILABLE TO THE PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY. Author: Edward M. Persky Bg. 12A, Rm. 2031 Computer Systems Laboratory Division of Computer Research and Technology National Institutes of Health Bethesda, Maryland 20892 Phone: (301) 402-1818 uucp: uunet!nih-csl!tpersky Internet: tpersky@alw.nih.gov Function: Provides an object that contains a date, stored as a Julian Day Number. Note: Julian Day Number for Jan. 29, 1988 is not 88029; it is different. Log: Date.c,v * * Revision 3.15 92/12/19 15:52:57 sandy * removed extraneous semi-colon * * Revision 3.14 92/07/26 14:32:04 sandy * include directive in form '#include ' * * Revision 3.13 92/04/30 15:48:02 sandy * one initor in DEFINE_CLASS macros * * Revision 3.12 92/01/23 15:18:41 sandy * changed usage of ::time() in Date::Date() to use time_t * * Revision 3.11 91/08/15 09:27:04 tpersky * Changed Ted's phone no. * * Revision 3.10 91/02/18 21:06:08 kgorlen * Release for 3rd printing of 1st edition. * * Revision 3.3 91/02/18 13:31:07 kgorlen * Fix overflow in mdy() on 16-bit machines. * * Revision 3.2 91/02/05 13:08:17 kgorlen * Correct test for invalid monthNumber and weekDayNumber. * * Revision 3.1 90/12/22 08:45:09 kgorlen * ARM-compliant nested types. * * Revision 3.0 90/05/20 00:19:23 kgorlen * Release for 1st edition. * */ /* Modified by Vectaport, Inc. */ #include

{ if templ} template { endif} {if struct} struct {endif} {else} {if union} union {endif}{else} class {endelse} {endelse} {classlinked}{templ} {if parents} : {parents} {endif} {!autolink}(Return to index) {autolink}

{if brief}{brief}

{endif} Type:
    {if abstract}Abstract{endif}{else}Instantiable{endelse}

{if parents} Base Classes:
    {parents}

{endif} Derived Classes

{if hfile} Include file:

    {!autolink}{filter includeflt}{hfile}{endfilter}{autolink}

{endif} {if detail} Description:

{detail}

{endif}

{if public} Public:



{endif public} {if protected} Protected:



{endif protected} {if friend} Friend methods:



{endif friend} {!autolink}
(more documentation) {autolink}

ivtools-1.2.11a1/src/html/templates/bug_m.flt000066400000000000000000000003631214471147700210600ustar00rootroot00000000000000# PERL script to process bug remark description # Malcolm Wilkins 3.11.97 sub filter { local ($in) = @_; local ($start) = 'Known bugs:
    '; local ($end) = '
'; $str = $start.$in.$end; return $str; } ivtools-1.2.11a1/src/html/templates/dr_m.flt000066400000000000000000000003721214471147700207100ustar00rootroot00000000000000# PERL script to process design remark description # Malcolm Wilkins 3.11.97 sub filter { local ($in) = @_; local ($start) = 'Design remarks:
    '; local ($end) = '
'; $str = $start.$in.$end; return $str; } ivtools-1.2.11a1/src/html/templates/err_m.flt000066400000000000000000000003751214471147700210760ustar00rootroot00000000000000# PERL script to process error condition description # Malcolm Wilkins 3.11.97 sub filter { local ($in) = @_; local ($start) = 'Error condition:
    '; local ($end) = '
'; $str = $start.$in.$end; return $str; } ivtools-1.2.11a1/src/html/templates/in_m.flt000066400000000000000000000014611214471147700207110ustar00rootroot00000000000000# PERL script to process input argument lists # Malcolm Wilkins 3.11.97 sub filter { local ($in) = @_; local ($start) = 'Inputs:
    '; local ($end) = '
'; local ($key, $pname, $pdesc, $descriptions, $str); local (@words) = split (" ", $in); while (@words) { if ( ($key, ) = $words[0] =~ /(\w+):/ ) { if ($pname) { $descriptions .= "$pname:$pdesc"; } $pname=$key; $pdesc=""; } else { $pdesc .= $words [0] . " "; } shift @words; } if ($pname) { $descriptions .= "$pname:$pdesc"; } $str = $start.$descriptions.$end; return $str; } ivtools-1.2.11a1/src/html/templates/includeflt.flt000066400000000000000000000002431214471147700221150ustar00rootroot00000000000000 # PERL script to process include pathnames for ivtools. # Scott Johnston, Jan. 5th 1999 sub filter { local ($str)=@_; $str =~ s/include\///g; return $str } ivtools-1.2.11a1/src/html/templates/index.html.tmpl000066400000000000000000000014531214471147700222310ustar00rootroot00000000000000ivtools class index

back to ivtools doc page {foreach class} {next class}
ivtools class index
{classname}{templ} {brief}
Other Documented Items Other non-class items documented by PERCEPS
back to ivtools doc page ivtools-1.2.11a1/src/html/templates/linkflt.flt000066400000000000000000000002601214471147700214260ustar00rootroot00000000000000 # PERL script to remove whitespace from member names to generate link names # Malcolm Wilkins, Nov 4, 1997 sub filter { local ($str)=@_; $str =~ s/\s//g; return $str; } ivtools-1.2.11a1/src/html/templates/other.html.tmpl000066400000000000000000000023601214471147700222410ustar00rootroot00000000000000Other Documented Items

Other Documented Items



FUNCTIONS

    {foreach func}
    {type}{name}({args}) {if const}const{endif}{if throws} throws {throwclass}({throwargs}) {endif};
    {if brief} {brief}
    {endif} {if detail} {detail}
    {endif}

    {next}
GLOBALS

    {foreach global}
    {type}{name}{if enum} {lb}{args}{rb} {endif};
    {if brief} {brief}
    {endif} {if detail} {detail}
    {endif}

    {next}
TYPEDEFS

    {foreach typedef}
    {type}{name}{if enum} {lb}{args}{rb} {endif};
    {if brief} {brief}
    {endif} {if detail} {detail}
    {endif}

    {next}
MACROS

    {foreach macro}
    {name} : {args}
    {if brief} {brief}
    {endif} {if detail} {detail}
    {endif}

    {next}
ivtools-1.2.11a1/src/html/templates/out_m.flt000066400000000000000000000014631214471147700211140ustar00rootroot00000000000000# PERL script to process output argument lists # Malcolm Wilkins 3.11.97 sub filter { local ($in) = @_; local ($start) = 'Outputs:
    '; local ($end) = '
'; local ($key, $pname, $pdesc, $descriptions, $str); local (@words) = split (" ", $in); while (@words) { if ( ($key, ) = $words[0] =~ /(\w+):/ ) { if ($pname) { $descriptions .= "$pname:$pdesc"; } $pname=$key; $pdesc=""; } else { $pdesc .= $words [0] . " "; } shift @words; } if ($pname) { $descriptions .= "$pname:$pdesc"; } $str = $start.$descriptions.$end; return $str; } ivtools-1.2.11a1/src/html/templates/ret_m.flt000066400000000000000000000003611214471147700210730ustar00rootroot00000000000000# PERL script to process return type description # Malcolm Wilkins 3.11.97 sub filter { local ($in) = @_; local ($start) = 'Returns:
    '; local ($end) = '
'; $str = $start.$in.$end; return $str; } ivtools-1.2.11a1/src/html/templates/smindex.html.tmpl000066400000000000000000000003671214471147700225740ustar00rootroot00000000000000Example Class Index {foreach class} {classname}
{next class}
ivtools-1.2.11a1/src/html/templates/time.flt000066400000000000000000000001631214471147700207230ustar00rootroot00000000000000 sub filter { local($str)=@_; local ($day,$month,$date)=split(" ",$str); return "$month $date"; } ivtools-1.2.11a1/src/iclass/000077500000000000000000000000001214471147700155725ustar00rootroot00000000000000ivtools-1.2.11a1/src/iclass/classbuffer.cc000066400000000000000000000260751214471147700204120ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ClassBuffer implementation. */ #include "classbuffer.h" #include "classinfo.h" #include "direct.h" #include "globals.h" #include #include #include #include #define boolean _lib_os(boolean) #include #include #include #include #include #include #ifndef S_ISDIR #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) #endif /*****************************************************************************/ static const int MINTEXTSIZE = 10000; /*****************************************************************************/ class Classes { public: Classes(); ~Classes(); void Include(ClassInfo*); ClassInfo* Class(int index); ClassInfo* Find(const char* className); void Clear(); private: void Insert(ClassInfo*, int index); void Remove(int index); int Index(ClassInfo*); int Position(ClassInfo*); private: ClassInfo** _buf; int _bufsize; int _count; }; Classes::Classes () { const int defaultSize = 64; _bufsize = defaultSize; _buf = new ClassInfo*[_bufsize]; _count = 0; } Classes::~Classes () { Clear(); delete _buf; } void Classes::Include (ClassInfo* info) { Insert(info, Position(info)); } ClassInfo* Classes::Class (int index) { return (0 <= index && index < _count) ? _buf[index] : nil; } ClassInfo* Classes::Find (const char* className) { for (int i = 0; i < _count; ++i) { if (strcmp(className, _buf[i]->Name()) == 0) { return _buf[i]; } } return nil; } void Classes::Insert (ClassInfo* info, int index) { BufInsert(info, index, (const void**&) _buf, _bufsize, _count); } void Classes::Remove (int index) { if (0 <= index && index < _count) { BufRemove(index, (const void**) _buf, _count); } } int Classes::Index (ClassInfo* info) { for (int i = 0; i < _count; ++i) { if (info == _buf[i]) { return i; } } return -1; } int Classes::Position (ClassInfo* info) { for (int i = 0; i < _count; ++i) { if (strcmp(info->Name(), _buf[i]->Name()) < 0) { return i; } } return _count; } void Classes::Clear () { for (int i = 0; i < _count; ++i) { delete _buf[i]; } _count = 0; } /*****************************************************************************/ ClassBuffer::ClassBuffer ( boolean recursive, boolean verbose, boolean CPlusPlusFiles ) { _classes = new Classes; _recursive = recursive; _verbose = verbose; _CPlusPlusFiles = CPlusPlusFiles; } ClassBuffer::~ClassBuffer () { delete _classes; } const char* ClassBuffer::Class (int index) { ClassInfo* info = _classes->Class(index); return (info == nil) ? nil : info->Name(); } const char* ClassBuffer::Parent (const char* className, int index) { ClassInfo* info = _classes->Find(className); ClassInfo* parentInfo = (info == nil) ? nil : info->Parent(index); return (parentInfo == nil) ? nil : parentInfo->Name(); } const char* ClassBuffer::Child (const char* className, int index) { ClassInfo* info = _classes->Find(className); ClassInfo* childInfo = (info == nil) ? nil : info->Child(index); return (childInfo == nil) ? nil : childInfo->Name(); } const char* ClassBuffer::Path (const char* className) { ClassInfo* info = _classes->Find(className); return (info == nil) ? nil : info->Path(); } int ClassBuffer::LineNumber (const char* className) { ClassInfo* info = _classes->Find(className); return (info == nil) ? nil : info->LineNumber(); } ClassInfo* ClassBuffer::Info (const char* className) { return _classes->Find(className); } inline boolean DotOrDotDot (const char* dir) { return strcmp(dir, ".") == 0 || strcmp(dir, "..") == 0; } inline boolean HeaderFile (const char* file) { int length = strlen(file); return (file[length-1] == 'h' && file[length-2] == '.') || (file[length-1] == 'h' && file[length-2] == 'h' && file[length-3] == '.'); } inline boolean CPlusPlusFile (const char* file) { int length = strlen(file); return file[length-1] == 'C' && file[length-2] == '.'; } static boolean IsADirectory (const char* path, struct stat& filestats) { stat(path, &filestats); return S_ISDIR(filestats.st_mode); } void ClassBuffer::Search (const char* path) { struct stat filestats; if (IsADirectory(path, filestats)) { if (_recursive) { SearchDirs(path); } else { SearchDir(path); } } else if (HeaderFile(path) || (_CPlusPlusFiles && CPlusPlusFile(path))) { SearchFile(path, filestats); } } void ClassBuffer::SearchDir (const char* path) { Directory dir(path); if (_verbose) { printf("searching directory %s\n", path); } for (int i = 0; i < dir.Count(); ++i) { const char* file = dir.File(i); if (HeaderFile(file) || (_CPlusPlusFiles && CPlusPlusFile(path))) { struct stat filestats; char filePath[MAXPATHLEN+1]; strcpy(filePath, dir.Normalize(path)); strcat(filePath, file); if (!IsADirectory(filePath, filestats)) { SearchFile(filePath, filestats); } } } } void ClassBuffer::SearchDirs (const char* path) { Directory dir(path); if (_verbose) { printf("recursively searching directory %s\n", path); } for (int i = 0; i < dir.Count(); ++i) { const char* file = dir.File(i); if (!DotOrDotDot(file)) { char filePath[MAXPATHLEN+1]; strcpy(filePath, dir.Normalize(path)); strcat(filePath, file); Search(filePath); } } } #include #include #include void ClassBuffer::SearchFile (const char* path, struct stat&) { InputFile* f = InputFile::open(path); if (f == nil) { return; } const char* buf; int len = f->read(buf); if (len <= 0) { return; } if (_verbose) { printf("searching file %s (%d)\n", path, len); } /* * stupid regular expression requires writable strings to guarantee * null-termination */ char* tbuf = new char[len + 1]; Memory::copy(buf, tbuf, len); tbuf[len] = '\0'; TextBuffer textbuf(tbuf, len, len); SearchTextBuffer(&textbuf, path); delete tbuf; f->close(); delete f; } void ClassBuffer::SearchTextBuffer (TextBuffer* tb, const char* path) { int beg = 0; for (;;) { char* className = FindClassDecl(tb, beg); if (className == nil) { break; } ClassInfo* info = _classes->Find(className); if (info == nil) { info = new ClassInfo(className, path, tb->LineNumber(beg)); _classes->Include(info); } else { info->Path(path); info->LineNumber(tb->LineNumber(beg)); } for (;;) { char* parentName = ParentName(tb, beg); if (parentName == nil) { break; } ClassInfo* parentInfo = _classes->Find(parentName); if (parentInfo == nil) { parentInfo = new ClassInfo(parentName); _classes->Include(parentInfo); } info->IncludeParent(parentInfo); parentInfo->IncludeChild(info); delete parentName; } delete className; } } inline boolean KeyWord (const char* string) { return strcmp(string, "public") == 0 || strcmp(string, "protected") == 0 || strcmp(string, "private") == 0 || strcmp(string, "virtual") == 0; } char* ClassBuffer::ParentName (TextBuffer* tb, int& beg) { Regexp delimiter("{"); int delim = tb->ForwardSearch(&delimiter, beg); if (delim < 0) { return nil; } for (;;) { char* string = Identifier(tb, beg); if (string == nil || beg >= delim) { delete string; beg = delim; return nil; } else if (KeyWord(string)) { delete string; string = nil; } else { return string; } } } char* ClassBuffer::FindClassDecl (TextBuffer* tb, int& beg) { Regexp classKeyWord("^class[ $]"); Regexp delimiter("[:{;]"); char* className = nil; int obeg = beg; for (;;) { beg = tb->ForwardSearch(&classKeyWord, beg); if (beg < 0) { break; } int tmp = beg; int delim = tb->ForwardSearch(&delimiter, tmp); if (delim >= 0 && *tb->Text(delim-1) != ';') { className = Identifier(tb, beg); break; } } if (className && (strcmp(className, "VTK_EXPORT")==0||strcmp(className, "ACE_Export")==0)) { // retry this time skipping the extra token Regexp classKeyWord(strcmp(className, "VTK_EXPORT")==0 ? "^class VTK_EXPORT[ $]" : "^class ACE_Export[ $]"); Regexp delimiter("[:{;]"); beg = obeg; for (;;) { beg = tb->ForwardSearch(&classKeyWord, beg); if (beg < 0) { break; } int tmp = beg; int delim = tb->ForwardSearch(&delimiter, tmp); if (delim >= 0 && *tb->Text(delim-1) != ';') { className = Identifier(tb, beg); break; } } } return className; } inline boolean IsValidChar (char c) { return isalpha(c) || c == '_' || c == '$'; } char* ClassBuffer::Identifier (TextBuffer* tb, int& beg) { int i, j; const char* text = tb->Text(); char* string = nil; for (i = beg; i < tb->Length(); ++i) { if (IsValidChar(text[i])) { break; } } for (j = i+1; j < tb->Length(); ++j) { char c = text[j]; if (!IsValidChar(c) && !isdigit(c)) { break; } } if (j < tb->Length()) { string = strnnew(&text[i], j-i); beg = j; } return string; } ivtools-1.2.11a1/src/iclass/classbuffer.h000066400000000000000000000044041214471147700202440ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ClassBuffer - caches information about class hierarchies from header files. */ #ifndef classbuffer_h #define classbuffer_h #include #include #include #include class Classes; class ClassInfo; class TextBuffer; class ClassBuffer { public: ClassBuffer( boolean recursive = false, boolean verbose = false, boolean CPlusPlusFiles = false ); virtual ~ClassBuffer(); void Search(const char* path); const char* Class(int index); const char* Parent(const char* classname, int index = 0); const char* Child(const char*, int index = 0); const char* Path(const char*); int LineNumber(const char*); ClassInfo* Info(const char*); private: void SearchDir(const char* path); void SearchDirs(const char* path); void SearchFile(const char* path, struct stat&); void SearchTextBuffer(TextBuffer*, const char* path); char* FindClassDecl(TextBuffer*, int&); char* ParentName(TextBuffer*, int&); char* Identifier(TextBuffer*, int&); private: Classes* _classes; boolean _recursive, _verbose, _CPlusPlusFiles; }; #endif ivtools-1.2.11a1/src/iclass/classeditor.cc000066400000000000000000000117511214471147700204220ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ClassEditor implementation */ #include "classeditor.h" #include #include #include #include #include #include /*****************************************************************************/ static const char FirstLine = 'g'; static const char LastLine = 'G'; static const char NextLine = 'n'; static const char PrevLine= 'p'; static const char ScrollDown = 'j'; static const char ScrollUp = 'k'; static const char PageDown = ' '; static const char PageUp = 'b'; static const char HalfPageDown = 'd'; static const char HalfPageUp = 'u'; /*****************************************************************************/ ClassEditor::ClassEditor ( ButtonState* bs, int r, int c, int t, int h, const char* done ) : TextEditor(r, c, t, h) { Init(bs, done); } ClassEditor::ClassEditor ( ButtonState* bs, const char* name, int r, int c, int t, int h, const char* done ) : TextEditor(name, r, c, t, h) { Init(bs, done); } void ClassEditor::Init (ButtonState* bs, const char* done) { SetClassName("ClassEditor"); input = new Sensor; input->Catch(DownEvent); input->Catch(KeyEvent); _state = bs; _done = done; } void ClassEditor::ScrollBy (int lines) { TextEditor::ScrollBy(0, -lines*shape->vunits); // explicit TextEditor:: works around cfront 1.2 bug int line = text->LineNumber(Dot()); Coord b = display->Base(line); Coord t = display->Top(line); if (b < 0) { Select(Locate(0, 0)); } else if (t > ymax) { Select(Locate(0, ymax)); } } void ClassEditor::Handle (Event& e) { if (e.eventType == KeyEvent) { HandleKeyEvent(e); } else { boolean done = false; do { switch (e.eventType) { case DownEvent: done = HandleDownEvent(e); break; case KeyEvent: done = HandleKeyEvent(e); break; } if (!done) { Read(e); } } while (!done); } } boolean ClassEditor::HandleKeyEvent (Event& e) { boolean done = false; if (e.len != 0) { done = HandleChar(e.keystring[0]); } return done; } boolean ClassEditor::HandleDownEvent (Event& e) { boolean done = true; if (e.target == this) { switch (e.button) { case LEFTMOUSE: Select(Locate(e.x, e.y)); done = false; break; case MIDDLEMOUSE: GrabScroll(e); break; case RIGHTMOUSE: RateScroll(e); break; } } else { UnRead(e); } return done; } boolean ClassEditor::HandleChar (char c) { boolean done = false; int lines = display->LineNumber(0) - display->LineNumber(ymax) + 1; int i; switch (c) { case FirstLine: BeginningOfText(); ScrollToSelection(); break; case LastLine: EndOfText(); ScrollToSelection(); break; case PrevLine: BackwardLine(); ScrollToSelection(); break; case NextLine: ForwardLine(); ScrollToSelection(); break; case PageDown: ForwardPage(); ScrollToSelection(); break; case PageUp: BackwardPage(1); ScrollToSelection(); break; case HalfPageDown: ForwardLine(lines/2); ScrollToSelection(); break; case HalfPageUp: BackwardLine(lines/2); ScrollToSelection(); break; case ScrollDown: ScrollBy(1); break; case ScrollUp: ScrollBy(-1); break; default: for (i = 0; _done[i] != '\0'; ++i) { if (c == _done[i]) { _state->SetValue(c); done = true; } } break; } return done; } ivtools-1.2.11a1/src/iclass/classeditor.h000066400000000000000000000036211214471147700202610ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ClassEditor - edits a class definition */ #ifndef classeditor_h #define classeditor_h #include static const char* CEDone = "\r\t\007\033"; class ButtonState; class ClassEditor : public TextEditor { public: ClassEditor( ButtonState*, int rows, int cols, int tab, int highlight, const char* done = CEDone ); ClassEditor( ButtonState*, const char* name, int r, int c, int t, int h, const char* done = CEDone ); void ScrollBy(int lines); virtual void Handle(Event&); private: boolean HandleDownEvent(Event&); boolean HandleKeyEvent(Event&); boolean HandleChar(char); private: void Init(ButtonState*, const char*); private: const char* _done; ButtonState* _state; }; #endif ivtools-1.2.11a1/src/iclass/classinfo.cc000066400000000000000000000072451214471147700200720ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ClassInfo implementation. */ #include "classinfo.h" #include "globals.h" #include #include /*****************************************************************************/ ClassInfo::ClassInfo (const char* name, const char* path, int lineno) { const int defaultSize = 8; _name = strnew(name); _path = nil; _lineno = lineno; Path(path); _childbufsize = _parentbufsize = defaultSize; _childbuf = new ClassInfo*[_childbufsize]; _parentbuf = new ClassInfo*[_parentbufsize]; _childcount = _parentcount = 0; } ClassInfo::~ClassInfo () { delete _name; delete _path; delete _childbuf; delete _parentbuf; } void ClassInfo::Path (const char* path) { delete _path; _path = (path == nil) ? nil : strnew(path); } void ClassInfo::IncludeChild (ClassInfo* child) { Insert( child, Position(child, _childbuf, _childcount), _childbuf, _childbufsize, _childcount ); } void ClassInfo::IncludeParent (ClassInfo* parent) { Insert( parent, Position(parent, _parentbuf, _parentcount), _parentbuf, _parentbufsize, _parentcount ); } int ClassInfo::ChildIndex (const char* child) { return Index(child, _childbuf, _childcount); } int ClassInfo::ParentIndex (const char* parent) { return Index(parent, _parentbuf, _parentcount); } ClassInfo* ClassInfo::Child (int index) { return Info(index, _childbuf, _childcount); } ClassInfo* ClassInfo::Parent (int index) { return Info(index, _parentbuf, _parentcount); } void ClassInfo::Insert ( ClassInfo* info, int index, ClassInfo**& buf, int& bufsize, int& count ) { BufInsert(info, index, (const void**&) buf, bufsize, count); } void ClassInfo::Remove (int index, ClassInfo** buf, int& count) { if (0 <= index && index < count) { BufRemove(index, (const void**) buf, count); } } int ClassInfo::Index (const char* s, ClassInfo** buf, int count) { for (int i = 0; i < count; ++i) { if (strcmp(s, buf[i]->Name()) == 0) { return i; } } return -1; } ClassInfo* ClassInfo::Info (int index, ClassInfo** buf, int count) { return (0 <= index && index < count) ? buf[index] : nil; } int ClassInfo::Position (ClassInfo* info, ClassInfo** buf, int count) { for (int i = 0; i < count; ++i) { if (strcmp(info->Name(), buf[i]->Name()) < 0) { return i; } } return count; } void ClassInfo::Clear (ClassInfo** buf, int count) { for (int i = 0; i < count; ++i) { delete buf[i]; } count = 0; } ivtools-1.2.11a1/src/iclass/classinfo.h000066400000000000000000000047111214471147700177270ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ClassInfo - an object containing information about a class. */ #ifndef classinfo_h #define classinfo_h #include class ClassInfo { public: ClassInfo(const char* className, const char* path = "", int lineno = 1); ~ClassInfo(); const char* Name(); const char* Path(); void Path(const char*); int LineNumber(); void LineNumber(int); void IncludeChild(ClassInfo*); void IncludeParent(ClassInfo*); int ChildIndex(const char* child); int ParentIndex(const char* parent); ClassInfo* Child(int index); ClassInfo* Parent(int index); private: void Insert(ClassInfo*, int index, ClassInfo**&, int&, int&); void Remove(int index, ClassInfo**, int&); int Index(const char*, ClassInfo**, int); ClassInfo* Info(int index, ClassInfo**, int); int Position(ClassInfo*, ClassInfo**, int); void Clear(ClassInfo**, int); private: char* _name; char* _path; int _lineno; ClassInfo** _childbuf; int _childbufsize; int _childcount; ClassInfo** _parentbuf; int _parentbufsize; int _parentcount; }; inline const char* ClassInfo::Name () { return _name; } inline const char* ClassInfo::Path () { return _path; } inline int ClassInfo::LineNumber () { return _lineno; } inline void ClassInfo::LineNumber (int n) { _lineno = n; } #endif ivtools-1.2.11a1/src/iclass/dialogs.cc000066400000000000000000000235621214471147700175330ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Implementation of various dialogs boxes. */ #include "dialogs.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if !defined(AIXV3) && !defined(hpux) && !(defined(sun) && defined(__svr4__)) && !defined(sgi) && !defined(linux) /* sigh, not all systems have this prototype */ extern "C" { char* getcwd(char*, size_t); } #endif /*****************************************************************************/ static const float fspace = .375; // space in cm static const int MAX_PATH_LENGTH = 256; /*****************************************************************************/ BasicDialog::BasicDialog () : Dialog(new ButtonState, nil) { input = new Sensor; input->Catch(KeyEvent); } boolean BasicDialog::Accept () { Event e; int v = 0; state->SetValue(0); do { Read(e); if (e.target == nil) { break; } if (!KeyEquiv(e)) { Forward(e); } state->GetValue(v); } while (v == 0); return v == '\r'; } void BasicDialog::Forward (Event& e) { Coord x = e.x, y = e.y; e.target->GetRelative(x, y, this); if (x >= 0 && y >= 0 && x <= xmax && y <= ymax) { e.target->Handle(e); } } boolean BasicDialog::KeyEquiv (Event& e) { boolean keyEquiv = false; if (e.eventType == KeyEvent && e.len > 0) { char c = e.keystring[0]; if (c == '\r' || c == '\004' || c == '\007' || c == '\033') { state->SetValue(c); keyEquiv = true; } } return keyEquiv; } /*****************************************************************************/ AcknowledgeDialog::AcknowledgeDialog (const char* msg, const char* btnLbl) { int space = Math::round(fspace*ivcm); Insert( new MarginFrame( new VBox( new Message(msg), new VGlue(space), new HBox( new HGlue, new PushButton(btnLbl, state, '\r'), new HGlue ) ), space, space, 0 ) ); } void AcknowledgeDialog::Acknowledge () { Event e; int v = 0; state->SetValue(v); do { Read(e); if (e.target == nil) { break; } if (!KeyEquiv(e)) { Forward(e); } state->GetValue(v); } while (v == 0); } /*****************************************************************************/ ConfirmDialog::ConfirmDialog (const char* msg) { Insert(Interior(msg)); input = new Sensor(noEvents); input->Catch(KeyEvent); } inline boolean Confirmed (int v) { return v == 'y' || v == 'n' || v == '\007'; } char ConfirmDialog::Confirm () { Event e; int v = 0; state->SetValue(v); do { Read(e); if (e.target == nil) { break; } if (e.eventType == KeyEvent) { state->SetValue(e.keystring[0]); } else { Forward(e); } state->GetValue(v); } while (!Confirmed(v)); return v; } Interactor* ConfirmDialog::Interior (const char* msg) { const int space = Math::round(.5*ivcm); return new MarginFrame( new VBox( new HBox(new Message(msg), new HGlue), new VGlue(space), new HBox( new HGlue, new PushButton(" Yes ", state, 'y'), new HGlue(space, 0), new PushButton(" No ", state, 'n'), new HGlue(space, 0), new PushButton("Cancel", state, '\007'), new HGlue ) ), space, space/2, 0 ); } /*****************************************************************************/ StringDialog::StringDialog ( const char* msg, const char* sample, const char* confirmLbl ) { Init(msg, confirmLbl); _sedit->Message(sample); } StringDialog::StringDialog ( const char* msg, int width, const char* confirmLbl ) { Init(msg, confirmLbl, width); } void StringDialog::Select () { _sedit->Select(0, strlen(_sedit->Text())); } void StringDialog::Select (int pos) { _sedit->Select(pos); } void StringDialog::Select (int left, int right) { _sedit->Select(left, right);} void StringDialog::Init (const char* msg, const char* confirmLbl, int width) { int space = Math::round(fspace*ivcm); _sedit = new StringEditor(state, ""); HBox* framedSedit = new HBox; if (width == 0) { framedSedit->Insert(_sedit); } else { framedSedit->Insert(new HGlue); framedSedit->Insert( new VBox( new Frame(new MarginFrame(_sedit, 2)), new HGlue(width, 0, 0) ) ); framedSedit->Insert(new HGlue); } Insert( new MarginFrame( new VBox( new Message(msg), new VGlue(space), framedSedit, new VGlue(space), new HBox( new HGlue, new PushButton(" Cancel ", state, '\007'), new HGlue(space, 0), new PushButton(confirmLbl, state, '\r') ) ), space, space, 0 ) ); } const char* StringDialog::String () { return _sedit->Text(); } boolean StringDialog::Accept () { Event e; int v = 0; state->SetValue(0); Select(); _sedit->Edit(); for (;;) { state->GetValue(v); if (v != 0) { break; } Read(e); if (e.target == nil) { break; } if (!KeyEquiv(e)) { Forward(e); } } return v == '\r'; } /*****************************************************************************/ FileDialog::FileDialog ( const char* msg, const char* dir, const char* confirmLbl ) { int space = Math::round(fspace*ivcm); _browser = new FileBrowser(state, dir, 20, 35, false, Reversed,"\000\007"); _dirs = new FileBrowser( "dirBrowser", state, dir, 20, 24, true, Reversed,"d\007" ); _dirs->SetTextFilter("^$"); // show directories only _dirs->Update(); _cur_dir = new MarginFrame(new Message("path", FullPath(_dirs))); HBox* dirBox = new HBox( new Message("Directory: "), _cur_dir, new HGlue ); dirBox->Propagate(false); Insert( new MarginFrame( new VBox( new HBox( new VBox( new Message("Change directory to:", Left, 0, hfil), new Frame(AddScroller(_dirs)) ), new HGlue(space, 0), new VBox( new Message(msg, Left, 0, hfil), new Frame(AddScroller(_browser)) ) ), new VGlue(space, 0), dirBox, new VGlue(space, 0), new HBox( new HGlue, new PushButton(" Cancel ", state, '\007'), new HGlue(space, 0), new PushButton(confirmLbl, state, '\r') ) ), space, space, 0 ) ); } Interactor* FileDialog::AddScroller (Interactor* i) { return new HBox( new MarginFrame(i, 2), new VBorder, new VScrollBar(i) ); } boolean FileDialog::Accept () { Event e; int v = 0; state->SetValue(0); do { Read(e); if (e.target == nil) { break; } if (!KeyEquiv(e)) { Forward(e); } state->GetValue(v); if (v == 'd') { if (_dirs->Selections() > 0) { int sel = _dirs->Selection(); char path[MAX_PATH_LENGTH]; strcpy(path, _dirs->Path(sel)); _browser->SetDirectory(path); _dirs->SetDirectory(path); Message* path_msg = new Message("path", FullPath(_dirs)); _cur_dir->Insert(path_msg); _cur_dir->Change(path_msg); } state->SetValue(0); v = 0; } } while (v == 0); return v == '\r'; } const char* FileDialog::FullPath (const char* relpath) { return FullPath(_dirs, relpath); } const char* FileDialog::FullPath (FileBrowser* fb, const char* rp) { const char* relpath = (rp == nil) ? fb->GetDirectory() : rp; char path[MAX_PATH_LENGTH]; getcwd(path, sizeof(path) - strlen(relpath) - 1); strcat(path, "/"); strcat(path, relpath); return fb->Normalize(path); } ivtools-1.2.11a1/src/iclass/dialogs.h000066400000000000000000000054641214471147700173760ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Various dialog boxes. */ #ifndef dialogs_h #define dialogs_h #include class FileBrowser; class MarginFrame; class StringEditor; class BasicDialog : public Dialog { public: BasicDialog(); virtual boolean Accept(); protected: void Forward(Event&); boolean KeyEquiv(Event&); }; class AcknowledgeDialog : public BasicDialog { public: AcknowledgeDialog(const char* msg, const char* btnLbl = " OK "); virtual void Acknowledge(); }; class ConfirmDialog : public BasicDialog { public: ConfirmDialog(const char* title); virtual char Confirm(); private: Interactor* Interior(const char*); }; class StringDialog : public BasicDialog { public: StringDialog( const char* msg, const char* sample = "", const char* confirmLbl = " OK " ); StringDialog( const char* msg, int width, const char* confirmLbl = " OK " ); const char* String(); void Select(); void Select(int); void Select(int, int); virtual boolean Accept(); private: void Init(const char*, const char*, int width = 0); private: StringEditor* _sedit; }; class FileDialog : public BasicDialog { public: FileDialog( const char* msg, const char* dir = "~", const char* confirmLbl = " OK " ); FileBrowser* GetBrowser(); const char* FullPath(const char* relpath); virtual boolean Accept(); private: Interactor* AddScroller(Interactor*); const char* FullPath(FileBrowser*, const char* relpath = nil); private: FileBrowser* _browser; FileBrowser* _dirs; MarginFrame* _cur_dir; }; inline FileBrowser* FileDialog::GetBrowser () { return _browser; } #endif ivtools-1.2.11a1/src/iclass/direct.cc000066400000000000000000000161331214471147700173570ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Directory object implementation. */ #include "direct.h" #include "globals.h" #include #include #include #include #include #include #include #include #include #ifdef __DECCXX extern "C" { extern uid_t getuid(); extern struct passwd* getpwuid(uid_t); } #endif #undef File #undef Directory #define SysDir _lib_os(Directory) class DirectoryRep { private: friend class Directory; SysDir* dir; }; static const int MAX_PATH_LENGTH = 256; /*****************************************************************************/ Directory::Directory (const char* name) { rep_ = new DirectoryRep; rep_->dir = nil; LoadDirectory(name); } Directory::~Directory () { delete rep_->dir; delete rep_; } const char* Directory::RealPath (const char* path) { const char* realpath; if (*path == '\0') { realpath = "./"; } else { realpath = InterpTilde(InterpSlashSlash(path)); } return realpath; } boolean Directory::LoadDirectory (const char* name) { char buf[MAX_PATH_LENGTH+2]; const char* path = buf; strcpy(buf, ValidDirectories(RealPath(name))); return Reset(buf); } int Directory::Index (const char* name) { _lib_os(String) s(name); return rep_->dir == nil ? -1 : rep_->dir->index(s); } boolean Directory::Reset (char* path) { SysDir* d = SysDir::open(_lib_os(String)(path)); if (d != nil) { delete rep_->dir; rep_->dir = d; return true; } return false; } boolean Directory::IsADirectory (const char* path) { struct stat filestats; stat(path, &filestats); return filestats.st_mode & S_IFDIR; } int Directory::Count() { return rep_->dir == nil ? 0 : rep_->dir->count(); } const char* Directory::File(int index) { if (rep_->dir == nil) { return nil; } const _lib_os(String)* s = rep_->dir->name(index); if (s == nil) { return nil; } return s->string(); } const char* Directory::Home (const char* name) { struct passwd* pw = (name == nil) ? getpwuid(getuid()) : getpwnam(name); return (pw == nil) ? nil : pw->pw_dir; } inline boolean DotSlash (const char* path) { return path[0] != '\0' && path[0] == '.' && (path[1] == '/' || path[1] == '\0'); } inline boolean DotDotSlash (const char* path) { return path[0] != '\0' && path[1] != '\0' && path[0] == '.' && path[1] == '.' && (path[2] == '/' || path[2] == '\0'); } const char* Directory::Normalize (const char* path) { static char newpath[MAX_PATH_LENGTH+1]; const char* buf; buf = InterpSlashSlash(path); buf = ElimDot(buf); buf = ElimDotDot(buf); buf = InterpTilde(buf); if (*buf == '\0') { strcpy(newpath, "./"); } else if (!DotSlash(buf) && !DotDotSlash(buf) && *buf != '/') { strcpy(newpath, "./"); strcat(newpath, buf); } else { strcpy(newpath, buf); } if (IsADirectory(newpath) && newpath[strlen(newpath)-1] != '/') { strcat(newpath, "/"); } return newpath; } const char* Directory::ValidDirectories (const char* path) { static char buf[MAX_PATH_LENGTH+1]; strcpy(buf, path); int i = strlen(path); while (!IsADirectory(RealPath(buf)) && i >= 0) { for (--i; buf[i] != '/' && i >= 0; --i); buf[i+1] = '\0'; } return buf; } const char* Directory::InterpSlashSlash (const char* path) { for (int i = strlen(path)-1; i > 0; --i) { if (path[i] == '/' && path[i-1] == '/') { return &path[i]; } } return path; } const char* Directory::ElimDot (const char* path) { static char newpath[MAX_PATH_LENGTH+1]; const char* src; char* dest = newpath; for (src = path; src < &path[strlen(path)]; ++src) { if (!DotSlash(src)) { *dest++ = *src; } else if (*(dest-1) == '/') { ++src; } else { *dest++ = *src; } } *dest = '\0'; return newpath; } static boolean CollapsedDotDotSlash (char* path, char*& start) { if (path == start || *(start-1) != '/') { return false; } else if (path == start-1 && *path == '/') { return true; } else if (path == start-2) { // NB: won't handle '//' right start = path; return *start != '.'; } else if (path < start-2 && !DotDotSlash(start-3)) { for (start -= 2; path <= start; --start) { if (*start == '/') { ++start; return true; } } start = path; return true; } return false; } const char* Directory::ElimDotDot (const char* path) { static char newpath[MAX_PATH_LENGTH+1]; const char* src; char* dest = newpath; for (src = path; src < &path[strlen(path)]; ++src) { if (DotDotSlash(src) && CollapsedDotDotSlash(newpath, dest)) { src += 2; } else { *dest++ = *src; } } *dest = '\0'; return newpath; } const char* Directory::InterpTilde (const char* path) { static char realpath[MAX_PATH_LENGTH+1]; const char* beg = strrchr(path, '~'); boolean validTilde = beg != nil && (beg == path || *(beg-1) == '/'); if (validTilde) { const char* end = strchr(beg, '/'); int length = (end == nil) ? strlen(beg) : end - beg; const char* expandedTilde = ExpandTilde(beg, length); if (expandedTilde == nil) { validTilde = false; } else { strcpy(realpath, expandedTilde); if (end != nil) { strcat(realpath, end); } } } return validTilde ? realpath : path; } const char* Directory::ExpandTilde (const char* tildeName, int length) { const char* name = nil; if (length > 1) { static char buf[MAX_PATH_LENGTH+1]; strncpy(buf, tildeName+1, length-1); buf[length-1] = '\0'; name = buf; } return Home(name); } ivtools-1.2.11a1/src/iclass/direct.h000066400000000000000000000037361214471147700172260ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Directory - a class interface to Unix directory operations. */ #ifndef direct_h #define direct_h #include class DirectoryRep; class Directory { public: Directory(const char* name); ~Directory(); boolean LoadDirectory(const char*); const char* Normalize(const char*); const char* ValidDirectories(const char*); int Index(const char*); const char* File(int index); int Count(); boolean IsADirectory(const char*); private: const char* Home(const char* = nil); const char* ElimDot(const char*); const char* ElimDotDot(const char*); const char* InterpSlashSlash(const char*); const char* InterpTilde(const char*); const char* ExpandTilde(const char*, int); const char* RealPath(const char*); boolean Reset(char*); private: DirectoryRep* rep_; }; #endif ivtools-1.2.11a1/src/iclass/globals.cc000066400000000000000000000057651214471147700175410ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Implementation of global definitions. */ #include "globals.h" #include #include #include #include /*****************************************************************************/ #if 0 char* strnew (const char* s) { char* dup = new char[strlen(s) + 1]; strcpy(dup, s); return dup; } #endif char* strnnew (const char* s, int len) { char* dup = new char[len + 1]; strncpy(dup, s, len); dup[len] = '\0'; return dup; } void BufCheck (const void**& buf, int& bufsize, int count, int index) { void** newbuf; if (index >= bufsize) { int length = count*sizeof(void*); bufsize = (index+1) * 2; newbuf = new void*[bufsize]; Memory::copy(buf, newbuf, length); delete buf; buf = (const void**)newbuf; } } void BufInsert ( const void* s, int index, const void**& buf, int& bufsize, int& count ) { const void** spot; index = (index < 0) ? count : index; if (index < count) { BufCheck(buf, bufsize, count, count+1); spot = &buf[index]; Memory::copy(spot, spot+1, (count - index)*sizeof(void*)); } else { BufCheck(buf, bufsize, count, index); spot = &buf[index]; } *spot = s; ++count; } void BufRemove (int index, const void** buf, int& count) { if (index < --count) { const void** spot = &buf[index]; Memory::copy(spot+1, spot, (count - index)*sizeof(void*)); } } int BufFind ( int index, const void** srcbuf, int srccount, const void** dstbuf, int dstcount ) { if (0 <= index && index < srccount) { const void* s = srcbuf[index]; if (s != nil) { for (int i = 0; i < dstcount; ++i) { if (dstbuf[i] == s) { return i; } } } } return -1; } ivtools-1.2.11a1/src/iclass/globals.h000066400000000000000000000031721214471147700173710ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Global definitions. */ #ifndef globals_h #define globals_h extern char* strnew(const char*); extern char* strnnew(const char*, int); extern void BufCheck(const void**& buf, int& bufsize, int count, int index); extern void BufInsert( const void* s, int index, const void**& buf, int& bufsize, int& count ); extern void BufRemove(int index, const void** buf, int& count); extern int BufFind ( int index, const void** srcbuf, int srccount, const void** dstbuf, int dstcount ); #endif ivtools-1.2.11a1/src/iclass/iclass.cc000066400000000000000000000423341214471147700173650ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * IClass implementation. */ #include "classbuffer.h" #include "classeditor.h" #include "classinfo.h" #include "dialogs.h" #include "globals.h" #include "iclass.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ static const float fspace = .375; // space in cm static const char* NONE = ""; static const int BUFFERSIZE = 100; static const int FILENAMESIZE = 100; static const int MINTEXTSIZE = 10000; #define BSRCH_LBL "^R" #define BSRCH_CODE '\022' #define FSRCH_LBL "^S" #define FSRCH_CODE '\023' #define GOTO_LBL "^N" #define GOTO_CODE '\016' #define QUIT_LBL "^Q" #define QUIT_CODE '\021' #define SCAN_LBL "^V" #define SCAN_CODE '\026' #define CLEAR_LBL "^C" #define CLEAR_CODE '\003' /*****************************************************************************/ class Command : public MenuItem { public: Command(const char* lbl, const char* klbl, char kcode, IClass*); virtual void Do(); private: IClass* _iclass; char _kcode; }; Command::Command ( const char* lbl, const char* klbl, char kcode, IClass* s ) : MenuItem((Interactor*) nil) { Insert( new HBox( new Message(lbl, Left, 2, hfil), new Message(" ", Center, 2, hfil), new Message(klbl, Right, 2, hfil) ) ); _iclass = s; _kcode = kcode; } void Command::Do () { _iclass->Command(_kcode); } struct MenuInfo { const char* _lbl; const char* _klbl; char _kcode; }; /*****************************************************************************/ IClass::IClass (ClassBuffer* cb) { SetClassName("IClass"); Init(cb); Visit(""); _editor->Edit(_text); } IClass::~IClass () { delete _cbuf; delete _buf; delete _text; delete _lastFile; _state->Detach(this); Unref(_state); if (_scanner != nil) delete _scanner; if (_fwdSearch != nil) delete _fwdSearch; if (_bwdSearch != nil) delete _bwdSearch; if (_goto != nil) delete _goto; if (_completions != nil) delete _completions; } void IClass::Init (ClassBuffer* cb) { _cbuf = cb; _state = new ButtonState; _state->Attach(this); _curClass = new CompletionEditor(_state, ""); _focus = _curClass; _classes = new StringBrowser(_state, 5, 24); _parents = new StringBrowser(_state, 2, 24); _children = new StringBrowser(_state, 5, 24); _fileIndic = new MarginFrame(new Message("testing")); _editor = new ClassEditor(_state, 24, 80, 8, Reversed); _editor->SetScrollAlignment(TopLeft); _scanner = new FileDialog("Scan through files/directories:", "."); _fwdSearch = nil; _bwdSearch = nil; _goto = nil; _buf = nil; _text = nil; _lastFile = nil; _completions = nil; input = new Sensor; input->Catch(KeyEvent); Insert(Interior()); UpdateClassesBrowser(); } void IClass::Visit (const char* filename) { if (_lastFile == nil || strcmp(_lastFile, filename) != 0) { class Message* msg = new Message(_scanner->FullPath(filename)); _fileIndic->Insert(msg); _fileIndic->Change(msg); delete _lastFile; _lastFile = strnew(filename); delete _buf; delete _text; FILE* f = nil; if (strlen(filename) != 0) { /* cast to work around bug in prototype on some systems */ f = fopen((char*)filename, "r"); } if (f != nil) { struct stat filestats; stat(filename, &filestats); _bufsize = max(Math::round(filestats.st_size * 1.2), MINTEXTSIZE); _buf = new char[_bufsize]; char* b = _buf; int remaining = _bufsize; while (remaining > 1 && fgets(b, remaining, f) != nil) { int l = strlen(b); remaining -= l; b += l; } fclose(f); _text = new TextBuffer(_buf, b-_buf, _bufsize); } else { _bufsize = MINTEXTSIZE; _buf = new char[_bufsize]; _text = new TextBuffer(_buf, 0, _bufsize); } } } void IClass::Run () { Event e; int value; do { Read(e); if (e.target == nil) { /* probably quit from window manager */ break; } Handle(e); _state->GetValue(value); } while (value != QUIT_CODE); } void IClass::Handle (Event& e) { if (e.eventType == KeyEvent && e.len > 0) { char c = e.keystring[0]; if (!Command(c)) { _focus->Handle(e); } } else if (e.target != this && e.eventType != KeyEvent) { boolean focusable = e.target == _classes || e.target == _parents || e.target == _children || e.target == _editor; if (focusable && e.button == LEFTMOUSE) { UnselectCurClass(); UnselectBrowsers(); _focus = e.target; } e.target->Handle(e); } } boolean IClass::Command (char c) { boolean executed = true; switch (c) { case BSRCH_CODE: BackwardSearchCmd(); break; case FSRCH_CODE: ForwardSearchCmd(); break; case GOTO_CODE: GotoCmd(); break; case QUIT_CODE: QuitCmd(); break; case SCAN_CODE: ScanCmd(); break; case CLEAR_CODE: ClearCmd(); break; default: executed = false; break; } return executed; } boolean IClass::ForwardSearch (const char* string) { Regexp re(string); boolean successful = false; if ( _text->ForwardSearch(&re, _editor->Dot()) >= 0 || _text->ForwardSearch(&re, _text->BeginningOfText()) >= 0 ) { _editor->Select(re.EndOfMatch(), re.BeginningOfMatch()); successful = true; } return successful; } boolean IClass::BackwardSearch (const char* string) { Regexp re(string); boolean successful = false; if ( _text->BackwardSearch(&re, _editor->Mark()) >= 0 || _text->BackwardSearch(&re, _text->EndOfText()) >= 0 ) { _editor->Select(re.EndOfMatch(), re.BeginningOfMatch()); successful = true; } return successful; } void IClass::UnselectBrowsers () { int index; if ((index = _classes->Selection()) >= 0) { _classes->UnselectAll(); } else if ((index = _parents->Selection()) >= 0) { _parents->UnselectAll(); } else if ((index = _children->Selection()) >= 0) { _children->UnselectAll(); } } void IClass::Update () { int value; _state->GetValue(value); if (value == '\r') { UpdateCurClass(); UpdateParentBrowser(); UpdateChildBrowser(); } else if (value == '\t' || value == '\033') { SelectCurClass(); _focus = _curClass; } else if (value == '\007') { Complain(); } if (value != QUIT_CODE) { UnselectBrowsers(); _state->SetValue('\0'); } } void IClass::UpdateCurClass () { int index; if ((index = _classes->Selection()) >= 0) { UpdateCurClass(_classes->String(index)); } else if ((index = _parents->Selection()) >= 0) { UpdateCurClass(_parents->String(index)); } else if ((index = _children->Selection()) >= 0) { UpdateCurClass(_children->String(index)); } else { UpdateCurClass(_curClass->Text()); } } void IClass::UpdateCurClass (const char* string) { if (strcmp(string, NONE) != 0) { if (strcmp(string, _curClass->Text()) != 0) { _curClass->Message(string); } ClassInfo* info = _cbuf->Info(string); if (info == nil) { SelectCurClass(); Complain(); } else { Visit(info->Path()); int line = info->LineNumber(); _editor->Edit(_text, _text->LineIndex(line)); ForwardSearch(info->Name()); boolean backward_success = BackwardSearch("//: "); _editor->ScrollToSelection(); if (backward_success) ForwardSearch(info->Name()); _focus = _editor; } } } void IClass::UpdateClassesBrowser () { const char* className; int i = 0; _classes->Clear(); int count = 0; for (;;) { className = _cbuf->Class(i++); if (className == nil) { break; } else { _classes->Append(className); ++count; } } if (_completions != nil) { delete _completions; } _completions = new const char*[count]; for (i = 0; i < count; ++i) { _completions[i] = _cbuf->Class(i); } _curClass->Completions(_completions, count); } void IClass::UpdateParentBrowser () { const char* parent; int i = 0; _parents->Clear(); for (;;) { parent = _cbuf->Parent(_curClass->Text(), i++); if (parent == nil) { if (i == 1) { _parents->Append(NONE); } break; } else { _parents->Append(parent); } } } void IClass::UpdateChildBrowser () { const char* child; int i = 0; _children->Clear(); for (;;) { child = _cbuf->Child(_curClass->Text(), i++); if (child == nil) { if (i == 1) { _children->Append(NONE); } break; } else { _children->Append(child); } } } void IClass::SelectCurClass () { _curClass->Select(0, strlen(_curClass->Text())); } void IClass::UnselectCurClass () { _curClass->Select(strlen(_curClass->Text())); } Interactor* IClass::Interior () { int space = Math::round(fspace*ivcm); const char* showButton = GetAttribute("showButton"); Interactor* selector = SelectedClass(); if (showButton != nil && strcmp(showButton, "true") == 0) { selector = new HBox( selector, new HGlue(space, space, 0), new PushButton(" Show ", _state, '\r') ); } return new VBox( new HBox(Commands(), new HGlue), new HBorder, new MarginFrame( new VBox( new HBox( Classes(), new HGlue(space, space, 0), new VBox( selector, new VGlue(space, space, 0), Parents(), new VGlue(space, space, 0), Children() ) ), new VGlue(space, space, 0), Editor() ), space, space, 0 ) ); } static MenuInfo fileMenu[] = { { "Scan Files/Directories...", SCAN_LBL, SCAN_CODE }, { "Clear Classes", CLEAR_LBL, CLEAR_CODE }, { "Quit", QUIT_LBL, QUIT_CODE }, { nil } }; static MenuInfo searchMenu[] = { { "Forward Search...", FSRCH_LBL, FSRCH_CODE }, { "Backward Search...", BSRCH_LBL, BSRCH_CODE }, { "Go to Line...", GOTO_LBL, GOTO_CODE }, { nil } }; static PulldownMenu* MakePulldown( const char* name, MenuInfo* item, IClass* ic ) { PulldownMenu* menu = new PulldownMenu( new Message(name, Left, Math::round(.1*ivcm)) ); for (MenuInfo* i = item; i->_lbl != nil; i++) { menu->Include(new Command(i->_lbl, i->_klbl, i->_kcode, ic)); } return menu; } Interactor* IClass::Commands () { MenuBar* menuBar = new MenuBar; menuBar->Include(MakePulldown("File", fileMenu, this)); menuBar->Include(MakePulldown("Search", searchMenu, this)); return menuBar; } Interactor* IClass::Classes () { return new VBox( new HBox( new Message("classes"), new HGlue ), new Frame( AddScroller(_classes) ) ); } Interactor* IClass::SelectedClass () { return new VBox( new HBox( new Message("selected class"), new HGlue ), new Frame(new MarginFrame(_curClass, 2)) ); } Interactor* IClass::Parents () { return new VBox( new HBox( new Message("parents"), new HGlue ), new Frame(AddScroller(_parents)) ); } Interactor* IClass::Children () { return new VBox( new HBox( new Message("children"), new HGlue ), new Frame(AddScroller(_children)) ); } Interactor* IClass::Editor () { HBox* fileBox = new HBox( new Message("file: "), _fileIndic, new HGlue ); fileBox->Propagate(false); return new VBox( fileBox, new Frame(AddScroller(_editor)) ); } Interactor* IClass::AddScroller (Interactor* i) { return new HBox( new MarginFrame(i, 2), new VBorder, new VScrollBar(i) ); } void IClass::InsertDialog (Interactor* dialog) { World* world = GetWorld(); Coord x, y; Align(Center, 0, 0, x, y); GetRelative(x, y, world); world->InsertTransient(dialog, this, x, y, Center); } void IClass::RemoveDialog (Interactor* dialog) { GetWorld()->Remove(dialog); } void IClass::Complain (const char* msg) { if (msg == nil) { fprintf(stderr, "%c", '\007'); } else { AcknowledgeDialog complaint(msg); InsertDialog(&complaint); complaint.Acknowledge(); RemoveDialog(&complaint); } } void IClass::ScanCmd () { InsertDialog(_scanner); if (_scanner->Accept()) { FileBrowser* browser = _scanner->GetBrowser(); for (int i = 0; i < browser->Selections(); ++i) { int index = browser->Selection(i); _cbuf->Search(browser->Path(index)); } } RemoveDialog(_scanner); UpdateClassesBrowser(); } void IClass::ClearCmd () { ConfirmDialog dialog("Really clear all classes?"); InsertDialog(&dialog); boolean accepted = dialog.Confirm() == 'y'; RemoveDialog(&dialog); if (accepted) { World* world = GetWorld(); const char* recursive = world->GetAttribute("recursive"); const char* verbose = world->GetAttribute("verbose"); const char* CPlusPlusFiles = world->GetAttribute("CPlusPlusFiles"); delete _cbuf; _cbuf = new ClassBuffer( strcmp(recursive, "true") == 0, strcmp(verbose, "true") == 0, strcmp(CPlusPlusFiles, "true") == 0 ); UpdateClassesBrowser(); UpdateParentBrowser(); UpdateChildBrowser(); } } void IClass::QuitCmd () { _state->SetValue(QUIT_CODE); } void IClass::ForwardSearchCmd () { if (_fwdSearch == nil) { _fwdSearch = new StringDialog("Search forward for: ", Math::round(3*ivinches)); } InsertDialog(_fwdSearch); if (_fwdSearch->Accept()) { if (ForwardSearch(_fwdSearch->String())) { _editor->ScrollToSelection(); } else { Complain(); } } RemoveDialog(_fwdSearch); } void IClass::BackwardSearchCmd () { if (_bwdSearch == nil) { _bwdSearch = new StringDialog("Search backward for:", Math::round(3*ivinches)); } InsertDialog(_bwdSearch); if (_bwdSearch->Accept()) { if (BackwardSearch(_bwdSearch->String())) { _editor->ScrollToSelection(); } else { Complain(); } } RemoveDialog(_bwdSearch); } void IClass::GotoCmd () { if (_goto == nil) { int width = output->GetFont()->Width("9999999"); _goto = new StringDialog("Go to line:", width); } InsertDialog(_goto); if (_goto->Accept()) { const char* string = _goto->String(); int line = atoi(string); _editor->Select(_text->LineIndex(line-1)); _editor->ScrollToSelection(); } RemoveDialog(_goto); } ivtools-1.2.11a1/src/iclass/iclass.h000066400000000000000000000057121214471147700172260ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * IClass - interface to choosing classes. */ #ifndef iclass_h #define iclass_h #include class ButtonState; class ClassBuffer; class ClassEditor; class CompletionEditor; class FileDialog; class MarginFrame; class StringBrowser; class StringDialog; class TextBuffer; class IClass : public MonoScene { public: IClass(ClassBuffer*); virtual ~IClass(); void Run(); boolean Command(char); void ScanCmd(); void ClearCmd(); void QuitCmd(); void ForwardSearchCmd(); void BackwardSearchCmd(); void GotoCmd(); virtual void Handle(Event&); virtual void Update(); private: void Init(ClassBuffer*); Interactor* Commands(); Interactor* Classes(); Interactor* SelectedClass(); Interactor* Parents(); Interactor* Children(); Interactor* Editor(); Interactor* Interior(); Interactor* AddScroller(Interactor*); void InsertDialog(Interactor*); void RemoveDialog(Interactor*); void Visit(const char*); void Complain(const char* = nil); boolean ForwardSearch(const char*); boolean BackwardSearch(const char*); void UpdateClassesBrowser(); void UpdateParentBrowser(); void UpdateChildBrowser(); void UpdateCurClass(); void UpdateCurClass(const char*); void UnselectBrowsers(); void SelectCurClass(); void UnselectCurClass(); private: ButtonState* _state; ClassBuffer* _cbuf; CompletionEditor* _curClass; Interactor* _focus; StringBrowser* _classes; StringBrowser* _children; StringBrowser* _parents; MarginFrame* _fileIndic; FileDialog* _scanner; StringDialog* _fwdSearch; StringDialog* _bwdSearch; StringDialog* _goto; TextBuffer* _text; ClassEditor* _editor; const char** _completions; char* _lastFile; char* _buf; int _bufsize; }; #endif ivtools-1.2.11a1/src/iclass/main.cc000066400000000000000000000127151214471147700170330ustar00rootroot00000000000000/* * Copyright (c) 1989 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * InterViews class browser main program. */ #include "classbuffer.h" #include "iclass.h" #include #include #include #include #include #include #include using std::cout; /*****************************************************************************/ static PropertyData properties[] = { { "*Message*font", "*helvetica-bold-r-normal--10*" }, { "*Dialog*Message*font", "*helvetica-bold-r-normal--12*" }, { "*path*font", "*helvetica-bold-r-normal--12*" }, { "*PulldownMenu*Message*font", "*helvetica-bold-r-normal--12*" }, { "*PushButton*font", "*helvetica-bold-r-normal--12*" }, { "*StringBrowser*font", "*helvetica-bold-r-normal--10*" }, { "*dirBrowser*font", "*helvetica-bold-r-normal--10*" }, { "*StringEditor*font", "*helvetica-bold-r-normal--10*" }, { "*recursive", "false" }, { "*verbose", "false" }, { "*CPlusPlusFiles", "false" }, { "*DerivedClassGraph", "false" }, { "*DerivedClassTree", "false" }, { "*showButton", "true" }, { "*dirBrowser*singleClick", "on" }, { nil } }; static OptionDesc options[] = { { "-r", "*recursive", OptionValueImplicit, "true" }, { "-v", "*verbose", OptionValueImplicit, "true" }, { "-c", "*CPlusPlusFiles", OptionValueImplicit, "true" }, { "-d", "*DerivedClassGraph", OptionValueImplicit, "true" }, { "-t", "*DerivedClassTree", OptionValueImplicit, "true" }, { nil } }; /*****************************************************************************/ void print_class_subtree(ostream& out, ClassBuffer* cbuffer, const char* classname, int depth) { for(int i=0; i" << classname << "
\n"; const char* childname; char* prevname=strdup(""); int childindex=0; while (childname = cbuffer->Child(classname, childindex)) { if (strcmp(prevname, childname)!=0) print_class_subtree(out, cbuffer, childname, depth+1); delete prevname; prevname = strdup(childname); childindex++; } } /*****************************************************************************/ int main (int argc, char** argv) { World world("iclass", argc, argv, options, properties); const char* recursive = world.GetAttribute("recursive"); const char* verbose = world.GetAttribute("verbose"); const char* CPlusPlusFiles = world.GetAttribute("CPlusPlusFiles"); const char* DerivedClassGraph = world.GetAttribute("DerivedClassGraph"); const char* DerivedClassTree = world.GetAttribute("DerivedClassTree"); ClassBuffer* buffer = new ClassBuffer( strcmp(recursive, "true") == 0, strcmp(verbose, "true") == 0, strcmp(CPlusPlusFiles, "true") == 0 ); for (int i = 1; i < argc; ++i) { buffer->Search(argv[i]); } if (strcmp(DerivedClassGraph, "true")==0) { const char* classname; int classindex = 0; while (classname = buffer->Class(classindex)) { classindex++; cout << "" << classname << ":
\n"; const char* childname; char* prevname=strdup(""); int childindex = 0; while (childname = buffer->Child(classname, childindex)) { childindex++; if (strcmp(prevname, childname)!=0) cout << "
  • " << childname << "
  • \n"; delete prevname; prevname = strdup(childname); } cout << "

    \n"; } return 0; } if (strcmp(DerivedClassTree, "true")==0) { const char* classname; int classindex = 0; while (classname = buffer->Class(classindex)) { const char* parent = buffer->Parent(classname); if (!parent) print_class_subtree(cout, buffer, classname, 0); classindex++; } return 0; } IClass* iclass = new IClass(buffer); ApplicationWindow* window = new ApplicationWindow(iclass); Style* s = new Style(Session::instance()->style()); s->attribute("name", "InterViews class browser"); s->attribute("iconName", "iclass"); window->style(s); window->map(); iclass->Run(); return 0; } ivtools-1.2.11a1/src/idemo/000077500000000000000000000000001214471147700154115ustar00rootroot00000000000000ivtools-1.2.11a1/src/idemo/Idemo.defaults000066400000000000000000000005731214471147700202040ustar00rootroot00000000000000Idemo*background: #7d9ec0 Idemo*font: *-helvetica-medium-r-*-*-*-120-* Idemo*rotation: 90 Idemo*title*foreground: gray20 Idemo*title*font: *-helvetica-medium-o-normal-*-*-120-* large*font: *-helvetica-medium-r-*-*-*-180-* large*title*font: *-helvetica-medium-o-normal-*-*-180-* Large*font: *-helvetica-medium-r-*-*-*-240-* Large*title*font: *-helvetica-medium-o-normal-*-*-240-* ivtools-1.2.11a1/src/idemo/main.cc000066400000000000000000000370731214471147700166560ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static const Coord tool_scale = 12.0; struct CommandInfo; class App { public: App(); ~App(); int run(int, char**); void open(); void save(); void cut(); void copy(); void paste(); void black(); void red(); void green(); void blue(); void do_nothing(); void quit(); private: WidgetKit* kit_; LayoutKit* layout_; Style* style_; Style* title_style_; Menu* file_; Composition* body_; Glyph* sep_; Coord size_; ApplicationWindow* main_; FileChooser* dialog_; Menu* menubar(); Menu* make_menu(Menu*, CommandInfo*, int = 0); MenuItem* make_submenu(MenuItem*, Menu*); MenuItem* make_item(MenuItem*, Action*); void add(const char* label, Glyph*); }; App::App() { main_ = nil; dialog_ = nil; } App::~App() { Resource::unref(dialog_); } declareActionCallback(App) implementActionCallback(App) struct CommandInfo { const char* str; ActionMemberFunction(App) func; CommandInfo* submenu; int options; }; CommandInfo filemenu[] = { { "File Chooser ...", &App::open }, { "Save", &App::save }, { "", nil }, { "Quit", &App::quit }, { nil } }; CommandInfo editmenu[] = { { "Cut", &App::cut }, { "Copy", &App::copy }, { "Paste", &App::paste }, { nil } }; CommandInfo times_menu[] = { { "Normal", &App::do_nothing }, { "Bold", &App::do_nothing }, { "Italic", &App::do_nothing }, { nil } }; CommandInfo helv_menu[] = { { "Normal", &App::do_nothing }, { "Bold", &App::do_nothing }, { "Oblique", &App::do_nothing }, { nil } }; CommandInfo fontmenu[] = { { "Times", nil, times_menu, 2 }, { "Helvetica", nil, helv_menu, 2 }, { nil } }; CommandInfo colormenu[] = { { "Black", &App::black }, { "Red", &App::red }, { "Green", &App::green }, { "Blue", &App::blue }, { nil } }; class BoundedValue : public Adjustable { protected: BoundedValue(); public: BoundedValue(Coord lower, Coord upper); virtual ~BoundedValue(); virtual void lower_bound(Coord); virtual void upper_bound(Coord); virtual void current_value(Coord); virtual void scroll_incr(Coord); virtual void page_incr(Coord); virtual Coord lower(DimensionName) const; virtual Coord upper(DimensionName) const; virtual Coord length(DimensionName) const; virtual Coord cur_lower(DimensionName) const; virtual Coord cur_upper(DimensionName) const; virtual Coord cur_length(DimensionName) const; virtual void scroll_to(DimensionName, Coord position); virtual void scroll_forward(DimensionName); virtual void scroll_backward(DimensionName); virtual void page_forward(DimensionName); virtual void page_backward(DimensionName); private: Coord curvalue_; Coord lower_; Coord span_; Coord scroll_incr_; Coord page_incr_; }; class Valuator : public MonoGlyph, public Observer { public: Valuator(BoundedValue*, Style*); virtual ~Valuator(); virtual InputHandler* focusable() const; virtual void update(Observable*); virtual void disconnect(Observable*); private: BoundedValue* bvalue_; FieldEditor* editor_; void accept_editor(FieldEditor*); void cancel_editor(FieldEditor*); }; static OptionDesc options[] = { { "-titlefg", "Idemo*title*foreground", OptionValueNext }, { "-chiseled", "Idemo*labelStyle", OptionValueImplicit, "chiseled" }, { "-flattext", "Idemo*labelStyle", OptionValueImplicit, "normal" }, { "-raised", "Idemo*labelStyle", OptionValueImplicit, "raised" }, { "-rot", "Idemo*rotation", OptionValueNext }, { "-rotate", "Idemo*rotation", OptionValueNext }, { nil } }; int main(int argc, char** argv) { App* a = new App; return a->run(argc, argv); } int App::run(int argc, char** argv) { Session* session = new Session("Idemo", argc, argv, options); kit_ = WidgetKit::instance(); layout_ = LayoutKit::instance(); WidgetKit& kit = *kit_; const LayoutKit& layout = *layout_; style_ = kit_->style(); title_style_ = new Style(style_); Resource::ref(title_style_); title_style_->alias("title"); const Font* f = kit_->font(); size_ = tool_scale * f->width('m'); body_ = new LRComposition( layout.vbox(), new TeXCompositor(10), nil, size_ + 1.0 + size_ + 1.0 + size_ + 2.0 ); Glyph* space = layout.spaces(2, 0.5, f, kit_->foreground()); Glyph* begin_par = layout.vstrut(0, 0, 0, fil, 0); Glyph* end_par = layout.strut(f, 0, fil, 0); Glyph* begin_line = layout.vstrut(0, 0, 0, fil, 0); Glyph* end_line = layout.strut(f, 0, fil, 0); Glyph* vfil = layout.vglue(); Glyph* vspace1 = layout.vspace(1.0); Glyph* vspace2 = layout.vspace(2.0); Glyph* vspace4 = layout.vspace(4.0); sep_ = layout.discretionary( 0, space, end_line, layout.discretionary(0, vfil, vfil, nil, nil), begin_line ); sep_ = layout.vcenter(sep_, 1.0); Style* s = style_; Transformer t; float rotation; s->find_attribute("rotation", rotation); t.rotate(rotation); Action* action = new ActionCallback(App)(this, &App::do_nothing); add( "Labels", layout.vbox( layout.center(kit.label("Normal text"), 0.5, 1.0), vspace2, layout.hcenter( new TransformSetter(kit.label("Rotated text"), t) ) ) ); body_->append(sep_); Button* disabled = kit.push_button("Disabled", nil); disabled->state()->set(TelltaleState::is_enabled, false); add( "Push buttons", layout.vbox( layout.hcenter(kit.push_button("Do nothing", action)), vspace2, layout.hcenter(disabled), vspace2, layout.hcenter(kit.push_button("Quit", kit_->quit())) ) ); body_->append(sep_); Button* column_c = kit.check_box("Column C", nil); column_c->state()->set(TelltaleState::is_chosen, true); column_c->state()->set(TelltaleState::is_enabled, false); add( "Check boxes", layout.vbox( kit.check_box("Column A", action), vspace2, kit.check_box("Column B", nil), vspace2, column_c ) ); body_->append(sep_); TelltaleGroup* group = new TelltaleGroup; add( "Radio buttons", layout.vbox( kit.radio_button(group, "Able", action), vspace4, kit_->radio_button(group, "Baker", nil), vspace4, kit_->radio_button(group, "Charlie", nil) ) ); body_->append(sep_); add( "Palette buttons", layout.vbox( layout.vcenter(kit.palette_button("One", nil), 1.0), vspace2, kit.palette_button("Two", nil), vspace2, kit.palette_button("Three", nil) ) ); body_->append(sep_); BoundedValue* bv1 = new BoundedValue(0.0, 100.0); bv1->current_value(50.0); bv1->scroll_incr(5.0); bv1->page_incr(20.0); BoundedValue* bv2 = new BoundedValue(0.0, 100.0); bv2->current_value(50.0); bv2->scroll_incr(5.0); bv2->page_incr(10.0); Valuator* v1 = new Valuator(bv1, s); Valuator* v2 = new Valuator(bv2, s); InputHandler* vgroup = new InputHandler( layout.vbox(v1, vspace4, v2, layout.vspace(15.0)), s ); vgroup->append_input_handler(v1->focusable()); vgroup->append_input_handler(v2->focusable()); add("Field editors", vgroup); body_->append(sep_); add( "Panner", layout.fixed_span(kit.panner(bv1, bv2), size_ - 10.0, size_ - 10.0) ); body_->append(sep_); add( "HScrollBar", layout.vcenter(layout.h_fixed_span(kit.hscroll_bar(bv1), size_ - 8.0)) ); body_->append(sep_); add( "VScrollBar", layout.hcenter(layout.v_fixed_span(kit.vscroll_bar(bv2), size_ - 8.0)) ); body_->append( layout.vcenter( layout.discretionary( PenaltyGood, end_par, end_par, layout.discretionary(0, vfil, vfil, nil, nil), begin_par ), 1.0 ) ); body_->repair(); main_ = new ApplicationWindow( new Background( layout.vcenter( layout.vbox( layout.vcenter(menubar(), 1.0), body_ ) ), kit.background() ) ); return session->run_window(main_); } declareFileChooserCallback(App) implementFileChooserCallback(App) void App::open() { if (dialog_ == nil) { dialog_ = DialogKit::instance()->file_chooser(".", style_); Resource::ref(dialog_); } if (dialog_->post_for(main_)) { const String* name = dialog_->selected(); if (name != nil) { printf("%.*s\n", name->length(), name->string()); fflush(stdout); } } } void App::save() { printf("save\n"); } void App::cut() { printf("cut\n"); } void App::copy() { printf("copy\n"); } void App::paste() { printf("paste\n"); } void App::black() { printf("black\n"); } void App::red() { printf("red\n"); } void App::green() { printf("green\n"); } void App::blue() { printf("blue\n"); } void App::do_nothing() { printf("do nothing\n"); } void App::quit() { delete main_; kit_->quit()->execute(); } Menu* App::menubar() { WidgetKit& kit = *kit_; Menu* m = kit.menubar(); Menu* file = make_menu(kit.pulldown(), filemenu); m->append_item(make_submenu(kit.menubar_item("Dialog"), file)); m->append_item( make_submenu( kit.menubar_item("Edit"), make_menu(kit.pulldown(), editmenu, 1) ) ); m->append_item( make_submenu( kit.menubar_item("Font"), make_menu(kit.pulldown(), fontmenu, 2) ) ); /* disable save */ file->item(1)->state()->set(TelltaleState::is_enabled, false); return m; } Menu* App::make_menu(Menu* m, CommandInfo* info, int options) { WidgetKit& kit = *kit_; TelltaleGroup* group = nil; for (CommandInfo* i = info; i->str != nil; i++) { if (i->str[0] == '\0') { m->append_item(kit.menu_item_separator()); } else { Glyph* g = layout_->r_margin(kit.label(i->str), 0.0, fil, 0.0); MenuItem* item; switch (options) { case 1: item = kit.check_menu_item(g); break; case 2: if (group == nil) { group = new TelltaleGroup; } item = kit.radio_menu_item(group, g); break; default: item = kit.menu_item(g); break; } if (i->func == nil) { if (i->submenu != nil) { make_submenu( item, make_menu(kit.pullright(), i->submenu, i->options) ); } } else { make_item(item, new ActionCallback(App)(this, i->func)); } m->append_item(item); } } return m; } MenuItem* App::make_submenu(MenuItem* i, Menu* s) { i->menu(s); return i; } MenuItem* App::make_item(MenuItem* i, Action* a) { i->action(a); return i; } void App::add(const char* title, Glyph* glyph) { const LayoutKit& layout = *layout_; Glyph* g = layout.margin( glyph, 0.0, fil, 0.0, 0.0, fil, 0.0, 0.0, 0.25*fil, 0.0, 0.0, 0.75*fil, 0.0 ); if (title != nil) { WidgetKit& kit = *kit_; kit.push_style(); kit.style(title_style_); g = layout.overlay( layout.center(g), layout.center( layout.margin( kit.fancy_label(title), 0.0, fil, 0.0, 0.0, fil, 0.0, 0.0, 0.90*fil, 0.0, 0.0, 0.10*fil, 0.0 ) ) ); kit.pop_style(); } body_->append( layout.center(layout.fixed_span(g, size_, size_), 0.0, 1.0) ); } /* class BoundedValue */ BoundedValue::BoundedValue() { scroll_incr_ = 0.0; page_incr_ = 0.0; } BoundedValue::BoundedValue(Coord lower, Coord upper) { lower_ = lower; span_ = upper - lower; scroll_incr_ = span_ * 0.04; page_incr_ = span_ * 0.4; curvalue_ = (lower + upper) * 0.5; } BoundedValue::~BoundedValue() { } void BoundedValue::lower_bound(Coord c) { lower_ = c; } void BoundedValue::upper_bound(Coord c) { span_ = c - lower_; } void BoundedValue::current_value(Coord value) { curvalue_ = value; constrain(Dimension_X, curvalue_); notify(Dimension_X); notify(Dimension_Y); } void BoundedValue::scroll_incr(Coord c) { scroll_incr_ = c; } void BoundedValue::page_incr(Coord c) { page_incr_ = c; } Coord BoundedValue::lower(DimensionName) const { return lower_; } Coord BoundedValue::upper(DimensionName) const { return lower_ + span_; } Coord BoundedValue::length(DimensionName) const { return span_; } Coord BoundedValue::cur_lower(DimensionName) const { return curvalue_; } Coord BoundedValue::cur_upper(DimensionName) const { return curvalue_; } Coord BoundedValue::cur_length(DimensionName) const { return 0; } void BoundedValue::scroll_to(DimensionName d, Coord position) { Coord p = position; constrain(d, p); if (p != curvalue_) { curvalue_ = p; notify(Dimension_X); notify(Dimension_Y); } } void BoundedValue::scroll_forward(DimensionName d) { scroll_to(d, curvalue_ + scroll_incr_); } void BoundedValue::scroll_backward(DimensionName d) { scroll_to(d, curvalue_ - scroll_incr_); } void BoundedValue::page_forward(DimensionName d) { scroll_to(d, curvalue_ + page_incr_); } void BoundedValue::page_backward(DimensionName d) { scroll_to(d, curvalue_ - page_incr_); } /* class Valuator */ declareFieldEditorCallback(Valuator) implementFieldEditorCallback(Valuator) Valuator::Valuator(BoundedValue* bv, Style* style) : MonoGlyph(nil) { Style* s = new Style(style); s->alias("Valuator"); bvalue_ = bv; bv->attach(Dimension_X, this); editor_ = DialogKit::instance()->field_editor( "100.00", s, new FieldEditorCallback(Valuator)( this, &Valuator::accept_editor, &Valuator::cancel_editor ) ); body(editor_); update(bv->observable(Dimension_X)); } Valuator::~Valuator() { if (bvalue_ != nil) { bvalue_->detach(Dimension_X, this); } } InputHandler* Valuator::focusable() const { return editor_; } void Valuator::update(Observable*) { Coord v = bvalue_->cur_lower(Dimension_X); char buf[20]; sprintf(buf, "%.2f", v); editor_->field(buf); } void Valuator::disconnect(Observable*) { bvalue_ = nil; } void Valuator::accept_editor(FieldEditor*) { Coord v; const String& value = *editor_->text(); if (value.convert(v)) { bvalue_->current_value(v); } } void Valuator::cancel_editor(FieldEditor*) { update(bvalue_->observable(Dimension_X)); } ivtools-1.2.11a1/src/idraw/000077500000000000000000000000001214471147700154225ustar00rootroot00000000000000ivtools-1.2.11a1/src/idraw/README000066400000000000000000000545651214471147700163210ustar00rootroot00000000000000NAME idraw - drawing editor SYNOPSIS idraw [options] [file] DESCRIPTION Idraw is a drawing editor that lets you create and edit drawings made up of graphics like text, lines, splines, rec- tangles, polygons, and ellipses. Drawings are stored in files that can be printed on a PostScript printer. You can can open an existing drawing when starting up idraw by typ- ing a file name on the command line. Idraw displays a portrait or landscape view of an 8.5 by 11 inch page in its drawing area. In a column along the draw- ing area's left side is a set of drawing tool icons, and above the drawing area is a set of pull-down menus contain- ing commands. A panner in the lower left corner lets you pan and zoom the the drawing area. Along the top is a set of indicators that display editing information. DRAWING TOOLS You must engage a tool before you can use it. You engage a tool by clicking on its icon or by typing the character below and to the right of its icon. The icon of the drawing tool that's engaged appears in inverted colors. Once engaged, you use the tool by clicking the left mouse button in the drawing area. The Select, Move, Scale, Stretch, Rotate, and Alter tools manipulate existing graphics. Magnify makes a part of the view expand to fill the entire view. Text, Line, Multiline, Open Spline, Ellipse, Rectangle, Polygon, and Closed Spline create new graphics. Each tool works as follows: Select Select a graphic, unselecting all others. A graphic is selected if its handles are visi- ble. Handles are small inverse-video squares that either surround the graphic or demarcate its important points (such as the endpoints of a line). If you hold down the shift key, Select extends the selection: it selects the unselected graphic (or unselects the selected graphic) you clicked on but does not unselect other selections. Clicking anywhere other than on a graphic unselects everything; you may also drag a rubberband rectangle around a group of graphics to select all of them at once. Shortcut: the right mouse button invokes Select while the mouse is in the drawing area. Move Move graphics from one spot to another. Shortcut: the middle mouse button invokes Move while the mouse is in the drawing area. Scale Scale graphics about their centers. Stretch Stretch graphics vertically or horizontally while tying down the opposite edge. Rotate Rotate graphics about their centers according to the angle between two radii: the one defined by the original clicking point and the one defined by the current dragging point. Alter Modify a graphic's structure. This tool's effect is described below for each graphic. Magnify Magnify a portion of the drawing specified by sweeping out a rectangular area. Idraw will magnify the area to occupy the entire screen, if possible. Text Create some text. Left-click to position the first line of text, and then type as much text as you want. You may use emacs-style keystrokes to edit the text as well as enter it. You can leave text editing mode by typ- ing ESC or by simply clicking somewhere else. The Alter tool lets you edit the text in an existing text graphic. Line Create a line. The shift key constrains the line to lie on either the vertical or the horizontal axis. You may left-click with the Alter tool on either endpoint of a line to move the endpoint to a new location. Multiline Create a set of connected lines. The shift key constrains each segment to lie on either the vertical or the horizontal axis. Each left-click starts a new segment (i.e., adds a vertex); each right-click removes the last vertex added. The middle button finalizes the multiline. The Alter tool lets you move, add, and remove vertices from an existing multiline. Open Spline Create an open B-spline. The shift key con- strains each control point to lie on either the vertical or the horizontal axis with the preceding point. Each left-click adds a control point; each right-click removes the last control point added. The middle button finalizes the spline. The Alter tool lets you move, add, and remove control points from an existing open spline. Ellipse Create an ellipse. The shift key constrains the ellipse to the shape of a circle. The Alter tool does not affect ellipses. Rectangle Create a rectangle. The shift key constrains the rectangle to the shape of a square. The Alter tool lets you move the rectangle's corners independently to form a four-sided polygon. Polygon Create a polygon. The shift key constrains each side to lie on either the vertical or the horizontal axis. Each left-click starts a new segment (i.e., adds a vertex); each right-click removes the last vertex added. The middle button finalizes the polygon. The Alter tool lets you move, add, and remove vertices from an existing polygon. Closed Spline Create a closed B-spline. The shift key con- strains each control point to lie on either the vertical or the horizontal axis with the preceding point. Each left-click adds a con- trol point; each right-click removes the last control point added. The middle button finalizes the spline. The Alter tool lets you move, add, and remove control points from an existing closed spline. PULL-DOWN MENUS The pull-down menus File, Edit, Structure, Font, Brush, Pat- tern, FgColor, BgColor, Align, and View above the drawing area contain commands for editing the drawing and for con- trolling idraw's execution. The File menu contains the fol- lowing commands to operate on files: New Destroy the current drawing and replace it with an unnamed blank drawing. Revert Reread the current drawing, destroying any unsaved changes. Open... Specify an existing drawing to edit through a FileChooser(3I), which lets you browse the file system easily. Save As... Save the current drawing in a file with a specific name. Save Save the current drawing in the file it came from. Print... Send a PostScript version of the drawing to a printer or to a file. The bold rectangular outline (called the page boundary) appearing in the drawing area indicates the portion of the drawing that will appear on the printed page. Import Graphic... Create a graphic from the information in a file and insert it into the current drawing. Idraw can import images from files in the following formats: TIFF; PostScript generated by pgmtops, ppmtops, and idraw; X bitmap for- mat; and Unidraw format. Quit Quit idraw. The Edit menu contains the following commands for editing graphics: Undo Undo the last editing operation. Successive Undo commands undo earlier and earlier edit- ing operations. Redo Redo the last editing operation. Successive Redo commands redo later and later editing operations up to the first operation undone by Undo. Undone operations that have not been redone are lost as soon as a new opera- tion is performed. Cut Remove the selected graphics from the drawing and place them in a temporary storage area called the clipboard. Copy Copy the selected graphics into the clip- board. Paste Paste copies of the graphics in the clipboard into the drawing. Together, Cut, Copy, and Paste let you transfer graphics between draw- ings simply by cutting graphics out of one view and pasting them into another. Duplicate Duplicate the selected graphics and add the copies to the drawing. Delete Destroy the selected graphics. Select All Select every graphic in the drawing. Flip Horizontal, Flip Vertical Flip the selected graphics into their mirror images along the horizontal or vertical axes. 90 Clockwise, 90 CounterCW Rotate the selected graphics 90 degrees clockwise or counterclockwise. Precise Move..., Precise Scale..., Precise Rotate... Move, scale, or rotate graphics by exact amounts that you type in a dialog box. You can specify movements in pixels, points, cen- timeters, or inches. Scalings are specified in terms of magnification factors in the hor- izontal and vertical dimensions. Rotations are in degrees. The Structure menu contains the following commands to modify the structure of the drawing, that is, the order in which graphics are drawn: Group Nest the selected graphics in a newly created picture. A picture is just a graphic that contains other graphics. Group allows you to build hierarchies of graphics. Ungroup Dissolve any selected pictures. Bring To Front Bring the selected graphics to the front of the drawing so that they are drawn on top of (after) other graphics. Send To Back Send the selected graphics to the back of the drawing so that they are drawn behind (before) other graphics. The Font menu contains a set of fonts in which to display text. When you set the current font from the menu, you will also set all the selected graphics' fonts to that font. A font indicator in the upper right corner displays the current font. The Brush menu contains a set of brushes with which to draw lines. When you set the current brush from the menu, you will also set all the selected graphics' brushes to that brush. The nonexistent brush draws invisible lines and non-outlined graphics. The arrowhead brushes add arrowheads to either or both ends of lines, multilines, and open splines. A brush indicator in the upper left corner displays the current brush. The Pattern menu contains a set of patterns with which to fill graphics but not text. Text always appears solid, but you can use a different color than black to get a halftoned shade. When you set the current pattern from the menu, you will also set all the selected graphics' patterns to that pattern. The nonexistent pattern draws unfilled graphics, while the other patterns draw graphics filled with a bitmap or a halftoned shade. The FgColor and BgColor menus contains a set of colors with which to draw graphics and text. When you set the current foreground or background color from the FgColor or BgColor menu, you will also set all the selected graphics' fore- ground or background colors. The ``on'' bits in the bitmaps for dashed lines and fill patterns appear in the foreground color while the ``off'' bits appear in the background color. A black and white printer will print a halftoned shade of gray for any color other than black or white. The brush, pattern, and font indicators all reflect the current colors. The Align menu contains commands to align graphics with other graphics. The first graphic selected stays fixed while the other graphics move in the order they were selected according to the type of alignment chosen. The last Align command, Align to Grid, aligns a key point on each selected graphic to the nearest point on idraw's grid (see below). The View menu contains the following commands: New View Create a duplicate idraw window containing a second view of the current drawing. The second view may be panned, zoomed, and edited independently of the first. Any number of additional views may be made in this manner. Changes made to a drawing through one view appear synchronously in all other views of the same drawing. You may also view another drawing in any idraw window via the Open com- mand. Close View Close the current idraw window. Closing the last idraw window is equivalent to issuing a Quit command. Normal Size Set the magnification to unity so the drawing appears at actual size. Reduce to Fit Reduce the magnification until the drawing fits entirely within the view. Center Page Center the view over the center of the 8.5 by 11 inch page. Orientation Toggle the drawing's orientation. If the editor was formerly showing a portrait view of the drawing, it will now show a landscape view of the drawing and vice versa. Grid on/off Toggle idraw's grid on or off. When the grid is on, idraw draws a grid of equally spaced points behind the drawing. Grid Spacing... Change the grid spacing by specifying one or two values in the units desired (pixels, points, centimeters, or inches). If two values are given (separated by a space), the first specifies the horizontal spacing and second the vertical spacing. One value will specify equal horizontal and vertical spac- ing. Gravity on/off Toggle gravity on or off. Gravity constrains tool operation to the grid, whether or not the grid is visible. X DEFAULTS You can customize the number of undoable changes and the font, brush, pattern, or color menus by setting resources in your X defaults database. Each string of the form ``idraw.resource:definition'' sets a resource. For example, to customize any of the paint menus, set a resource given by the concatenation of the menu's name and the entry's number (e.g., ``idraw.pattern8'') for each entry that you want to override. All menus use the number 1 for the first entry. You must set resources only for the entries that you want to override, not all of them. If you want to add entries to the menus, simply set resources for them. However, don't skip any numbers after the end of the menu, because the menu will end at the first undefined resource. To shorten a menu instead of extending it, specify a blank string as the resource for the entry following the last. Idraw understands the following resources: history Set the maximum number of undoable changes (20 by default). initialfont Specify the font that will be active on startup. Supply a number that identifies the font by its position in the Font menu starting from 1 for the first entry. fonti Define a custom font to use for the ith entry in the Font menu. Give three strings separated by whitespace. The first string defines the font's name, the second string the corresponding print font, and the third string the print size. For example, ``idraw.font3:8x13bold Courier-Bold 13'' defines the third font entry. initialbrush Specify the brush that will be active on startup. Give a number that identifies the brush by its position in the Brush menu starting from 1 for the first entry. brushi Define a custom brush to use for the ith entry in the Brush menu. The definition requires two numbers: a 16-bit hexadecimal number to define the brush's line style (each 1 bit draws a dash and each 0 bit produces a gap), and a decimal integer to define the brush's width in pixels. For example, ``idraw.brush2:ffff 1'' defines a single pixel wide solid line. If the definition specifies only the string ``none'', then it defines the nonexistent brush. initialpattern Specify the pattern that will be active on startup. Give a number that identifies the pattern by its position in the Pattern menu starting from 1 for the first entry. patterni Define a custom pattern to use for the ith entry in the Pattern menu. You can specify the pattern from a 16x16 bitmap, a 8x8 bit- map, a 4x4 bitmap, a grayscale number, or the string ``none''. You specify the 16x16 bit- map with sixteen 16-bit hexadecimal numbers, the 8x8 bitmap with eight 8-bit hexadecimal numbers, the 4x4 bitmap with a single 16-bit hexadecimal number, and the grayscale number with a single floating point number. The floating point number must contain a period to distinguish itself from the single hexade- cimal number, and it must lie between 0.0 and 1.0, where 0.0 corresponds to a solid pattern and 1.0 to a clear pattern. On the printer, the bitmap patterns appear as bitmaps, the grayscale patterns appear as halftoned shades, and the ``none'' patterns never obscure any underlying graphics. For exam- ple, ``idraw.pattern8:8421'' defines a diago- nally hatched pattern. initialfgcolor Specify the foreground color that will be active on startup. Give a number that iden- tifies the color by its position in the FgColor menu starting from 1 for the first entry. fgcolori Define a custom color to use for the ith entry in the FgColor menu. Give a string defining the name of the color and optionally three decimal numbers between 0 and 65535 following the name to define the red, green, and blue components of the color's intensity. The intensities override the name; that is, idraw will look the name up in a window sys- tem database of common colors only if you omit the intensities. You can define shades of gray by using equal proportions of each primary color. For example, ``idraw.fgcolor8:Indigo 48896 0 65280'' defines a color that is a mixture of red and blue. initialbgcolor Specify the background color that will be active on startup. Give a number that iden- tifies the color by its position in the BgColor menu starting from 1 for the first entry. bgcolori Define a custom color to use for the ith entry in the BgColor menu. The same rules apply to background colors as to foreground colors. WEB PAGE http://www.ivtools.org/ivtools/idraw.html ivtools-1.2.11a1/src/idraw/main.cc000066400000000000000000000122071214471147700166570ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Idraw editor main program. */ #include #include #include #include #include #include #include #include #include using std::cerr; /*****************************************************************************/ static PropertyData properties[] = { { "*IdrawEditor*name", "InterViews drawing editor" }, { "*IdrawEditor*iconName", "Idraw" }, { "*domain", "drawing" }, { "*initialbrush", "2" }, { "*initialfgcolor","1" }, { "*initialbgcolor","10" }, { "*initialfont", "4" }, { "*initialpattern","1" }, { "*initialarrow", "none" }, { "*pagewidth", "8.5" }, { "*pageheight", "11" }, { "*gridxincr", "8" }, { "*gridyincr", "8" }, { "*font1", "-*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8" }, { "*font2", "-*-courier-medium-r-normal-*-10-*-*-*-*-*-*-* Courier 10" }, { "*font3", "-*-courier-bold-r-normal-*-12-*-*-*-*-*-*-* Courier-Bold 12" }, { "*font4", "-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-* Helvetica 12" }, { "*font5", "-*-helvetica-medium-r-normal-*-14-*-*-*-*-*-*-* Helvetica 14" }, { "*font6", "-*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-* Helvetica-Bold 14" }, { "*font7", "-*-helvetica-medium-o-normal-*-14-*-*-*-*-*-*-* Helvetica-Oblique 14" }, { "*font8", "-*-times-medium-r-normal-*-12-*-*-*-*-*-*-* Times-Roman 12" }, { "*font9", "-*-times-medium-r-normal-*-14-*-*-*-*-*-*-* Times-Roman 14" } , { "*font10", "-*-times-bold-r-normal-*-14-*-*-*-*-*-*-* Times-Bold 14" }, { "*font11", "-*-times-medium-i-normal-*-14-*-*-*-*-*-*-* Times-Italic 14" }, { "*brush1", "none" }, { "*brush2", "ffff 0" }, { "*brush3", "ffff 1" }, { "*brush4", "ffff 2" }, { "*brush5", "ffff 3" }, { "*brush6", "fff0 0" }, { "*brush7", "fff0 1" }, { "*brush8", "fff0 2" }, { "*brush9", "fff0 3" }, { "*pattern1", "none" }, { "*pattern2", "0.0" }, { "*pattern3", "1.0" }, { "*pattern4", "0.75" }, { "*pattern5", "0.5" }, { "*pattern6", "0.25" }, { "*pattern7", "1248" }, { "*pattern8", "8421" }, { "*pattern9", "f000" }, { "*pattern10", "8888" }, { "*pattern11", "f888" }, { "*pattern12", "8525" }, { "*pattern13", "cc33" }, { "*pattern14", "7bed" }, { "*fgcolor1", "Black" }, { "*fgcolor2", "Brown 42240 10752 10752" }, { "*fgcolor3", "Red" }, { "*fgcolor4", "Orange" }, { "*fgcolor5", "Yellow" }, { "*fgcolor6", "Green" }, { "*fgcolor7", "Blue" }, { "*fgcolor8", "Indigo 48896 0 65280" }, { "*fgcolor9", "Violet 20224 12032 20224" }, { "*fgcolor10", "White" }, { "*fgcolor11", "LtGray 50000 50000 50000" }, { "*fgcolor12", "DkGray 33000 33000 33000" }, { "*bgcolor1", "Black" }, { "*bgcolor2", "Brown 42240 10752 10752" }, { "*bgcolor3", "Red" }, { "*bgcolor4", "Orange" }, { "*bgcolor5", "Yellow" }, { "*bgcolor6", "Green" }, { "*bgcolor7", "Blue" }, { "*bgcolor8", "Indigo 48896 0 65280" }, { "*bgcolor9", "Violet 20224 12032 20224" }, { "*bgcolor10", "White" }, { "*bgcolor11", "LtGray 50000 50000 50000" }, { "*bgcolor12", "DkGray 33000 33000 33000" }, { "*history", "20" }, { nil } }; static OptionDesc options[] = { { nil } }; /*****************************************************************************/ int main (int argc, char** argv) { int exit_status = 0; IdrawCreator creator; Unidraw* unidraw = new Unidraw( new IdrawCatalog("idraw", &creator), argc, argv, options, properties ); if (argc > 2) { cerr << "Usage: idraw [file]" << "\n"; exit_status = 1; } else { const char* initial_file = (argc == 2) ? argv[1] : nil; IdrawEditor* ed = new IdrawEditor(initial_file); unidraw->Open(ed); cerr << "ivtools-" << VersionString << " idraw: see \"man idraw\" for more info\n"; unidraw->Run(); } delete unidraw; return exit_status; } ivtools-1.2.11a1/src/include/000077500000000000000000000000001214471147700157375ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/Dispatch/000077500000000000000000000000001214471147700174765ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/Dispatch/_defines.h000066400000000000000000000010661214471147700214260ustar00rootroot00000000000000#define Dispatcher _lib_dp(Dispatcher) #define FdMask _lib_dp(FdMask) #define IOHandler _lib_dp(IOHandler) #define RpcHdr _lib_dp(RpcHdr) #define RpcPeer _lib_dp(RpcPeer) #define RpcReader _lib_dp(RpcReader) #define RpcRegistry _lib_dp(RpcRegistry) #define RpcService _lib_dp(RpcService) #define RpcWriter _lib_dp(RpcWriter) #define TimerQueue _lib_dp(TimerQueue) #define iosb _lib_dp(iosb) #define iostreamb _lib_dp(iostreamb) #define istreamb _lib_dp(istreamb) #define ostreamb _lib_dp(ostreamb) #define rpcbuf _lib_dp(rpcbuf) #define rpcstream _lib_dp(rpcstream) ivtools-1.2.11a1/src/include/Dispatch/_undefs.h000066400000000000000000000004031214471147700212670ustar00rootroot00000000000000#undef Dispatcher #undef FdMask #undef IOHandler #undef RpcHdr #undef RpcPeer #undef RpcReader #undef RpcRegistry #undef RpcService #undef RpcWriter #undef TimerQueue #undef iosb #undef iostreamb #undef istreamb #undef ostreamb #undef rpcbuf #undef rpcstream ivtools-1.2.11a1/src/include/Dispatch/dispatcher.h000066400000000000000000000064501214471147700220020ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Wait on multiple file descriptors until a condition occurs. */ #ifndef dp_dispatcher_h #define dp_dispatcher_h #include class FdMask; class IOHandler; class TimerQueue; class ChildQueue; struct timeval; //: wait on multiple file descriptors until a condition occurs // man page class Dispatcher { public: enum DispatcherMask { ReadMask, WriteMask, ExceptMask }; Dispatcher(); virtual ~Dispatcher(); virtual void link(int fd, DispatcherMask, IOHandler*); virtual IOHandler* handler(int fd, DispatcherMask) const; virtual void unlink(int fd); virtual void startTimer(long sec, long usec, IOHandler*); virtual void stopTimer(IOHandler*); virtual void startChild(int pid, IOHandler*); virtual void stopChild(IOHandler*); virtual boolean setReady(int fd, DispatcherMask); virtual void dispatch(); virtual boolean dispatch(long& sec, long& usec); static Dispatcher& instance(); static void instance(Dispatcher*); protected: virtual void attach(int fd, DispatcherMask, IOHandler*); virtual void detach(int fd); virtual boolean dispatch(timeval*); virtual boolean anyReady() const; virtual int fillInReady(FdMask&, FdMask&, FdMask&); virtual int waitFor(FdMask&, FdMask&, FdMask&, timeval*); virtual void notify(int, FdMask&, FdMask&, FdMask&); virtual timeval* calculateTimeout(timeval*) const; virtual boolean handleError(); virtual void checkConnections(); protected: int _nfds; FdMask* _rmask; FdMask* _wmask; FdMask* _emask; FdMask* _rmaskready; FdMask* _wmaskready; FdMask* _emaskready; IOHandler** _rtable; IOHandler** _wtable; IOHandler** _etable; TimerQueue* _queue; ChildQueue* _cqueue; #if defined(__GNUC__) && !defined(__GNUC_MINOR__) static void sigCLD(); #else static void sigCLD(...); #endif private: static Dispatcher* _instance; private: /* deny access since member-wise won't work */ Dispatcher(const Dispatcher&); Dispatcher& operator =(const Dispatcher&); }; #endif ivtools-1.2.11a1/src/include/Dispatch/dp.h000066400000000000000000000025531214471147700202570ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp_h #define dp_h #if defined(__STDC__) || defined(__ANSI_CPP__) #define _lib_dp(name) dp##name #else #define _lib_dp(name) dp/**/name #endif #endif ivtools-1.2.11a1/src/include/Dispatch/enter-scope.h000066400000000000000000000030431214471147700220730ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp__scope_h #define dp__scope_h #include #include #ifndef os__scope_h #include #include #define String _lib_os(String) #define boolean _lib_os(boolean) #define true _lib_os(true) #define false _lib_os(false) #define u_char _lib_os(u_char) #endif #endif ivtools-1.2.11a1/src/include/Dispatch/iocallback.h000066400000000000000000000064021214471147700217350ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp_iocallback_h #define dp_iocallback_h /* * IOCallback allows a member function to be used as an IO handler * instead of requiring derivation of a subclass. */ #include #if defined(__STDC__) || defined(__ANSI_CPP__) #define __IOCallback(T) T##_IOCallback #define IOCallback(T) __IOCallback(T) #define __IOReady(T) T##_IOReady #define IOReady(T) __IOReady(T) #define __IOTimer(T) T##_IOTimer #define IOTimer(T) __IOTimer(T) #else #define __IOCallback(T) T/**/_IOCallback #define IOCallback(T) __IOCallback(T) #define __IOReady(T) T/**/_IOReady #define IOReady(T) __IOReady(T) #define __IOTimer(T) T/**/_IOTimer #define IOTimer(T) __IOTimer(T) #endif #define declareIOCallback(T) \ typedef int (T::*IOReady(T))(int fd); \ typedef void (T::*IOTimer(T))(long sec, long usec); \ class IOCallback(T) : public IOHandler { \ public: \ IOCallback(T)( \ T*, IOReady(T) in, IOReady(T) out = nil, IOReady(T) ex = nil \ ); \ IOCallback(T)( \ T*, IOTimer(T), \ IOReady(T) in = nil, IOReady(T) out = nil, IOReady(T) ex = nil \ ); \ \ virtual int inputReady(int fd); \ virtual int outputReady(int fd); \ virtual int exceptionRaised(int fd); \ virtual void timerExpired(long sec, long usec); \ private: \ T* _obj; \ IOReady(T) _input; \ IOReady(T) _output; \ IOReady(T) _except; \ IOTimer(T) _timer; \ }; #define implementIOCallback(T) \ IOCallback(T)::IOCallback(T)( \ T* obj, IOReady(T) in, IOReady(T) out, IOReady(T) ex \ ) { \ _obj = obj; _timer = nil; \ _input = in; _output = out; _except = ex; \ } \ \ IOCallback(T)::IOCallback(T)( \ T* obj, IOTimer(T) t, IOReady(T) in, IOReady(T) out, IOReady(T) ex \ ) { \ _obj = obj; _timer = t; \ _input = in; _output = out; _except = ex; \ } \ \ int IOCallback(T)::inputReady(int fd) { return (_obj->*_input)(fd); } \ int IOCallback(T)::outputReady(int fd) { return (_obj->*_output)(fd); } \ int IOCallback(T)::exceptionRaised(int fd) { return (_obj->*_except)(fd); } \ void IOCallback(T)::timerExpired(long s, long u) { (_obj->*_timer)(s, u); } #endif ivtools-1.2.11a1/src/include/Dispatch/iohandler.h000066400000000000000000000036051214471147700216200ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp_iohandler_h #define dp_iohandler_h #include #include //: read input, write output, or handle an I/O exception or timeout // Derived classes read input on a file number, write output on a file // number, handle an exception raised on a file number, or handle a // timers expiration. //

    man page class IOHandler { protected: IOHandler(); public: virtual ~IOHandler(); virtual int inputReady(int fd); virtual int outputReady(int fd); virtual int exceptionRaised(int fd); virtual void timerExpired(long sec, long usec); virtual void childStatus(pid_t pid, int status); }; #endif ivtools-1.2.11a1/src/include/Dispatch/iostreamb.h000066400000000000000000000076621214471147700216470ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp_iostreamb_h #define dp_iostreamb_h #include #include //: Modify ios to store extra state information for binary I/O. //

    man page class iosb : public virtual ios { public: iosb(); ~iosb(); boolean binary() const; void binary(boolean); boolean swapped() const; void swapped(boolean); protected: boolean _binary; // are my peer and I performing binary I/O? boolean _swapped; // does my peer have a swapped endian? }; //: unformatted input stream // Modify istream to extract unformatted data where possible for // faster I/O throughput and to discard delimiters automatically. //

    man page class istreamb : public virtual iosb, public istream { protected: istreamb(); public: istreamb(streambuf*); ~istreamb(); istreamb& operator>>(char&); istreamb& operator>>(unsigned char&); istreamb& operator>>(short&); istreamb& operator>>(unsigned short&); istreamb& operator>>(int&); istreamb& operator>>(unsigned int&); istreamb& operator>>(long&); istreamb& operator>>(unsigned long&); istreamb& operator>>(float&); istreamb& operator>>(double&); istreamb& operator>>(char*); istreamb& operator>>(unsigned char*); istreamb& operator>>(istream& (*)(istream&)); istreamb& operator>>(ios& (*)(ios&)); }; //: unformatted output stream // Modify ostream to insert unformatted data where possible for faster // I/O throughput and to delimit formatted data automatically. //

    man page class ostreamb : public virtual iosb, public ostream { protected: ostreamb(); public: ostreamb(streambuf*); ~ostreamb(); ostreamb& operator<<(char); ostreamb& operator<<(unsigned char); ostreamb& operator<<(short); ostreamb& operator<<(unsigned short); ostreamb& operator<<(int); ostreamb& operator<<(unsigned int); ostreamb& operator<<(long); ostreamb& operator<<(unsigned long); ostreamb& operator<<(float); ostreamb& operator<<(double); ostreamb& operator<<(const char*); ostreamb& operator<<(const unsigned char*); ostreamb& operator<<(ostream& (*)(ostream&)); ostreamb& operator<<(ios& (*)(ios&)); protected: void fixwidth(); }; //: unformatted input/output stream // Replace iostream with a stream that inserts and extracts // unformatted data where possible for faster I/O throughput and // delimits formatted data automatically. //

    man page class iostreamb : public istreamb, public ostreamb { protected: iostreamb(); public: iostreamb(streambuf*); ~iostreamb(); void negotiate(boolean binary); }; #endif ivtools-1.2.11a1/src/include/Dispatch/leave-scope.h000066400000000000000000000024451214471147700220570ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifdef dp__scope_h #undef dp__scope_h #include #undef nil #endif ivtools-1.2.11a1/src/include/Dispatch/rpcbuf.h000066400000000000000000000070101214471147700211260ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp_rpcbuf_h #define dp_rpcbuf_h #include //: streambuf specialized for sending and receiving RPC requests // Specialize streambuf to sending and receiving RPC requests to and // from remote machines. //

    man page class rpcbuf : public streambuf { public: rpcbuf(iostreamb* = nil); virtual ~rpcbuf(); const char* host(); int port(); int fd(); boolean opened(); boolean nonblocking(); enum { anyport = 0 }; rpcbuf* listen(int port); rpcbuf* connect(const char* host, int port); rpcbuf* accept(int& fd); rpcbuf* attach(int fd); rpcbuf* nonblocking(boolean); rpcbuf* verbose(boolean); rpcbuf* close(); int start_request(); int read_request(); virtual int overflow(int c = EOF); virtual int underflow(); virtual int sync(); #ifdef cplusplus_2_1 virtual streampos seekoff(streamoff, ios::seek_dir, int); #else virtual streampos seekoff(streamoff, seek_dir, int); #endif virtual streambuf* setbuf(char*, int); protected: virtual int doallocate(); void finish_request(); boolean expand_g(int); boolean expand_p(); void error(const char*); void sys_error(const char*); iostreamb& mystream(); char* rptr(); void setr(char*); void rbump(int); protected: iostreamb* _mystream; // reference to the stream that uses me char* _rptr; // beginning of outgoing RPC request int _actualWidth; // width of outgoing RPC request's length field const char* _host; // name of my peer's host or nil if no peer int _port; // my peer's port or my port if I'm a listener int _fd; // my IPC connection's file descriptor boolean _opened; // do I have an open file descriptor? boolean _close; // should I close my file descriptor on exit? boolean _nonblocking; // can I read or write without blocking? boolean _verbose; // should I print system error messages? }; // Get the stream which will format the length field of RPC requests. inline iostreamb& rpcbuf::mystream() { return *_mystream; } // Get and set the pointer to the outgoing RPC request's beginning. inline char* rpcbuf::rptr() { return _rptr; } inline void rpcbuf::setr(char* rptr) { _rptr = rptr; } inline void rpcbuf::rbump(int n) { _rptr += n; } #endif ivtools-1.2.11a1/src/include/Dispatch/rpchdr.h000066400000000000000000000043001214471147700211260ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp_rpchdr_h #define dp_rpchdr_h #include class rpcstream; //: header for remote procedure calls // Insert or extract this header to send or receive a RPC request. //

    man page class RpcHdr { public: RpcHdr(void* writer, int request); RpcHdr(); unsigned long reader(); int request(); int ndata(); protected: friend rpcstream& operator>>(rpcstream&, RpcHdr&); friend rpcstream& operator<<(rpcstream&, const RpcHdr&); protected: union { void* _writer; // stores writer sending this RPC request unsigned long _reader; // maps to reader for this RPC request }; int _request; // maps to member function to be called int _ndata; // gives size (in bytes) of data to extract }; // Get information about the RPC request. inline unsigned long RpcHdr::reader() { return _reader; } inline int RpcHdr::request() { return _request; } inline int RpcHdr::ndata() { return _ndata; } #endif ivtools-1.2.11a1/src/include/Dispatch/rpcpeer.h000066400000000000000000000047231214471147700213150ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp_rpcpeer_h #define dp_rpcpeer_h #include class rpcbuf; //: support bi-directional RPC between two services // Support bi-directional RPC between two peers. Derived classes // create both a reader and a writer so each peer can send RPC // requests to its opposite over the same connection. //

    man page class RpcPeer : public IOHandler { public: virtual ~RpcPeer(); void run(); void quitRunning(); protected: RpcPeer( const char* lPath, int lPort = 0 ); void init(const char* rPath); void startListening(); void stopListening(); virtual int inputReady(int); virtual boolean createReaderAndWriter(const char* rHost, int rPort) = 0; virtual void createReaderAndWriter(int fd) = 0; protected: const char* _lPath; // my registration's path int _lPort; // my port's address rpcbuf* _service; // my network socket boolean _running; // am I running my dispatch loop? boolean _remote; // am I connected to a remote RPC service? char* _rHost; // dynamically allocated storage to be freed private: // deny access since unimplemented and member-wise won't work RpcPeer(const RpcPeer&); RpcPeer& operator=(const RpcPeer&); }; #endif ivtools-1.2.11a1/src/include/Dispatch/rpcreader.h000066400000000000000000000051301214471147700216150ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp_rpcreader_h #define dp_rpcreader_h #include class RpcHdr; class rpcstream; //: read RPC requests from a client // Read RPC requests from a client. Derived classes initialize the // function array with addresses of static member functions to // unmarshall RPC requests and implement the virtual function called // when the client closes the connection. //

    man page class RpcReader : public IOHandler { public: virtual ~RpcReader(); protected: RpcReader(rpcstream* client, int nfcns); RpcReader(int fd, int nfcns, boolean binary); rpcstream& client(); virtual int inputReady(int); virtual RpcReader* map(unsigned long); boolean execute(RpcReader*, RpcHdr&); virtual void connectionClosed(int fd) = 0; protected: typedef void (*PF)(RpcReader*, RpcHdr&, rpcstream&); int _nfcns; /* size of function array */ PF* _function; /* function array indexed by request number */ rpcstream* _client; /* source of RPC requests coming from client */ boolean _delete; /* should the destructor delete _client? */ int _fd; /* file number of connection with client */ private: /* deny access since unimplemented and member-wise won't work */ RpcReader(const RpcReader&); RpcReader& operator=(const RpcReader&); }; inline rpcstream& RpcReader::client() { return *_client; } #endif ivtools-1.2.11a1/src/include/Dispatch/rpcregistry.h000066400000000000000000000032731214471147700222310ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp_rpcregistry_h #define dp_rpcregistry_h #include //: name space for finding RPC services // Store or retrieve a RPC service's hostname and port number so that // clients can contact the RPC service. //

    man page class RpcRegistry { public: static boolean record(const char* path, int port); static boolean erase(const char* path); static boolean find(const char* path, char*& host, int& port); }; #endif ivtools-1.2.11a1/src/include/Dispatch/rpcservice.h000066400000000000000000000043461214471147700220230ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp_rpcservice_h #define dp_rpcservice_h #include class rpcbuf; //: support RPC between a service and its clients // Support communication between a RPC service and its clients. // Derived classes create readers to read RPC requests from // connections with clients. //

    man page class RpcService : public IOHandler { public: virtual ~RpcService(); void run(); void quitRunning(); protected: RpcService(int port); RpcService(const char* path, int port = 0); void startListening(); void stopListening(); virtual int inputReady(int); virtual void createReader(int fd) = 0; protected: const char* _path; // my registration's path int _port; // my port's address rpcbuf* _service; // my network socket boolean _running; // am I running my dispatch loop? private: // deny access since unimplemented and member-wise won't work RpcService(const RpcService&); RpcService& operator=(const RpcService&); }; #endif ivtools-1.2.11a1/src/include/Dispatch/rpcstream.h000066400000000000000000000046531214471147700216570ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp_rpcstream_h #define dp_rpcstream_h #include //: iostreamb specialized to RPC requests // Modify iostreamb to store a rpcbuf and provide operations on the // rpcbuf, therefore specializing iostreamb to RPC requests. // man page class rpcstream : public #if !defined(_IO_NEW_STREAMS) virtual #endif iostreamb { public: rpcstream(); #if !defined(_IO_NEW_STREAMS) ~rpcstream(); #endif void listen(int port); void connect(const char* host, int port); int accept(); void attach(int fd); void close(); void nonblocking(boolean); void verbose(boolean); rpcbuf* rdbuf(); boolean incomplete_request(); void incomplete_request(boolean); protected: void verify(int); protected: rpcbuf _buf; // streambuf specialized to RPC requests boolean _incomplete_request; // is the incoming request still incomplete? }; // Return or set protected member variables. inline rpcbuf* rpcstream::rdbuf() { return &_buf; } inline boolean rpcstream::incomplete_request() { return _incomplete_request; } inline void rpcstream::incomplete_request(boolean incomplete_request) { _incomplete_request = incomplete_request; } #endif ivtools-1.2.11a1/src/include/Dispatch/rpcwriter.h000066400000000000000000000047301214471147700216740ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef dp_rpcwriter_h #define dp_rpcwriter_h #include class rpcstream; //: write RPC requests to a server // Write RPC requests to a server. Derived classes should add member // functions corresponding to the RPC service's protocol. //

    man page class RpcWriter { public: ~RpcWriter(); rpcstream& server(); protected: RpcWriter(const char* path, boolean fatal, boolean binary); RpcWriter(const char* host, int port, boolean fatal, boolean binary); RpcWriter(int fd, boolean fatal, boolean binary); RpcWriter(rpcstream* server); void open(const char* path, boolean fatal, boolean binary); rpcstream* _server; // sink of RPC requests going to server boolean _delete; // should the destructor delete _server? char* _host; // dynamically allocated storage to be deleted private: // deny access since unimplemented and member-wise won't work RpcWriter(const RpcWriter&); RpcWriter& operator=(const RpcWriter&); }; // Give this function public access so that programs can test this // connection's state or attach a RpcReader to it to read as well // as send RPC requests over the same connection. inline rpcstream& RpcWriter::server() { return *_server; } #endif ivtools-1.2.11a1/src/include/IV-2_6/000077500000000000000000000000001214471147700166415ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/IV-2_6/InterViews/000077500000000000000000000000001214471147700207405ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/IV-2_6/InterViews/adjuster.h000066400000000000000000000100471214471147700227340ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Adjuster - button-like interactors for incremental adjustment of an * interactor's perspective. */ #ifndef ivlook2_6_adjuster_h #define ivlook2_6_adjuster_h #include #include static const int NO_AUTOREPEAT = -1; class Bitmap; class Shape; //: manipulate a perspective using a pushbutton like interface (iv-2.6). // man page class Adjuster : public Interactor { public: Adjuster(Interactor*, int = NO_AUTOREPEAT); Adjuster(const char*, Interactor*, int = NO_AUTOREPEAT); virtual ~Adjuster(); void Handle(Event&); virtual void Highlight(boolean on); void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); void Reshape(Shape&); protected: Interactor* view; Bitmap* plain; Bitmap* hit; Bitmap* mask; int delay; boolean timer; Perspective* shown; boolean highlighted; virtual void AdjustView(Event&); void AutoRepeat(); void Flash(); void HandlePress(); void Invert(); virtual void Reconfig(); void TimerOn(); void TimerOff(); private: void Init(Interactor*, int); }; class Zoomer : public Adjuster { public: Zoomer(Interactor*, float factor); Zoomer(const char*, Interactor*, float factor); virtual ~Zoomer(); protected: void AdjustView(Event&); private: float factor; void Init(float); }; class Enlarger : public Zoomer { public: Enlarger(Interactor*); Enlarger(const char*, Interactor*); virtual ~Enlarger(); private: void Init(); }; class Reducer : public Zoomer { public: Reducer(Interactor*); Reducer(const char*, Interactor*); virtual ~Reducer(); private: void Init(); }; class Mover : public Adjuster { public: Mover(Interactor*, int delay, int moveType); Mover(const char*, Interactor*, int delay, int moveType); virtual ~Mover(); protected: int moveType; void AdjustView(Event&); private: void Init(int); }; class LeftMover : public Mover { public: LeftMover(Interactor*, int delay = NO_AUTOREPEAT); LeftMover(const char*, Interactor*, int delay = NO_AUTOREPEAT); virtual ~LeftMover(); private: void Init(); }; class RightMover : public Mover { public: RightMover(Interactor*, int delay = NO_AUTOREPEAT); RightMover(const char*, Interactor*, int delay = NO_AUTOREPEAT); virtual ~RightMover(); private: void Init(); }; class UpMover : public Mover { public: UpMover(Interactor*, int delay = NO_AUTOREPEAT); UpMover(const char*, Interactor*, int delay = NO_AUTOREPEAT); virtual ~UpMover(); private: void Init(); }; class DownMover : public Mover { public: DownMover(Interactor*, int delay = NO_AUTOREPEAT); DownMover(const char*, Interactor*, int delay = NO_AUTOREPEAT); virtual ~DownMover(); private: void Init(); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/alignment.h000066400000000000000000000042741214471147700230760ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Common definitions for all of InterViews. */ #ifndef iv2_6_alignment_h #define iv2_6_alignment_h #include #include #define ALIGNMENT_DEFINED /* * Alignment needs to be unsigned so that it can be stored * as a bit field. */ typedef unsigned Alignment; /* * Use the concrete type (unsigned) instead of Alignment * to get around cfront 2.1 incorrect warning. */ static const unsigned TopLeft = 0; static const unsigned TopCenter = 1; static const unsigned TopRight = 2; static const unsigned CenterLeft = 3; static const unsigned Center = 4; static const unsigned CenterRight = 5; static const unsigned BottomLeft = 6; static const unsigned BottomCenter = 7; static const unsigned BottomRight = 8; static const unsigned Left = 9; static const unsigned Right = 10; static const unsigned Top = 11; static const unsigned Bottom = 12; static const unsigned HorizCenter = 13; static const unsigned VertCenter = 14; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/banner.h000066400000000000000000000036731214471147700223670ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * A banner is a one line title bar. */ #ifndef ivlook2_6_banner_h #define ivlook2_6_banner_h #include #include //: one line title bar (iv-2.6 // man page class Banner : public Interactor { public: char* left; char* middle; char* right; boolean highlight; Banner(char* lt, char* mid, char* rt); Banner(const char*, char* lt, char* mid, char* rt); ~Banner(); void Update(); protected: int lw, mw, rw; IntCoord lx, mx, rx; Painter* inverse; void Init(char*, char*, char*); void Reconfig(); void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); void Resize(); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/border.h000066400000000000000000000042221214471147700223660ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * A border is simply a infinitely stretchable line. */ #ifndef ivlook2_6_border_h #define ivlook2_6_border_h #include #include //: infinitely stretchable dividing line (iv-2.6) // man page class Border : public Interactor { protected: int thickness; Border(int); Border(const char*, int); virtual ~Border(); void DefaultThickness(int); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); }; class HBorder : public Border { public: HBorder(int thick = -1); HBorder(const char*, int thick = -1); virtual ~HBorder(); protected: virtual void Reconfig(); private: void Init(); }; class VBorder : public Border { public: VBorder(int thick = -1); VBorder(const char*, int thick = -1); virtual ~VBorder(); protected: virtual void Reconfig(); private: void Init(); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/box.h000066400000000000000000000073111214471147700217030ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Boxes are used to compose side-by-side. */ #ifndef iv2_6_box_h #define iv2_6_box_h #include #include class BoxElement; class BoxCanonical; //: used to compose side-by-side (iv-2.6) // man page class Box : public Scene { public: virtual ~Box(); void Align(Alignment); void Draw(); void GetComponents(Interactor**, int, Interactor**&, int&); void Resize(); protected: Alignment align; Box(); virtual void ComputeShape(Shape*); virtual void GetActual(int& major_size, int& minor_size); virtual void GetCanonical(Shape*, BoxCanonical&); BoxElement* Head(); virtual void PlaceElement( Interactor*, Coord major_size, int len, int thick, int minor_size ); virtual void Reconfig(); private: int nelements; BoxElement* head; BoxElement* tail; void DoInsert(Interactor*, boolean, Coord& x, Coord& y); void DoChange(Interactor*); void DoRemove(Interactor*); }; class HBox : public Box { public: HBox(); HBox(Interactor*); HBox(Interactor*, Interactor*); HBox(Interactor*, Interactor*, Interactor*); HBox(Interactor*, Interactor*, Interactor*, Interactor*); HBox(Interactor*, Interactor*, Interactor*, Interactor*, Interactor*); HBox( Interactor*, Interactor*, Interactor*, Interactor*, Interactor*, Interactor* ); HBox( Interactor*, Interactor*, Interactor*, Interactor*, Interactor*, Interactor*, Interactor* ); virtual ~HBox(); protected: void ComputeShape(Shape*); void GetActual(int& major_size, int& minor_size); void GetCanonical(Shape*, BoxCanonical&); void PlaceElement(Interactor*, Coord, int, int, int); private: void Init(); }; class VBox : public Box { public: VBox(); VBox(Interactor*); VBox(Interactor*, Interactor*); VBox(Interactor*, Interactor*, Interactor*); VBox(Interactor*, Interactor*, Interactor*, Interactor*); VBox(Interactor*, Interactor*, Interactor*, Interactor*, Interactor*); VBox( Interactor*, Interactor*, Interactor*, Interactor*, Interactor*, Interactor* ); VBox( Interactor*, Interactor*, Interactor*, Interactor*, Interactor*, Interactor*, Interactor* ); virtual ~VBox(); protected: void ComputeShape(Shape*); void GetActual(int& major_size, int& minor_size); void GetCanonical(Shape*, BoxCanonical&); void PlaceElement(Interactor*, Coord, int, int, int); private: void Init(); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/button.h000066400000000000000000000112411214471147700224230ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * A button is a view of some value that is normally set when * the button is pressed. */ #ifndef ivlook2_6_button_h #define ivlook2_6_button_h #include #include #include class Button; class ButtonList; class Bitmap; class ButtonState : public Subject { public: ButtonState(); ButtonState(int); ButtonState(void*); virtual ~ButtonState(); void operator=(ButtonState&); void SetValue(int); void SetValue(void*); void GetValue (int& v) { v = int(long(value)); } void GetValue (void*& v) { v = value; } protected: void* value; void Modify(void*); }; //: button object (iv-2_6) // A button is a view of some value that is normally set when // the button is pressed. //

    man page class Button : public Interactor { public: void Attach(Button*); void Detach(Button*); void Enable(); void Disable(); void Choose(); void UnChoose(); virtual void Press(); virtual void Refresh(); virtual void Handle(Event&); virtual void Update(); protected: Button(ButtonState*, void*); Button(const char*, ButtonState*, void*); ~Button(); void* value; /* value associated with this button */ ButtonState* subject; /* set to this->value when pressed */ ButtonList* associates; /* enable/disable when chosen/unchosen */ boolean enabled; /* can be pressed */ boolean chosen; /* currently toggled on */ boolean hit; /* currently being pushed */ private: void Init(ButtonState*, void*); }; class TextButton : public Button { protected: char* text; Painter* background; Painter* grayout; /* for disabled buttons */ TextButton(const char*, const char*, ButtonState*, void*); TextButton(const char*, ButtonState*, void*); virtual ~TextButton(); virtual void Reconfig(); void MakeBackground(); void MakeShape(); private: void Init(const char*); }; class PushButton : public TextButton { public: PushButton(const char*, ButtonState*, int); PushButton(const char*, ButtonState*, void*); PushButton(const char*, const char*, ButtonState*, int); PushButton(const char*, const char*, ButtonState*, void*); virtual ~PushButton(); virtual void Refresh(); protected: virtual void Reconfig(); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); private: void Init(); }; class RadioButton : public TextButton { public: RadioButton(const char*, ButtonState*, int); RadioButton(const char*, ButtonState*, void*); RadioButton(const char*, const char*, ButtonState*, int); RadioButton(const char*, const char*, ButtonState*, void*); virtual ~RadioButton(); virtual void Refresh(); protected: virtual void Reconfig(); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); private: void Init(); }; class CheckBox : public TextButton { public: CheckBox(const char*, ButtonState*, int, int); CheckBox(const char*, ButtonState*, void*, void*); CheckBox(const char*, const char*, ButtonState*, int, int); CheckBox(const char*, const char*, ButtonState*, void*, void*); virtual ~CheckBox(); virtual void Press(); virtual void Refresh(); virtual void Update(); protected: virtual void Reconfig(); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); private: void* offvalue; void Init(void*); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/compeditor.h000066400000000000000000000040311214471147700232540ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * CompletionEditor - StringEditor with completion */ #ifndef ivlook2_6_compeditor_h #define ivlook2_6_compeditor_h #include #include const char CEComplete = ' '; //: string-editor with completion (iv-2_6) //

    man page class CompletionEditor : public StringEditor { public: CompletionEditor(ButtonState*, const char* samp, const char* = SEDone); CompletionEditor( const char* name, ButtonState*, const char*, const char* = SEDone ); virtual ~CompletionEditor(); void Completions(const char* list[], int count, char = CEComplete); protected: virtual boolean HandleChar(char); private: void Init(); char complete_; const char** completions_; int count_; }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/control.h000066400000000000000000000100261214471147700225700ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Controls provide an interface to selecting and executing some action. */ #ifndef ivlook2_6_control_h #define ivlook2_6_control_h #include #include #include #include class Control; class ControlState; //: provide an interface to selecting and executing some action (iv-2.6) // man page class Control : public MonoScene { public: Control(Interactor*); Control(const char* name, Interactor*); ~Control(); ControlState* State() { return state_; } void SetState(ControlState*); virtual void Handle(Event&); virtual void Enable(boolean); boolean Enabled(); virtual void Select(); /* highlight, open, and grab */ virtual void Unselect(); /* close, unhighlight */ virtual void Do(); /* action for selection */ Control* ParentControl(); Control* RootControl(); protected: virtual void Down(); /* activate control */ virtual void Enter(); /* select a control if active */ virtual void Open(); /* open subviews, if any */ virtual void Grab(); /* read input events */ virtual void Skip(); /* ignore until enter active control */ virtual void Leave(); /* unselect if active */ virtual void Close(); /* close subviews, if any */ virtual void Up(); /* deactivate control, do selection */ virtual void Busy(); virtual void Done(); virtual boolean IsGrabbing(Interactor*); void Reparent(Control*, Control* parent); private: ControlState* state_; boolean enabled_; Control* parent_; void Init(const char*, Interactor*); }; inline boolean Control::Enabled() { return enabled_; } inline Control* Control::ParentControl() { return parent_; } /* * ControlState is a subject that several controls share to exchange * common information. */ enum ControlStatus { ControlActive = 0x1 }; class ControlState : virtual public Subject { public: ControlState(unsigned status = 0); ~ControlState(); boolean Active() { return Set(ControlActive); } void Activate() { Set(ControlActive, true); } virtual void Deactivate(); Control* Selection() { return selection; } void Selection(Control* c) { selection = c; } virtual void NotifySelection(Control*); Control* Action() { return action; } void Action(Control* c) { action = c; } void Push(ControlState*); void Pop(); ControlState* Next() { return next; } ControlState* Prev() { return prev; } protected: unsigned status; Control* selection; Control* action; ControlState* next; ControlState* prev; boolean Set(ControlStatus s) { return (status & s) != 0; } void Set(ControlStatus s, boolean b) { status = b ? (status | s) : (status & ~s); } }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/deck.h000066400000000000000000000042311214471147700220170ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Deck - a Scene for stacking Interactors */ #ifndef iv2_6_deck_h #define iv2_6_deck_h #include #include class Card; //: a Scene for stacking one or more Interactor (iv-2.6) // man page class Deck : public Scene { public: Deck(); Deck(const char*); ~Deck(); void Flip(int = 1); void FlipTo(int); void Top () { FlipTo(1); } void Bottom () { FlipTo(-1); } virtual void Adjust(Perspective&); virtual void Draw(); virtual void GetComponents(Interactor**, int, Interactor**&, int&); virtual void Resize(); protected: Card* cards; Interactor* top; virtual void DoInsert(Interactor*, boolean, Coord&, Coord&); virtual void DoRemove(Interactor*); virtual void DoChange(Interactor*); virtual void Reconfig(); private: void FixPerspective(); void Init(); void NewTop(); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/defs.h000066400000000000000000000027641214471147700220430ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv2_6_defs_h #define iv2_6_defs_h #include #include #include #include #include #include #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/dialog.h000066400000000000000000000036711214471147700223570ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Dialog - a simple dialog box input handler. */ #ifndef ivlook2_6_dialog_h #define ivlook2_6_dialog_h #include #include class ButtonState; //: a simple dialog box input handler (iv-2.6) // man page class Dialog : public MonoScene { public: Dialog(ButtonState*, Interactor*, Alignment = Center); Dialog(const char*, ButtonState*, Interactor*, Alignment = Center); virtual ~Dialog(); virtual boolean Accept(); virtual boolean Popup(Event&, boolean placed = true); int Status(); protected: ButtonState* state; Alignment align; private: void Init(ButtonState*, Interactor*, Alignment); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/filebrowser.h000066400000000000000000000053551214471147700234440ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * FileBrowser - a StringBrowser that displays file names. */ #ifndef ivlook2_6_filebrowser_h #define ivlook2_6_filebrowser_h #include #include class FBDirectory; class Regexp; //: a StringBrowser that displays file names (iv-2.6) // man page class FileBrowser : public StringBrowser { public: FileBrowser( ButtonState*, const char* dir = "~", int rows = 10, int cols = 24, boolean uniqueSel = true, int highlight = Reversed, const char* done = SBDone ); FileBrowser( const char* name, ButtonState*, const char* = "~", int = 10, int = 24, boolean = true, int = Reversed, const char* = SBDone ); virtual ~FileBrowser(); boolean IsADirectory(const char*); boolean SetDirectory(const char*); const char* GetDirectory(); const char* ValidDirectories(const char*); const char* Normalize(const char*); const char* Path(int index); void RereadDirectory(); void SetTextFilter(const char*); void SetDirectoryTextFilter(const char*); void SetModeFilter(int); void SetDirectoryModeFilter(int); virtual void Update(); protected: void UpdateStrings(); virtual boolean Acceptable(const char*); private: void Init(const char*); FBDirectory* dir; char* lastpath; Regexp* regexp; Regexp* directory_regexp; int mode; int directory_mode; }; inline const char* FileBrowser::GetDirectory () { return lastpath; } #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/filechooser.h000066400000000000000000000054411214471147700234170ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * FileChooser - a StringChooser for choosing files from a directory. */ #ifndef ivlook2_6_filechooser_h #define ivlook2_6_filechooser_h #include #include class Button; class FileBrowser; class MarginFrame; #undef FileChooser #define FileChooser _lib_iv2_6(FileChooser) //: a StringChooser for choosing files from a directory (iv-2.6) // man page class FileChooser : public StringChooser { public: FileChooser( const char* title = "Please select a file:", const char* subtitle = "", const char* dir = "~", int rows = 10, int cols = 24, const char* acceptLabel = " Open ", Alignment = Center ); FileChooser( const char* name, const char* title, const char* subtitle, const char* dir, int, int, const char* acceptLabel, Alignment ); virtual ~FileChooser(); void SetTitle(const char*); void SetSubtitle(const char*); void SelectFile(); virtual boolean Accept(); virtual void Update(); protected: FileChooser(ButtonState*, Alignment = Center); FileChooser(ButtonState*, const char* dir, int rows, int cols, Alignment); void Init(const char*, const char*); Interactor* Interior(const char* acptlbl); Interactor* AddScroller(Interactor*); FileBrowser* browser(); virtual void UpdateEditor(); virtual void UpdateBrowser(); protected: MarginFrame* title, *subtitle; }; inline FileBrowser* FileChooser::browser () { return (FileBrowser*) _browser; } #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/frame.h000066400000000000000000000111741214471147700222070ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * A frame surrounds another interactor. */ #ifndef ivlook2_6_frame_h #define ivlook2_6_frame_h #include #include //: surrounds another Interactor (iv-2.6) // man page class Frame : public MonoScene { public: Frame(Interactor* = nil, int width = 1); Frame(const char*, Interactor* = nil, int width = 1); virtual ~Frame(); protected: int left:8, bottom:8, right:8, top:8; Frame(Interactor*, int, int, int, int); Frame(const char*, Interactor*, int, int, int, int); virtual void Reconfig(); virtual void Resize(); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); private: void Init(Interactor*, int, int, int, int); }; class ShowFrame : public Frame { public: ShowFrame(Interactor* i = nil, int width = 1) : Frame(i, width) { Init(); } ShowFrame( const char* name, Interactor* i = nil, int width = 1 ) : Frame(name, i, width) { Init(); } virtual ~ShowFrame(); virtual void Handle(Event&); virtual void HandleInput(Event&); virtual void InsideFrame(boolean); protected: ShowFrame( Interactor* i, int l, int b, int r, int h ) : Frame(i, l, b, r, h) { Init(); } ShowFrame( const char* name, Interactor* i, int l, int b, int r, int h ) : Frame(name, i, l, b, r, h) { Init(); } private: void Init(); }; class Banner; class TitleFrame : public ShowFrame { public: TitleFrame(Banner*, Interactor*, int width = 1); TitleFrame(const char*, Banner*, Interactor*, int width = 1); virtual ~TitleFrame(); virtual void InsideFrame(boolean); protected: Banner* banner; virtual Interactor* Wrap(Interactor*); private: void Init(Banner*, Interactor*); }; class BorderFrame : public ShowFrame { public: BorderFrame(Interactor* = nil, int width = 1); BorderFrame(const char*, Interactor* = nil, int width = 1); virtual ~BorderFrame(); virtual void InsideFrame(boolean); protected: virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); private: boolean normal; void Init(); }; class ShadowFrame : public Frame { public: ShadowFrame(Interactor* = nil, int h = 1, int v = 1); ShadowFrame(const char*, Interactor* = nil, int h = 1, int v = 1); virtual ~ShadowFrame(); protected: virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); private: void Init(Interactor*, int h, int v); }; class MarginFrame : public Frame { public: MarginFrame(Interactor* = nil, int margin = 0); MarginFrame(const char*, Interactor* = nil, int margin = 0); MarginFrame(Interactor*, int margin, int shrink, int stretch); MarginFrame(const char*, Interactor*, int margin, int shrink, int stretch); MarginFrame(Interactor*, int hmargin, int vmargin); MarginFrame(const char*, Interactor*, int hmargin, int vmargin); MarginFrame( Interactor*, int hmargin, int hshrink, int hstretch, int vmargin, int vshrink, int vstretch ); MarginFrame( const char*, Interactor*, int hmargin, int hshrink, int hstretch, int vmargin, int vshrink, int vstretch ); virtual ~MarginFrame(); protected: virtual void Reconfig(); virtual void Resize(); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); protected: int hmargin, hshrink, hstretch; int vmargin, vshrink, vstretch; private: void Init(int, int, int, int, int, int); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/glue.h000066400000000000000000000046031214471147700220500ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Glue is useful for variable spacing between interactors. */ #ifndef iv2_6_glue_h #define iv2_6_glue_h #include #include #include //: variable spacing between interactors (iv-2.6) // man page class Glue : public Interactor { protected: Glue(); Glue(const char*); virtual ~Glue(); void Redraw(Coord, Coord, Coord, Coord); private: void Init(); }; class HGlue : public Glue { public: HGlue(int natural = 0, int stretch = hfil); HGlue(const char*, int natural = 0, int stretch = hfil); HGlue(int natural, int shrink, int stretch); HGlue(const char*, int natural, int shrink, int stretch); virtual ~HGlue(); private: void Init(int nat, int shrink, int stretch); }; class VGlue : public Glue { public: VGlue(int natural = 0, int stretch = vfil); VGlue(const char*, int natural = 0, int stretch = vfil); VGlue(int natural, int shrink, int stretch); VGlue(const char*, int natural, int shrink, int stretch); virtual ~VGlue(); private: void Init(int nat, int shrink, int stretch); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/ihandler.h000066400000000000000000000031501214471147700226760ustar00rootroot00000000000000/* * Copyright (c) 1992 Stanford University * Copyright (c) 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * InteractorHandler - special handler for interactors */ #ifndef iv2_6_ihandler_h #define iv2_6_ihandler_h #include #include class Interactor; class InteractorHandler : public Handler { public: InteractorHandler(Interactor*); virtual ~InteractorHandler(); virtual boolean event(Event&); private: Interactor* interactor_; }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/interactor.h000066400000000000000000000127221214471147700232670ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Base class for interactive objects. */ #ifndef iv2_6_interactor_h #define iv2_6_interactor_h #include #include #include #include #include #include #include #include #include class Bitmap; class Cursor; class Event; class InteractorHandler; class InteractorWindow; class ManagedWindow; class Painter; class Perspective; class Scene; class Sensor; class Shape; class Style; class Window; class World; enum CanvasType { CanvasShapeOnly, CanvasInputOnly, CanvasInputOutput, CanvasSaveUnder, CanvasSaveContents, CanvasSaveBoth }; //: base class for interactive objects (iv-2.6) // man page class Interactor : public Glyph { protected: Interactor(); Interactor(const char*); public: virtual ~Interactor(); /* configuration */ void Align(Alignment, int w, int h, Coord& l, Coord& b) const; void Config(Scene* = nil); void Config(World*); virtual void Reconfig(); const char* GetAttribute(const char*) const; boolean AttributeIsSet(const char*) const; virtual void Reshape(Shape&); Shape* GetShape() const; void SetCursor(Cursor*); Cursor* GetCursor() const; const char* GetClassName() const; const char* GetInstance() const; void GetRelative(Coord& x, Coord &y, Interactor* = nil) const; void GetRelative(Coord& x, Coord &y, World*) const; void GetPosition(Coord& left, Coord& bottom) const; /* traversing hierarchy */ virtual void GetComponents(Interactor**, int, Interactor**&, int&); Scene* Parent() const; World* GetWorld() const; /* output */ Canvas* GetCanvas() const; virtual void Draw(); virtual void Highlight(boolean on); void Flush(); void Sync(); static boolean ValidCanvas(Canvas*); /* input events */ boolean Check(); int CheckQueue(); void Listen(Sensor*); void Poll(Event&); void Read(Event&); boolean Read(long sec, long usec, Event&); void UnRead(Event&); void Run(); void QuitRunning(Event&); virtual void Handle(Event&); /* subject-view communication */ virtual void Adjust(Perspective&); Perspective* GetPerspective() const; virtual void Update(); /* canvas properties */ void SetCanvasType(CanvasType); CanvasType GetCanvasType() const; /* top-level interactors */ ManagedWindow* GetTopLevelWindow() const; /* glyph */ virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual void undraw(); protected: Shape* shape; /* desired shape characteristics */ Canvas* canvas; /* actual display area */ Perspective* perspective; /* portion displayed */ Coord xmax; /* canvas->Width() - 1 */ Coord ymax; /* canvas->Height() - 1 */ Sensor* input; /* normal input event interest */ Painter* output; /* normal output parameters */ virtual void Redraw(Coord left, Coord bottom, Coord right, Coord top); virtual void RedrawList(int n, Coord[], Coord[], Coord[], Coord[]); virtual void Resize(); virtual void Activate(); virtual void Deactivate(); void SetClassName(const char*); void SetInstance(const char*); private: friend class InteractorHandler; friend class InteractorWindow; friend class Scene; friend class World; Scene* parent; Style* style; const char* classname; const char* instance; Sensor* cursensor; InteractorWindow* window; World* world; Window* insert_window; ManagedWindow* managed_window; Cursor* cursor_; CanvasType canvas_type_; InteractorHandler* handler_; void Init(); void DefaultConfig(boolean&); void DoConfig(boolean); virtual void Orphan(); }; inline Scene* Interactor::Parent() const { return parent; } inline Perspective* Interactor::GetPerspective() const { return perspective; } inline Shape* Interactor::GetShape() const { return shape; } #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/iwindow.h000066400000000000000000000035241214471147700225750ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * InteractorWindow - special subwindow for interactors */ #ifndef iv2_6_iwindow_h #define iv2_6_iwindow_h #include #include class Interactor; class InteractorWindow : public Window { public: InteractorWindow(Interactor*); InteractorWindow(Interactor*, Window*); virtual ~InteractorWindow(); virtual void bind(); virtual void unbind(); virtual void receive(const Event&); virtual Handler* target(const Event&) const; protected: virtual void set_attributes(); private: Interactor* interactor_; Window* parent_; }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/matcheditor.h000066400000000000000000000037241214471147700234220ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * MatchEditor - string editor with pattern matching */ #ifndef ivlook2_6_matcheditor_h #define ivlook2_6_matcheditor_h #include #include //: StringEditor with pattern matching. // man page class MatchEditor : public StringEditor { public: MatchEditor(ButtonState*, const char* sample, const char* done = SEDone); MatchEditor( const char* name, ButtonState*, const char*, const char* = SEDone ); virtual ~MatchEditor(); virtual void Match(const char* pattern, boolean keystoke = true); protected: virtual boolean HandleChar(char); char pattern[100]; boolean match_on_keystroke; private: void Init(); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/menu.h000066400000000000000000000074121214471147700220610ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Common menus built on top of controls */ #ifndef ivlook2_6_menu_h #define ivlook2_6_menu_h #include #include #include class MenuItem : public Control { public: MenuItem(Interactor*); MenuItem(const char* name, Interactor*); MenuItem(const char* str, Alignment = Left); MenuItem(const char* name, const char* str, Alignment = Left); virtual ~MenuItem(); protected: virtual void Busy(); virtual void Done(); private: void Init(); }; //: menu derived from Control (iv-2.6) // man page class Menu : public Control { public: Menu(Interactor*); Menu(const char* name, Interactor* i); virtual ~Menu(); void SetAlign(Alignment); Alignment GetAlign() { return align_; } void SetDepth(int); int GetDepth() { return depth_; } void SetBodyState(ControlState*); ControlState* GetBodyState() { return state_; } void SetScene(Scene*); Scene* GetScene() { return scene_; } virtual void Include(Control*); virtual void Popup(Event&); IntCoord InsertX() { return ins_x_; } IntCoord InsertY() { return ins_y_; } protected: virtual void Leave(); virtual void Open(); virtual void Close(); virtual void Reconfig(); virtual void Setup(); virtual void InsertBody(IntCoord, IntCoord); private: Interactor* body_; Scene* scene_; ControlState* state_; Interactor* shadow_; unsigned int depth_ : 16; unsigned int align_ : 16; class World* world_; IntCoord ins_x_, ins_y_; IntCoord rel_x_, rel_y_; private: void Init(); }; class MenuBar : public HBox { public: MenuBar(); MenuBar(const char* name); virtual ~MenuBar(); virtual void Include(Control*); protected: ControlState* state_; private: void Init(); }; class PulldownMenu : public Menu { public: PulldownMenu(Interactor* i); PulldownMenu(const char* name, Interactor* i); PulldownMenu(const char* str); PulldownMenu(const char* name, const char* str); virtual ~PulldownMenu(); private: void Init(); }; class PullrightMenu : public Menu { public: PullrightMenu(Interactor* i); PullrightMenu(const char* name, Interactor* i); PullrightMenu(const char* str); PullrightMenu(const char* name, const char* str); virtual ~PullrightMenu(); private: void Init(); }; class PopupMenu : public Menu { public: PopupMenu(); PopupMenu(const char*); virtual ~PopupMenu(); private: void Init(); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/message.h000066400000000000000000000042161214471147700225400ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Message - display a string of text */ #ifndef iv2_6_message_h #define iv2_6_message_h #include #include //: display a string of text (iv-2.6). // man page class Message : public Interactor { public: Message( const char* msg, Alignment al = Center, int pad = 0, int hstretch = 0, int vstretch = 0 ); Message( const char* name, const char* msg, Alignment al = Center, int pad = 0, int hstretch = 0, int vstretch = 0 ); virtual ~Message(); virtual void Highlight(boolean); virtual void Realign(Alignment); protected: char* text; Alignment alignment : 16; unsigned pad : 15; boolean highlighted : 1; virtual void Reconfig(); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); private: void Init(const char*, Alignment, int pad, int hstretch, int vstretch); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/minmax.h000066400000000000000000000042261214471147700224060ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv2_6_minmax_h #define iv2_6_minmax_h #include #if !defined(min) && !defined(max) #define declare_2(T) \ inline T min(T a, T b) { return a < b ? a : b; } \ inline T max(T a, T b) { return a > b ? a : b; } \ declare_2(int) declare_2(unsigned) declare_2(float) declare_2(double) /* * Compiler isn't smart enough to figure out how to do 4-way min inline. */ #define declare_4(T) \ inline T min(T a, T b, T c, T d) { \ T r1 = min(a, b), r2 = min(c, d); \ return min(r1, r2); \ } \ \ inline T max(T a, T b, T c, T d) { \ T r1 = max(a, b), r2 = max(c, d); \ return max(r1, r2); \ } declare_4(int) declare_4(float) declare_4(double) #endif /* !defined(min) && !defined(max) */ #if __GNUC__<3 && 0 /* removed, used Math::round from now on */ inline int round(double x) { return x > 0 ? int(x+0.5) : -int(-x+0.5); } #endif inline boolean equal(float x, float y, float e) { return x - y < e && y - x < e; } #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/paint.h000066400000000000000000000025721214471147700222320ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv2_6_paint_h #define iv2_6_paint_h #include #include #include #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/painter.h000066400000000000000000000147251214471147700225640ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Graphics interface */ #ifndef iv2_6_painter_h #define iv2_6_painter_h #include #include #include #include #include #include class Canvas; class Color; class PainterRep; class Pattern; class Brush; class Font; class Transformer; class Bitmap; class Raster; //: graphics rendering interface (iv-2.6) // man page class Painter : public Resource { public: Painter(); Painter(Painter*); ~Painter(); void FillBg(boolean); boolean BgFilled() const; void SetColors(const Color* f, const Color* b); const Color* GetFgColor() const; const Color* GetBgColor() const; void SetPattern(const Pattern*); const Pattern* GetPattern() const; void SetBrush(const Brush*); const Brush* GetBrush() const; void SetFont(const Font*); const Font* GetFont() const; void SetStyle(int); int GetStyle() const; void SetTransformer(Transformer*); Transformer* GetTransformer() const; void MoveTo(int x, int y); void GetPosition(int& x, int& y) const; void SetOrigin(int x0, int y0); void GetOrigin(int& x0, int& y0) const; void Translate(float dx, float dy); void Scale(float x, float y); void Rotate(float angle); virtual void Clip( Canvas*, Coord left, Coord bottom, Coord right, Coord top ); virtual void NoClip(); virtual void SetOverwrite(boolean); virtual void SetPlaneMask(int); virtual void Text(Canvas*, const char*); virtual void Text(Canvas*, const char*, int); virtual void Text(Canvas*, const char*, Coord, Coord); virtual void Text(Canvas*, const char*, int, Coord, Coord); virtual void Stencil( Canvas*, Coord x, Coord y, Bitmap* image, Bitmap* mask = nil ); #ifdef RasterRect #undef RasterRect virtual void RasterRect(Canvas*, Coord x, Coord y, Raster*); #define RasterRect _lib_iv(RasterRect) #else virtual void RasterRect(Canvas*, Coord x, Coord y, Raster*); #endif /* RasterRect */ #ifdef Point #undef Point virtual void Point(Canvas*, Coord x, Coord y); #define Point _lib_iv(Point) #else virtual void Point(Canvas*, Coord x, Coord y); #endif /* Point */ virtual void MultiPoint(Canvas*, Coord x[], Coord y[], int n); #ifdef Line #undef Line virtual void Line(Canvas*, Coord x1, Coord y1, Coord x2, Coord y2); #define Line _lib_iv(Line) #else virtual void Line(Canvas*, Coord x1, Coord y1, Coord x2, Coord y2); #endif /* Line */ virtual void Rect(Canvas*, Coord x1, Coord y1, Coord x2, Coord y2); virtual void FillRect(Canvas*, Coord x1, Coord y1, Coord x2, Coord y2); virtual void ClearRect(Canvas*, Coord x1, Coord y1, Coord x2, Coord y2); virtual void Circle(Canvas*, Coord x, Coord y, int r); virtual void FillCircle(Canvas*, Coord x, Coord y, int r); #ifdef Ellipse #undef Ellipse virtual void Ellipse(Canvas*, Coord x, Coord y, int r1, int r2); #define Ellipse _lib_iv(Ellipse) #else virtual void Ellipse(Canvas*, Coord x, Coord y, int r1, int r2); #endif /* Ellipse */ virtual void FillEllipse(Canvas*, Coord x, Coord y, int r1, int r2); #ifdef MultiLine #undef MultiLine virtual void MultiLine(Canvas*, Coord x[], Coord y[], int n); #define MultiLine _lib_iv(MultiLine) #else virtual void MultiLine(Canvas*, Coord x[], Coord y[], int n); #endif /* MultiLine */ #ifdef Polygon #undef Polygon virtual void Polygon(Canvas*, Coord x[], Coord y[], int n); #define Polygon _lib_iv(Polygon) #else virtual void Polygon(Canvas*, Coord x[], Coord y[], int n); #endif /* Polygon */ virtual void FillPolygon(Canvas*, Coord x[], Coord y[], int n); virtual void BSpline(Canvas*, Coord x[], Coord y[], int n); #ifdef ClosedBSpline #undef ClosedBSpline virtual void ClosedBSpline(Canvas*, Coord x[], Coord y[], int n); #define ClosedBSpline _lib_iv(ClosedBSpline) #else virtual void ClosedBSpline(Canvas*, Coord x[], Coord y[], int n); #endif /* ClosedBSpline */ virtual void FillBSpline(Canvas*, Coord x[], Coord y[], int n); virtual void Curve(Canvas*, Coord x0, Coord y0, Coord x1, Coord y1, Coord x2, Coord y2, Coord x3, Coord y3 ); virtual void CurveTo(Canvas*, Coord x0, Coord y0, Coord x1, Coord y1, Coord x2, Coord y2 ); virtual void Copy( Canvas* src, Coord x1, Coord y1, Coord x2, Coord y2, Canvas* dst, Coord x0, Coord y0 ); PainterRep* Rep() const; private: friend class Rubberband; const Font* font; const Color* foreground; const Color* background; const Brush* br; const Pattern* pattern; int style; Coord curx, cury; int xoff, yoff; Transformer* matrix; PainterRep* rep; void Init(); void Copy(Painter*); void Begin_xor(); void End_xor(); void Map(Canvas*, Coord x, Coord y, Coord& mx, Coord& my); void Map(Canvas*, Coord x, Coord y, short& sx, short& sy); void MapList(Canvas*, Coord x[], Coord y[], int n, Coord mx[], Coord my[]); void MapList(Canvas*, float x[], float y[], int n, Coord mx[], Coord my[]); void MultiLineNoMap(Canvas* c, Coord x[], Coord y[], int n); void FillPolygonNoMap(Canvas* c, Coord x[], Coord y[], int n); }; inline PainterRep* Painter::Rep() const { return rep; } #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/panner.h000066400000000000000000000061401214471147700223750ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Panner - an interactor for two-dimensional scrolling and zooming. */ #ifndef ivlook2_6_panner_h #define ivlook2_6_panner_h #include #include //: an Interactor for two-dimensional scrolling and zooming (iv-2.6) // man page class Panner : public MonoScene { public: Panner(Interactor*, int size = 0); Panner(const char*, Interactor*, int size = 0); virtual ~Panner(); protected: int size; virtual void Reconfig(); private: Interactor* adjusters; Interactor* slider; void Init(Interactor*, int); }; class Slider : public Interactor { public: Slider(Interactor*); Slider(const char*, Interactor*); virtual ~Slider(); virtual void Draw(); virtual void Handle(Event&); virtual void Update(); virtual void Reshape(Shape&); virtual void Resize(); protected: virtual void Reconfig(); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); private: Interactor* interactor; Perspective* view; Perspective* shown; IntCoord left, bottom, right, top; IntCoord prevl, prevb, prevr, prevt; // for smart update IntCoord llim, blim, rlim, tlim; // sliding limits boolean constrained, syncScroll; int moveType; IntCoord origx, origy; void Init(Interactor*); IntCoord ViewX(IntCoord); IntCoord ViewY(IntCoord); IntCoord SliderX(IntCoord); IntCoord SliderY(IntCoord); void CalcLimits(Event&); // calculate sliding limits void SizeKnob(); // calculate size of slider knob boolean Inside(Event&); // true if inside slider knob void Constrain(Event&); // constrain slider knob motion void Move(IntCoord dx, IntCoord dy);// move view to reflect slider position void Slide(Event&); // rubberband rect while mousing void Jump(Event&); // for click outside knob }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/perspective.h000066400000000000000000000046621214471147700234520ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * A perspective describes what portion of the total view * an interactor shows. */ #ifndef iv2_6_perspective_h #define iv2_6_perspective_h #include #include #include #include class Interactor; class ViewList; //: indicates portion of total view shown (iv-2.6). // A Perspective describes what portion of the total view // an Interactor shows. //

    man page class Perspective : public Resource { public: IntCoord x0, y0; /* origin of view */ int width, height; /* total size of view */ IntCoord curx, cury; /* current position */ int curwidth, curheight; /* current size */ int sx, sy, lx, ly; /* small and large scrolling increments */ Perspective(); Perspective(Perspective&); ~Perspective(); void Init(IntCoord ix0, IntCoord iy0, int iwidth, int iheight); void Attach(Interactor*); void Detach(Interactor*); void Update(); boolean operator ==(Perspective&); boolean operator !=(Perspective&); Perspective& operator =(Perspective&); protected: ViewList* views; /* interactors that access the perspective */ }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/rubband.h000066400000000000000000000063531214471147700225350ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Rubber - rubberbanding graphical objects */ #ifndef iv2_6_rubband_h #define iv2_6_rubband_h #include #include #include typedef unsigned long ClassId; // borrowed from Unidraw enum Side { LeftSide, RightSide, BottomSide, TopSide }; enum RubberTypes { RUBBERBAND, FIXEDPIN, GROWINGVERTICES, GROWINGBSPLINE, GROWINGCLOSEDBSPLINE, GROWINGMULTILINE, GROWINGPOLYGON, ROTATINGRECT, RUBBERELLIPSE, RUBBERCIRCLE, SLIDINGELLIPSE, SLIDINGPIN, RUBBERGROUP, RUBBERLINE, ROTATINGLINE, RUBBERAXIS, SCALINGLINE, SLIDINGLINE, RUBBERPOINTLIST, ROTATINGLINELIST, RUBBERVERTEX, RUBBERCLOSEDSPLINE, RUBBERHANDLES, RUBBERSPLINE, SCALINGLINELIST, SLIDINGPOINTLIST, SLIDINGLINELIST, RUBBERRECT, RUBBERSQUARE, SCALINGRECT, SLIDINGRECT, STRETCHINGRECT }; class Canvas; class Painter; //: rubberbanding graphical objects (iv-2.6) // man page class Rubberband : public Resource { public: Rubberband(Painter*, Canvas*, IntCoord offx, IntCoord offy); virtual ~Rubberband(); virtual ClassId GetClassId () { return RUBBERBAND; } virtual boolean IsA(ClassId id) { return RUBBERBAND == id; } virtual void Draw(); virtual void Redraw(); virtual void Erase(); virtual void Track(IntCoord x, IntCoord y); void SetTrack(IntCoord x, IntCoord y) { trackx=x; tracky=y; } void GetTrack(IntCoord& x, IntCoord& y) { x=trackx; y=tracky; } IntCoord TrackX() { return trackx; } IntCoord TrackY() { return tracky; } virtual void SetPainter(Painter*); virtual void SetCanvas(Canvas*); Painter* GetPainter(); Canvas* GetCanvas(); protected: float Angle(IntCoord, IntCoord, IntCoord, IntCoord); float Distance(IntCoord, IntCoord, IntCoord, IntCoord); protected: Painter* output; Canvas* canvas; boolean drawn; IntCoord trackx, offx; IntCoord tracky, offy; }; inline Painter* Rubberband::GetPainter () { return output; } inline Canvas* Rubberband::GetCanvas () { return canvas; } #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/rubcurve.h000066400000000000000000000201551214471147700227510ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Rubberbanding for curves. */ #ifndef iv2_6_rubcurve_h #define iv2_6_rubcurve_h #include class RubberEllipse : public Rubberband { public: RubberEllipse( Painter*, Canvas*, IntCoord cx, IntCoord cy, IntCoord rx, IntCoord ry, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return RUBBERELLIPSE; } virtual boolean IsA (ClassId id) { return RUBBERELLIPSE == id || Rubberband::IsA(id); } virtual void GetOriginal( IntCoord& cx, IntCoord& cy, IntCoord& rx, IntCoord& ry ); virtual void GetCurrent( IntCoord& cx, IntCoord& cy, IntCoord& rx, IntCoord& ry ); virtual void OriginalRadii(int& xr, int& yr); virtual void CurrentRadii(int& xr, int& yr); virtual void Draw(); protected: IntCoord centerx, radiusx; IntCoord centery, radiusy; }; class SlidingEllipse : public RubberEllipse { public: SlidingEllipse( Painter*, Canvas*, IntCoord cx, IntCoord cy, IntCoord xr, IntCoord yr, IntCoord rfx, IntCoord rfy, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return SLIDINGELLIPSE; } virtual boolean IsA (ClassId id) { return SLIDINGELLIPSE == id || RubberEllipse::IsA(id); } virtual void GetCurrent( IntCoord& cx, IntCoord& cy, IntCoord& xr, IntCoord& yr ); virtual void OriginalRadii(int&, int&); virtual void CurrentRadii(int&, int&); protected: IntCoord refx; IntCoord refy; }; class RubberCircle : public RubberEllipse { public: RubberCircle( Painter*, Canvas*, IntCoord cx, IntCoord cy, IntCoord rx, IntCoord ry, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return RUBBERCIRCLE; } virtual boolean IsA (ClassId id) { return RUBBERCIRCLE == id || RubberEllipse::IsA(id); } virtual void OriginalRadii(int& xr, int& yr); virtual void CurrentRadii(int& xr, int& yr); virtual void Draw(); }; class RubberPointList : public Rubberband { public: RubberPointList( Painter*, Canvas*, IntCoord px[], IntCoord py[], int n, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return RUBBERPOINTLIST; } virtual boolean IsA (ClassId id) { return RUBBERPOINTLIST == id || Rubberband::IsA(id); } ~RubberPointList(); protected: void Copy(IntCoord*, IntCoord*, int, IntCoord*&, IntCoord*&); protected: IntCoord *x; IntCoord *y; int count; }; class RubberVertex : public RubberPointList { public: RubberVertex( Painter*, Canvas*, IntCoord px[], IntCoord py[], int n, int pt, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return RUBBERVERTEX; } virtual boolean IsA (ClassId id) { return RUBBERVERTEX == id || RubberPointList::IsA(id); } virtual void GetOriginal(IntCoord*& px, IntCoord*& py, int& n, int& pt); virtual void GetCurrent(IntCoord*& px, IntCoord*& py, int& n, int& pt); protected: void DrawSplineSection (Painter*, Canvas*, IntCoord x[], IntCoord y[]); protected: int rubberPt; }; class RubberHandles : public RubberVertex { public: RubberHandles( Painter*, Canvas*, IntCoord x[], IntCoord y[], int n, int pt, int size, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return RUBBERHANDLES; } virtual boolean IsA (ClassId id) { return RUBBERHANDLES == id || RubberVertex::IsA(id); } virtual void Track(IntCoord x, IntCoord y); virtual void Draw(); protected: int d; /* half of handle size */ }; class RubberSpline : public RubberVertex { public: RubberSpline( Painter*, Canvas*, IntCoord px[], IntCoord py[], int n, int pt, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return RUBBERSPLINE; } virtual boolean IsA (ClassId id) { return RUBBERSPLINE == id || RubberVertex::IsA(id); } virtual void Draw(); }; class RubberClosedSpline : public RubberVertex { public: RubberClosedSpline( Painter*, Canvas*, IntCoord px[], IntCoord py[], int n, int pt, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return RUBBERCLOSEDSPLINE; } virtual boolean IsA (ClassId id) { return RUBBERCLOSEDSPLINE == id || RubberVertex::IsA(id); } virtual void Draw(); }; class SlidingPointList : public RubberPointList { public: SlidingPointList ( Painter*, Canvas*, IntCoord px[], IntCoord py[], int n, IntCoord rfx, IntCoord rfy, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return SLIDINGPOINTLIST; } virtual boolean IsA (ClassId id) { return SLIDINGPOINTLIST == id || RubberPointList::IsA(id); } virtual void GetOriginal(IntCoord*& px, IntCoord*& py, int& n); virtual void GetCurrent(IntCoord*& px, IntCoord*& py, int& n); virtual void Draw(); virtual void Track(IntCoord x, IntCoord y); protected: IntCoord refx; IntCoord refy; }; class SlidingLineList : public SlidingPointList { public: SlidingLineList( Painter*, Canvas*, IntCoord x[], IntCoord y[], int n, IntCoord rfx, IntCoord rfy, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return SLIDINGLINELIST; } virtual boolean IsA (ClassId id) { return SLIDINGLINELIST == id || SlidingPointList::IsA(id); } virtual void Draw(); }; class ScalingLineList : public RubberPointList { public: ScalingLineList ( Painter*, Canvas*, IntCoord px[], IntCoord py[], int n, IntCoord cx, IntCoord cy, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return SCALINGLINELIST; } virtual boolean IsA (ClassId id) { return SCALINGLINELIST == id || RubberPointList::IsA(id); } virtual ~ScalingLineList(); virtual void GetOriginal(IntCoord*& px, IntCoord*& py, int& n); virtual void GetCurrent(IntCoord*& px, IntCoord*& py, int& n); virtual void Track(IntCoord, IntCoord); virtual void Draw(); float CurrentScaling(); protected: virtual void Update(); protected: IntCoord* newx, *newy; IntCoord centerx, centery; IntCoord width, height; }; class RotatingLineList : public RubberPointList { public: RotatingLineList ( Painter*, Canvas*, IntCoord px[], IntCoord py[], int n, IntCoord cx, IntCoord cy, IntCoord rfx, IntCoord rfy, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return ROTATINGLINELIST; } virtual boolean IsA (ClassId id) { return ROTATINGLINELIST == id || RubberPointList::IsA(id); } virtual ~RotatingLineList(); virtual void GetOriginal(IntCoord*& px, IntCoord*& py, int& n); virtual void GetCurrent(IntCoord*& px, IntCoord*& py, int& n); virtual void Track(IntCoord, IntCoord); virtual void Draw(); float OriginalAngle(); float CurrentAngle(); protected: virtual void Update(); protected: IntCoord* newx, *newy; IntCoord centerx, centery; IntCoord refx, refy; }; #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/rubgroup.h000066400000000000000000000043121214471147700227560ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * RubberGroup - a group of Rubberbands to track simultaneously. */ #ifndef iv2_6_rubgroup_h #define iv2_6_rubgroup_h #include class RubberList; class RubberGroup : public Rubberband { public: RubberGroup(Painter*, Canvas*); virtual ClassId GetClassId() { return RUBBERGROUP; } virtual boolean IsA (ClassId id) { return RUBBERGROUP == id || Rubberband::IsA(id); } virtual ~RubberGroup(); virtual void Draw(); virtual void Erase(); virtual void Track(IntCoord, IntCoord); virtual void SetPainter(Painter*); virtual void SetCanvas(Canvas*); void Append( Rubberband*, Rubberband* = nil, Rubberband* = nil, Rubberband* = nil ); void Remove(Rubberband*); void RemoveCur(); void SetCurrent(Rubberband*); Rubberband* GetCurrent(); Rubberband* First(); Rubberband* Last(); Rubberband* Next(); Rubberband* Prev(); boolean IsEmpty(); boolean AtEnd(); private: RubberList* rlist, *cur; }; #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/rubline.h000066400000000000000000000102051214471147700225470ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Rubberbanding for simple lines. */ #ifndef iv2_6_rubline_h #define iv2_6_rubline_h #include class RubberLine : public Rubberband { public: RubberLine( Painter*, Canvas*, IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return RUBBERLINE; } virtual boolean IsA (ClassId id) { return RUBBERLINE == id || Rubberband::IsA(id); } virtual void GetOriginal( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); virtual void GetCurrent( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); virtual void Draw(); protected: IntCoord fixedx, fixedy; IntCoord movingx, movingy; }; class RubberAxis : public RubberLine { public: RubberAxis( Painter*, Canvas*, IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return RUBBERAXIS; } virtual boolean IsA (ClassId id) { return RUBBERAXIS == id || RubberLine::IsA(id); } virtual void GetCurrent( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); }; class SlidingLine : public RubberLine { public: SlidingLine( Painter*, Canvas*, IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1, IntCoord rfx, IntCoord rfy, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return SLIDINGLINE; } virtual boolean IsA (ClassId id) { return SLIDINGLINE == id || RubberLine::IsA(id); } virtual void GetCurrent( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); protected: IntCoord refx; IntCoord refy; }; class ScalingLine : public RubberLine { public: ScalingLine( Painter*, Canvas*, IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1, IntCoord cx, IntCoord cy, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return SCALINGLINE; } virtual boolean IsA (ClassId id) { return SCALINGLINE == id || RubberLine::IsA(id); } virtual void GetCurrent( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); float CurrentScaling(); protected: IntCoord centerx, centery; int width, height; }; class RotatingLine : public RubberLine { public: RotatingLine( Painter*, Canvas*, IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1, IntCoord cx, IntCoord cy, IntCoord rfx, IntCoord rfy, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return ROTATINGLINE; } virtual boolean IsA (ClassId id) { return ROTATINGLINE == id || RubberLine::IsA(id); } virtual void GetCurrent( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); float OriginalAngle(); float CurrentAngle(); protected: void Transform ( IntCoord& x, IntCoord& y, double a0, double a1, double b0, double b1, double c0, double c1 ); protected: IntCoord centerx, centery, refx, refy; }; #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/rubrect.h000066400000000000000000000116321214471147700225620ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Rubberbanding for rectangles. */ #ifndef iv2_6_rubrect_h #define iv2_6_rubrect_h #include class RubberRect : public Rubberband { public: RubberRect( Painter*, Canvas*, IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return RUBBERRECT; } virtual boolean IsA (ClassId id) { return RUBBERRECT == id || Rubberband::IsA(id); } virtual void GetOriginal( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); virtual void GetCurrent( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); virtual void Draw(); protected: IntCoord fixedx, fixedy; IntCoord movingx, movingy; }; class RubberSquare : public RubberRect { public: RubberSquare( Painter*, Canvas*, IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return RUBBERSQUARE; } virtual boolean IsA (ClassId id) { return RUBBERSQUARE == id || RubberRect::IsA(id); } virtual void GetCurrent( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); }; class SlidingRect : public RubberRect { public: SlidingRect( Painter*, Canvas*, IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1, IntCoord rfx, IntCoord rfy, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return SLIDINGRECT; } virtual boolean IsA (ClassId id) { return SLIDINGRECT == id || RubberRect::IsA(id); } virtual void GetCurrent( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); protected: IntCoord refx; IntCoord refy; }; class StretchingRect : public RubberRect { public: StretchingRect ( Painter*, Canvas*, IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1, Side s, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return STRETCHINGRECT; } virtual boolean IsA (ClassId id) { return STRETCHINGRECT == id || RubberRect::IsA(id); } virtual void GetCurrent( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); float CurrentStretching(); protected: Side side; }; class ScalingRect : public RubberRect { public: ScalingRect( Painter*, Canvas*, IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1, IntCoord cx, IntCoord cy, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return SCALINGRECT; } virtual boolean IsA (ClassId id) { return SCALINGRECT == id || RubberRect::IsA(id); } virtual void GetCurrent( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); float CurrentScaling(); protected: IntCoord centerx, centery; int width, height; }; class RotatingRect : public Rubberband { public: RotatingRect( Painter*, Canvas*, IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1, IntCoord cx, IntCoord cy, IntCoord rfx, IntCoord rfy, IntCoord offx = 0, IntCoord offy = 0 ); virtual ClassId GetClassId() { return ROTATINGRECT; } virtual boolean IsA (ClassId id) { return ROTATINGRECT == id || Rubberband::IsA(id); } virtual void Draw(); virtual void GetOriginal( IntCoord& x0, IntCoord& y0, IntCoord& x1, IntCoord& y1 ); virtual void GetCurrent( IntCoord& leftbotx, IntCoord& leftboty, IntCoord& rightbotx, IntCoord& rightboty, IntCoord& righttopx, IntCoord& righttopy, IntCoord& lefttopx, IntCoord& lefttopy ); float CurrentAngle(); protected: void Transform ( IntCoord& x, IntCoord& y, double a0, double a1, double b0, double b1, double c0, double c1 ); protected: IntCoord left, right, centerx, refx; IntCoord bottom, top, centery, refy; }; #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/rubverts.h000066400000000000000000000105021214471147700227630ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * GrowingVertices and subclasses - rubberbands defined by a set of vertices * that can grow dynamically in number. */ #ifndef iv2_6_rubverts_h #define iv2_6_rubverts_h #include class GrowingVertices : public Rubberband { public: virtual ClassId GetClassId() { return GROWINGVERTICES; } virtual boolean IsA (ClassId id) { return GROWINGVERTICES == id || Rubberband::IsA(id); } virtual ~GrowingVertices(); virtual void AddVertex(IntCoord, IntCoord); virtual void RemoveVertex(); virtual void Draw(); virtual void GetOriginal(IntCoord*& px, IntCoord*& py, int& n, int& pt); virtual void GetCurrent(IntCoord*& px, IntCoord*& py, int& n, int& pt); protected: GrowingVertices( Painter*, Canvas*, IntCoord px[], IntCoord py[], int n, int pt = -1, int handleSize = -1 ); void Init(IntCoord px[], IntCoord py[], int, int, int); void CheckBufs(); void Copy(IntCoord*, IntCoord*, int, IntCoord*&, IntCoord*&); virtual void DrawVertices(IntCoord*, IntCoord*, int); virtual void DrawHandles(); protected: IntCoord* x, *y; int count, bufsize, origbufsize; int curPt, origPt; int handleSize; public: // obsolete calls virtual void AppendVertex(IntCoord, IntCoord); virtual void GetOriginal(IntCoord*& px, IntCoord*& py, int& n); virtual void GetCurrent(IntCoord*& px, IntCoord*& py, int& n); int Count() { return count; } }; class GrowingMultiLine : public GrowingVertices { public: GrowingMultiLine( Painter*, Canvas*, IntCoord px[], IntCoord py[], int n, int pt = -1, int handleSize = -1 ); virtual ClassId GetClassId() { return GROWINGMULTILINE; } virtual boolean IsA (ClassId id) { return GROWINGMULTILINE == id || GrowingVertices::IsA(id); } protected: virtual void DrawVertices(IntCoord*, IntCoord*, int); }; class GrowingPolygon : public GrowingVertices { public: GrowingPolygon( Painter*, Canvas*, IntCoord px[], IntCoord py[], int n, int pt = -1, int handleSize = -1 ); virtual ClassId GetClassId() { return GROWINGPOLYGON; } virtual boolean IsA (ClassId id) { return GROWINGPOLYGON == id || GrowingVertices::IsA(id); } protected: virtual void DrawVertices(IntCoord*, IntCoord*, int); }; class GrowingBSpline : public GrowingVertices { public: GrowingBSpline( Painter*, Canvas*, IntCoord px[], IntCoord py[], int n, int pt = -1, int handleSize = -1 ); virtual ClassId GetClassId() { return GROWINGBSPLINE; } virtual boolean IsA (ClassId id) { return GROWINGBSPLINE == id || GrowingVertices::IsA(id); } protected: virtual void DrawVertices(IntCoord*, IntCoord*, int); }; class GrowingClosedBSpline : public GrowingVertices { public: GrowingClosedBSpline( Painter*, Canvas*, IntCoord px[], IntCoord py[], int n, int pt = -1, int handleSize = -1 ); virtual ClassId GetClassId() { return GROWINGCLOSEDBSPLINE; } virtual boolean IsA (ClassId id) { return GROWINGCLOSEDBSPLINE == id || GrowingVertices::IsA(id); } protected: virtual void DrawVertices(IntCoord*, IntCoord*, int); }; #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/scene.h000066400000000000000000000063551214471147700222170ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Basic composite object for interaction. */ #ifndef iv2_6_scene_h #define iv2_6_scene_h #include #include //: basic composite object for interaction. // man page class Scene : public Interactor { protected: Scene(); public: virtual ~Scene(); void Insert(Interactor*); void Insert(Interactor*, Coord x, Coord y, Alignment = BottomLeft); void Change(Interactor* = nil); void Remove(Interactor*); void Move(Interactor*, Coord x, Coord y, Alignment = BottomLeft); void Raise(Interactor*); void Lower(Interactor*); void Propagate(boolean); virtual void Highlight(boolean); protected: boolean propagate; void PrepareToInsert(Interactor*); virtual Interactor* Wrap(Interactor*); virtual void DoInsert(Interactor*, boolean, Coord& x, Coord& y); virtual void DoChange(Interactor*); virtual void DoMove(Interactor*, Coord& x, Coord& y); virtual void DoRemove(Interactor*); virtual void DoRaise(Interactor*); virtual void DoLower(Interactor*); void Place(Interactor*, Coord, Coord, Coord, Coord, boolean map = true); void Map(Interactor*, boolean raised = true); void Unmap(Interactor*); private: void DoAlign(Interactor*, Alignment, Coord& x, Coord& y); virtual void Orphan(); }; /* Scene with a single component */ class MonoScene : public Scene { protected: MonoScene(); public: virtual ~MonoScene(); virtual void Draw(); virtual void GetComponents(Interactor**, int, Interactor**&, int&); virtual void Resize(); protected: Interactor* interior(); void interior(Interactor*); virtual void DoInsert(Interactor*, boolean, Coord&, Coord&); virtual void DoChange(Interactor*); virtual void DoRemove(Interactor*); virtual void Reconfig(); private: Interactor* interior_; }; inline Interactor* MonoScene::interior() { return interior_; } inline void MonoScene::interior(Interactor* i) { interior_ = i; } #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/scrollbar.h000066400000000000000000000041251214471147700230760ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * ScrollBar - simple scrolling interface. */ #ifndef ivlook2_6_scrollbar_h #define ivlook2_6_scrollbar_h #include #include class ScrollBar : public MonoScene { protected: Interactor* interactor; int size; ScrollBar(Interactor*, int); ScrollBar(const char*, Interactor*, int); virtual ~ScrollBar(); void Use(Interactor*); }; class HScrollBar : public ScrollBar { public: HScrollBar(Interactor*, int size = 0); HScrollBar(const char*, Interactor*, int size = 0); virtual ~HScrollBar(); virtual void Reconfig(); private: void Init(); }; class VScrollBar : public ScrollBar { public: VScrollBar(Interactor*, int size = 0); VScrollBar(const char*, Interactor*, int size = 0); virtual ~VScrollBar(); virtual void Reconfig(); private: void Init(); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/scroller.h000066400000000000000000000060161214471147700227410ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * General scrolling interface. */ #ifndef ivlook2_6_scroller_h #define ivlook2_6_scroller_h #include #include //: general scrolling interface (iv-2.6) // man page class Scroller : public Interactor { protected: Interactor* interactor; int size; Perspective* view; Perspective* shown; double scale; Sensor* tracking; boolean syncScroll; Scroller(Interactor*, int); Scroller(const char*, Interactor*, int); virtual ~Scroller(); void Background(IntCoord, IntCoord, IntCoord, IntCoord); void MakeBackground(); virtual void Resize(); private: void Init(); }; class HScroller : public Scroller { public: HScroller(Interactor*, int size = 0); HScroller(const char*, Interactor*, int size = 0); virtual ~HScroller(); virtual void Handle(Event&); virtual void Update(); private: void Bar(IntCoord, int); void Border(IntCoord); void GetBarInfo(Perspective*, IntCoord&, int&); void Init(); void Outline(IntCoord, int); virtual void Reconfig(); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); void Sides(IntCoord, IntCoord); IntCoord Slide(Event&); }; class VScroller : public Scroller { public: VScroller(Interactor*, int size = 0); VScroller(const char*, Interactor*, int size = 0); virtual ~VScroller(); virtual void Handle(Event&); virtual void Update(); private: void Bar(IntCoord, int); void Border(IntCoord); void GetBarInfo(Perspective*, IntCoord&, int&); void Init(); void Outline(IntCoord, int); virtual void Reconfig(); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); void Sides(IntCoord, IntCoord); IntCoord Slide(Event&); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/sensor.h000066400000000000000000000056051214471147700224300ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Sensors describe input events of interest. */ #ifndef iv2_6_sensor_h #define iv2_6_sensor_h #include #include #include class Interactor; class InteractorWindow; //: describe input events of interest (iv-2.6) // man page class Sensor : virtual public Resource { public: Sensor(); Sensor(const Sensor&); Sensor(const Sensor*); virtual ~Sensor(); virtual Sensor& operator =(const Sensor&); void Catch(EventType); void CatchButton(EventType, int); void Ignore(EventType); void IgnoreButton(EventType, int); boolean Caught(const Event&) const; static void init(); protected: unsigned long mask; unsigned long down[8]; unsigned long up[8]; int ButtonIndex(unsigned long b) const { return (b >> 5) & 07; } int ButtonFlag(unsigned long b) const{ return 1 << (b & 0x1f); } void SetButton(unsigned long a[], unsigned long b) { a[ButtonIndex(b)] |= ButtonFlag(b); } void ClearButton(unsigned long a[], unsigned long b) { a[ButtonIndex(b)] &= ~ButtonFlag(b); } boolean ButtonIsSet(const unsigned long a[], unsigned long b) const { return (a[ButtonIndex(b)] & ButtonFlag(b)) != 0; } void SetMouseButtons(unsigned long a[]) { a[0] |= 0x7; } void ClearMouseButtons(unsigned long a[]) { a[0] &= ~0x7; } boolean MouseButtons(const unsigned long a[]) const { return (a[0] & 0x7) != 0; } private: friend class Interactor; friend class InteractorWindow; }; extern Sensor* allEvents; extern Sensor* onoffEvents; extern Sensor* updownEvents; extern Sensor* noEvents; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/shape.h000066400000000000000000000040741214471147700222160ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv2_6_shape_h #define iv2_6_shape_h #include /* * Constants for defining "infinite" stretchability or shrinkability. */ static const int hfil = 1000000; static const int vfil = 1000000; //: for defining "infinite" stretchability or shrinkability (iv-2.6) // man page class Shape { public: int width, height; /* natural dimensions */ int hstretch, vstretch; /* stretchability */ int hshrink, vshrink; /* shrinkability */ int aspect; /* desired aspect ratio, 0 means don't care */ int hunits, vunits; /* allocate in multiples */ Shape(); ~Shape(); void Square(int); void Rect(int w, int h); void Rigid(int hshr = 0, int hstr = 0, int vshr = 0, int vstr = 0); void SetUndefined(); boolean Defined(); boolean Undefined () { return !Defined(); } }; #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/strbrowser.h000066400000000000000000000114221214471147700233250ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * StringBrowser - a Mac minifinder-like object for perusing and choosing * from list of strings. */ #ifndef ivlook2_6_strbrowser_h #define ivlook2_6_strbrowser_h #include #include #include static const char* SBDone = "\r\t\007\033"; static const char SBFirstString = 'g'; static const char SBLastString = 'G'; static const char SBSelectAll = 'a'; static const char SBUnselectAll = '\177'; static const char SBUnselectAllAlt = '\010'; static const char SBSelectPreviousString = 'p'; static const char SBSelectNextString = 'n'; static const char SBSelectTopString = '<'; static const char SBSelectBottomString = '>'; static const char SBScrollDown = 'j'; static const char SBScrollUp = 'k'; static const char SBPageDown = ' '; static const char SBPageUp = 'b'; static const char SBHalfPageDown = 'd'; static const char SBHalfPageUp = 'u'; class ButtonState; class TextDisplay; //: for choosing from list of strings (iv-2.6) // man page class StringBrowser : public Interactor { public: StringBrowser( ButtonState*, int rows, int cols, boolean uniqueSel = true, int highlight = Reversed, const char* done = SBDone ); StringBrowser( const char* name, ButtonState*, int, int, boolean = true, int = Reversed, const char* = SBDone ); virtual ~StringBrowser(); void Browse(); void Insert(const char*, int index); void Replace(const char*, int index); void Append(const char*); void Remove(int index); int Index(const char*); char* String(int); int Count(); void Clear(); void Select(int index); void SelectAll(); void Unselect(int index); void UnselectAll(); int Selection(int selindex = 0); int SelectionIndex(int index); int Selections(); boolean Selected(int index); virtual void Handle(Event&); virtual void Adjust(Perspective&); protected: void Select(int dot, int mark); void Unselect(int dot, int mark); void ScrollBy(int, int); void ScrollBy(int lines); void ScrollTo(int, int); void ScrollTo(int index); void ScrollToView(IntCoord, IntCoord); void GrabScroll(Event&); void RateScroll(Event&); int Locate(IntCoord, IntCoord); boolean DoubleClicked(Event&); virtual boolean HandleChar(char); virtual boolean LeftButtonDown(Event&); virtual void Reconfig(); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); virtual void Resize(); protected: int rows; int columns; boolean uniqueSel; boolean singleClick; int clickDelay; int highlight; ButtonState* subject; const char* done; private: void Init(ButtonState*, int, int, boolean, int, const char*); void InitTextDisplay(); void InitPerspective(boolean scroll_to_top); void UpdateSelection(int dot, int mark, int style); void UpdateWidth(); void Note(Event&); boolean HandleDownEvent(Event&); boolean HandleKeyEvent(Event&); private: char** strbuf; int strbufsize; int strcount; char** selbuf; int selbufsize; int selcount; TextDisplay* display; int lineheight; unsigned long lasttime; IntCoord lastx, lasty; int lastdot, lastmark; }; inline void StringBrowser::Append (const char* s) { Insert(s, strcount); } inline int StringBrowser::Count () { return strcount; } inline int StringBrowser::Selections () { return selcount; } inline boolean StringBrowser::Selected (int i) {return SelectionIndex(i) >= 0;} #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/strchooser.h000066400000000000000000000050401214471147700233030ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * StringChooser - a dialog box that provides a keyboard and mouse interface * to selecting from a list of strings. */ #ifndef ivlook2_6_strchooser_h #define ivlook2_6_strchooser_h #include #include class StringBrowser; class StringEditor; //: dialog box for choosing from list of strings (iv-2.6) // man page class StringChooser : public Dialog { public: StringChooser( ButtonState*, int rows, int cols, const char* sample, Alignment =Center ); StringChooser( const char* name, ButtonState*, int, int, const char*, Alignment = Center ); virtual ~StringChooser(); void Select(int = -1); void Select(int left, int right); void SelectMessage(); void Message(const char*); virtual const char* Choice(); virtual boolean Accept(); virtual void Handle(Event&); protected: StringChooser(ButtonState*, Alignment = Center); void Init(StringEditor*, StringBrowser*); void Forward(Event&); virtual void SwitchFocus(); virtual boolean CanFocus(Interactor*); virtual void HandleFocus(); virtual void UpdateEditor(); virtual void UpdateBrowser(); protected: StringEditor* _sedit; StringBrowser* _browser; Interactor* _focus; }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/streditor.h000066400000000000000000000060341214471147700231330ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * StringEditor - interactive editor for character strings */ #ifndef ivlook2_6_streditor_h #define ivlook2_6_streditor_h #include #include static const char* SEDone = "\r\t\007\033"; static const char SEBeginningOfLine = '\001'; static const char SEEndOfLine = '\005'; static const char SESelectAll = '\025'; static const char SESelectWord = '\027'; static const char SEPreviousCharacter = '\002'; static const char SENextCharacter = '\006'; static const char SEDeleteNextCharacter = '\004'; static const char SEDeletePreviousCharacter = '\177'; static const char SEDeletePreviousCharacterAlt = '\010'; static const char SEDeleteUntilEndOfLine = '\013'; class ButtonState; class TextDisplay; class TextBuffer; //: interactive editor for character strings (iv-2.6) // man page class StringEditor : public Interactor { public: StringEditor(ButtonState*, const char* sample, const char* done = SEDone); StringEditor( const char* name, ButtonState*, const char*, const char* = SEDone ); virtual ~StringEditor(); void Message(const char* text); void Select(int); void Select(int left, int right); void Edit(); void Edit(const char* text, int left, int right); const char* Text(); virtual void Handle(Event&); virtual void Reconfig(); protected: virtual boolean HandleChar(char); void InsertText(const char*, int); void DoSelect(int left, int right); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); virtual void Resize(); TextBuffer* text; int left, right; ButtonState* subject; char* done; char* sample; char* buffer; int size; TextDisplay* display; private: void Init(ButtonState*, const char*, const char*); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/subject.h000066400000000000000000000035411214471147700225530ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * A subject is an object that has one or more views * that it wishes to notify when it changes. */ #ifndef iv2_6_subject_h #define iv2_6_subject_h #include #include class Interactor; class SubjectRep; //: object with one or more views to notify when it changes (iv-2.6) // man page class Subject : virtual public Resource { public: virtual ~Subject(); virtual void Attach(Interactor*); virtual void Detach(Interactor*); virtual void Notify(); virtual boolean IsView(Interactor*); protected: Subject(); private: SubjectRep* rep_; }; #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/textbuffer.h000066400000000000000000000100031214471147700232610ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TextBuffer - editable text buffer */ #ifndef iv2_6_textbuffer_h #define iv2_6_textbuffer_h #include class Regexp; //: editable text buffer (iv-2.6) // man page class TextBuffer { public: TextBuffer(char* buffer, int length, int size); virtual ~TextBuffer(); int Search(Regexp* regexp, int index, int range, int stop); int ForwardSearch(Regexp* regexp, int index); int BackwardSearch(Regexp* regexp, int index); int Match(Regexp* regexp, int index, int stop); boolean ForwardMatch(Regexp* regexp, int index); boolean BackwardMatch(Regexp* regexp, int index); virtual int Insert(int index, const char* string, int count); virtual int Delete(int index, int count); int Copy(int index, char* buffer, int count); int Height(); int Width(); int Length(); const char* Text(); const char* Text(int index); const char* Text(int index1, int index2); char Char (int index); int LineIndex(int line); int LinesBetween(int index1, int index2); int LineNumber(int index); int LineOffset (int index); int PreviousCharacter(int index); int NextCharacter(int index); boolean IsBeginningOfText(int index); int BeginningOfText(); boolean IsEndOfText(int index); int EndOfText(); boolean IsBeginningOfLine(int index); int BeginningOfLine(int index); int BeginningOfNextLine(int index); boolean IsEndOfLine(int index); int EndOfLine(int index); int EndOfPreviousLine(int index); boolean IsBeginningOfWord(int index); int BeginningOfWord(int index); int BeginningOfNextWord(int index); boolean IsEndOfWord(int index); int EndOfWord(int index); int EndOfPreviousWord(int index); protected: char* text; int length; int size; private: int linecount; int lastline; int lastindex; }; inline char TextBuffer::Char (int i) { return (i<0) ? text[0] : (i>length) ? text[length] : text[i]; } inline const char* TextBuffer::Text () { return text; } inline const char* TextBuffer::Text (int i) { return text + ((i<0) ? 0 : (i>length) ? length : i); } inline const char* TextBuffer::Text (int i, int) { return text + ((i<0) ? 0 : (i>length) ? length : i); } inline int TextBuffer::PreviousCharacter (int i) { return (i<=0) ? 0 : i-1; } inline int TextBuffer::NextCharacter (int i) { return (i>=length) ? length : i+1; } inline boolean TextBuffer::IsBeginningOfText (int i) { return i <= 0; } inline int TextBuffer::BeginningOfText () { return 0; } inline boolean TextBuffer::IsEndOfText (int i) { return i >= length; } inline int TextBuffer::EndOfText () { return length; } inline int TextBuffer::Height () { return linecount; } inline int TextBuffer::Length () { return length; } #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/textdisplay.h000066400000000000000000000072521214471147700234710ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TextDisplay - basic text displaying */ #ifndef iv2_6_textdisplay_h #define iv2_6_textdisplay_h #include #include #include #include #include enum CaretStyleOptions { NoCaret, DefaultCaret, BarCaret, UnderscoreCaret, OutlineCaret }; class Painter; class Canvas; class TextLine; //: basic text display (iv-2.6) // man page class TextDisplay { public: TextDisplay(boolean autosized = false); ~TextDisplay(); void Draw(Painter*, Canvas*); void LineHeight(IntCoord height); void TabWidth(IntCoord width); void Scroll(int line, IntCoord x, IntCoord y); void Resize(IntCoord xmin, IntCoord ymin, IntCoord xmax, IntCoord ymax); void Bounds( IntCoord& xmin, IntCoord& ymin, IntCoord& xmax, IntCoord& ymax ); void Redraw(IntCoord l, IntCoord b, IntCoord r, IntCoord t); void InsertLinesAfter(int line, int count = 1); void InsertLinesBefore(int line, int count = 1); void DeleteLinesAfter(int line, int count = 1); void DeleteLinesBefore(int line, int count = 1); void InsertText(int line, int index, const char*, int count); void DeleteText(int line, int index, int count); void ReplaceText(int line, const char*, int count); void Style(int line1, int index1, int line2, int index2, int style); void AddStyle(int line1, int index1, int line2, int index2, int style); void RemoveStyle(int line1, int index1, int line2, int index2, int style); void Caret(int line, int index); void CaretStyle(int); int LineNumber(IntCoord y); int LineIndex(int line, IntCoord x, boolean between = true); IntCoord Width(); IntCoord Height(); IntCoord Base(int line); IntCoord Top(int line); IntCoord Left(int line, int index); IntCoord Right(int line, int index); private: friend class TextLine; void Size(int, int); TextLine* Line(int, boolean); int Index(int); void HideCaret(); void ShowCaret(); Painter* painter; Canvas* canvas; boolean autosized; IntCoord xmin, xmax; IntCoord ymin, ymax; IntCoord x0, y0; IntCoord width; int lineheight; int tabwidth; TextLine** lines; int maxlines; int firstline; int lastline; int topline; int bottomline; int widestline; int caretline; int caretindex; int caretstyle; }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/texteditor.h000066400000000000000000000071141214471147700233070ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TextEditor - basic interactive editor for mulit-line text */ #ifndef ivlook2_6_texteditor_h #define ivlook2_6_texteditor_h #include #include class TextDisplay; class TextBuffer; //: basic interactive editor for mulit-line text (iv-2.6) // man page class TextEditor : public Interactor { public: TextEditor(int rows, int cols, int tabsize, int highlight); TextEditor(const char* name, int r, int c, int t, int h); virtual ~TextEditor(); void Edit(TextBuffer*, int index = 0); int Dot(); int Mark(); void InsertText(const char*, int); void DeleteText(int); void DeleteSelection(); void BackwardCharacter(int = 1), ForwardCharacter(int = 1); void BackwardLine(int = 1), ForwardLine(int = 1); void BackwardWord(int = 1), ForwardWord(int = 1); void BackwardPage(int = 1), ForwardPage(int = 1); void BeginningOfLine(), EndOfLine(); void BeginningOfWord(), EndOfWord(); void BeginningOfSelection(), EndOfSelection(); void BeginningOfText(), EndOfText(); void SetScrollAlignment(Alignment); Alignment GetScrollAlignment(); void ScrollToSelection(boolean always = false); void ScrollToView(IntCoord x, IntCoord y); void ScrollBy(IntCoord dx, IntCoord dy); void GrabScroll(Event&); void RateScroll(Event&); virtual void Adjust(Perspective&); void Select(int dot); void SelectMore(int mark); void SelectAll(); void Select(int dot, int mark); int Locate(IntCoord x, IntCoord y); void DisableCaret(); void EnableCaret(); protected: virtual void Reconfig(); virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); virtual void Resize(); TextBuffer* text; TextDisplay* display; private: void ScrollTo(int x, int y); void Init(int r, int c, int t, int h); int dot, mark; int tabsize; int lineheight; int highlight; int shaperows; int shapecolumns; Alignment scrollalign; int caret_off; }; inline int TextEditor::Dot () { return dot; } inline int TextEditor::Mark () { return mark; } inline void TextEditor::SetScrollAlignment (Alignment a) { scrollalign = a; } inline Alignment TextEditor::GetScrollAlignment() { return scrollalign; } #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/textstyle.h000066400000000000000000000026441214471147700231640ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv2_6_textstyle_h #define iv2_6_textstyle_h #include enum TextStyle { Plain = 0x0, Boldface = 0x1, Underlined = 0x2, Reversed = 0x4, Outlined = 0x8 }; #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/tray.h000066400000000000000000000064461214471147700221020ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Tray - composes interactors into (possibly) overlapping layouts. */ #ifndef iv2_6_tray_h #define iv2_6_tray_h #include #include #include #include class TrayElement; class TSolver; class TGlue : public Resource { public: TGlue(int w = 0, int h = 0, int hstretch = hfil, int vstretch = vfil); TGlue(int w, int h, int hshr, int hstr, int vshr, int vstr); ~TGlue(); Shape* GetShape(); private: Shape* shape; }; //: composes interactors into (possibly) overlapping layouts (iv-2.6) // man page class Tray : public Scene { public: Tray(Interactor* background = nil); Tray(const char*, Interactor* background = nil); ~Tray(); virtual void Draw(); virtual void Reshape(Shape&); virtual void GetComponents(Interactor**, int, Interactor**&, int&); void Align(Alignment, Interactor*, TGlue* = nil); void Align(Alignment, Interactor*, Alignment, Interactor*, TGlue* = nil); void Align( Alignment, Interactor*, Interactor*, Interactor* = nil, Interactor* = nil, Interactor* = nil, Interactor* = nil, Interactor* = nil ); void HBox( Interactor*, Interactor*, Interactor* = nil, Interactor* = nil, Interactor* = nil, Interactor* = nil, Interactor* = nil ); void VBox( Interactor*, Interactor*, Interactor* = nil, Interactor* = nil, Interactor* = nil, Interactor* = nil, Interactor* = nil ); protected: virtual void DoInsert(Interactor*, boolean, Coord& x, Coord& y); virtual void DoChange(Interactor*); virtual void DoRemove(Interactor*); virtual void Reconfig(); virtual void Resize(); private: int nelements; TrayElement* head; TrayElement* tail; Interactor* bg; TSolver* tsolver; void Init(Interactor*); void ComponentBounds(int&, int&); boolean AlreadyInserted(Interactor*); void CalcShape(); void PlaceElement(TrayElement*); boolean TrayOrBg(Interactor*); }; inline Shape* TGlue::GetShape () { return shape; } #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/viewport.h000066400000000000000000000063021214471147700227710ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * A viewport contains another interactor. Unlike a MonoScene or Frame, * a viewport always gives the interactor its desired shape. However, * the interactor may not be entirely viewable through the viewport. * The viewport's perspective can be used to adjust what portion is visible. */ #ifndef iv2_6_viewport_h #define iv2_6_viewport_h #include #include //: Interactor that shows a portion of another Interactor (iv-2.6) // A viewport contains another interactor. Unlike a MonoScene or Frame, // a viewport always gives the interactor its desired shape. However, // the interactor may not be entirely viewable through the viewport. // The viewport's Perspective can be used to adjust what portion is visible. //

    man page class Viewport : public MonoScene { public: Viewport(Interactor* = nil, Alignment = Center); Viewport(const char*, Interactor* = nil, Alignment = Center); ~Viewport(); virtual void Adjust(Perspective&); virtual void Resize(); void AdjustTo(float px, float py, float zx, float zy); void AdjustBy(float dpx, float dpy, float dzx, float dzy); void ScrollTo(float px, float py); void ScrollXTo(float px); void ScrollYTo(float py); void ScrollBy(float dpx, float dpy); void ScrollXBy(float dpx); void ScrollYBy(float dpy); void ZoomTo(float zx, float zy); void ZoomXTo(float zx); void ZoomYTo(float zy); void ZoomBy(float dzx, float dzy); void ZoomXBy(float dzx); void ZoomYBy(float dzy); float XPos(); float YPos(); float XMag(); float YMag(); protected: Alignment align; Painter* background; virtual void Reconfig(); virtual void Redraw(Coord, Coord, Coord, Coord); virtual void DoMove(Interactor*, Coord& x, Coord& y); private: int cwidth; int cheight; void Init(Interactor*, Alignment); void DoAdjust(float px, float py, float zx, float zy); }; #include #endif ivtools-1.2.11a1/src/include/IV-2_6/InterViews/world.h000066400000000000000000000130561214471147700222450ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * World -- object representing a display */ #ifndef iv_world_h #define iv_world_h #include #include class Color; class Event; class Font; class Interactor; class Sensor; //: object representing a display (iv-2.6) // man page class World { protected: World(); public: World( const char*, int& argc, char** argv, const OptionDesc* = nil, const PropertyData* = nil ); virtual ~World(); virtual Session* session() const; virtual Display* display() const; virtual const char* name() const; virtual const char* classname() const; virtual int argc() const; virtual char** argv() const; virtual Style* style() const; virtual const char* property_value(const char*) const; virtual boolean property_is_on(const char*) const; virtual const Font* font() const; virtual const Color* foreground() const; virtual const Color* background() const; virtual boolean shaped_windows() const; virtual boolean double_buffered() const; virtual void flush(); virtual void sync(); virtual Coord width() const; virtual Coord height() const; virtual unsigned int pwidth() const; virtual unsigned int pheight() const; virtual void run(); virtual void quit(); virtual boolean done() const; virtual boolean pending() const; virtual void read(Event&); virtual boolean read(long sec, long usec, Event&); virtual void unread(Event&); virtual void poll(Event&); virtual void RingBell(int); virtual void SetKeyClick(int); virtual void SetAutoRepeat(boolean); virtual void SetFeedback(int thresh, int scale); virtual void SetScreen(int); static World* current(); protected: void make_current(); private: friend class Interactor; static World* current_; Session* session_; Display* display_; /* * Old functions for backward compatibility * * We use "unsigned" for Alignment and "6" for BottomLeft to avoid * conflicts with new 3.0 names (like Center). */ public: void InsertApplication(Interactor*); void InsertApplication( Interactor*, _lib_iv2_6(Coord) x, _lib_iv2_6(Coord) y, unsigned = 6 ); void InsertToplevel(Interactor*, Interactor*); void InsertToplevel( Interactor*, Interactor*, _lib_iv2_6(Coord) x, _lib_iv2_6(Coord) y, unsigned = 6 ); void InsertPopup(Interactor*); void InsertPopup( Interactor*, _lib_iv2_6(Coord) x, _lib_iv2_6(Coord) y, unsigned = 6 ); void InsertTransient(Interactor*, Interactor*); void InsertTransient( Interactor*, Interactor*, _lib_iv2_6(Coord) x, _lib_iv2_6(Coord) y, unsigned = 6 ); void InsertIcon(Interactor*); void InsertIcon( Interactor*, _lib_iv2_6(Coord) x, _lib_iv2_6(Coord) y, unsigned = 6 ); void Insert(Interactor*); void Insert( Interactor*, _lib_iv2_6(Coord) x, _lib_iv2_6(Coord) y, unsigned = 6 ); void Change(Interactor*); void Remove(Interactor*); void Move(Interactor*, _lib_iv2_6(Coord) x, _lib_iv2_6(Coord) y); void Raise(Interactor*); void Lower(Interactor*); unsigned int Width() const; unsigned int Height() const; void Run(); void Flush(); void Sync(); /* * ParseGeometry return values contains one or more of these bits set. */ # define GeomNoValue 0x00 # define GeomXValue 0x01 # define GeomYValue 0x02 # define GeomWidthValue 0x04 # define GeomHeightValue 0x08 # define GeomAllValues 0x0F # define GeomXNegative 0x10 # define GeomYNegative 0x20 unsigned int ParseGeometry( const char*, int&, int&, unsigned int&, unsigned int& ) const; const char* GetAttribute(const char*) const; int Fileno() const; }; /* * Old functions for backward compatibilty */ inline void World::Insert(Interactor* i) { InsertToplevel(i, i); } inline void World::Insert( Interactor* i, _lib_iv2_6(Coord) x, _lib_iv2_6(Coord) y, unsigned a ) { InsertToplevel(i, i, x, y, a); } inline unsigned int World::Width() const { return pwidth(); } inline unsigned int World::Height() const { return pheight(); } inline void World::Run() { run(); } inline void World::Flush() { flush(); } inline void World::Sync() { sync(); } inline const char* World::GetAttribute(const char* s) const { return property_value(s); } #include #endif ivtools-1.2.11a1/src/include/IV-2_6/_enter.h000066400000000000000000000025061214471147700202710ustar00rootroot00000000000000/* * Copyright (c) 1990 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Include this to override the current names and use the old 2.6 ones. */ #ifndef iv__2_6_h #define iv__2_6_h #ifdef iv__current_h #undef iv__current_h #endif #include #endif ivtools-1.2.11a1/src/include/IV-2_6/_leave.h000066400000000000000000000024111214471147700202430ustar00rootroot00000000000000/* * Copyright (c) 1990 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifdef iv__2_6_h #if !defined(iv2_6_compatible)||defined(iv2_6_incompatible) #undef iv__2_6_h #include #endif #endif ivtools-1.2.11a1/src/include/IV-2_6/_names.h000066400000000000000000000053721214471147700202630ustar00rootroot00000000000000/* * Copyright (c) 1990 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Use 2.6 by default for ambiguous names */ #undef Adjuster #undef Border #undef Box #undef Button #undef PushButton #undef RadioButton #undef Center #undef Coord #undef Deck #undef Dialog #undef FileBrowser #undef FileChooser #undef Glue #undef HGlue #undef VGlue #undef Menu #undef MenuBar #undef MenuItem #undef Mover #undef UpMover #undef DownMover #undef LeftMover #undef RightMover #undef Panner #undef Scroller #undef HScroller #undef VScroller #undef ScrollBar #undef HScrollBar #undef VScrollBar #undef Slider #define Adjuster _lib_iv2_6(Adjuster) #define Border _lib_iv2_6(Border) #define Box _lib_iv2_6(Box) #define Button _lib_iv2_6(Button) #define PushButton _lib_iv2_6(PushButton) #define RadioButton _lib_iv2_6(RadioButton) #define Center _lib_iv2_6(Center) #define Coord _lib_iv2_6(Coord) #define Deck _lib_iv2_6(Deck) #define Dialog _lib_iv2_6(Dialog) #define FileBrowser _lib_iv2_6(FileBrowser) #define FileChooser _lib_iv2_6(FileChooser) #define Glue _lib_iv2_6(Glue) #define HGlue _lib_iv2_6(HGlue) #define VGlue _lib_iv2_6(VGlue) #define Menu _lib_iv2_6(Menu) #define MenuBar _lib_iv2_6(MenuBar) #define MenuItem _lib_iv2_6(MenuItem) #define Mover _lib_iv2_6(Mover) #define UpMover _lib_iv2_6(UpMover) #define DownMover _lib_iv2_6(DownMover) #define LeftMover _lib_iv2_6(LeftMover) #define RightMover _lib_iv2_6(RightMover) #define Panner _lib_iv2_6(Panner) #define Scroller _lib_iv2_6(Scroller) #define HScroller _lib_iv2_6(HScroller) #define VScroller _lib_iv2_6(VScroller) #define ScrollBar _lib_iv2_6(ScrollBar) #define HScrollBar _lib_iv2_6(HScrollBar) #define VScrollBar _lib_iv2_6(VScrollBar) #define Slider _lib_iv2_6(Slider) ivtools-1.2.11a1/src/include/IV-3_1/000077500000000000000000000000001214471147700166355ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/IV-3_1/InterViews000077700000000000000000000000001214471147700231072../InterViewsustar00rootroot00000000000000ivtools-1.2.11a1/src/include/IV-X11/000077500000000000000000000000001214471147700166245ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/IV-X11/Xdefs.h000066400000000000000000000005011214471147700200420ustar00rootroot00000000000000#undef boolean #undef Bitmap #undef Colormap #undef Cursor #undef Display #undef Drawable #undef Font #undef Screen #undef Window #define Bitmap XBitmap #define Colormap XColormap #define Cursor XCursor #define Display XDisplay #define Drawable XDrawable #define Font XFont #define Screen XScreen #define Window XWindow ivtools-1.2.11a1/src/include/IV-X11/Xext.h000066400000000000000000000060171214471147700177310ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef IV_X11_Xext_h #define IV_X11_Xext_h extern "C" { #include #define XShapeQueryExtension cc_XShapeQueryExtension #define XShapeQueryVersion cc_XShapeQueryVersion #define XShapeCombineRegion cc_XShapeCombineRegion #define XShapeCombineRectangles cc_XShapeCombineRectangles #define XShapeCombineMask cc_XShapeCombineMask #define XShapeCombineShape cc_XShapeCombineShape #define XShapeOffsetShape cc_XShapeOffsetShape #define XShapeQueryExtents cc_XShapeQueryExtents #define XShapeSelectInput cc_XShapeSelectInput #define XShapeInputSelected cc_XShapeInputSelected #define XShapeGetRectangles cc_XShapeGetRectangles #include #include #undef XShapeQueryExtension #undef XShapeQueryVersion #undef XShapeCombineRegion #undef XShapeCombineRectangles #undef XShapeCombineMask #undef XShapeCombineShape #undef XShapeOffsetShape #undef XShapeQueryExtents #undef XShapeSelectInput #undef XShapeInputSelected #undef XShapeGetRectangles Bool XShapeQueryExtension (Display*, int*, int*); Status XShapeQueryVersion (Display*, int*, int*); void XShapeCombineRegion (Display*, XWindow, int, int, int, Region, int); void XShapeCombineRectangles ( Display*, XWindow, int, int, int, XRectangle*, int, int, int ); void XShapeCombineMask (Display*, XWindow, int, int, int, Pixmap, int); void XShapeCombineShape (Display*, XWindow, int, int, int, XWindow, int, int); void XShapeOffsetShape (Display*, XWindow, int, int, int); Status XShapeQueryExtents ( Display*, XWindow, Bool*, int*, int*, unsigned int*, unsigned int*, Bool*, int*, int*, unsigned int*, unsigned int* ); void XShapeSelectInput (Display*, XWindow, Bool); unsigned long XShapeInputSelected (Display*, XWindow); XRectangle *XShapeGetRectangles (Display*, XWindow, int, int*, int*); #include } #endif ivtools-1.2.11a1/src/include/IV-X11/Xlib.h000066400000000000000000000032611214471147700176750ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * C++ interface to standard Xlib.h. */ #ifndef InterViews_Xlib_h #define InterViews_Xlib_h extern "C" { #ifdef AIXV3 struct _XDisplay; struct _XFreeFuncs; struct _XSQEvent; struct _XExten; struct _XKeytrans; struct _XDisplayAtoms; struct _XContextDB; struct _XIMFilter; struct _XrmHashBucketRec; #endif #ifdef __DECCXX struct _XDisplay; struct _XPrivate; struct _XrmHashBucketRec; #endif #include #include #include } #endif ivtools-1.2.11a1/src/include/IV-X11/Xundefs.h000066400000000000000000000007071214471147700204150ustar00rootroot00000000000000#undef Bitmap #undef Colormap #undef Cursor #undef Display #undef Drawable #undef Font #undef Screen #undef Window #define boolean _lib_os(boolean) #define Bitmap _lib_iv(Bitmap) #define Colormap _lib_iv(Colormap) #define Cursor _lib_iv(Cursor) #define Display _lib_iv(Display) #define Drawable _lib_iv(Drawable) #define Font _lib_iv(Font) #define Screen _lib_iv(Screen) #define Window _lib_iv(Window) #ifdef iv__2_6_h #include #endif ivtools-1.2.11a1/src/include/IV-X11/Xutil.h000066400000000000000000000045411214471147700201060ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef IV_X11_Xutil_h #define IV_X11_Xutil_h #include extern "C" { #include #include #include } /* * These are macros that make use of untype-checking pointers to functions. */ #undef XDestroyImage #undef XGetPixel #undef XPutPixel #undef XSubImage #undef XAddPixel inline int XDestroyImage(XImage* i) { typedef int (*PF)(XImage*); return (*((PF)i->f.destroy_image))(i); } inline unsigned long XGetPixel(XImage* i, int x, int y) { typedef unsigned long (*PF)(XImage*, int, int); return (*((PF)i->f.get_pixel))(i, x, y); } inline int XPutPixel(XImage* i, int x, int y, unsigned long pixel) { typedef int (*PF)(XImage*, int, int, unsigned long); return (*((PF)i->f.put_pixel))(i, x, y, pixel); } inline XImage* XSubImage( XImage* i, int x, int y, unsigned int width, unsigned int height ) { typedef XImage* (*PF)(XImage*, int, int, unsigned int, unsigned int); return (*((PF)i->f.sub_image))(i, x, y, width, height); } inline int XAddPixel(XImage* i, long value) { typedef int (*PF)(XImage*, long); return (*((PF)i->f.add_pixel))(i, value); } #endif ivtools-1.2.11a1/src/include/IV-X11/xbitmap.h000066400000000000000000000034711214471147700204460ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_xbitmap_h #define iv_xbitmap_h #include #include #include class BitmapRep { public: enum { copy, fliph, flipv, rot90, rot180, rot270, inv }; BitmapRep(); BitmapRep(BitmapRep*, unsigned int); ~BitmapRep(); void fill(); void flush(); Display* display_; XImage* image_; Pixmap pixmap_; Coord left_; Coord bottom_; Coord right_; Coord top_; Coord width_; Coord height_; unsigned int pwidth_; unsigned int pheight_; boolean modified_; }; #include #endif ivtools-1.2.11a1/src/include/IV-X11/xbrush.h000066400000000000000000000026621214471147700203160ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_xbrush_h #define iv_xbrush_h class Display; class BrushRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif Display* display_; char* dash_list_; int dash_count_; int width_; }; #endif ivtools-1.2.11a1/src/include/IV-X11/xcanvas.h000066400000000000000000000067631214471147700204540ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_xcanvas_h #define iv_xcanvas_h #include #include #include #include class ClippingStack; class Display; class TransformerStack; class CanvasDamage { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif Coord left; Coord bottom; Coord right; Coord top; }; class TextRenderInfo { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif CanvasRep* canvas_; GC drawgc_; int x0_; int y0_; Coord width_; Coord curx_; Coord cury_; char* text_; char* cur_text_; int spaces_; XTextItem* items_; }; class PathRenderInfo { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif Coord curx_; Coord cury_; XPoint* point_; XPoint* cur_point_; XPoint* end_point_; }; class CanvasRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif Display* display_; Window* window_; XDrawable xdrawable_; Coord width_; Coord height_; PixelCoord pwidth_; PixelCoord pheight_; boolean damaged_ : 1; boolean on_damage_list_ : 1; boolean repairing_ : 1; CanvasDamage damage_; XDrawable drawbuffer_; XDrawable copybuffer_; XRectangle clip_; const Brush* brush_; const Color* color_; const Font* font_; Region clipping_; Region empty_; GC drawgc_; GC copygc_; int op_; Pixmap stipple_; unsigned long pixel_; int brush_width_; char* dash_list_; int dash_count_; XFontStruct* xfont_; boolean text_twobyte_; boolean text_reencode_; boolean font_is_scaled_; boolean transformed_; TransformerStack* transformers_; ClippingStack* clippers_; static TextRenderInfo text_; static PathRenderInfo path_; enum { unbound = 0 }; XDisplay* dpy() const; Transformer& matrix() const; void flush(); void swapbuffers(); void brush(const Brush*); void color(const Color*); void font(const Font*); void new_damage(); void clear_damage(); boolean start_repair(); void finish_repair(); void bind(boolean double_buffered); void unbind(); /* for backward compability */ public: CanvasLocation status_; void wait_for_copy(); }; #include #endif ivtools-1.2.11a1/src/include/IV-X11/xcolor.h000066400000000000000000000032331214471147700203040ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * X11-dependent Color representation. */ #ifndef iv_colorrep_h #define iv_colorrep_h #include #include #include #include class WindowVisual; class ColorRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif WindowVisual* visual_; ColorOp op_; boolean masking_; XColor xcolor_; Pixmap stipple_; }; #include #endif ivtools-1.2.11a1/src/include/IV-X11/xcursor.h000066400000000000000000000064121214471147700205050ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_xcursor_h #define iv_xcursor_h #include #include class Color; class Display; class Style; class WindowVisual; class CursorRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif const Color* fg_; const Color* bg_; Display* display_; XCursor xcursor_; CursorRep(const Color* fg, const Color* bg); virtual ~CursorRep(); XCursor xid(Display*, WindowVisual*); virtual void make_xcursor(Display*, WindowVisual*) = 0; const Color* make_color( Display*, Style*, const char* str1, const char* str2, const char* str3, const char* default_value ); }; class CursorRepData : public CursorRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif short x_, y_; const int* pat_; const int* mask_; CursorRepData( short x_hot, short y_hot, const int* pat, const int* mask, const Color* fg, const Color* bg ); virtual ~CursorRepData(); virtual void make_xcursor(Display*, WindowVisual*); Pixmap make_cursor_pixmap(XDisplay*, XWindow, const int* scanline); }; class CursorRepBitmap : public CursorRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif const Bitmap* pat_; const Bitmap* mask_; CursorRepBitmap( const Bitmap* pat, const Bitmap* mask, const Color* fg, const Color* bg ); virtual ~CursorRepBitmap(); virtual void make_xcursor(Display*, WindowVisual*); }; class CursorRepFont : public CursorRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif const Font* font_; int pat_; int mask_; CursorRepFont( const Font*, int pat, int mask, const Color* fg, const Color* bg ); virtual ~CursorRepFont(); virtual void make_xcursor(Display*, WindowVisual*); }; class CursorRepXFont : public CursorRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif int code_; CursorRepXFont(int code, const Color* fg, const Color* bg); virtual ~CursorRepXFont(); virtual void make_xcursor(Display*, WindowVisual*); }; #include #endif ivtools-1.2.11a1/src/include/IV-X11/xdisplay.h000066400000000000000000000042131214471147700206320ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * X11-dependent Display representation. */ #ifndef iv_xdisplay_h #define iv_xdisplay_h #include #include #include #include #include #include class ColorTable; class DamageList; class GrabList; class RGBTable; class SelectionList; class String; class Transformer; class Window; class WindowTable; class DisplayRep { public: XDisplay* display_; unsigned int screen_; XWindow root_; WindowVisualList visuals_; WindowVisual* default_visual_; Coord width_; Coord height_; unsigned int pwidth_; unsigned int pheight_; Style* style_; GrabList* grabbers_; DamageList* damaged_; SelectionList* selections_; WindowTable* wtable_; void set_dpi(Coord&); void needs_repair(Window*); void remove(Window*); void init(XDisplay*); }; #include #endif ivtools-1.2.11a1/src/include/IV-X11/xdrag.h000066400000000000000000000026611214471147700201070ustar00rootroot00000000000000/* * Copyright (c) 1992 Redwood Design Automation * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the name of * Redwood Design Automation may not be used in any advertising or publicity * relating to the software without the specific, prior written permission of * Redwood Design Automation. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL REDWOOD DESIGN AUTOMATION BE LIABLE FOR ANY SPECIAL, * INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #ifndef iv_xdrag_h #define iv_xdrag_h #include class XDrag { public: // these are used by xevent to detect and interpret a drag client message. static boolean isDrag(const XEvent&); static void locate(const XEvent&, int& x, int& y); }; #include #endif ivtools-1.2.11a1/src/include/IV-X11/xevent.h000066400000000000000000000035221214471147700203100ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * X11-dependent Event representation. */ #ifndef iv_xevent_h #define iv_xevent_h #include #include #include #include class Display; class Window; class EventRep { public: XEvent xevent_; Display* display_; Window* window_; Coord pointer_x_; Coord pointer_y_; Coord pointer_root_x_; Coord pointer_root_y_; void clear(); void locate(); boolean has_pointer_location(); void acknowledge_motion(); private: boolean location_valid_; boolean has_pointer_location_; }; #include #endif ivtools-1.2.11a1/src/include/IV-X11/xfont.h000066400000000000000000000042021214471147700201310ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * X11-dependent Font representation. */ #ifndef iv_xfont_h #define iv_xfont_h #include #include #include #include class Display; class KnownFonts; class String; class FontRep : public Resource { public: FontRep(Display*, XFontStruct*, float); ~FontRep(); Display* display_; XFontStruct* font_; float scale_; boolean unscaled_; String* name_; String* encoding_; float size_; KnownFonts* entry_; }; class FontFamilyRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif Display* display_; int count_; int min_weight_; int max_weight_; int min_width_; int max_width_; int min_slant_; int max_slant_; int min_size_; int max_size_; char** names_; int* weights_; int* slants_; int* widths_; int* sizes_; }; #include #endif ivtools-1.2.11a1/src/include/IV-X11/xpainter.h000066400000000000000000000036351214471147700206360ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * X11-dependent painter interface. */ #ifndef iv_xpainter_h #define iv_xpainter_h #include class Brush; class Pattern; class Transformer; class PainterRep { public: PainterRep(); ~PainterRep(); void PrepareFill(const Pattern*); void PrepareDash(const Brush*); GC fillgc; GC dashgc; boolean fillbg; boolean overwrite; boolean x_or; boolean clipped; Display* display; XRectangle xclip[1]; }; void DrawTransformedImage( XImage* src, int sx0, int sy0, XImage* mask, int mx0, int my0, XDrawable d, unsigned int height, int dx0, int dy0, boolean stencil, unsigned long fg, unsigned long bg, GC gc, const Transformer& matrix ); #endif ivtools-1.2.11a1/src/include/IV-X11/xpattern.h000066400000000000000000000027531214471147700206510ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_xpattern_h #define iv_xpattern_h #include #include class Display; class PatternRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif Display* display_; Pixmap pixmap_; }; #include #endif ivtools-1.2.11a1/src/include/IV-X11/xraster.h000066400000000000000000000044561214471147700204760ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * X11-dependent Raster representation. */ #ifndef iv_xraster_h #define iv_xraster_h // should be defined externally #if !defined(__CYGWIN__) /* &&(!defined(__APPLE__)||__GNUC__>2) */ #define XSHM #endif #include #include #ifdef XSHM #include #include #include #endif #include class Display; class RasterRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif Display* display_; boolean modified_; Coord left_; Coord bottom_; Coord right_; Coord top_; Coord width_; Coord height_; unsigned int pwidth_; unsigned int pheight_; XImage* image_; Pixmap pixmap_; GC gc_; boolean shared_memory_; #ifdef XSHM static void free_shared_memory(Display&, XShmSegmentInfo&); static boolean init_shared_memory( boolean& shared_memory, Display&, XShmSegmentInfo&, unsigned int pwidth, unsigned int pheight, XImage*&, Pixmap ); XShmSegmentInfo shminfo_; #endif }; #include #endif ivtools-1.2.11a1/src/include/IV-X11/xselection.h000066400000000000000000000035451214471147700211610ustar00rootroot00000000000000/* * Copyright (c) 1992 Stanford University * Copyright (c) 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_xselection_h #define iv_xselection_h #include #include class PopupWindow; class SelectionManagerRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif XDisplay* xdisplay_; String* name_; XSelectionRequestEvent x_req_; PopupWindow* owner_; SelectionHandler* convert_; SelectionHandler* lose_; SelectionHandler* done_; SelectionHandler* ok_; SelectionHandler* fail_; SelectionManagerRep(Display*, const String&); ~SelectionManagerRep(); void request(SelectionManager*, const XSelectionRequestEvent&); void notify(SelectionManager*, const XSelectionEvent&); }; #endif ivtools-1.2.11a1/src/include/IV-X11/xwindow.h000066400000000000000000000153301214471147700204760ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_xwindow_h #define iv_xwindow_h #include #include #include #include #include #include class Bitmap; class ColorTable; class Cursor; class Display; class Glyph; class Handler; class ManagedWindow; class ManagedWindowRep; class RGBTable; class String; class Style; class WindowCursorStack; class WindowTable; struct WindowOverlayInfo { VisualID id_; long type_; long transparent_; long layer_; }; struct WindowVisualInfo { XDisplay* display_; int screen_; int depth_; Visual* visual_; XColormap cmap_; WindowOverlayInfo overlay_; }; class WindowVisual { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif WindowVisual(const WindowVisualInfo&); ~WindowVisual(); static WindowVisual* find_visual(Display*, Style*); void init_color_tables(); void find_color(unsigned long, XColor&); void find_color( unsigned short r, unsigned short g, unsigned short b, XColor& ); unsigned long x_or(const Style&) const; unsigned long x_or_(const Style&) const; XDisplay* display() const; int screen() const; int depth() const; Visual* visual() const; XColormap colormap() const; private: WindowVisualInfo info_; ColorTable* ctable_; RGBTable* rgbtable_; XColor* localmap_; unsigned int localmapsize_; unsigned long red_; unsigned long red_shift_; unsigned long green_; unsigned long green_shift_; unsigned long blue_; unsigned long blue_shift_; unsigned long white_; unsigned long xor_; boolean bytesize_; static void find_visual_by_class_name(const String&, WindowVisualInfo&); static boolean find_layer(const String&, int& layer); static void find_overlay(int layer, WindowVisualInfo&); static void find_visual_by_info( XVisualInfo&, long mask, WindowVisualInfo& ); void set_shift(unsigned long mask, unsigned long& v, unsigned long& shift); static unsigned int MSB(unsigned long); static double distance( unsigned short r, unsigned short g, unsigned short b, const XColor& ); static unsigned long rescale( unsigned long value, unsigned long in_scale, unsigned long out_scale ); }; inline XDisplay* WindowVisual::display() const { return info_.display_; } inline int WindowVisual::screen() const { return info_.screen_; } inline int WindowVisual::depth() const { return info_.depth_; } inline Visual* WindowVisual::visual() const { return info_.visual_; } inline XColormap WindowVisual::colormap() const { return info_.cmap_; } declarePtrList(WindowVisualList,WindowVisual) class WindowRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif Glyph* glyph_; Style* style_; Display* display_; WindowVisual* visual_; Canvas* canvas_; Requisition shape_; Allocation allocation_; Cursor* cursor_; WindowCursorStack* cursor_stack_; Coord left_; Coord bottom_; float xalign_; float yalign_; Handler* focus_in_; Handler* focus_out_; Handler* wm_delete_; XWindow xwindow_; XSetWindowAttributes xattrs_; unsigned long xattrmask_; unsigned int xclass_; int xpos_; int ypos_; Window* toplevel_; XWindow xtoplevel_; boolean placed_ : 1; boolean aligned_ : 1; boolean needs_resize_ : 1; boolean resized_ : 1; boolean moved_ : 1; boolean unmapped_ : 1; boolean wm_mapped_ : 1; boolean map_pending_ : 1; static Atom wm_delete_atom_; static Atom wm_protocols_atom_; enum { unbound = 0 }; XDisplay* dpy(); Atom wm_delete_atom(); Atom wm_protocols_atom(); void clear_mapping_info(); void map_notify(Window*, XMapEvent&); void unmap_notify(Window*, XUnmapEvent&); void expose(Window*, XExposeEvent&); void configure_notify(Window*, XConfigureEvent&); void move(Window*, int x, int y); void resize(Window*, unsigned int w, unsigned int h); void check_position(const Window*); void check_binding(Window*); void do_bind(Window*, XWindow parent, int left, int top); void init_renderer(Window*); static Window* find(XWindow, WindowTable*); }; class ManagedWindowHintInfo { private: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif friend class ManagedWindowRep; Style* style_; XWMHints* hints_; XDisplay* dpy_; XWindow xwindow_; unsigned int pwidth_; unsigned int pheight_; Display* display_; }; typedef boolean (ManagedWindowRep::*HintFunction)(ManagedWindowHintInfo&); class ManagedWindowRep { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif ManagedWindow* icon_; Bitmap* icon_bitmap_; Bitmap* icon_mask_; Window* group_leader_; Window* transient_for_; void do_set(Window*, HintFunction); boolean set_name(ManagedWindowHintInfo&); boolean set_geometry(ManagedWindowHintInfo&); boolean set_group_leader(ManagedWindowHintInfo&); boolean set_transient_for(ManagedWindowHintInfo&); boolean set_icon_name(ManagedWindowHintInfo&); boolean set_icon_geometry(ManagedWindowHintInfo&); boolean set_icon(ManagedWindowHintInfo&); boolean set_icon_bitmap(ManagedWindowHintInfo&); boolean set_icon_mask(ManagedWindowHintInfo&); boolean set_all(ManagedWindowHintInfo&); void wm_normal_hints(Window*); void wm_name(Window*); void wm_class(Window*); void wm_protocols(Window*); void wm_colormap_windows(Window*); void wm_hints(Window*); }; #include #endif ivtools-1.2.11a1/src/include/IV-look/000077500000000000000000000000001214471147700172175ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/IV-look/bevel.h000066400000000000000000000074741214471147700205010ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Bevel - beveled framing of a glyph */ #ifndef ivlook_bevel_h #define ivlook_bevel_h #include class BevelFrame : public MonoGlyph { public: BevelFrame( Glyph*, Coord, float xalign = 0.0, float yalign = 0.0, boolean hmargin = true, boolean vmargin = true ); virtual ~BevelFrame(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual void draw_frame(Canvas*, const Allocation&, Coord thickness) const; private: Coord thickness_; float xalign_; float yalign_; boolean hmargin_ : 1; boolean vmargin_ : 1; Coord thickness(Canvas*) const; void allocate_body(Glyph*, Coord, Allocation&) const; }; class Color; typedef void (*Beveler)( Canvas*, const Color* light, const Color* medium, const Color* dark, Coord thickness, Coord left, Coord bottom, Coord right, Coord top ); class Bevel : public BevelFrame { public: Bevel( Glyph*, Beveler, const Color* light, const Color* medium, const Color* dark, Coord thickness, float xalign = 0.0, float yalign = 0.0, boolean hmargin = true, boolean vmargin = true ); virtual ~Bevel(); virtual void draw_frame(Canvas*, const Allocation&, Coord thickness) const; static void rect( Canvas*, const Color* light, const Color* medium, const Color* dark, Coord thickness, Coord left, Coord bottom, Coord right, Coord top ); static void left_arrow( Canvas*, const Color* light, const Color* medium, const Color* dark, Coord thickness, Coord left, Coord bottom, Coord right, Coord top ); static void right_arrow( Canvas*, const Color* light, const Color* medium, const Color* dark, Coord thickness, Coord left, Coord bottom, Coord right, Coord top ); static void up_arrow( Canvas*, const Color* light, const Color* medium, const Color* dark, Coord thickness, Coord left, Coord bottom, Coord right, Coord top ); static void down_arrow( Canvas*, const Color* light, const Color* medium, const Color* dark, Coord thickness, Coord left, Coord bottom, Coord right, Coord top ); static void diamond( Canvas*, const Color* light, const Color* medium, const Color* dark, Coord thickness, Coord left, Coord bottom, Coord right, Coord top ); private: Beveler beveler_; const Color* light_; const Color* medium_; const Color* dark_; Coord thickness(Canvas*) const; void allocate_body(Glyph*, Coord, Allocation&) const; }; #endif ivtools-1.2.11a1/src/include/IV-look/browser.h000066400000000000000000000043451214471147700210610ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Browser -- select an item */ #ifndef ivlook_browser_h #define ivlook_browser_h #include #include class Action; class BrowserList; class TelltaleState; class Browser : public InputHandler, public Observer { public: Browser(Glyph*, Style*, Action* accept, Action* cancel); virtual ~Browser(); virtual void append_selectable(TelltaleState*); virtual void replace_selectable(GlyphIndex, TelltaleState*); virtual void remove_selectable(GlyphIndex); virtual TelltaleState* state(GlyphIndex) const; virtual void select(GlyphIndex); virtual GlyphIndex selected() const; virtual void choose(GlyphIndex) const; virtual void cancel(); virtual void press(const Event&); virtual void drag(const Event&); virtual void release(const Event&); virtual void double_click(const Event&); virtual void update(Observable*); private: Action* accept_; Action* cancel_; BrowserList* items_; GlyphIndex item_; void active(GlyphIndex i, boolean); }; #endif ivtools-1.2.11a1/src/include/IV-look/button.h000066400000000000000000000037301214471147700207060ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Button - clickable Action */ #ifndef ivlook_button_h #define ivlook_button_h #include #include #include class Action; class TelltaleState; class Button : public ActiveHandler, public Observer { public: Button(Glyph*, Style*, TelltaleState*, Action*); virtual ~Button(); virtual void state(TelltaleState*); virtual TelltaleState* state() const; virtual void action(Action*); virtual Action* action() const; virtual void enter(); virtual void leave(); virtual void press(const Event&); virtual void release(const Event&); virtual void update(Observable*); private: TelltaleState* state_; Action* action_; }; #include #endif ivtools-1.2.11a1/src/include/IV-look/choice.h000066400000000000000000000040601214471147700206220ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef ivlook_choice_h #define ivlook_choice_h /* * ChoiceItem - telltale with different look for each state */ #include class Deck; class ChoiceItem : public Telltale { public: ChoiceItem(TelltaleState*); ChoiceItem(TelltaleState*, Glyph* normal, Glyph* pressed); ChoiceItem( TelltaleState*, Glyph* disabled, Glyph* enabled, Glyph* visible, Glyph* visible_active, Glyph* active, Glyph* chosen, Glyph* visible_chosen, Glyph* active_chosen, Glyph* visible_active_chosen, Glyph* disabled_chosen ); virtual ~ChoiceItem(); virtual void look( const TelltaleFlags include, const TelltaleFlags exclude, Glyph* ); virtual Glyph* look(const TelltaleFlags) const; virtual void update(Observable*); private: Deck* deck_; GlyphIndex index_[TelltaleState::max_flags]; void init(); }; #endif ivtools-1.2.11a1/src/include/IV-look/dialogs.h000066400000000000000000000046601214471147700210200ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * DialogKit -- object for creating common dialog boxes */ #ifndef ivlook_dialogs_h #define ivlook_dialogs_h #include #include #include class DialogKitImpl; class String; class Style; class WidgetKit; //: factory object for widgets. // in reference manual class DialogKit { protected: DialogKit(); public: static DialogKit* instance(); virtual ~DialogKit(); virtual WidgetKit* widget_kit() const; virtual FieldEditor* field_editor( const char* sample, Style*, FieldEditorAction* = nil ) const; virtual FieldEditor* field_editor( const String& sample, Style*, FieldEditorAction* = nil ) const; virtual FileChooser* file_chooser( const char* dir, Style*, FileChooserAction* = nil ) const; virtual FileChooser* file_chooser( const String& dir, Style*, FileChooserAction* = nil ) const; virtual FieldEditor* make_field_editor( const String& sample, WidgetKit*, Style*, FieldEditorAction* = nil ) const; virtual FileChooser* make_file_chooser( const String& dir, WidgetKit*, Style*, FileChooserAction* = nil ) const; private: DialogKitImpl* impl_; }; #include #endif ivtools-1.2.11a1/src/include/IV-look/fbrowser.h000066400000000000000000000035661214471147700212330ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * FileBrowser -- browse a directory */ #ifndef ivlook_fbrowser_h #define ivlook_fbrowser_h #include class Adjustable; class FileBrowserImpl; class WidgetKit; class FileBrowser : public Browser { public: FileBrowser(WidgetKit*, Action* accept, Action* cancel); virtual ~FileBrowser(); virtual void press(const Event&); virtual void drag(const Event&); virtual void release(const Event&); virtual void keystroke(const Event&); virtual InputHandler* focus_in(); virtual void focus_out(); virtual void select(GlyphIndex); virtual Adjustable* adjustable() const; virtual void refresh(); private: FileBrowserImpl* impl_; }; #endif ivtools-1.2.11a1/src/include/IV-look/fchooser.h000066400000000000000000000061171214471147700212050ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * FileChooser -- select a file */ #ifndef ivlook_fchooser_h #define ivlook_fchooser_h #include #include #include class FileChooser; class FileChooserImpl; class String; class WidgetKit; class FileChooserAction : public Resource { protected: FileChooserAction(); virtual ~FileChooserAction(); public: virtual void execute(FileChooser*, boolean accept); }; #if defined(__STDC__) || defined(__ANSI_CPP__) #define FileChooserCallback(T) T##_FileChooserCallback #define FileChooserMemberFunction(T) T##_FileChooserMemberFunction #else #define FileChooserCallback(T) T/**/_FileChooserCallback #define FileChooserMemberFunction(T) T/**/_FileChooserMemberFunction #endif #define declareFileChooserCallback(T) \ typedef void (T::*FileChooserMemberFunction(T))(FileChooser*, boolean); \ class FileChooserCallback(T) : public FileChooserAction { \ public: \ FileChooserCallback(T)(T*, FileChooserMemberFunction(T)); \ virtual ~FileChooserCallback(T)(); \ \ virtual void execute(FileChooser*, boolean accept); \ private: \ T* obj_; \ FileChooserMemberFunction(T) func_; \ }; #define implementFileChooserCallback(T) \ FileChooserCallback(T)::FileChooserCallback(T)( \ T* obj, FileChooserMemberFunction(T) func \ ) { \ obj_ = obj; \ func_ = func; \ } \ \ FileChooserCallback(T)::~FileChooserCallback(T)() { } \ \ void FileChooserCallback(T)::execute(FileChooser* f, boolean accept) { \ FileChooserMemberFunction(T) pf = func_; \ (obj_->*pf)(f, accept); \ } class FileChooser : public Dialog { public: FileChooser( const String& dir, WidgetKit*, Style*, FileChooserAction* = nil ); virtual ~FileChooser(); virtual const String* selected() const; virtual void reread(); virtual void dismiss(boolean); void bodyclear(); private: FileChooserImpl* impl_; }; #include #endif ivtools-1.2.11a1/src/include/IV-look/field.h000066400000000000000000000101401214471147700204470ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * FieldEditor -- simple editor for text fields */ #ifndef ivlook_field_h #define ivlook_field_h #include #include class FieldEditor; class FieldEditorImpl; class String; class Style; class WidgetKit; class FieldEditorAction : public Resource { protected: FieldEditorAction(); virtual ~FieldEditorAction(); public: virtual void accept(FieldEditor*); virtual void cancel(FieldEditor*); }; #if defined(__STDC__) || defined(__ANSI_CPP__) #define __FieldEditorCallback(T) T##_FieldEditorCallback #define FieldEditorCallback(T) __FieldEditorCallback(T) #define __FieldEditorMemberFunction(T) T##_FieldEditorMemberFunction #define FieldEditorMemberFunction(T) __FieldEditorMemberFunction(T) #else #define __FieldEditorCallback(T) T/**/_FieldEditorCallback #define FieldEditorCallback(T) __FieldEditorCallback(T) #define __FieldEditorMemberFunction(T) T/**/_FieldEditorMemberFunction #define FieldEditorMemberFunction(T) __FieldEditorMemberFunction(T) #endif #define declareFieldEditorCallback(T) \ typedef void (T::*FieldEditorMemberFunction(T))(FieldEditor*); \ class FieldEditorCallback(T) : public FieldEditorAction { \ public: \ FieldEditorCallback(T)( \ T*, FieldEditorMemberFunction(T) accept, \ FieldEditorMemberFunction(T) cancel \ ); \ virtual ~FieldEditorCallback(T)(); \ \ virtual void accept(FieldEditor*); \ virtual void cancel(FieldEditor*); \ private: \ T* obj_; \ FieldEditorMemberFunction(T) accept_; \ FieldEditorMemberFunction(T) cancel_; \ }; #define implementFieldEditorCallback(T) \ FieldEditorCallback(T)::FieldEditorCallback(T)( \ T* obj, FieldEditorMemberFunction(T) accept, \ FieldEditorMemberFunction(T) cancel \ ) { \ obj_ = obj; \ accept_ = accept; \ cancel_ = cancel; \ } \ \ FieldEditorCallback(T)::~FieldEditorCallback(T)() { } \ \ void FieldEditorCallback(T)::accept(FieldEditor* f) { (obj_->*accept_)(f); } \ void FieldEditorCallback(T)::cancel(FieldEditor* f) { (obj_->*cancel_)(f); } //: field editor. // in reference manual class FieldEditor : public InputHandler { public: FieldEditor( const String& sample, WidgetKit*, Style*, FieldEditorAction* = nil ); virtual ~FieldEditor(); virtual void undraw(); virtual void press(const Event&); virtual void selection_notify(const Event&); virtual void drag(const Event&); virtual void release(const Event&); virtual void keystroke(const Event&); virtual InputHandler* focus_in(); virtual void focus_out(); virtual void field(const char*); virtual void field(const String&); virtual void select(int pos); virtual void select(int left, int right); virtual void edit(); virtual void edit(const char*, int left, int right); virtual void edit(const String&, int left, int right); virtual const String* text() const; private: FieldEditorImpl* impl_; }; #endif ivtools-1.2.11a1/src/include/IV-look/kit.h000066400000000000000000000167331214471147700201710ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * WidgetKit -- object for creating common UI components */ #ifndef ivlook_kit_h #define ivlook_kit_h #include #include #include #include #include #include class Adjustable; class Color; class Cursor; class Font; class String; class Style; class WidgetKitImpl; //: factory object for widgets. // in reference manual class WidgetKit { protected: WidgetKit(); public: static WidgetKit* instance(); virtual ~WidgetKit(); virtual const char* gui() const; /* style management */ virtual void style(Style*); virtual Style* style() const; virtual const Font* font() const; virtual const Color* foreground() const; virtual const Color* background() const; virtual void begin_style(const String&); virtual void begin_style(const char*); virtual void begin_style(const String& name, const String& alias); virtual void begin_style(const char* name, const char* alias); virtual void alias(const String&); virtual void alias(const char*); virtual void end_style(); virtual void push_style(); virtual void push_style(Style*); virtual void pop_style(); virtual void style_changed(Style*); /* shared objects */ virtual Cursor* hand_cursor() const; virtual Cursor* lfast_cursor() const; virtual Cursor* lufast_cursor() const; virtual Cursor* ufast_cursor() const; virtual Cursor* rufast_cursor() const; virtual Cursor* rfast_cursor() const; virtual Cursor* rdfast_cursor() const; virtual Cursor* dfast_cursor() const; virtual Cursor* ldfast_cursor() const; /* shading */ virtual MonoGlyph* outset_frame(Glyph*) const = 0; virtual MonoGlyph* inset_frame(Glyph*) const = 0; virtual MonoGlyph* bright_inset_frame(Glyph*) const = 0; /* styled low-level glyphs */ virtual Glyph* label(const char*) const; virtual Glyph* label(const String&) const; virtual Glyph* chiseled_label(const char*) const; virtual Glyph* chiseled_label(const String&) const; virtual Glyph* raised_label(const char*) const; virtual Glyph* raised_label(const String&) const; virtual Glyph* fancy_label(const char*) const; virtual Glyph* fancy_label(const String&) const; /* menus */ virtual Menu* menubar() const; virtual Menu* pulldown() const; virtual Menu* pullright() const; virtual MenuItem* menubar_item(const char*) const; virtual MenuItem* menubar_item(const String&) const; virtual MenuItem* menubar_item(Glyph*) const; virtual MenuItem* menu_item(const char*) const; virtual MenuItem* menu_item(const String&) const; virtual MenuItem* menu_item(Glyph*) const; virtual MenuItem* check_menu_item(const char*) const; virtual MenuItem* check_menu_item(const String&) const; virtual MenuItem* check_menu_item(Glyph*) const; virtual MenuItem* radio_menu_item(TelltaleGroup*, const char*) const; virtual MenuItem* radio_menu_item(TelltaleGroup*, const String&) const; virtual MenuItem* radio_menu_item(TelltaleGroup*, Glyph*) const; virtual MenuItem* menu_item_separator() const; /* buttons */ virtual Button* push_button(const char*, Action*) const; virtual Button* push_button(const String&, Action*) const; virtual Button* push_button(Glyph*, Action*) const; virtual Button* default_button(const char*, Action*) const; virtual Button* default_button(const String&, Action*) const; virtual Button* default_button(Glyph*, Action*) const; virtual Button* check_box(const char*, Action*) const; virtual Button* check_box(const String&, Action*) const; virtual Button* check_box(Glyph*, Action*) const; virtual Button* palette_button(const char*, Action*) const; virtual Button* palette_button(const String&, Action*) const; virtual Button* palette_button(Glyph*, Action*) const; virtual Button* radio_button(TelltaleGroup*, const char*, Action*) const; virtual Button* radio_button(TelltaleGroup*, const String&, Action*) const; virtual Button* radio_button(TelltaleGroup*, Glyph*, Action*) const; virtual Action* quit() const; /* adjusters */ virtual Glyph* hslider(Adjustable*) const; virtual Glyph* hscroll_bar(Adjustable*) const; virtual Glyph* vslider(Adjustable*) const; virtual Glyph* vscroll_bar(Adjustable*) const; virtual Glyph* panner(Adjustable*, Adjustable*) const; virtual Stepper* enlarger(Adjustable*) const; virtual Stepper* reducer(Adjustable*) const; virtual Stepper* up_mover(Adjustable*) const; virtual Stepper* down_mover(Adjustable*) const; virtual Stepper* left_mover(Adjustable*) const; virtual Stepper* right_mover(Adjustable*) const; /* looks implemented by subclass, usually not called directly */ virtual Glyph* menubar_look() const = 0; virtual Glyph* pulldown_look() const = 0; virtual Glyph* pullright_look() const; virtual Glyph* menubar_item_look(Glyph*, TelltaleState*) const = 0; virtual Glyph* menu_item_look(Glyph*, TelltaleState*) const = 0; virtual Glyph* check_menu_item_look(Glyph*, TelltaleState*) const = 0; virtual Glyph* radio_menu_item_look(Glyph*, TelltaleState*) const = 0; virtual Glyph* menu_item_separator_look() const = 0; virtual Glyph* push_button_look(Glyph*, TelltaleState*) const = 0; virtual Glyph* default_button_look(Glyph*, TelltaleState*) const = 0; virtual Glyph* check_box_look(Glyph*, TelltaleState*) const = 0; virtual Glyph* palette_button_look(Glyph*, TelltaleState*) const = 0; virtual Glyph* radio_button_look(Glyph*, TelltaleState*) const = 0; virtual Glyph* slider_look(DimensionName, Adjustable*) const = 0; virtual Glyph* scroll_bar_look(DimensionName, Adjustable*) const = 0; virtual Glyph* panner_look(Adjustable*, Adjustable*) const = 0; virtual Glyph* enlarger_look(TelltaleState*) const = 0; virtual Glyph* reducer_look(TelltaleState*) const = 0; virtual Glyph* up_mover_look(TelltaleState*) const = 0; virtual Glyph* down_mover_look(TelltaleState*) const = 0; virtual Glyph* left_mover_look(TelltaleState*) const = 0; virtual Glyph* right_mover_look(TelltaleState*) const = 0; private: WidgetKitImpl* impl_; }; #include #endif ivtools-1.2.11a1/src/include/IV-look/menu.h000066400000000000000000000062521214471147700203410ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Menu -- visible list of actions */ #ifndef ivlook_menu_h #define ivlook_menu_h #include #include #include class Action; class Menu; class MenuImpl; class Patch; class TelltaleState; class Window; class MenuItem : public Resource, public Observer { public: MenuItem(Glyph*, TelltaleState*); MenuItem(Glyph*, TelltaleState*, Action*); MenuItem(Glyph*, TelltaleState*, Menu*, Window* = nil); virtual ~MenuItem(); Glyph* body() const; TelltaleState* state() const; virtual void action(Action*); Action* action() const; virtual void menu(Menu*, Window* = nil); Menu* menu() const; Window* window() const; virtual void update(Observable*); private: friend class Menu; friend class MenuImpl; Patch* patch_; TelltaleState* state_; Action* action_; Menu* menu_; Window* window_; void init(Glyph*, TelltaleState*); }; inline TelltaleState* MenuItem::state() const { return state_; } inline Action* MenuItem::action() const { return action_; } inline Menu* MenuItem::menu() const { return menu_; } inline Window* MenuItem::window() const { return window_; } class Menu : public InputHandler { public: Menu(Glyph*, Style*, float x1, float y1, float x2, float y2); virtual ~Menu(); virtual void append_item(MenuItem*); virtual void prepend_item(MenuItem*); virtual void insert_item(GlyphIndex, MenuItem*); virtual void remove_item(GlyphIndex); virtual void replace_item(GlyphIndex, MenuItem*); virtual GlyphIndex item_count() const; virtual MenuItem* item(GlyphIndex) const; virtual void select(GlyphIndex); virtual GlyphIndex selected() const; virtual void unselect(); virtual void press(const Event&); virtual void drag(const Event&); virtual void release(const Event&); virtual void open(); virtual void close(); private: MenuImpl* impl_; }; #include #endif ivtools-1.2.11a1/src/include/IV-look/mf_dialogs.h000066400000000000000000000033031214471147700214730ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * MFDialogKit -- object for creating common Motif dialog boxes */ #ifndef ivlook_mf_dialogs_h #define ivlook_mf_dialogs_h #include class String; class MFDialogKit : public DialogKit { public: MFDialogKit(); virtual ~MFDialogKit(); virtual FieldEditor* make_field_editor( const String& sample, WidgetKit*, Style*, FieldEditorAction* = nil ) const; virtual FileChooser* make_file_chooser( const String& dir, WidgetKit*, Style*, FileChooserAction* = nil ) const; }; #endif ivtools-1.2.11a1/src/include/IV-look/mf_kit.h000066400000000000000000000057131214471147700206470ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * MFKit -- object for creating common UI Motif-ish components */ #ifndef ivlook_mfkit_h #define ivlook_mfkit_h #include class MFKitImpl; class MFKit : public WidgetKit { public: MFKit(); virtual ~MFKit(); virtual const char* gui() const; virtual void style_changed(Style*); virtual MonoGlyph* outset_frame(Glyph*) const; virtual MonoGlyph* inset_frame(Glyph*) const; virtual MonoGlyph* bright_inset_frame(Glyph*) const; virtual Glyph* menubar_look() const; virtual Glyph* pulldown_look() const; virtual Glyph* menubar_item_look(Glyph*, TelltaleState*) const; virtual Glyph* menu_item_look(Glyph*, TelltaleState*) const; virtual Glyph* check_menu_item_look(Glyph*, TelltaleState*) const; virtual Glyph* radio_menu_item_look(Glyph*, TelltaleState*) const; virtual Glyph* menu_item_separator_look() const; virtual Glyph* push_button_look(Glyph*, TelltaleState*) const; virtual Glyph* default_button_look(Glyph*, TelltaleState*) const; virtual Glyph* check_box_look(Glyph*, TelltaleState*) const; virtual Glyph* palette_button_look(Glyph*, TelltaleState*) const; virtual Glyph* radio_button_look(Glyph*, TelltaleState*) const; virtual Glyph* slider_look(DimensionName, Adjustable*) const; virtual Glyph* scroll_bar_look(DimensionName, Adjustable*) const; virtual Glyph* panner_look(Adjustable*, Adjustable*) const; virtual Glyph* enlarger_look(TelltaleState*) const; virtual Glyph* reducer_look(TelltaleState*) const; virtual Glyph* up_mover_look(TelltaleState*) const; virtual Glyph* down_mover_look(TelltaleState*) const; virtual Glyph* left_mover_look(TelltaleState*) const; virtual Glyph* right_mover_look(TelltaleState*) const; private: MFKitImpl* impl_; }; #endif ivtools-1.2.11a1/src/include/IV-look/mono_kit.h000066400000000000000000000061641214471147700212160ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * MonoKit -- object for creating common UI monochrome Motif-ish components */ #ifndef ivlook_mono_mf_kit_h #define ivlook_mono_mf_kit_h #include class MonoKitImpl; class MonoKit : public WidgetKit { public: MonoKit(); virtual ~MonoKit(); virtual const char* gui() const; virtual void style_changed(Style*); virtual MonoGlyph* outset_frame(Glyph*) const; virtual MonoGlyph* inset_frame(Glyph*) const; virtual MonoGlyph* bright_inset_frame(Glyph*) const; virtual Glyph* menubar_look() const; virtual Glyph* pulldown_look() const; virtual Glyph* menubar_item_look(Glyph*, TelltaleState*) const; virtual Glyph* menu_item_look(Glyph*, TelltaleState*) const; virtual Glyph* check_menu_item_look(Glyph*, TelltaleState*) const; virtual Glyph* radio_menu_item_look(Glyph*, TelltaleState*) const; virtual Glyph* menu_item_separator_look() const; virtual Glyph* push_button_look(Glyph*, TelltaleState*) const; virtual Glyph* default_button_look(Glyph*, TelltaleState*) const; virtual Glyph* check_box_look(Glyph*, TelltaleState*) const; virtual Glyph* palette_button_look(Glyph*, TelltaleState*) const; virtual Glyph* radio_button_look(Glyph*, TelltaleState*) const; virtual Glyph* slider_look(DimensionName, Adjustable*) const; virtual Glyph* scroll_bar_look(DimensionName, Adjustable*) const; virtual Glyph* panner_look(Adjustable*, Adjustable*) const; virtual Glyph* enlarger_look(TelltaleState*) const; virtual Glyph* reducer_look(TelltaleState*) const; virtual Glyph* up_mover_look(TelltaleState*) const; virtual Glyph* down_mover_look(TelltaleState*) const; virtual Glyph* left_mover_look(TelltaleState*) const; virtual Glyph* right_mover_look(TelltaleState*) const; /* hack for reverse video labels */ virtual Glyph* label(const char *) const; virtual Glyph* label(const String&) const; private: MonoKitImpl* impl_; }; #endif ivtools-1.2.11a1/src/include/IV-look/ol_dialogs.h000066400000000000000000000033061214471147700215060ustar00rootroot00000000000000/* * Copyright (c) 1992 Stanford University * Copyright (c) 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * OLDialogKit -- object for creating common OpenLook dialog boxes */ #ifndef ivlook_ol_dialogs_h #define ivlook_ol_dialogs_h #include class String; class OLDialogKit : public DialogKit { public: OLDialogKit(); virtual ~OLDialogKit(); virtual FieldEditor* make_field_editor( const String& sample, WidgetKit*, Style*, FieldEditorAction* = nil ) const; virtual FileChooser* make_file_chooser( const String& dir, WidgetKit*, Style*, FileChooserAction* = nil ) const; }; #endif ivtools-1.2.11a1/src/include/IV-look/ol_kit.h000066400000000000000000000111011214471147700206430ustar00rootroot00000000000000/* * Copyright (c) 1991, 1992 Stanford University * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef ivlook_olkit_h #define ivlook_olkit_h #include class OLKitImpl; class Window; class OLKit : public WidgetKit { /* * OpenLook ==> WidgetKit mappings: * * exclusive setting ==> radio_button * non-exclusive setting ==> pallette_button * exclusive menu setting ==> radio_menu_item * non-exclusive setting ==> radio_menu_item(*) * scrolling button ==> {up,down,left,down}_mover * text field ==> DialogKit::make_field_editor * * * Remove the telltale state of each exclusive menu item * from the radio_menu_item's telltale group. * * Use -xrm "olglyph:size" to specify the font size used for the OpenLook * font, where size is one of (10, 12, 14, 19). Default size is 12. */ public: OLKit(); virtual ~OLKit(); virtual const char* gui() const; /* shading */ virtual MonoGlyph* outset_frame(Glyph*) const; virtual MonoGlyph* inset_frame(Glyph*) const; virtual MonoGlyph* bright_inset_frame(Glyph*) const; /* menus */ virtual Menu* menubar() const; /* looks implemented by subclass, usually not called directly */ virtual Glyph* menubar_look() const; virtual Glyph* pulldown_look() const; virtual Glyph* pullright_look() const; virtual Glyph* menubar_item_look(Glyph*, TelltaleState*) const; virtual Glyph* menu_item_look(Glyph*, TelltaleState*) const; virtual Glyph* check_menu_item_look(Glyph*, TelltaleState*) const; virtual Glyph* radio_menu_item_look(Glyph*, TelltaleState*) const; virtual Glyph* menu_item_separator_look() const; virtual Glyph* push_button_look(Glyph*, TelltaleState*) const; virtual Glyph* default_button_look(Glyph*, TelltaleState*) const; virtual Glyph* check_box_look(Glyph*, TelltaleState*) const; virtual Glyph* palette_button_look(Glyph*, TelltaleState*) const; virtual Glyph* radio_button_look(Glyph*, TelltaleState*) const; virtual Glyph* slider_look(DimensionName, Adjustable*) const; virtual Glyph* scroll_bar_look(DimensionName, Adjustable*) const; virtual Glyph* panner_look(Adjustable*, Adjustable*) const; virtual Glyph* enlarger_look(TelltaleState*) const; virtual Glyph* reducer_look(TelltaleState*) const; virtual Glyph* up_mover_look(TelltaleState*) const; virtual Glyph* down_mover_look(TelltaleState*) const; virtual Glyph* left_mover_look(TelltaleState*) const; virtual Glyph* right_mover_look(TelltaleState*) const; /* OLKit-specific */ virtual const Color* white() const; virtual const Color* bg1() const; virtual const Color* bg2() const; virtual const Color* bg3() const; virtual const Color* black() const; virtual const Color* inactive() const; virtual const Color* busy() const; virtual Button* pushpin(const Window* unpinned, Window* pinned) const; virtual void pinnable(Menu*, const Window* unpinned) const; virtual MenuItem* habbrev_menu_button() const; virtual MenuItem* vabbrev_menu_button() const; virtual Glyph* hgauge(Adjustable*) const; virtual Glyph* vgauge(Adjustable*) const; virtual Glyph* htick() const; virtual Glyph* vtick() const; virtual Glyph* top_end_box(Adjustable*) const; virtual Glyph* bottom_end_box(Adjustable*) const; virtual Glyph* left_end_box(Adjustable*) const; virtual Glyph* right_end_box(Adjustable*) const; private: OLKitImpl* impl_; }; #endif ivtools-1.2.11a1/src/include/IV-look/slider.h000066400000000000000000000100101214471147700206420ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Slider - common slider behavior */ #ifndef ivlook_slider_h #define ivlook_slider_h #include #include #include class SliderImpl; class Stepper; class Style; typedef void (Adjustable::*SliderAdjustment)(DimensionName); class Slider : public ActiveHandler, public Observer { public: Slider(Style*); virtual ~Slider(); virtual void normal_thumb(Glyph*); virtual void visible_thumb(Glyph*); virtual void old_thumb(Glyph*); virtual Coord minimum_thumb_size() const; virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void undraw(); virtual void move(const Event&); virtual void press(const Event&); virtual void drag(const Event&); virtual void release(const Event&); virtual void allocation_changed(Canvas*, const Allocation&); virtual void update(Observable*); virtual void forward_stepper(Stepper*); virtual void backward_stepper(Stepper*); virtual void move_to(Coord x, Coord y); virtual void allocate_thumb(const Allocation&); virtual void allot_thumb_major_axis( const Allocation&, DimensionName, Adjustable*, Coord min_thumb_size, float& scale, Allotment& ); virtual void allot_thumb_minor_axis(const Allotment&, Allotment&); virtual void redraw_thumb(); virtual void reallocate_thumb(const Allocation&); virtual void apply_adjustment(SliderAdjustment); virtual void do_adjustment(Adjustable*, SliderAdjustment, DimensionName); private: SliderImpl* impl_; }; class XSlider : public Slider { public: XSlider(Style*, Adjustable*); virtual ~XSlider(); virtual void move_to(Coord x, Coord y); virtual void allocate_thumb(const Allocation&); virtual void disconnect(Observable*); virtual void apply_adjustment(SliderAdjustment); private: Adjustable* adjustable_; float xscale_; Stepper* forward_; Stepper* backward_; }; class YSlider : public Slider { public: YSlider(Style*, Adjustable*); virtual ~YSlider(); virtual void move_to(Coord x, Coord y); virtual void allocate_thumb(const Allocation&); virtual void disconnect(Observable*); virtual void apply_adjustment(SliderAdjustment); private: Adjustable* adjustable_; float yscale_; Stepper* forward_; Stepper* backward_; }; class XYSlider : public Slider { public: XYSlider(Style*, Adjustable* x, Adjustable* y); virtual ~XYSlider(); virtual void move_to(Coord x, Coord y); virtual void allocate_thumb(const Allocation&); virtual void disconnect(Observable*); virtual void apply_adjustment(SliderAdjustment); private: Adjustable* x_adjustable_; Adjustable* y_adjustable_; float xscale_; float yscale_; }; #endif ivtools-1.2.11a1/src/include/IV-look/smf_kit.h000066400000000000000000000057671214471147700210430ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * SMFKit -- object for creating SGI Motif components */ #ifndef ivlook_smfkit_h #define ivlook_smfkit_h #include class SMFKitImpl; class SMFKit : public WidgetKit { public: SMFKit(); virtual ~SMFKit(); virtual const char* gui() const; virtual void style_changed(Style*); virtual MonoGlyph* outset_frame(Glyph*) const; virtual MonoGlyph* inset_frame(Glyph*) const; virtual MonoGlyph* bright_inset_frame(Glyph*) const; virtual Glyph* menubar_look() const; virtual Glyph* pulldown_look() const; virtual Glyph* pullright_look() const; virtual Glyph* menubar_item_look(Glyph*, TelltaleState*) const; virtual Glyph* menu_item_look(Glyph*, TelltaleState*) const; virtual Glyph* check_menu_item_look(Glyph*, TelltaleState*) const; virtual Glyph* radio_menu_item_look(Glyph*, TelltaleState*) const; virtual Glyph* menu_item_separator_look() const; virtual Glyph* push_button_look(Glyph*, TelltaleState*) const; virtual Glyph* default_button_look(Glyph*, TelltaleState*) const; virtual Glyph* check_box_look(Glyph*, TelltaleState*) const; virtual Glyph* palette_button_look(Glyph*, TelltaleState*) const; virtual Glyph* radio_button_look(Glyph*, TelltaleState*) const; virtual Glyph* slider_look(DimensionName, Adjustable*) const; virtual Glyph* scroll_bar_look(DimensionName, Adjustable*) const; virtual Glyph* panner_look(Adjustable*, Adjustable*) const; virtual Glyph* enlarger_look(TelltaleState*) const; virtual Glyph* reducer_look(TelltaleState*) const; virtual Glyph* up_mover_look(TelltaleState*) const; virtual Glyph* down_mover_look(TelltaleState*) const; virtual Glyph* left_mover_look(TelltaleState*) const; virtual Glyph* right_mover_look(TelltaleState*) const; private: SMFKitImpl* impl_; }; #endif ivtools-1.2.11a1/src/include/IV-look/stepper.h000066400000000000000000000054141214471147700210560ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Stepper -- button with autorepeat */ #ifndef ivlook_stepper_h #define ivlook_stepper_h #include #include #include class Color; class IOHandler; class TelltaleState; class Stepper : public Button { public: Stepper(Glyph*, Style*, TelltaleState*, Action* = nil); virtual ~Stepper(); virtual void press(const Event&); virtual void release(const Event&); virtual void start_stepping(); virtual void stop_stepping(); protected: virtual void adjust() = 0; private: long start_delay_; long next_delay_; IOHandler* timer_; void tick(long, long); }; #define declareAdjustStepper(StepperSubclassName) \ class StepperSubclassName : public Stepper { \ public: \ StepperSubclassName( \ Glyph*, Style*, TelltaleState*, Adjustable*, DimensionName \ ); \ virtual ~StepperSubclassName(); \ \ virtual void adjust(); \ private: \ Adjustable* adjustable_; \ DimensionName dimension_; \ }; declareAdjustStepper(ForwardScroller) declareAdjustStepper(BackwardScroller) declareAdjustStepper(ForwardPager) declareAdjustStepper(BackwardPager) #define declareArrowGlyph(ArrowSubclassName) \ class ArrowSubclassName : public Glyph { \ public: \ ArrowSubclassName(const Color*); \ virtual ~ArrowSubclassName(); \ \ virtual void draw(Canvas*, const Allocation&) const; \ private: \ const Color* color_; \ }; declareArrowGlyph(UpArrow) declareArrowGlyph(DownArrow) declareArrowGlyph(LeftArrow) declareArrowGlyph(RightArrow) #include #endif ivtools-1.2.11a1/src/include/IV-look/telltale.h000066400000000000000000000000761214471147700212010ustar00rootroot00000000000000/* backward compatibility */ #include ivtools-1.2.11a1/src/include/InterViews/000077500000000000000000000000001214471147700200365ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/InterViews/Bitmaps/000077500000000000000000000000001214471147700214355ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/InterViews/Bitmaps/big_checkmark.bm000066400000000000000000000004421214471147700245260ustar00rootroot00000000000000#define checkmark_width 16 #define checkmark_height 16 static char checkmark_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x18, 0x00, 0x0c, 0x00, 0x06, 0x18, 0x03, 0xbe, 0x01, 0xfc, 0x01, 0xf8, 0x00, 0xf0, 0x00, 0x60, 0x00, 0x40, 0x00, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/checkmark.bm000066400000000000000000000003271214471147700237070ustar00rootroot00000000000000#define checkmark_width 8 #define checkmark_height 12 #define checkmark_x_hot 0 #define checkmark_y_hot 9 static char checkmark_bits[] = { 0x00, 0x80, 0x80, 0x40, 0x40, 0x20, 0x32, 0x1f, 0x1f, 0x1e, 0x0c, 0x08}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/chkbox.bm000066400000000000000000000005601214471147700232340ustar00rootroot00000000000000#define checkbox_plain_width 16 #define checkbox_plain_height 16 #define checkbox_plain_x_hot 0 #define checkbox_plain_y_hot 11 static char checkbox_plain_bits[] = { 0x00, 0x00, 0xfe, 0x7f, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0xfe, 0x7f, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/chkboxBoth.bm000066400000000000000000000005531214471147700240530ustar00rootroot00000000000000#define checkbox_both_width 16 #define checkbox_both_height 16 #define checkbox_both_x_hot 0 #define checkbox_both_y_hot 11 static char checkbox_both_bits[] = { 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x06, 0x60, 0x36, 0x6c, 0x76, 0x6e, 0xe6, 0x67, 0xc6, 0x63, 0xc6, 0x63, 0xe6, 0x67, 0x76, 0x6e, 0x36, 0x6c, 0x06, 0x60, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/chkboxChosen.bm000066400000000000000000000005651214471147700244010ustar00rootroot00000000000000#define checkbox_chosen_width 16 #define checkbox_chosen_height 16 #define checkbox_chosen_x_hot 0 #define checkbox_chosen_y_hot 11 static char checkbox_chosen_bits[] = { 0x00, 0x00, 0xfe, 0x7f, 0x02, 0x40, 0x02, 0x40, 0x32, 0x4c, 0x72, 0x4e, 0xe2, 0x47, 0xc2, 0x43, 0xc2, 0x43, 0xe2, 0x47, 0x72, 0x4e, 0x32, 0x4c, 0x02, 0x40, 0x02, 0x40, 0xfe, 0x7f, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/chkboxHit.bm000066400000000000000000000005461214471147700237050ustar00rootroot00000000000000#define checkbox_hit_width 16 #define checkbox_hit_height 16 #define checkbox_hit_x_hot 0 #define checkbox_hit_y_hot 11 static char checkbox_hit_bits[] = { 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/dfast.bm000066400000000000000000000005021214471147700230530ustar00rootroot00000000000000#define dfast_width 16 #define dfast_height 16 #define dfast_x_hot 8 #define dfast_y_hot 7 static char dfast_bits[] = { 0x00, 0x00, 0xfc, 0x7f, 0x08, 0x20, 0x10, 0x10, 0x20, 0x08, 0x40, 0x04, 0x80, 0x02, 0x00, 0x01, 0xfc, 0x7f, 0x08, 0x20, 0x10, 0x10, 0x20, 0x08, 0x40, 0x04, 0x80, 0x02, 0x00, 0x01, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/dfastMask.bm000066400000000000000000000005331214471147700236730ustar00rootroot00000000000000#define dfast_mask_width 16 #define dfast_mask_height 16 #define dfast_mask_x_hot 8 #define dfast_mask_y_hot 7 static char dfast_mask_bits[] = { 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03, 0x00, 0x01}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/dmover.bm000066400000000000000000000004461214471147700232550ustar00rootroot00000000000000#define dmover_plain_width 11 #define dmover_plain_height 11 #define dmover_plain_x_hot 5 #define dmover_plain_y_hot 5 static char dmover_plain_bits[] = { 0x00, 0x00, 0xf8, 0x00, 0x88, 0x01, 0x88, 0x01, 0x8e, 0x03, 0x02, 0x06, 0x04, 0x07, 0x88, 0x03, 0xd0, 0x01, 0xe0, 0x00, 0x40, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/dmoverHit.bm000066400000000000000000000004341214471147700237170ustar00rootroot00000000000000#define dmover_hit_width 11 #define dmover_hit_height 11 #define dmover_hit_x_hot 6 #define dmover_hit_y_hot 6 static char dmover_hit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x10, 0x01, 0x10, 0x01, 0x1c, 0x07, 0x04, 0x04, 0x08, 0x02, 0x10, 0x01, 0xa0, 0x00, 0x40, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/dmoverMask.bm000066400000000000000000000004411214471147700240640ustar00rootroot00000000000000#define dmover_mask_width 11 #define dmover_mask_height 11 #define dmover_mask_x_hot 6 #define dmover_mask_y_hot 6 static char dmover_mask_bits[] = { 0x00, 0x00, 0xf8, 0x00, 0xf8, 0x01, 0xf8, 0x01, 0xfe, 0x03, 0xfe, 0x07, 0xfc, 0x07, 0xf8, 0x03, 0xf0, 0x01, 0xe0, 0x00, 0x40, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/enlarge.bm000066400000000000000000000010361214471147700233720ustar00rootroot00000000000000#define enlarger_plain_width 25 #define enlarger_plain_height 15 #define enlarger_plain_x_hot 12 #define enlarger_plain_y_hot 6 static char enlarger_plain_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x80, 0x01, 0x03, 0x00, 0x60, 0x00, 0x0c, 0x00, 0x18, 0x00, 0x30, 0x00, 0xf8, 0x01, 0x3f, 0x00, 0x88, 0x00, 0x22, 0x00, 0x78, 0x00, 0x3c, 0x00, 0xc0, 0xff, 0x07, 0x00, 0x40, 0x00, 0x04, 0x00, 0x40, 0x00, 0x04, 0x00, 0xc0, 0xff, 0x07, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/enlargeHit.bm000066400000000000000000000010241214471147700240340ustar00rootroot00000000000000#define enlarger_hit_width 25 #define enlarger_hit_height 15 #define enlarger_hit_x_hot 12 #define enlarger_hit_y_hot 5 static char enlarger_hit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xee, 0x00, 0x00, 0xc0, 0x01, 0x07, 0x00, 0x30, 0x00, 0x18, 0x00, 0xf0, 0x83, 0x1f, 0x00, 0x10, 0x01, 0x11, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0x80, 0x00, 0x02, 0x00, 0x80, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/enlargeMask.bm000066400000000000000000000010311214471147700242010ustar00rootroot00000000000000#define enlarger_mask_width 25 #define enlarger_mask_height 15 #define enlarger_mask_x_hot 12 #define enlarger_mask_y_hot 6 static char enlarger_mask_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xc0, 0xff, 0x07, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xc0, 0xff, 0x07, 0x00, 0xc0, 0xff, 0x07, 0x00, 0xc0, 0xff, 0x07, 0x00, 0xc0, 0xff, 0x07, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/hand.bm000066400000000000000000000004751214471147700226750ustar00rootroot00000000000000#define hand_width 16 #define hand_height 16 #define hand_x_hot 8 #define hand_y_hot 8 static char hand_bits[] = { 0x80, 0x00, 0x40, 0x09, 0x48, 0x16, 0x54, 0x12, 0x54, 0x12, 0x64, 0x52, 0x64, 0xb2, 0x68, 0xb2, 0x48, 0x92, 0x4a, 0x92, 0x15, 0x80, 0x19, 0x40, 0x12, 0x40, 0x04, 0x40, 0x08, 0x20, 0x10, 0x20}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/handMask.bm000066400000000000000000000005261214471147700235060ustar00rootroot00000000000000#define hand_mask_width 16 #define hand_mask_height 16 #define hand_mask_x_hot 8 #define hand_mask_y_hot 8 static char hand_mask_bits[] = { 0x80, 0x00, 0xc0, 0x09, 0xc8, 0x1f, 0xdc, 0x1f, 0xdc, 0x1f, 0xfc, 0x5f, 0xfc, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xfa, 0xff, 0xf7, 0xff, 0xff, 0x7f, 0xfe, 0x7f, 0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x3f}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/ldfast.bm000066400000000000000000000005071214471147700232340ustar00rootroot00000000000000#define ldfast_width 16 #define ldfast_height 16 #define ldfast_x_hot 6 #define ldfast_y_hot 9 static char ldfast_bits[] = { 0x00, 0x00, 0x40, 0x00, 0xc0, 0x00, 0x40, 0x01, 0x40, 0x02, 0x40, 0x04, 0x42, 0x08, 0x46, 0x10, 0x4a, 0x20, 0xd2, 0x7f, 0x22, 0x00, 0x42, 0x00, 0x82, 0x00, 0x02, 0x01, 0xfe, 0x03, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/ldfastMask.bm000066400000000000000000000005401214471147700240450ustar00rootroot00000000000000#define ldfast_mask_width 16 #define ldfast_mask_height 16 #define ldfast_mask_x_hot 6 #define ldfast_mask_y_hot 9 static char ldfast_mask_bits[] = { 0x60, 0x00, 0xe0, 0x00, 0xe0, 0x01, 0xe0, 0x03, 0xe0, 0x07, 0xe3, 0x0f, 0xe7, 0x1f, 0xef, 0x3f, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0x01, 0xff, 0x03, 0xff, 0x07, 0xff, 0x07}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lfast.bm000066400000000000000000000005021214471147700230630ustar00rootroot00000000000000#define lfast_width 16 #define lfast_height 16 #define lfast_x_hot 8 #define lfast_y_hot 7 static char lfast_bits[] = { 0x00, 0x00, 0x80, 0x40, 0xc0, 0x60, 0xa0, 0x50, 0x90, 0x48, 0x88, 0x44, 0x84, 0x42, 0x82, 0x41, 0x84, 0x42, 0x88, 0x44, 0x90, 0x48, 0xa0, 0x50, 0xc0, 0x60, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lfastMask.bm000066400000000000000000000005331214471147700237030ustar00rootroot00000000000000#define lfast_mask_width 16 #define lfast_mask_height 16 #define lfast_mask_x_hot 8 #define lfast_mask_y_hot 7 static char lfast_mask_bits[] = { 0x80, 0xc1, 0xc0, 0xe1, 0xe0, 0xf1, 0xf0, 0xf9, 0xf8, 0xfd, 0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xfc, 0xff, 0xf8, 0xfd, 0xf0, 0xf9, 0xe0, 0xf1, 0xc0, 0xe1, 0x80, 0xc1, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lmover.bm000066400000000000000000000004461214471147700232650ustar00rootroot00000000000000#define lmover_plain_width 11 #define lmover_plain_height 11 #define lmover_plain_x_hot 5 #define lmover_plain_y_hot 5 static char lmover_plain_bits[] = { 0x00, 0x00, 0x60, 0x00, 0x50, 0x00, 0xc8, 0x03, 0x04, 0x06, 0x02, 0x06, 0x04, 0x06, 0xc8, 0x07, 0xd0, 0x07, 0xe0, 0x00, 0xc0, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lmoverHit.bm000066400000000000000000000004341214471147700237270ustar00rootroot00000000000000#define lmover_hit_width 11 #define lmover_hit_height 11 #define lmover_hit_x_hot 6 #define lmover_hit_y_hot 6 static char lmover_hit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0x90, 0x07, 0x08, 0x04, 0x04, 0x04, 0x08, 0x04, 0x90, 0x07, 0xa0, 0x00, 0xc0, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lmoverMask.bm000066400000000000000000000004411214471147700240740ustar00rootroot00000000000000#define lmover_mask_width 11 #define lmover_mask_height 11 #define lmover_mask_x_hot 6 #define lmover_mask_y_hot 5 static char lmover_mask_bits[] = { 0x00, 0x00, 0x60, 0x00, 0x70, 0x00, 0xf8, 0x03, 0xfc, 0x07, 0xfe, 0x07, 0xfc, 0x07, 0xf8, 0x07, 0xf0, 0x07, 0xe0, 0x00, 0xc0, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lufast.bm000066400000000000000000000005071214471147700232550ustar00rootroot00000000000000#define lufast_width 16 #define lufast_height 16 #define lufast_x_hot 6 #define lufast_y_hot 6 static char lufast_bits[] = { 0x00, 0x00, 0xfe, 0x03, 0x02, 0x01, 0x82, 0x00, 0x42, 0x00, 0x22, 0x00, 0xd2, 0x7f, 0x4a, 0x20, 0x46, 0x10, 0x42, 0x08, 0x40, 0x04, 0x40, 0x02, 0x40, 0x01, 0xc0, 0x00, 0x40, 0x00, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lufastMask.bm000066400000000000000000000005401214471147700240660ustar00rootroot00000000000000#define lufast_mask_width 16 #define lufast_mask_height 16 #define lufast_mask_x_hot 6 #define lufast_mask_y_hot 6 static char lufast_mask_bits[] = { 0xff, 0x07, 0xff, 0x07, 0xff, 0x03, 0xff, 0x01, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xef, 0x3f, 0xe7, 0x1f, 0xe3, 0x0f, 0xe0, 0x07, 0xe0, 0x03, 0xe0, 0x01, 0xe0, 0x00, 0x60, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/page.bm000066400000000000000000000013101214471147700226640ustar00rootroot00000000000000#define page_plain_width 20 #define page_plain_height 30 #define page_plain_x_hot 10 #define page_plain_y_hot 21 static char page_plain_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x04, 0x18, 0x00, 0x04, 0x28, 0x00, 0x04, 0x48, 0x00, 0x04, 0x88, 0x00, 0x04, 0x08, 0x01, 0x04, 0x08, 0x02, 0x04, 0xf8, 0x07, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/pageBoth.bm000066400000000000000000000013031214471147700235030ustar00rootroot00000000000000#define page_both_width 20 #define page_both_height 30 #define page_both_x_hot 10 #define page_both_y_hot 21 static char page_both_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x1f, 0x00, 0xfc, 0x3f, 0x00, 0x0c, 0x7c, 0x00, 0x0c, 0xfc, 0x00, 0x0c, 0xfc, 0x01, 0x0c, 0xfc, 0x03, 0x0c, 0xfc, 0x07, 0x0c, 0xfc, 0x07, 0x0c, 0xfc, 0x07, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0xfc, 0xff, 0x07, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/pageChosen.bm000066400000000000000000000013151214471147700240310ustar00rootroot00000000000000#define page_chosen_width 20 #define page_chosen_height 30 #define page_chosen_x_hot 10 #define page_chosen_y_hot 21 static char page_chosen_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x1f, 0x00, 0xfc, 0x3f, 0x00, 0x0c, 0x6c, 0x00, 0x0c, 0xcc, 0x00, 0x0c, 0x8c, 0x01, 0x0c, 0x0c, 0x03, 0x0c, 0x0c, 0x06, 0x0c, 0xfc, 0x07, 0x0c, 0xfc, 0x07, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0xfc, 0xff, 0x07, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/pageHit.bm000066400000000000000000000012761214471147700233440ustar00rootroot00000000000000#define page_hit_width 20 #define page_hit_height 30 #define page_hit_x_hot 10 #define page_hit_y_hot 21 static char page_hit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x04, 0x18, 0x00, 0x04, 0x38, 0x00, 0x04, 0x78, 0x00, 0x04, 0xf8, 0x00, 0x04, 0xf8, 0x01, 0x04, 0xf8, 0x03, 0x04, 0xf8, 0x07, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/radio.bm000066400000000000000000000004411214471147700230520ustar00rootroot00000000000000#define radio_plain_width 11 #define radio_plain_height 11 #define radio_plain_x_hot 5 #define radio_plain_y_hot 5 static char radio_plain_bits[] = { 0x70, 0x00, 0x8c, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x02, 0x02, 0x02, 0x02, 0x8c, 0x01, 0x70, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/radioBoth.bm000066400000000000000000000004341214471147700236710ustar00rootroot00000000000000#define radio_both_width 11 #define radio_both_height 11 #define radio_both_x_hot 5 #define radio_both_y_hot 5 static char radio_both_bits[] = { 0x70, 0x00, 0xfc, 0x01, 0x8e, 0x03, 0x76, 0x03, 0xfb, 0x06, 0xfb, 0x06, 0xfb, 0x06, 0x76, 0x03, 0x8e, 0x03, 0xfc, 0x01, 0x70, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/radioChosen.bm000066400000000000000000000004461214471147700242170ustar00rootroot00000000000000#define radio_chosen_width 11 #define radio_chosen_height 11 #define radio_chosen_x_hot 5 #define radio_chosen_y_hot 5 static char radio_chosen_bits[] = { 0x70, 0x00, 0x8c, 0x01, 0x02, 0x02, 0x72, 0x02, 0xf9, 0x04, 0xf9, 0x04, 0xf9, 0x04, 0x72, 0x02, 0x02, 0x02, 0x8c, 0x01, 0x70, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/radioHit.bm000066400000000000000000000004271214471147700235230ustar00rootroot00000000000000#define radio_hit_width 11 #define radio_hit_height 11 #define radio_hit_x_hot 5 #define radio_hit_y_hot 5 static char radio_hit_bits[] = { 0x70, 0x00, 0xfc, 0x01, 0x8e, 0x03, 0x06, 0x03, 0x03, 0x06, 0x03, 0x06, 0x03, 0x06, 0x06, 0x03, 0x8e, 0x03, 0xfc, 0x01, 0x70, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/radioMask.bm000066400000000000000000000004341214471147700236700ustar00rootroot00000000000000#define radio_mask_width 11 #define radio_mask_height 11 #define radio_mask_x_hot 5 #define radio_mask_y_hot 5 static char radio_mask_bits[] = { 0x70, 0x00, 0xfc, 0x01, 0xfe, 0x03, 0xfe, 0x03, 0xff, 0x07, 0xff, 0x07, 0xff, 0x07, 0xfe, 0x03, 0xfe, 0x03, 0xfc, 0x01, 0x70, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rdfast.bm000066400000000000000000000005071214471147700232420ustar00rootroot00000000000000#define rdfast_width 16 #define rdfast_height 16 #define rdfast_x_hot 9 #define rdfast_y_hot 9 static char rdfast_bits[] = { 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x80, 0x02, 0x40, 0x02, 0x20, 0x02, 0x10, 0x42, 0x08, 0x62, 0x04, 0x52, 0xfe, 0x4b, 0x00, 0x44, 0x00, 0x42, 0x00, 0x41, 0x80, 0x40, 0xc0, 0x7f, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rdfastMask.bm000066400000000000000000000005401214471147700240530ustar00rootroot00000000000000#define rdfast_mask_width 16 #define rdfast_mask_height 16 #define rdfast_mask_x_hot 9 #define rdfast_mask_y_hot 9 static char rdfast_mask_bits[] = { 0x00, 0x06, 0x00, 0x07, 0x80, 0x07, 0xc0, 0x07, 0xe0, 0x07, 0xf0, 0xc7, 0xf8, 0xe7, 0xfc, 0xf7, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0x80, 0xff, 0xc0, 0xff, 0xe0, 0xff, 0xe0, 0xff}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/reducer.bm000066400000000000000000000010311214471147700234010ustar00rootroot00000000000000#define reducer_plain_width 25 #define reducer_plain_height 15 #define reducer_plain_x_hot 12 #define reducer_plain_y_hot 5 static char reducer_plain_bits[] = { 0x00, 0x7c, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0xf8, 0x00, 0x3e, 0x00, 0x38, 0x00, 0x38, 0x00, 0xc8, 0x00, 0x26, 0x00, 0x08, 0x83, 0x21, 0x00, 0x30, 0x6c, 0x18, 0x00, 0xc0, 0x10, 0x06, 0x00, 0x00, 0x93, 0x01, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/reducerHit.bm000066400000000000000000000010171214471147700240520ustar00rootroot00000000000000#define reducer_hit_width 25 #define reducer_hit_height 15 #define reducer_hit_x_hot 12 #define reducer_hit_y_hot 7 static char reducer_hit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x80, 0x00, 0x02, 0x00, 0x40, 0x00, 0x04, 0x00, 0x3f, 0x00, 0xf8, 0x01, 0x07, 0x00, 0xc0, 0x01, 0x19, 0x00, 0x30, 0x01, 0x61, 0x00, 0x0c, 0x01, 0x86, 0x01, 0xc3, 0x00, 0x18, 0xc6, 0x30, 0x00, 0x60, 0x38, 0x0c, 0x00, 0x80, 0x11, 0x03, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/reducerMask.bm000066400000000000000000000010241214471147700242170ustar00rootroot00000000000000#define reducer_mask_width 25 #define reducer_mask_height 15 #define reducer_mask_x_hot 12 #define reducer_mask_y_hot 8 static char reducer_mask_bits[] = { 0x00, 0x7c, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xe0, 0xff, 0x0f, 0x00, 0x80, 0xff, 0x03, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rfast.bm000066400000000000000000000005021214471147700230710ustar00rootroot00000000000000#define rfast_width 16 #define rfast_height 16 #define rfast_x_hot 7 #define rfast_y_hot 7 static char rfast_bits[] = { 0x00, 0x00, 0x02, 0x01, 0x06, 0x03, 0x0a, 0x05, 0x12, 0x09, 0x22, 0x11, 0x42, 0x21, 0x82, 0x41, 0x42, 0x21, 0x22, 0x11, 0x12, 0x09, 0x0a, 0x05, 0x06, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rfastMask.bm000066400000000000000000000005331214471147700237110ustar00rootroot00000000000000#define rfast_mask_width 16 #define rfast_mask_height 16 #define rfast_mask_x_hot 7 #define rfast_mask_y_hot 7 static char rfast_mask_bits[] = { 0x83, 0x01, 0x87, 0x03, 0x8f, 0x07, 0x9f, 0x0f, 0xbf, 0x1f, 0xff, 0x3f, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0x3f, 0xbf, 0x1f, 0x9f, 0x0f, 0x8f, 0x07, 0x87, 0x03, 0x83, 0x01, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rmover.bm000066400000000000000000000004461214471147700232730ustar00rootroot00000000000000#define rmover_plain_width 11 #define rmover_plain_height 11 #define rmover_plain_x_hot 5 #define rmover_plain_y_hot 5 static char rmover_plain_bits[] = { 0x00, 0x00, 0x30, 0x00, 0x50, 0x00, 0x9e, 0x00, 0x02, 0x01, 0x02, 0x02, 0x02, 0x07, 0x9e, 0x03, 0xdc, 0x01, 0xf0, 0x00, 0x60, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rmoverHit.bm000066400000000000000000000004341214471147700237350ustar00rootroot00000000000000#define rmover_hit_width 11 #define rmover_hit_height 11 #define rmover_hit_x_hot 6 #define rmover_hit_y_hot 6 static char rmover_hit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0xa0, 0x00, 0x3c, 0x01, 0x04, 0x02, 0x04, 0x04, 0x04, 0x02, 0x3c, 0x01, 0xa0, 0x00, 0x60, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rmoverMask.bm000066400000000000000000000004411214471147700241020ustar00rootroot00000000000000#define rmover_mask_width 11 #define rmover_mask_height 11 #define rmover_mask_x_hot 5 #define rmover_mask_y_hot 5 static char rmover_mask_bits[] = { 0x00, 0x00, 0x30, 0x00, 0x70, 0x00, 0xfe, 0x00, 0xfe, 0x01, 0xfe, 0x03, 0xfe, 0x07, 0xfe, 0x03, 0xfc, 0x01, 0xf0, 0x00, 0x60, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rufast.bm000066400000000000000000000005071214471147700232630ustar00rootroot00000000000000#define rufast_width 16 #define rufast_height 16 #define rufast_x_hot 9 #define rufast_y_hot 6 static char rufast_bits[] = { 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x40, 0x00, 0x41, 0x00, 0x42, 0x00, 0x44, 0xfe, 0x4b, 0x04, 0x52, 0x08, 0x62, 0x10, 0x42, 0x20, 0x02, 0x40, 0x02, 0x80, 0x02, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rufastMask.bm000066400000000000000000000005401214471147700240740ustar00rootroot00000000000000#define rufast_mask_width 16 #define rufast_mask_height 16 #define rufast_mask_x_hot 9 #define rufast_mask_y_hot 6 static char rufast_mask_bits[] = { 0xe0, 0xff, 0xe0, 0xff, 0xc0, 0xff, 0x80, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xfc, 0xf7, 0xf8, 0xe7, 0xf0, 0xc7, 0xe0, 0x07, 0xc0, 0x07, 0x80, 0x07, 0x00, 0x07, 0x00, 0x06}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/ufast.bm000066400000000000000000000005021214471147700230740ustar00rootroot00000000000000#define ufast_width 16 #define ufast_height 16 #define ufast_x_hot 8 #define ufast_y_hot 8 static char ufast_bits[] = { 0x00, 0x00, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, 0x20, 0x08, 0x10, 0x10, 0x08, 0x20, 0xfc, 0x7f, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, 0x20, 0x08, 0x10, 0x10, 0x08, 0x20, 0xfc, 0x7f, 0x00, 0x00}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/ufastMask.bm000066400000000000000000000005331214471147700237140ustar00rootroot00000000000000#define ufast_mask_width 16 #define ufast_mask_height 16 #define ufast_mask_x_hot 8 #define ufast_mask_y_hot 8 static char ufast_mask_bits[] = { 0x00, 0x01, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/umover.bm000066400000000000000000000004461214471147700232760ustar00rootroot00000000000000#define umover_plain_width 11 #define umover_plain_height 11 #define umover_plain_x_hot 5 #define umover_plain_y_hot 5 static char umover_plain_bits[] = { 0x00, 0x00, 0x20, 0x00, 0x50, 0x00, 0x88, 0x00, 0x04, 0x01, 0x02, 0x02, 0x8e, 0x07, 0x88, 0x07, 0x88, 0x01, 0xf8, 0x01, 0xf0, 0x01}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/umoverHit.bm000066400000000000000000000004341214471147700237400ustar00rootroot00000000000000#define umover_hit_width 11 #define umover_hit_height 11 #define umover_hit_x_hot 6 #define umover_hit_y_hot 6 static char umover_hit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x10, 0x01, 0x08, 0x02, 0x04, 0x04, 0x1c, 0x07, 0x10, 0x01, 0x10, 0x01, 0xf0, 0x01}; ivtools-1.2.11a1/src/include/InterViews/Bitmaps/umoverMask.bm000066400000000000000000000004411214471147700241050ustar00rootroot00000000000000#define umover_mask_width 11 #define umover_mask_height 11 #define umover_mask_x_hot 5 #define umover_mask_y_hot 5 static char umover_mask_bits[] = { 0x00, 0x00, 0x20, 0x00, 0x70, 0x00, 0xf8, 0x00, 0xfc, 0x01, 0xfe, 0x03, 0xfe, 0x07, 0xf8, 0x07, 0xf8, 0x01, 0xf8, 0x01, 0xf0, 0x01}; ivtools-1.2.11a1/src/include/InterViews/_defines.h000066400000000000000000000272351214471147700217740ustar00rootroot00000000000000#define Alignment _lib_iv(Alignment) #define ColorIntensity _lib_iv(ColorIntensity) #define ColorOp _lib_iv(ColorOp) #define Coord _lib_iv(Coord) #define EventType _lib_iv(EventType) #define EventButton _lib_iv(EventButton) #define GlyphBreakType _lib_iv(GlyphBreakType) #define GlyphIndex _lib_iv(GlyphIndex) #define IntCoord _lib_iv(IntCoord) #define PixelCoord _lib_iv(PixelCoord) #define FloatCoord _lib_iv(FloatCoord) #define Selection _lib_iv(Selection) #define Action _lib_iv(Action) #define ActiveHandler _lib_iv(ActiveHandler) #define Adjustable _lib_iv(Adjustable) #define Adjuster _lib_iv(Adjuster) #define Aggregate _lib_iv(Aggregate) #define AggregateInfo_List _lib_iv(AggregateInfo_List) #define Align _lib_iv(Align) #define Allocation _lib_iv(Allocation) #define AllocationInfo _lib_iv(AllocationInfo) #define AllocationTable _lib_iv(AllocationTable) #define AllocationTableImpl _lib_iv(AllocationTableImpl) #define Allotment _lib_iv(Allotment) #define ApplicationWindow _lib_iv(ApplicationWindow) #define ArrayCompositor _lib_iv(ArrayCompositor) #define ArrowSubclassName _lib_iv(ArrowSubclassName) #define Background _lib_iv(Background) #define Banner _lib_iv(Banner) #define Bevel _lib_iv(Bevel) #define BevelFrame _lib_iv(BevelFrame) #define Bitmap _lib_iv(Bitmap) #define BitmapRep _lib_iv(BitmapRep) #define Border _lib_iv(Border) #define BorderFrame _lib_iv(BorderFrame) #define Box _lib_iv(Box) #define BoxCanonical _lib_iv(BoxCanonical) #define BoxElement _lib_iv(BoxElement) #define BoxImpl _lib_iv(BoxImpl) #define Break _lib_iv(Break) #define Break_List _lib_iv(Break_List) #define Browser _lib_iv(Browser) #define BrowserList _lib_iv(BrowserList) #define Brush _lib_iv(Brush) #define BrushImpl _lib_iv(BrushImpl) #define BrushRep _lib_iv(BrushRep) #define Button _lib_iv(Button) #define ButtonList _lib_iv(ButtonList) #define ButtonState _lib_iv(ButtonState) #define Canvas _lib_iv(Canvas) #define CanvasDamage _lib_iv(CanvasDamage) #define CanvasRep _lib_iv(CanvasRep) #define Card _lib_iv(Card) #define CenterLayout _lib_iv(CenterLayout) #define Character _lib_iv(Character) #define CheckBox _lib_iv(CheckBox) #define ChoiceItem _lib_iv(ChoiceItem) #define ClippingStack _lib_iv(ClippingStack) #define Color _lib_iv(Color) #define ColorImpl _lib_iv(ColorImpl) #define ColorRep _lib_iv(ColorRep) #define ColorTable _lib_iv(ColorTable) #define CompletionEditor _lib_iv(CompletionEditor) #define Composition _lib_iv(Composition) #define CompositionComponent_List _lib_iv(CompositionComponent_List) #define Compositor _lib_iv(Compositor) #define Control _lib_iv(Control) #define ControlState _lib_iv(ControlState) #define Cursor _lib_iv(Cursor) #define CursorRep _lib_iv(CursorRep) #define CursorRepBitmap _lib_iv(CursorRepBitmap) #define CursorRepData _lib_iv(CursorRepData) #define CursorRepFont _lib_iv(CursorRepFont) #define CursorRepXFont _lib_iv(CursorRepXFont) #define DamageList _lib_iv(DamageList) #define DebugGlyph _lib_iv(DebugGlyph) #define Deck _lib_iv(Deck) #define Dialog _lib_iv(Dialog) #define DialogKit _lib_iv(DialogKit) #define Display _lib_iv(Display) #define DisplayRep _lib_iv(DisplayRep) #define DownMover _lib_iv(DownMover) #define Enlarger _lib_iv(Enlarger) #define Event _lib_iv(Event) #define EventRep _lib_iv(EventRep) #define Extension _lib_iv(Extension) #define FBDirectory _lib_iv(FBDirectory) #define FieldEditor _lib_iv(FieldEditor) #define FieldEditorAction _lib_iv(FieldEditorAction) #define FieldEditorImpl _lib_iv(FieldEditorImpl) #define FileBrowser _lib_iv(FileBrowser) #define FileBrowserImpl _lib_iv(FileBrowserImpl) #define FileChooser _lib_iv(FileChooser) #define FileChooserAction _lib_iv(FileChooserAction) #define FileChooserImpl _lib_iv(FileChooserImpl) #define FixedLayout _lib_iv(FixedLayout) #define Font _lib_iv(Font) #define FontBoundingBox _lib_iv(FontBoundingBox) #define FontFamily _lib_iv(FontFamily) #define FontFamilyImpl _lib_iv(FontFamilyImpl) #define FontFamilyRep _lib_iv(FontFamilyRep) #define FontImpl _lib_iv(FontImpl) #define FontRep _lib_iv(FontRep) #define Frame _lib_iv(Frame) #define GLContext _lib_iv(GLContext) #define GLContextImpl _lib_iv(GLContextImpl) #define GLWindow _lib_iv(GLWindow) #define Glue _lib_iv(Glue) #define Glyph _lib_iv(Glyph) #define GrabList _lib_iv(GrabList) #define Group _lib_iv(Group) #define GrowingBSpline _lib_iv(GrowingBSpline) #define GrowingClosedBSpline _lib_iv(GrowingClosedBSpline) #define GrowingMultiLine _lib_iv(GrowingMultiLine) #define GrowingPolygon _lib_iv(GrowingPolygon) #define GrowingVertices _lib_iv(GrowingVertices) #define HBorder _lib_iv(HBorder) #define HBox _lib_iv(HBox) #define HGlue _lib_iv(HGlue) #define HRule _lib_iv(HRule) #define HScrollBar _lib_iv(HScrollBar) #define HScroller _lib_iv(HScroller) #define Handler _lib_iv(Handler) #define Hit _lib_iv(Hit) #define HitImpl _lib_iv(HitImpl) #define IconWindow _lib_iv(IconWindow) #define Image _lib_iv(Image) #define InputHandler _lib_iv(InputHandler) #define InputHandlerImpl _lib_iv(InputHandlerImpl) #define Interactor _lib_iv(Interactor) #define InteractorHandler _lib_iv(InteractorHandler) #define InteractorWindow _lib_iv(InteractorWindow) #define KnownFonts _lib_iv(KnownFonts) #define LRComposition _lib_iv(LRComposition) #define LRMarker _lib_iv(LRMarker) #define Label _lib_iv(Label) #define Layout _lib_iv(Layout) #define LayoutKit _lib_iv(LayoutKit) #define LeftMover _lib_iv(LeftMover) #define MFDialogKit _lib_iv(MFDialogKit) #define MFKit _lib_iv(MFKit) #define MFKitImpl _lib_iv(MFKitImpl) #define Macro _lib_iv(Macro) #define ManagedWindow _lib_iv(ManagedWindow) #define ManagedWindowHintInfo _lib_iv(ManagedWindowHintInfo) #define ManagedWindowRep _lib_iv(ManagedWindowRep) #define MarginFrame _lib_iv(MarginFrame) #define MarginLayout _lib_iv(MarginLayout) #define MatchEditor _lib_iv(MatchEditor) #define Menu _lib_iv(Menu) #define MenuBar _lib_iv(MenuBar) #define MenuImpl _lib_iv(MenuImpl) #define MenuItem _lib_iv(MenuItem) #define Message _lib_iv(Message) #define MonoGlyph _lib_iv(MonoGlyph) #define MonoScene _lib_iv(MonoScene) #define Mover _lib_iv(Mover) #define NaturalLayout _lib_iv(NaturalLayout) #define Observable _lib_iv(Observable) #define Observer _lib_iv(Observer) #define ObserverList _lib_iv(ObserverList) #define OptionDesc _lib_iv(OptionDesc) #define PSFont _lib_iv(PSFont) #define PSFontImpl _lib_iv(PSFontImpl) #define Page _lib_iv(Page) #define PageInfo_List _lib_iv(PageInfo_List) #define Painter _lib_iv(Painter) #define PainterRep _lib_iv(PainterRep) #define Panner _lib_iv(Panner) #define Patch _lib_iv(Patch) #define PathRenderInfo _lib_iv(PathRenderInfo) #define Pattern _lib_iv(Pattern) #define PatternRep _lib_iv(PatternRep) #define Perspective _lib_iv(Perspective) #define Placement _lib_iv(Placement) #define PolyGlyph _lib_iv(PolyGlyph) #define PolyGlyphImpl _lib_iv(PolyGlyphImpl) #define PopupMenu _lib_iv(PopupMenu) #define PopupWindow _lib_iv(PopupWindow) #define Printer _lib_iv(Printer) #define PrinterRep _lib_iv(PrinterRep) #define PropertyData _lib_iv(PropertyData) #define PulldownMenu _lib_iv(PulldownMenu) #define PullrightMenu _lib_iv(PullrightMenu) #define PushButton _lib_iv(PushButton) #define RGBTable _lib_iv(RGBTable) #define RadioButton _lib_iv(RadioButton) #define Raster _lib_iv(Raster) #define RasterRep _lib_iv(RasterRep) #define Reducer _lib_iv(Reducer) #define Regexp _lib_iv(Regexp) #define ReqErr _lib_iv(ReqErr) #define Requirement _lib_iv(Requirement) #define Requisition _lib_iv(Requisition) #define Resource _lib_iv(Resource) #define RightMover _lib_iv(RightMover) #define RotatingLine _lib_iv(RotatingLine) #define RotatingLineList _lib_iv(RotatingLineList) #define RotatingRect _lib_iv(RotatingRect) #define RubberAxis _lib_iv(RubberAxis) #define RubberCircle _lib_iv(RubberCircle) #define RubberClosedSpline _lib_iv(RubberClosedSpline) #define RubberEllipse _lib_iv(RubberEllipse) #define RubberGroup _lib_iv(RubberGroup) #define RubberHandles _lib_iv(RubberHandles) #define RubberLine _lib_iv(RubberLine) #define RubberList _lib_iv(RubberList) #define RubberPointList _lib_iv(RubberPointList) #define RubberRect _lib_iv(RubberRect) #define RubberSpline _lib_iv(RubberSpline) #define RubberSquare _lib_iv(RubberSquare) #define RubberVertex _lib_iv(RubberVertex) #define Rubberband _lib_iv(Rubberband) #define Rule _lib_iv(Rule) #define SMFKit _lib_iv(SMFKit) #define SMFKitImpl _lib_iv(SMFKitImpl) #define ScalingLine _lib_iv(ScalingLine) #define ScalingLineList _lib_iv(ScalingLineList) #define ScalingRect _lib_iv(ScalingRect) #define Scene _lib_iv(Scene) #define ScrollBar _lib_iv(ScrollBar) #define ScrollBox _lib_iv(ScrollBox) #define Scroller _lib_iv(Scroller) #define SelectionHandler _lib_iv(SelectionHandler) #define SelectionList _lib_iv(SelectionList) #define SelectionManager _lib_iv(SelectionManager) #define SelectionManagerRep _lib_iv(SelectionManagerRep) #define Sensor _lib_iv(Sensor) #define Session _lib_iv(Session) #define SessionRep _lib_iv(SessionRep) #define Shadow _lib_iv(Shadow) #define ShadowFrame _lib_iv(ShadowFrame) #define Shape _lib_iv(Shape) #define ShowFrame _lib_iv(ShowFrame) #define SimpleCompositor _lib_iv(SimpleCompositor) #define Slider _lib_iv(Slider) #define SliderImpl _lib_iv(SliderImpl) #define SlidingEllipse _lib_iv(SlidingEllipse) #define SlidingLine _lib_iv(SlidingLine) #define SlidingLineList _lib_iv(SlidingLineList) #define SlidingPointList _lib_iv(SlidingPointList) #define SlidingRect _lib_iv(SlidingRect) #define Stencil _lib_iv(Stencil) #define Stepper _lib_iv(Stepper) #define StepperSubclassName _lib_iv(StepperSubclassName) #define StretchingRect _lib_iv(StretchingRect) #define StringBrowser _lib_iv(StringBrowser) #define StringChooser _lib_iv(StringChooser) #define StringEditor _lib_iv(StringEditor) #define Style _lib_iv(Style) #define StyleRep _lib_iv(StyleRep) #define Subject _lib_iv(Subject) #define SubjectRep _lib_iv(SubjectRep) #define Superpose _lib_iv(Superpose) #define TBComposition _lib_iv(TBComposition) #define TBScrollBox _lib_iv(TBScrollBox) #define TBScrollBoxImpl _lib_iv(TBScrollBoxImpl) #define TGlue _lib_iv(TGlue) #define TIFFRaster _lib_iv(TIFFRaster) #define TSolver _lib_iv(TSolver) #define Target _lib_iv(Target) #define TeXCompositor _lib_iv(TeXCompositor) #define Telltale _lib_iv(Telltale) #define TelltaleGroup _lib_iv(TelltaleGroup) #define TelltaleState _lib_iv(TelltaleState) #define TextBuffer _lib_iv(TextBuffer) #define TextButton _lib_iv(TextButton) #define TextDisplay _lib_iv(TextDisplay) #define TextEditor _lib_iv(TextEditor) #define TextRenderInfo _lib_iv(TextRenderInfo) #define Tile _lib_iv(Tile) #define TileFirstAligned _lib_iv(TileFirstAligned) #define TileReversed _lib_iv(TileReversed) #define TileReversedFirstAligned _lib_iv(TileReversedFirstAligned) #define TitleFrame _lib_iv(TitleFrame) #define TopLevelWindow _lib_iv(TopLevelWindow) #define TransformFitter _lib_iv(TransformFitter) #define TransformSetter _lib_iv(TransformSetter) #define Transformer _lib_iv(Transformer) #define TransformerStack _lib_iv(TransformerStack) #define TransientWindow _lib_iv(TransientWindow) #define Tray _lib_iv(Tray) #define TrayElement _lib_iv(TrayElement) #define UpMover _lib_iv(UpMover) #define VBorder _lib_iv(VBorder) #define VBox _lib_iv(VBox) #define VGlue _lib_iv(VGlue) #define VRule _lib_iv(VRule) #define VScrollBar _lib_iv(VScrollBar) #define VScroller _lib_iv(VScroller) #define VariableLayout _lib_iv(VariableLayout) #define ViewList _lib_iv(ViewList) #define Viewport _lib_iv(Viewport) #define WidgetKit _lib_iv(WidgetKit) #define WidgetKitImpl _lib_iv(WidgetKitImpl) #define Window _lib_iv(Window) #define WindowRep _lib_iv(WindowRep) #define WindowTable _lib_iv(WindowTable) #define WindowVisual _lib_iv(WindowVisual) #define World _lib_iv(World) #define XSlider _lib_iv(XSlider) #define XYMarker _lib_iv(XYMarker) #define XYSlider _lib_iv(XYSlider) #define YSlider _lib_iv(YSlider) #define Zoomer _lib_iv(Zoomer) ivtools-1.2.11a1/src/include/InterViews/_enter.h000066400000000000000000000025431214471147700214670ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv__current_h #define iv__current_h #ifdef iv__2_6_h #undef iv__2_6_h #ifndef MAKEDEPEND #include #endif #endif #endif ivtools-1.2.11a1/src/include/InterViews/_leave.h000066400000000000000000000026111214471147700214420ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifdef iv__current_h #if defined(iv2_6_compatible)&&!defined(iv2_6_incompatible) #undef iv__current_h #define iv__2_6_h #ifndef MAKEDEPEND #include #endif #endif #endif ivtools-1.2.11a1/src/include/InterViews/_names.h000066400000000000000000000053621214471147700214570ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Use current by default for ambiguous names. */ #undef Adjuster #undef Border #undef Box #undef Button #undef PushButton #undef RadioButton #undef Center #undef Coord #undef Deck #undef Dialog #undef FileBrowser #undef FileChooser #undef Glue #undef HGlue #undef VGlue #undef Menu #undef MenuBar #undef MenuItem #undef Mover #undef UpMover #undef DownMover #undef LeftMover #undef RightMover #undef Panner #undef Scroller #undef HScroller #undef VScroller #undef ScrollBar #undef HScrollBar #undef VScrollBar #undef Slider #define Adjuster _lib_iv(Adjuster) #define Border _lib_iv(Border) #define Box _lib_iv(Box) #define Button _lib_iv(Button) #define PushButton _lib_iv(PushButton) #define RadioButton _lib_iv(RadioButton) #define Center _lib_iv(Center) #define Coord _lib_iv(Coord) #define Deck _lib_iv(Deck) #define Dialog _lib_iv(Dialog) #define FileBrowser _lib_iv(FileBrowser) #define FileChooser _lib_iv(FileChooser) #define Glue _lib_iv(Glue) #define HGlue _lib_iv(HGlue) #define VGlue _lib_iv(VGlue) #define Menu _lib_iv(Menu) #define MenuBar _lib_iv(MenuBar) #define MenuItem _lib_iv(MenuItem) #define Mover _lib_iv(Mover) #define UpMover _lib_iv(UpMover) #define DownMover _lib_iv(DownMover) #define LeftMover _lib_iv(LeftMover) #define RightMover _lib_iv(RightMover) #define Panner _lib_iv(Panner) #define Scroller _lib_iv(Scroller) #define HScroller _lib_iv(HScroller) #define VScroller _lib_iv(VScroller) #define ScrollBar _lib_iv(ScrollBar) #define HScrollBar _lib_iv(HScrollBar) #define VScrollBar _lib_iv(VScrollBar) #define Slider _lib_iv(Slider) ivtools-1.2.11a1/src/include/InterViews/_undefs.h000066400000000000000000000125631214471147700216410ustar00rootroot00000000000000#undef Alignment #undef ColorIntensity #undef ColorOp #undef Coord #undef EventType #undef EventButton #undef GlyphBreakType #undef GlyphIndex #undef IntCoord #undef PixelCoord #undef Selection #undef Action #undef ActiveHandler #undef Adjustable #undef Adjuster #undef Aggregate #undef AggregateInfo_List #undef Align #undef Allocation #undef AllocationInfo #undef AllocationTable #undef AllocationTableImpl #undef Allotment #undef ApplicationWindow #undef ArrayCompositor #undef ArrowSubclassName #undef Background #undef Banner #undef Bevel #undef BevelFrame #undef Bitmap #undef BitmapRep #undef Border #undef BorderFrame #undef Box #undef BoxCanonical #undef BoxElement #undef BoxImpl #undef Break #undef Break_List #undef Browser #undef BrowserList #undef Brush #undef BrushImpl #undef BrushRep #undef Button #undef ButtonList #undef ButtonState #undef Canvas #undef CanvasDamage #undef CanvasRep #undef Card #undef CenterLayout #undef Character #undef CheckBox #undef ChoiceItem #undef ClippingStack #undef Color #undef ColorImpl #undef ColorRep #undef ColorTable #undef CompletionEditor #undef Composition #undef CompositionComponent_List #undef Compositor #undef Control #undef ControlState #undef Cursor #undef CursorRep #undef CursorRepBitmap #undef CursorRepData #undef CursorRepFont #undef CursorRepXFont #undef DamageList #undef DebugGlyph #undef Deck #undef Dialog #undef DialogKit #undef Display #undef DisplayRep #undef DownMover #undef Enlarger #undef Event #undef EventRep #undef Extension #undef FBDirectory #undef FieldEditor #undef FieldEditorAction #undef FieldEditorImpl #undef FileBrowser #undef FileBrowserImpl #undef FileChooser #undef FileChooserAction #undef FileChooserImpl #undef FixedLayout #undef Font #undef FontBoundingBox #undef FontFamily #undef FontFamilyImpl #undef FontFamilyRep #undef FontImpl #undef FontRep #undef Frame #undef GLContext #undef GLContextImpl #undef GLWindow #undef Glue #undef Glyph #undef GrabList #undef Group #undef GrowingBSpline #undef GrowingClosedBSpline #undef GrowingMultiLine #undef GrowingPolygon #undef GrowingVertices #undef HBorder #undef HBox #undef HGlue #undef HRule #undef HScrollBar #undef HScroller #undef Handler #undef Hit #undef HitImpl #undef IconWindow #undef Image #undef InputHandler #undef InputHandlerImpl #undef Interactor #undef InteractorHandler #undef InteractorWindow #undef KnownFonts #undef LRComposition #undef LRMarker #undef Label #undef Layout #undef LayoutKit #undef LeftMover #undef MFDialogKit #undef MFKit #undef MFKitImpl #undef Macro #undef ManagedWindow #undef ManagedWindowHintInfo #undef ManagedWindowRep #undef MarginFrame #undef MarginLayout #undef MatchEditor #undef Menu #undef MenuBar #undef MenuImpl #undef MenuItem #undef Message #undef MonoGlyph #undef MonoScene #undef Mover #undef NaturalLayout #undef Observable #undef Observer #undef ObserverList #undef OptionDesc #undef PSFont #undef PSFontImpl #undef Page #undef PageInfo_List #undef Painter #undef PainterRep #undef Panner #undef Patch #undef PathRenderInfo #undef Pattern #undef PatternRep #undef Perspective #undef Placement #undef PolyGlyph #undef PolyGlyphImpl #undef PopupMenu #undef PopupWindow #undef Printer #undef PrinterRep #undef PropertyData #undef PulldownMenu #undef PullrightMenu #undef PushButton #undef RGBTable #undef RadioButton #undef Raster #undef RasterRep #undef Reducer #undef Regexp #undef ReqErr #undef Requirement #undef Requisition #undef Resource #undef RightMover #undef RotatingLine #undef RotatingLineList #undef RotatingRect #undef RubberAxis #undef RubberCircle #undef RubberClosedSpline #undef RubberEllipse #undef RubberGroup #undef RubberHandles #undef RubberLine #undef RubberList #undef RubberPointList #undef RubberRect #undef RubberSpline #undef RubberSquare #undef RubberVertex #undef Rubberband #undef Rule #undef SMFKit #undef SMFKitImpl #undef ScalingLine #undef ScalingLineList #undef ScalingRect #undef Scene #undef ScrollBar #undef ScrollBox #undef Scroller #undef SelectionHandler #undef SelectionList #undef SelectionManager #undef SelectionManagerRep #undef Sensor #undef Session #undef SessionRep #undef Shadow #undef ShadowFrame #undef Shape #undef ShowFrame #undef SimpleCompositor #undef Slider #undef SliderImpl #undef SlidingEllipse #undef SlidingLine #undef SlidingLineList #undef SlidingPointList #undef SlidingRect #undef Stencil #undef Stepper #undef StepperSubclassName #undef StretchingRect #undef StringBrowser #undef StringChooser #undef StringEditor #undef Style #undef StyleRep #undef Subject #undef SubjectRep #undef Superpose #undef TBComposition #undef TBScrollBox #undef TBScrollBoxImpl #undef TGlue #undef TIFFRaster #undef TSolver #undef Target #undef TeXCompositor #undef Telltale #undef TelltaleGroup #undef TelltaleState #undef TextBuffer #undef TextButton #undef TextDisplay #undef TextEditor #undef TextRenderInfo #undef Tile #undef TileFirstAligned #undef TileReversed #undef TileReversedFirstAligned #undef TitleFrame #undef TopLevelWindow #undef TransformFitter #undef TransformSetter #undef Transformer #undef TransformerStack #undef TransientWindow #undef Tray #undef TrayElement #undef UpMover #undef VBorder #undef VBox #undef VGlue #undef VRule #undef VScrollBar #undef VScroller #undef VariableLayout #undef ViewList #undef Viewport #undef WidgetKit #undef WidgetKitImpl #undef Window #undef WindowRep #undef WindowTable #undef WindowVisual #undef World #undef XSlider #undef XYMarker #undef XYSlider #undef YSlider #undef Zoomer ivtools-1.2.11a1/src/include/InterViews/action.h000066400000000000000000000060751214471147700214740ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Action - something to do */ #ifndef iv_action_h #define iv_action_h #include #include class Action : public Resource { protected: Action(); virtual ~Action(); public: virtual void execute() = 0; }; /* * Macro - list of actions */ typedef long MacroIndex; class MacroActionList; class Macro : public Action { public: Macro(Action* = nil, Action* = nil, Action* = nil, Action* = nil); virtual ~Macro(); virtual void prepend(Action*); virtual void append(Action*); virtual void insert(MacroIndex, Action*); virtual void remove(MacroIndex); virtual MacroIndex count() const; virtual Action* action(MacroIndex) const; virtual void execute(); private: MacroActionList* list_; }; /* * Action denoted by an object and member function to call on the object. */ #if defined(__STDC__) || defined(__ANSI_CPP__) #define __ActionCallback(T) T##_ActionCallback #define ActionCallback(T) __ActionCallback(T) #define __ActionMemberFunction(T) T##_ActionMemberFunction #define ActionMemberFunction(T) __ActionMemberFunction(T) #else #define __ActionCallback(T) T/**/_ActionCallback #define ActionCallback(T) __ActionCallback(T) #define __ActionMemberFunction(T) T/**/_ActionMemberFunction #define ActionMemberFunction(T) __ActionMemberFunction(T) #endif #define declareActionCallback(T) \ typedef void (T::*ActionMemberFunction(T))(); \ class ActionCallback(T) : public Action { \ public: \ ActionCallback(T)(T*, ActionMemberFunction(T)); \ \ virtual void execute(); \ private: \ T* obj_; \ ActionMemberFunction(T) func_; \ }; #define implementActionCallback(T) \ ActionCallback(T)::ActionCallback(T)(T* obj, ActionMemberFunction(T) func) { \ obj_ = obj; \ func_ = func; \ } \ \ void ActionCallback(T)::execute() { (obj_->*func_)(); } #include #endif ivtools-1.2.11a1/src/include/InterViews/adjust.h000066400000000000000000000057111214471147700215050ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Adjustable - object to scroll and/or zoom */ #ifndef iv_adjust_h #define iv_adjust_h #include #include class Observable; class Observer; struct AdjustableImpl; //: handles request to modify its viewing editor. // in reference manual. class Adjustable { public: Adjustable(); virtual ~Adjustable(); virtual Observable* observable(DimensionName) const; virtual void attach(DimensionName, Observer*); virtual void detach(DimensionName, Observer*); virtual Coord lower(DimensionName) const; virtual Coord upper(DimensionName) const; virtual Coord length(DimensionName) const; virtual Coord cur_lower(DimensionName) const; virtual Coord cur_upper(DimensionName) const; virtual Coord cur_length(DimensionName) const; virtual void small_scroll(DimensionName, Coord); virtual Coord small_scroll(DimensionName) const; virtual void large_scroll(DimensionName, Coord); virtual Coord large_scroll(DimensionName) const; virtual void begin_adjustment(DimensionName); virtual void commit_adjustment(DimensionName); virtual void abort_adjustment(DimensionName); virtual void scroll_forward(DimensionName); virtual void scroll_backward(DimensionName); virtual void page_forward(DimensionName); virtual void page_backward(DimensionName); virtual void scroll_to(DimensionName, Coord lower); virtual void scale_to(DimensionName, float fraction_visible); virtual void zoom_to(float magnification); virtual void constrain(DimensionName, Coord& lower) const; virtual void notify(DimensionName) const; virtual void notify_all() const; private: AdjustableImpl* impl_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/aggr.h000066400000000000000000000043661214471147700211400ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Aggregate - composite glyph */ #ifndef iv_aggr_h #define iv_aggr_h #include #include class AggregateInfo_List; class Aggregate : public Glyph { public: Aggregate(GlyphIndex size = 4); virtual ~Aggregate(); virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual void append(Glyph*); virtual void prepend(Glyph*); virtual void insert(GlyphIndex, Glyph*); virtual void remove(GlyphIndex); virtual void replace(GlyphIndex, Glyph*); virtual void change(GlyphIndex); virtual GlyphIndex count() const; virtual Glyph* component(GlyphIndex) const; virtual void allot(GlyphIndex, DimensionName, const Allotment&); virtual void allotment(GlyphIndex, DimensionName, Allotment&) const; private: AggregateInfo_List* info_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/align.h000066400000000000000000000033271214471147700213060ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Align - aligned layout */ #ifndef iv_align_h #define iv_align_h #include #include class Align : public Layout { public: Align(DimensionName); virtual ~Align(); virtual void request( GlyphIndex count, const Requisition*, Requisition& result ); virtual void allocate( const Allocation& given, GlyphIndex count, const Requisition*, Allocation* result ); private: DimensionName dimension_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/alloctbl.h000066400000000000000000000060331214471147700220050ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * AllocationTable - common information for pairs */ #ifndef iv_alloctbl_h #define iv_alloctbl_h #include #include class AllocationTable; class AllocationTableImpl; class AllocationInfo { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif Canvas* canvas() const; const Allocation& allocation() const; const Transformer& transformer() const; void extension(const Extension&); Extension& extension(); const Extension& extension() const; Allocation* component_allocations(); private: friend class AllocationTable; Canvas* canvas_; Transformer* transformer_; Allocation allocation_; Extension extension_; long num_components_; Allocation* component_allocation_; }; inline Canvas* AllocationInfo::canvas() const { return canvas_; } inline const Allocation& AllocationInfo::allocation() const { return allocation_; } inline const Transformer& AllocationInfo::transformer() const { return *transformer_; } inline void AllocationInfo::extension(const Extension& e) { extension_ = e; } inline Extension& AllocationInfo::extension() { return extension_; } inline const Extension& AllocationInfo::extension() const { return extension_; } inline Allocation* AllocationInfo::component_allocations() { return component_allocation_; } class AllocationTable { public: AllocationTable(GlyphIndex count = 1, long maximum_allocations = 5); virtual ~AllocationTable(); virtual AllocationInfo* find(Canvas*, const Allocation&) const; virtual AllocationInfo* find_same_size( Canvas*, const Allocation&, Coord& dx, Coord& dy ) const; virtual AllocationInfo* allocate(Canvas*, const Allocation&); virtual AllocationInfo* most_recent() const; virtual void flush(); private: AllocationTableImpl* impl_; }; #endif ivtools-1.2.11a1/src/include/InterViews/arraycomp.h000066400000000000000000000034661214471147700222150ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * ArrayCompositor */ #ifndef iv_arraycomp_h #define iv_arraycomp_h #include #include class ArrayCompositor : public Compositor { public: ArrayCompositor(CompositorIndex count); virtual ~ArrayCompositor(); virtual CompositorIndex compose( Coord* natural, Coord* stretch, Coord* shrink, int* penalites, CompositorIndex component_count, Coord* spans, CompositorIndex span_count, CompositorIndex* breaks, CompositorIndex break_count ); private: CompositorIndex count_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/background.h000066400000000000000000000033541214471147700223330ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Background - opaque glyph */ #ifndef iv_background_h #define iv_background_h #include #include class Color; class Background : public MonoGlyph { public: Background(Glyph* body, const Color*); virtual ~Background(); virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; private: const Color* color_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/bitmap.h000066400000000000000000000062741214471147700214740ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Bitmap - a two-dimensional boolean mask */ #ifndef iv_bitmap_h #define iv_bitmap_h #include #include #include class BitmapRep; class Font; class Transformer; //: binary raster data object. // in reference manual class Bitmap : public Resource { public: Bitmap( const void*, unsigned int width, unsigned int height, int x0 = -1, int y0 = -1 ); Bitmap(const Font*, long character, float scale = 1.0); Bitmap(const Bitmap&); virtual ~Bitmap(); static Bitmap* open(const char* filename); virtual void poke(boolean set, int x, int y); virtual boolean peek(int x, int y) const; virtual Coord width() const; virtual Coord height() const; virtual unsigned int pwidth() const; virtual unsigned int pheight() const; virtual Coord left_bearing() const; virtual Coord right_bearing() const; virtual Coord ascent() const; virtual Coord descent() const; virtual void flush() const; BitmapRep* rep() const; protected: Bitmap(); private: BitmapRep* rep_; public: /* anachronisms */ int Left() const; int Right() const; int Top() const; int Bottom() const; unsigned int Width() const; unsigned int Height() const; void Transform(const Transformer*); void Scale(float sx, float sy); void Rotate(float angle); void FlipHorizontal(); void FlipVertical(); void Rotate90(); void Rotate180(); void Rotate270(); void Invert(); boolean Peek(int x, int y) const; void Poke(boolean, int x, int y); }; inline BitmapRep* Bitmap::rep() const { return rep_; } inline unsigned int Bitmap::Width() const { return pwidth(); } inline unsigned int Bitmap::Height() const { return pheight(); } inline boolean Bitmap::Peek(int x, int y) const { return peek(x, y); } inline void Bitmap::Poke(boolean bit, int x, int y) { poke(bit, x, y); } #include #endif ivtools-1.2.11a1/src/include/InterViews/boolean.h000066400000000000000000000001021214471147700216170ustar00rootroot00000000000000/* backward compatibility */ #include ivtools-1.2.11a1/src/include/InterViews/border.h000066400000000000000000000033611214471147700214670ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Border - a glyph for framing */ #ifndef ivlook_border_h #define ivlook_border_h #include class Color; class Border : public MonoGlyph { public: Border(Glyph* body, const Color*); Border(Glyph* body, const Color*, Coord thickness); virtual ~Border(); virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; private: const Color* color_; Coord thickness_; }; #endif ivtools-1.2.11a1/src/include/InterViews/box.h000066400000000000000000000043471214471147700210070ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Box - tiling glyph */ #ifndef iv_box_h #define iv_box_h #include #include class BoxImpl; class Layout; //: box glyph base class // in reference manual class Box : public PolyGlyph { public: Box(Layout* layout, GlyphIndex size); Box( Layout* layout, Glyph* =nil, Glyph* =nil, Glyph* =nil, Glyph* =nil, Glyph* =nil, Glyph* =nil, Glyph* =nil, Glyph* =nil, Glyph* =nil, Glyph* =nil ); virtual ~Box(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual void undraw(); virtual void modified(GlyphIndex); virtual void allotment(GlyphIndex, DimensionName, Allotment&) const; private: BoxImpl* impl_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/brush.h000066400000000000000000000042621214471147700213360ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * A brush specifies how lines should be drawn. */ #ifndef iv_brush_h #define iv_brush_h #include #include #include class BrushRep; class BrushImpl; class Display; //: a brush style object // defines the line thickness and line style for drawing operations. //

    in reference manual. class Brush : public Resource { public: Brush(Coord width); Brush(int pattern, Coord width); Brush(const int* pattern, int count, Coord width); virtual ~Brush(); virtual Coord width() const; virtual int dash_count() const; virtual int dash_list(int index) const; boolean dashed(); BrushRep* rep(Display*) const; protected: void calc_dashes(int pat, int* dash, int& count); private: BrushImpl* impl_; void init(const int*, int, Coord); /* anachronisms */ public: unsigned int Width() const; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/canvas.h000066400000000000000000000104771214471147700214730ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Canvas - an area for drawing */ #ifndef iv_canvas_h #define iv_canvas_h #include #include class Bitmap; class Brush; class CanvasRep; class Color; class Extension; class Font; class Raster; class Transformer; class Window; /* anachronism */ typedef unsigned int CanvasLocation; //: 2d area for drawing. // in reference manual class Canvas { public: Canvas(); virtual ~Canvas(); virtual Window* window() const; virtual void size(Coord width, Coord height); virtual void psize(PixelCoord width, PixelCoord height); virtual Coord width() const; virtual Coord height() const; virtual PixelCoord pwidth() const; virtual PixelCoord pheight() const; virtual PixelCoord to_pixels(Coord) const; virtual Coord to_coord(PixelCoord) const; virtual Coord to_pixels_coord(Coord) const; virtual void new_path(); virtual void move_to(Coord x, Coord y); virtual void line_to(Coord x, Coord y); virtual void curve_to( Coord x, Coord y, Coord x1, Coord y1, Coord x2, Coord y2 ); virtual void close_path(); virtual void stroke(const Color*, const Brush*); virtual void line( Coord x1, Coord y1, Coord x2, Coord y2, const Color*, const Brush* ); virtual void rect( Coord l, Coord b, Coord r, Coord t, const Color*, const Brush* ); virtual void fill(const Color*); virtual void fill_rect(Coord l, Coord b, Coord r, Coord t, const Color*); virtual void character( const Font*, long ch, Coord width, const Color*, Coord x, Coord y ); virtual void stencil(const Bitmap*, const Color*, Coord x, Coord y); virtual void image(const Raster*, Coord x, Coord y); virtual void push_transform(); virtual void transform(const Transformer&); virtual void pop_transform(); virtual void transformer(const Transformer&); virtual const Transformer& transformer() const; virtual void push_clipping(); virtual void clip(); virtual void clip_rect(Coord l, Coord b, Coord r, Coord t); virtual void pop_clipping(); virtual void front_buffer(); virtual void back_buffer(); virtual void damage(const Extension&); virtual void damage(Coord left, Coord bottom, Coord right, Coord top); virtual boolean damaged(const Extension&) const; virtual boolean damaged( Coord left, Coord bottom, Coord right, Coord top ) const; virtual void damage_area(Extension&); virtual void damage_all(); virtual boolean any_damage() const; virtual void restrict_damage(const Extension&); virtual void restrict_damage( Coord left, Coord bottom, Coord right, Coord top ); virtual void redraw(Coord left, Coord bottom, Coord right, Coord top); virtual void repair(); CanvasRep* rep() const; private: CanvasRep* rep_; /* anachronisms */ public: enum { mapped, unmapped, offscreen }; virtual CanvasLocation status() const; unsigned int Width() const; unsigned int Height() const; virtual void SetBackground(const Color*); }; inline CanvasRep* Canvas::rep() const { return rep_; } #include #endif ivtools-1.2.11a1/src/include/InterViews/character.h000066400000000000000000000037211214471147700221460ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Character - a character glyph with font */ #ifndef iv_character_h #define iv_character_h #include class Color; class Font; class Character : public Glyph { public: Character(long c, const Font*, const Color*); virtual ~Character(); virtual long code() const; virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); private: long c_; const Font* font_; const Color* color_; Coord left_bearing_; Coord right_bearing_; Coord ascent_; Coord descent_; Coord width_; Coord height_; float alignment_; }; #endif ivtools-1.2.11a1/src/include/InterViews/color.h000066400000000000000000000062731214471147700213350ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_color_h #define iv_color_h #include #include class ColorImpl; class ColorRep; class Display; class String; class WindowVisual; typedef float ColorIntensity; typedef unsigned int ColorOp; //: an RGB-alpha color object // defines an output color, which is specified by a mix of RGB (red, // green, and blue) intensities, and an alpha value for blending //

    in reference manual. class Color : public Resource { public: enum { Copy, Xor, Invisible }; Color( ColorIntensity r, ColorIntensity g, ColorIntensity b, float alpha = 1.0, ColorOp = Copy ); Color(const Color&, float alpha = 1.0, ColorOp = Copy); virtual ~Color(); static boolean find( const Display*, const String&, ColorIntensity& r, ColorIntensity& g, ColorIntensity& b ); static boolean find( const Display*, const char* name, ColorIntensity& r, ColorIntensity& g, ColorIntensity& b ); static const Color* lookup(Display*, const String& name); static const Color* lookup(Display*, const char* name); virtual boolean distinguished(Display*, const Color*) const; virtual void intensities( Display*, ColorIntensity& r, ColorIntensity& g, ColorIntensity& b ) const; virtual float alpha() const; virtual ColorOp op() const; virtual const Color* brightness(float adjust) const; /* use default display */ boolean distinguished(const Color*) const; void intensities( ColorIntensity& r, ColorIntensity& g, ColorIntensity& b ) const; ColorRep* rep(WindowVisual*) const; private: ColorImpl* impl_; void remove(WindowVisual*) const; ColorRep* create( WindowVisual*, ColorIntensity, ColorIntensity, ColorIntensity, float, ColorOp ) const; void destroy(ColorRep*); /* anachronisms */ public: Color(int r, int g, int b); void Intensities(int& r, int& g, int& b) const; int PixelValue() const; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/composition.h000066400000000000000000000072561214471147700225640ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_composition_h #define iv_composition_h #include class CompositionComponent_List; class Break_List; class Compositor; class Break; class Composition : public MonoGlyph { protected: Composition( Glyph* context, Compositor*, Glyph* separator, DimensionName, Coord span, Coord stretch, Coord shrink, GlyphIndex size ); public: virtual ~Composition(); virtual void allocate(Canvas*, const Allocation&, Extension&); virtual boolean repair(); virtual GlyphIndex item(GlyphIndex index) const; virtual GlyphIndex beginning_of(GlyphIndex item) const; virtual GlyphIndex end_of(GlyphIndex item) const; virtual void margin(GlyphIndex item, Coord begin, Coord end); virtual void view(GlyphIndex first, GlyphIndex last); virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual void append(Glyph*); virtual void prepend(Glyph*); virtual void insert(GlyphIndex, Glyph*); virtual void remove(GlyphIndex); virtual void replace(GlyphIndex, Glyph*); virtual void change(GlyphIndex); virtual GlyphIndex count() const; virtual Glyph* component(GlyphIndex) const; virtual void allotment(GlyphIndex, DimensionName, Allotment&) const; protected: virtual void do_repair( GlyphIndex first_component, GlyphIndex first_break, GlyphIndex* breaks, GlyphIndex break_count ); virtual void damage(GlyphIndex first, GlyphIndex last); virtual Glyph* separator(Break&); virtual Glyph* make_item(Break&, boolean created); virtual Glyph* make(Break&); private: Compositor* compositor_; CompositionComponent_List* component_; Break_List* breaks_; Glyph* separator_; boolean view_all_; boolean damaged_; GlyphIndex first_damage_; GlyphIndex last_damage_; GlyphIndex item_; DimensionName dimension_; Coord span_; boolean resizable_; }; class LRComposition : public Composition { public: LRComposition( Glyph* context, Compositor*, Glyph* separator, Coord width, Coord stretch = fil, Coord shrink = fil, GlyphIndex size = 10 ); virtual ~LRComposition(); protected: virtual Glyph* make(Break&); }; class TBComposition : public Composition { public: TBComposition( Glyph* context, Compositor*, Glyph* separator, Coord height, Coord stretch = fil, Coord shrink = fil, GlyphIndex size = 10 ); virtual ~TBComposition(); protected: virtual Glyph* make(Break&); }; #endif ivtools-1.2.11a1/src/include/InterViews/compositor.h000066400000000000000000000035571214471147700224170ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Compositor - find breaks */ #ifndef iv_compositor_h #define iv_compositor_h #include #include #include static const int PenaltyBad = 10000; static const int PenaltyGood = -10000; typedef long CompositorIndex; class Compositor { public: Compositor(); virtual ~Compositor(); virtual CompositorIndex compose( Coord* natural, Coord* stretch, Coord* shrink, int* penalites, CompositorIndex component_count, Coord* spans, CompositorIndex span_count, CompositorIndex* breaks, CompositorIndex break_count ); }; #include #endif ivtools-1.2.11a1/src/include/InterViews/coord.h000066400000000000000000000037611214471147700213240ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Coordinates for graphics allocation and rendering. */ #ifndef iv_coord_h #define iv_coord_h #include typedef float _lib_iv(Coord); typedef float _lib_iv(FloatCoord); typedef int _lib_iv(IntCoord); typedef int _lib_iv(PixelCoord); /* * Should be a static const float, but some compilers don't * do a very good job on that. */ #define fil 10e6 /* * Old definitions */ typedef int _lib_iv2_6(Coord); #ifndef PDP_PLUS_PLUS extern double inch, inches, cm, mm, point, points; static const int pixels = 1; #define ivinch inch #define ivinches inches #define ivcm cm #define ivmm mm #define ivpoint point #define ivpoints points #define ivpixels pixels #else extern double ivinch, ivinches, ivcm, ivmm, ivpoint, ivpoints; static const int ivpixels = 1; #endif #endif ivtools-1.2.11a1/src/include/InterViews/cursor.h000066400000000000000000000051521214471147700215270ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * An input cursor is defined by two 16x16 bitmaps, one that * specifies which pixels are to be drawn and one that specifies * which pixels are in foreground color and which in background color. * If a device does not support a mask the background pixels are not drawn. */ #ifndef iv_cursor_h #define iv_cursor_h #include static const int cursorHeight = 16; static const int cursorWidth = 16; typedef int CursorPattern[cursorHeight]; class Color; class CursorRep; class Bitmap; class Font; class Cursor { public: Cursor( short xoff, short yoff, /* hot spot */ const int* pat, const int* mask, const Color* fg = nil, const Color* bg = nil ); Cursor( const Bitmap* pat, const Bitmap* mask, const Color* fg = nil, const Color* bg = nil ); Cursor( const Font*, int pat, int mask, const Color* fg = nil, const Color* bg = nil ); Cursor(int, const Color* fg = nil, const Color* bg = nil); ~Cursor(); static void init(); CursorRep* rep(); private: CursorRep* rep_; }; inline CursorRep* Cursor::rep() { return rep_; } /* * Predefined cursors. */ extern Cursor* defaultCursor; extern Cursor* arrow; extern Cursor* crosshairs; extern Cursor* ltextCursor; extern Cursor* rtextCursor; extern Cursor* hourglass; extern Cursor* upperleft; extern Cursor* upperright; extern Cursor* lowerleft; extern Cursor* lowerright; extern Cursor* noCursor; #endif ivtools-1.2.11a1/src/include/InterViews/debug.h000066400000000000000000000060261214471147700213010ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * DebugGlyph -- trace glyph calls */ #ifndef iv_debug_h #define iv_debug_h #include #include class DebugGlyph : public MonoGlyph { public: enum { trace_none = 0x0, trace_request = 0x1, trace_allocate = 0x2, trace_draw = 0x4, trace_print = 0x8, trace_pick = 0x10, trace_undraw = 0x20, /* convenient shorthand */ trace_request_allocate = 0x3, trace_request_draw = 0x5, trace_allocate_draw = 0x6, trace_request_allocate_draw = 0x7, trace_request_pick = 0x11, trace_allocate_pick = 0x12, trace_request_allocate_pick = 0x13, trace_draw_pick = 0x14, trace_request_draw_pick = 0x15, trace_request_undraw = 0x21, trace_allocate_undraw = 0x22, trace_request_allocate_undraw = 0x23, trace_draw_undraw = 0x24, trace_request_draw_undraw = 0x25, trace_allocate_draw_undraw = 0x26, trace_request_allocate_draw_undraw = 0x27, trace_pick_undraw = 0x30, trace_request_pick_undraw = 0x31, trace_allocate_pick_undraw = 0x32, trace_request_allocate_pick_undraw = 0x33, trace_draw_pick_undraw = 0x34, trace_request_draw_pick_undraw = 0x35, trace_allocate_draw_pick_undraw = 0x36, trace_request_allocate_draw_pick_undraw = 0x37, trace_all = 0x3f }; DebugGlyph(Glyph* g, const char* msg, unsigned int trace_flags); virtual ~DebugGlyph(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual void undraw(); static void print_requirement(const Requirement&); static void print_allotment(const Allotment&); private: const char* msg_; unsigned int flags_; void heading(const char*) const; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/deck.h000066400000000000000000000040341214471147700211160ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_deck_h #define iv_deck_h #include #include class Deck : public PolyGlyph { public: Deck(GlyphIndex size = 0); virtual ~Deck(); GlyphIndex card() const; void flip_to(GlyphIndex); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual void undraw(); virtual void modified(GlyphIndex); virtual void allotment(GlyphIndex, DimensionName, Allotment&) const; private: GlyphIndex card_; boolean changed_; Requisition requisition_; Allocation allocation_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/dialog.h000066400000000000000000000053451214471147700214550ustar00rootroot00000000000000/* * Copyright (c) 2000 IET Inc. * Copyright (c) 1992 Stanford University * Copyright (c) 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Dialog -- dialog box */ #ifndef iv_dialog_h #define iv_dialog_h #include #include class Window; class TransientWindow; /* * The post*_aligned operations replaced default parameters * due to an apparent bug in cfront 3.0. */ class Dialog : public InputHandler { public: Dialog(Glyph*, Style*); virtual ~Dialog(); boolean post_for(Window*); virtual boolean post_for_aligned(Window*, float xalign, float yalign); boolean post_at(Coord x, Coord y); virtual boolean post_at_aligned( Coord x, Coord y, float xalign, float yalign ); void map_for(Window*); virtual void map_for_aligned(Window*, float xalign, float yalign); void map_at(Coord x, Coord y); virtual void map_at_aligned( Coord x, Coord y, float xalign, float yalign ); void unmap(); boolean mapped(); virtual boolean run(); virtual void dismiss(boolean accept); boolean accepted() { return accepted_; } boolean unmap_for_dismiss() { return unmap_for_dismiss_; } private: boolean done_; boolean accepted_; boolean unmap_for_dismiss_; TransientWindow* t_; }; inline boolean Dialog::post_for(Window* w) { return post_for_aligned(w, 0.5, 0.5); } inline boolean Dialog::post_at(Coord x, Coord y) { return post_at_aligned(x, y, 0.5, 0.5); } inline void Dialog::map_for(Window* w) { map_for_aligned(w, 0.5, 0.5); } inline void Dialog::map_at(Coord x, Coord y) { map_at_aligned(x, y, 0.5, 0.5); } #include #endif ivtools-1.2.11a1/src/include/InterViews/display.h000066400000000000000000000067351214471147700216670ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Display -- workstation screen(s) and input devices */ #ifndef iv_display_h #define iv_display_h #include #include class Event; class DisplayRep; class Handler; class SelectionManager; class String; class Style; class Window; //: X window display object. // in reference manual. class Display { public: Display(DisplayRep*); static Display* open(const String&); static Display* open(const char*); static Display* open(); virtual void close(); virtual ~Display(); virtual int fd() const; virtual Coord width() const; virtual Coord height() const; virtual PixelCoord pwidth() const; virtual PixelCoord pheight() const; virtual Coord a_width() const; virtual Coord a_height() const; PixelCoord to_pixels(Coord) const; Coord to_coord(PixelCoord) const; virtual boolean defaults(String&) const; virtual void style(Style*); virtual Style* style() const; virtual void set_screen(int); virtual void repair(); virtual void flush(); virtual void sync(); virtual boolean get(Event&); virtual void put(const Event&); virtual boolean closed(); virtual void grab(Window*, Handler*); virtual void ungrab(Handler*, boolean all = false); virtual Handler* grabber() const; virtual boolean is_grabbing(Handler*) const; virtual void ring_bell(int); virtual void set_key_click(int); virtual void set_auto_repeat(boolean); virtual void set_pointer_feedback(int thresh, int scale); virtual void move_pointer(Coord x, Coord y); virtual SelectionManager* primary_selection(); virtual SelectionManager* secondary_selection(); virtual SelectionManager* clipboard_selection(); virtual SelectionManager* find_selection(const char*); virtual SelectionManager* find_selection(const String&); DisplayRep* rep() const; private: DisplayRep* rep_; Coord pixel_; Coord point_; }; inline PixelCoord Display::to_pixels(Coord c) const { return PixelCoord( c * point_ + ((c > 0) ? 0.5 : -0.5) ); } inline Coord Display::to_coord(PixelCoord p) const { return Coord(p)*pixel_; } inline DisplayRep* Display::rep() const { return rep_; } #include #endif ivtools-1.2.11a1/src/include/InterViews/drag.h000066400000000000000000000110011214471147700211150ustar00rootroot00000000000000/* * Copyright (c) 1992 Redwood Design Automation * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the name of * Redwood Design Automation may not be used in any advertising or publicity * relating to the software without the specific, prior written permission of * Redwood Design Automation. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL REDWOOD DESIGN AUTOMATION BE LIABLE FOR ANY SPECIAL, * INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #ifndef iv_drag_h #define iv_drag_h #include #include class Allocation; class Canvas; class Cursor; class DragRep; class DragZoneRep; class DragZoneSinkHandler; class Event; class Hit; /* * To create a dragable glyph: * 1) create a derived class of Drag * 2) implement the member functions dragGlyph and/or dragCursor. dragGlyph * should return a glyph that will be dragged across the screen in a window. * dragCursor should return a cursor that will be dragged across the screen. * 3) implement the member function dragData. dragData should produce a * string to be sent to a drag zone * 4) the dragType member function can be implemented to provide a string * that is sent to a drag zone when the drag zone is entered * 5) caught, commit, and abort can be implemented to change the default * behavior. the default behavior is that a middle button press starts a * drag, a chorded button press aborts, and a button release commits a drag. * 6) dragOffset can be implemented to calculate a transformed offset from * the left-top corner of the dragGlyph. */ class Drag : public MonoGlyph { public: Drag(Glyph* glyph); virtual ~Drag(); virtual void dragable(boolean); virtual boolean dragable() const; virtual Glyph* dragGlyph() = 0; virtual Cursor* dragCursor() = 0; virtual void dragData(char*& value, int& length) = 0; virtual void dragType(char*& value, int& length); virtual void dragOffset(Event& event, int& dx, int& dy); virtual boolean caught(const Event&) const; virtual boolean commit(const Event&) const; virtual boolean abort(const Event&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void pick(Canvas*, const Allocation&, int depth, Hit&); protected: DragRep* rep() const; private: DragRep* rep_; }; /* * To create a drag zone glyph: * 1) create a derived class of DragZone * 2) implement the member function drop. drop will be called when a drag * glyph is dropped in a DragZone glyph. * 3) enter, motion, and leave can be implemented to indicate when a drop * would be sent to a drag zone. */ class DragZone : public MonoGlyph { public: DragZone(Glyph*); virtual ~DragZone(); virtual void sensitive(boolean); virtual boolean sensitive() const; virtual void enter(Event&, const char* type, int length); virtual void motion(Event&); virtual void leave(Event&); virtual void drop(Event&, const char* data, int length) = 0; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void pick(Canvas*, const Allocation&, int depth, Hit&); protected: DragZoneRep* rep() const; private: DragZoneRep* rep_; }; /* * A drag zone sink publishes that a window can accept drag messages. It * also consumes any drag messages that do not fall in a drag zone. This * class could be eliminated and the code moved to xwindow.c. */ class DragZoneSink : public DragZone { public: DragZoneSink(Glyph*); virtual ~DragZoneSink(); virtual void drop(Event&, const char* data, int length); virtual void draw(Canvas*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual boolean event(Event& event); private: boolean dragPublished_; DragZoneSinkHandler* target_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/enter-scope.h000066400000000000000000000033701214471147700224360ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv__scope_h #define iv__scope_h #include #ifndef MAKEDEPEND #include #include #if defined(iv2_6_compatible)&&!defined(iv2_6_incompatible) #include #endif #ifndef iv_os__scope_h /* * Use OS boolean and String definitions. */ #include #include #define String _lib_os(String) #define boolean _lib_os(boolean) #define true _lib_os(true) #define false _lib_os(false) #define u_char _lib_os(u_char) #endif #endif #endif ivtools-1.2.11a1/src/include/InterViews/event.h000066400000000000000000000121641214471147700213340ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Input events. */ #ifndef iv_event_h #define iv_event_h #include #include class Display; class Event; class EventRep; class Interactor; class Handler; class Window; class World; typedef unsigned int EventType; typedef unsigned int EventButton; typedef void (*event_tracker_ptr)(Event&); /* anachronism */ enum { MotionEvent, /* mouse moved */ DownEvent, /* button pressed */ UpEvent, /* button released */ KeyEvent, /* key pressed, intepreted as ascii */ EnterEvent, /* mouse enters canvas */ LeaveEvent, /* mouse leaves canvas */ FocusInEvent, /* focus for keyboard events */ FocusOutEvent /* lose keyboard focus */ }; /* mouse button anachronisms */ static const int LEFTMOUSE = 0; static const int MIDDLEMOUSE = 1; static const int RIGHTMOUSE = 2; //: user input events. // in reference manual. class Event { public: enum { undefined, motion, down, up, key, selection_notify, other_event }; enum { none, any, left, middle, right, other_button }; Event(); Event(const Event&); virtual ~Event(); virtual Event& operator =(const Event&); virtual void display(Display*); virtual Display* display() const; virtual void window(Window*); virtual Window* window() const; virtual boolean pending() const; virtual void read(); virtual boolean read(long sec, long usec); virtual void unread(); virtual void poll(); virtual Handler* handler() const; virtual void handle(); virtual void grab(Handler*) const; virtual void ungrab(Handler*) const; virtual Handler* grabber() const; virtual boolean is_grabbing(Handler*) const; virtual EventType type() const; virtual unsigned long time() const; virtual Coord pointer_x() const; virtual Coord pointer_y() const; virtual Coord pointer_root_x() const; virtual Coord pointer_root_y() const; virtual EventButton pointer_button() const; virtual unsigned int keymask() const; virtual boolean control_is_down() const; virtual boolean meta_is_down() const; virtual boolean shift_is_down() const; virtual boolean capslock_is_down() const; virtual boolean left_is_down() const; virtual boolean middle_is_down() const; virtual boolean right_is_down() const; virtual unsigned char keycode() const; virtual unsigned long keysym() const; virtual unsigned int mapkey(char*, unsigned int len) const; EventRep* rep() const; static event_tracker_ptr event_tracker() { return _event_tracker; } static void event_tracker(event_tracker_ptr ptr) { _event_tracker = ptr; } protected: static event_tracker_ptr _event_tracker; private: EventRep* rep_; char free_store_[200]; void copy_rep(const Event&); /* * Old members for backward compatibility */ public: Interactor* target; unsigned long timestamp; EventType eventType; IntCoord x, y; /* mouse position relative to target */ boolean control : 1; /* true if down */ boolean meta : 1; boolean shift : 1; boolean shiftlock : 1; boolean leftmouse : 1; boolean middlemouse : 1; boolean rightmouse : 1; unsigned char button; /* button pressed or released, if any */ unsigned short len; /* length of ASCII string */ char* keystring; /* ASCII interpretation of event, if any */ void GetAbsolute(IntCoord&, IntCoord&); void GetAbsolute(World*&, IntCoord&, IntCoord&); EventRep* Rep() const; private: World* w; _lib_iv2_6(Coord) wx, wy; char keydata[sizeof(int)]; friend class Interactor; void GetInfo(); void GetMotionInfo(); void GetButtonInfo(EventType); void GetKeyInfo(); void GetKeyState(unsigned); void GetCrossingInfo(EventType); }; inline EventRep* Event::rep() const { return rep_; } inline EventRep* Event::Rep() const { return rep(); } #include #endif ivtools-1.2.11a1/src/include/InterViews/font.h000066400000000000000000000107241214471147700211610ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * A font is essentially an array of similar stencils that can be * indexed by a code corresponding to a character in an alphabet. */ #ifndef iv_font_h #define iv_font_h #include #include #include class Display; class FontFamilyImpl; class FontFamilyRep; class FontImpl; class FontRep; class String; /* * FontFamily - manages related fonts */ class FontFamily { public: FontFamily(const char* familyname); virtual ~FontFamily(); virtual boolean font(int size, const char*& name, float& scale) const; virtual boolean font( int size, const char* style, const char*& name, float& scale ) const; FontFamilyRep* rep(Display*) const; private: FontFamilyImpl* impl_; FontFamilyRep* create(Display*) const; void destroy(FontFamilyRep*); }; class FontBoundingBox { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif Coord left_bearing() const; Coord right_bearing() const; Coord width() const; Coord ascent() const; Coord descent() const; Coord font_ascent() const; Coord font_descent() const; private: friend class Font; Coord left_bearing_; Coord right_bearing_; Coord width_; Coord ascent_; Coord descent_; Coord font_ascent_; Coord font_descent_; }; inline Coord FontBoundingBox::left_bearing() const { return left_bearing_; } inline Coord FontBoundingBox::right_bearing() const { return right_bearing_; } inline Coord FontBoundingBox::width() const { return width_; } inline Coord FontBoundingBox::ascent() const { return ascent_; } inline Coord FontBoundingBox::descent() const { return descent_; } inline Coord FontBoundingBox::font_ascent() const { return font_ascent_; } inline Coord FontBoundingBox::font_descent() const { return font_descent_; } //: a font object // defines a mapping between character codes and their appearance on the screen. //

    in reference manual class Font : public Resource { public: Font(const String&, float scale = 1.0); Font(const char*, float scale = 1.0); virtual ~Font(); virtual void cleanup(); static const Font* lookup(const String&); static const Font* lookup(const char*); static boolean exists(Display*, const String&); static boolean exists(Display*, const char*); virtual const char* name() const; virtual const char* encoding() const; virtual Coord size() const; virtual void font_bbox(FontBoundingBox&) const; virtual void char_bbox(long, FontBoundingBox&) const; virtual void string_bbox(const char*, int, FontBoundingBox&) const; virtual Coord width(long) const; virtual Coord width(const char*, int) const; virtual int index(const char*, int, float offset, boolean between) const; FontRep* rep(Display*) const; protected: Font(FontImpl*); private: friend class FontImpl; FontImpl* impl_; /* anachronisms */ public: int Baseline() const; boolean FixedWidth() const; int Height() const; int Index(const char*, int offset, boolean between) const; int Index(const char*, int, int offset, boolean between) const; int Width(const char*) const; int Width(const char*, int) const; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/geometry.h000066400000000000000000000212721214471147700220460ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_geometry_h #define iv_geometry_h #include #include /* * Can't make DimensionName an enum because we want to be able * to iterate from 0 to number_of_dimensions. Alas, * C++ does not allow arithmetic on enums. */ typedef unsigned int DimensionName; enum { Dimension_X = 0, Dimension_Y, Dimension_Z, Dimension_Undefined }; class CoordinateSpace { public: enum { x = 0, y, z, dimensions }; #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif }; class Requirement { public: Requirement(); Requirement(Coord natural); Requirement(Coord natural, Coord stretch, Coord shrink, float alignment); Requirement( Coord natural_lead, Coord max_lead, Coord min_lead, Coord natural_trail, Coord max_trail, Coord min_trail ); boolean equals(const Requirement&, float epsilon) const; boolean defined() const; void natural(Coord); Coord natural() const; void stretch(Coord); Coord stretch() const; void shrink(Coord); Coord shrink() const; void alignment(float); float alignment() const; private: Coord natural_; Coord stretch_; Coord shrink_; float alignment_; #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif }; class Requisition { public: Requisition(); Requisition(const Requisition&); void penalty(int); int penalty() const; boolean equals(const Requisition&, float epsilon) const; void require(DimensionName, const Requirement&); void require_x(const Requirement&); void require_y(const Requirement&); const Requirement& requirement(DimensionName) const; const Requirement& x_requirement() const; const Requirement& y_requirement() const; Requirement& requirement(DimensionName); Requirement& x_requirement(); Requirement& y_requirement(); private: int penalty_; Requirement x_; Requirement y_; #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif }; class Allotment { public: Allotment(); Allotment(Coord origin, Coord span, float alignment); boolean equals(const Allotment&, float epsilon) const; void origin(Coord); void offset(Coord); Coord origin() const; void span(Coord); Coord span() const; void alignment(float); float alignment() const; Coord begin() const; Coord end() const; private: Coord origin_; Coord span_; float alignment_; #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif }; //: actual size a glyph is given. // in reference manual. class Allocation { public: Allocation(); Allocation(const Allocation&); boolean equals(const Allocation&, float epsilon) const; void allot(DimensionName, const Allotment&); void allot_x(const Allotment&); void allot_y(const Allotment&); Allotment& allotment(DimensionName); const Allotment& allotment(DimensionName) const; Allotment& x_allotment(); Allotment& y_allotment(); const Allotment& x_allotment() const; const Allotment& y_allotment() const; Coord x() const; Coord y() const; Coord left() const; Coord right() const; Coord bottom() const; Coord top() const; private: Allotment x_; Allotment y_; #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif }; class Canvas; //: area where a glyph actually draws after all. // in reference manual. class Extension { public: Extension(); Extension(const Extension&); void operator =(const Extension&); static void transform_xy( Canvas*, Coord& left, Coord& bottom, Coord& right, Coord& top ); void set(Canvas*, const Allocation&); void set_xy(Canvas*, Coord left, Coord bottom, Coord right, Coord top); void clear(); void merge(const Extension&); void merge(Canvas*, const Allocation&); void merge_xy(Canvas*, Coord left, Coord bottom, Coord right, Coord top); Coord left() const; Coord bottom() const; Coord right() const; Coord top() const; private: Coord x_begin_; Coord x_end_; Coord y_begin_; Coord y_end_; #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif }; inline Requirement::Requirement() { natural_ = -fil; stretch_ = 0; shrink_ = 0; alignment_ = 0; } inline Requirement::Requirement(Coord natural) { natural_ = natural; stretch_ = 0; shrink_ = 0; alignment_ = 0; } inline Requirement::Requirement( Coord natural, Coord stretch, Coord shrink, float alignment ) { natural_ = natural; stretch_ = stretch; shrink_ = shrink; alignment_ = alignment; } inline boolean Requirement::defined() const { return natural_ != -fil; } inline void Requirement::natural(Coord c) { natural_ = c; } inline Coord Requirement::natural() const { return natural_; } inline void Requirement::stretch(Coord c) { stretch_ = c; } inline Coord Requirement::stretch() const { return stretch_; } inline void Requirement::shrink(Coord c) { shrink_ = c; } inline Coord Requirement::shrink() const { return shrink_; } inline void Requirement::alignment(float a) { alignment_ = a; } inline float Requirement::alignment() const { return alignment_; } inline int Requisition::penalty() const { return penalty_; } inline void Requisition::penalty(int penalty) { penalty_ = penalty; } inline void Requisition::require_x(const Requirement& r) { x_ = r; } inline void Requisition::require_y(const Requirement& r) { y_ = r; } inline const Requirement& Requisition::x_requirement() const { return x_; } inline const Requirement& Requisition::y_requirement() const { return y_; } inline Requirement& Requisition::x_requirement() { return x_; } inline Requirement& Requisition::y_requirement() { return y_; } inline Allotment::Allotment() { origin_ = 0; span_ = 0; alignment_ = 0; } inline Allotment::Allotment(Coord origin, Coord span, float alignment) { origin_ = origin; span_ = span; alignment_ = alignment; } inline void Allotment::origin(Coord o) { origin_ = o; } inline void Allotment::offset(Coord o) { origin_ += o; } inline Coord Allotment::origin() const { return origin_; } inline void Allotment::span(Coord c) { span_ = c; } inline Coord Allotment::span() const { return span_; } inline void Allotment::alignment(float a) { alignment_ = a; } inline float Allotment::alignment() const { return alignment_; } inline Coord Allotment::begin() const { return origin_ - Coord(alignment_ * span_); } inline Coord Allotment::end() const { return origin_ - Coord(alignment_ * span_) + span_; } inline void Allocation::allot_x(const Allotment& a) { x_ = a; } inline void Allocation::allot_y(const Allotment& a) { y_ = a; } inline Allotment& Allocation::x_allotment() { return x_; } inline Allotment& Allocation::y_allotment() { return y_; } inline const Allotment& Allocation::x_allotment() const { return x_; } inline const Allotment& Allocation::y_allotment() const { return y_; } inline Coord Allocation::x() const { return x_.origin(); } inline Coord Allocation::y() const { return y_.origin(); } inline Coord Allocation::left() const { return x_.begin(); } inline Coord Allocation::right() const { return x_.end(); } inline Coord Allocation::bottom() const { return y_.begin(); } inline Coord Allocation::top() const { return y_.end(); } inline Coord Extension::left() const { return x_begin_; } inline Coord Extension::bottom() const { return y_begin_; } inline Coord Extension::right() const { return x_end_; } inline Coord Extension::top() const { return y_end_; } #include #endif ivtools-1.2.11a1/src/include/InterViews/glcontext.h000066400000000000000000000030771214471147700222250ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * GLContext -- glyph for 3D drawing */ #ifndef iv_glcontext_h #define iv_glcontext_h #include #include class GLContextImpl; class GLWindow; class GLContext : public MonoGlyph { public: GLContext(Glyph*); virtual ~GLContext(); virtual void draw(Canvas*, const Allocation&) const; private: GLContextImpl* impl_; }; #endif ivtools-1.2.11a1/src/include/InterViews/glue.h000066400000000000000000000034631214471147700211510ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Glue - filler glyph */ #ifndef iv_glue_h #define iv_glue_h #include #include //: glue glyph base class // in reference manual class Glue : public Glyph { public: Glue( DimensionName, Coord natural, Coord stretch, Coord shrink, float alignment ); Glue(const Requisition&); virtual ~Glue(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); private: Requisition requisition_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/glyph.h000066400000000000000000000051031214471147700213310ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Glyph - visible data */ #ifndef iv_glyph_h #define iv_glyph_h #include #include #include #include class Canvas; class Hit; class Printer; typedef long GlyphIndex; typedef unsigned int GlyphBreakType; //: InterViews 3.1 lightweight glyphs // in reference manual. class Glyph : public Resource { public: enum { no_break, pre_break, in_break, post_break }; virtual ~Glyph(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual void undraw(); virtual Glyph* clone() const; virtual Glyph* compose(GlyphBreakType); virtual void append(Glyph*); virtual void prepend(Glyph*); virtual void insert(GlyphIndex, Glyph*); virtual void remove(GlyphIndex); virtual void replace(GlyphIndex, Glyph*); virtual void change(GlyphIndex); virtual GlyphIndex count() const; virtual Glyph* component(GlyphIndex) const; virtual void allotment(GlyphIndex index, DimensionName, Allotment&) const; protected: Glyph(); }; #include #endif ivtools-1.2.11a1/src/include/InterViews/group.h000066400000000000000000000035161214471147700213500ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_group_h #define iv_group_h #include class Aggregate; class Layout; // GlyphIndex list added by Chad Dawson to 3/4/94 to fix memory leak // in map_. #include declareList(GlyphIndexList,GlyphIndex); class Group : public Glyph { public: Group(Aggregate* aggregate, DimensionName dimension); virtual ~Group(); void map(GlyphIndex); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); private: Aggregate* aggregate_; DimensionName dimension_; Layout* layout_; GlyphIndexList map_; int count_; }; #endif ivtools-1.2.11a1/src/include/InterViews/handler.h000066400000000000000000000031421214471147700216240ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_handler_h #define iv_handler_h #include #include class Event; // object passed an an event to process. // in reference manual. class Handler : public Resource { protected: Handler(); virtual ~Handler(); public: virtual boolean event(Event&) = 0; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/hit.h000066400000000000000000000051351214471147700207770ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Hit detection */ #ifndef iv_hit_h #define iv_hit_h #include #include #include class Event; class Handler; class HitImpl; class Transformer; class Hit { protected: Hit(HitImpl*); public: Hit(const Event*); Hit(Coord x, Coord y); Hit(Coord left, Coord bottom, Coord right, Coord top); virtual ~Hit(); virtual const Event* event() const; virtual Coord left() const; virtual Coord bottom() const; virtual Coord right() const; virtual Coord top() const; virtual void push_transform(); virtual void transform(const Transformer&); virtual void pop_transform(); virtual void begin(int depth, Glyph*, GlyphIndex, Handler* = nil); virtual void target(int depth, Glyph*, GlyphIndex, Handler* = nil); virtual void end(); virtual void remove(int depth, GlyphIndex target = 0); virtual void retarget( int depth, Glyph*, GlyphIndex, Handler* = nil, GlyphIndex target = 0 ); virtual boolean any() const; virtual int count() const; virtual int depth(GlyphIndex target = 0) const; virtual Glyph* target(int depth, GlyphIndex target = 0) const; virtual GlyphIndex index(int depth, GlyphIndex target = 0) const; virtual Handler* handler() const; private: HitImpl* impl_; char free_store_[4000]; void init(); }; #include #endif ivtools-1.2.11a1/src/include/InterViews/image.h000066400000000000000000000031741214471147700212760ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Image - displays a Raster */ #ifndef iv_image_h #define iv_image_h #include class Raster; class Image : public Glyph { public: Image(const Raster* raster); virtual ~Image(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; private: const Raster* raster_; }; #endif ivtools-1.2.11a1/src/include/InterViews/input.h000066400000000000000000000063541214471147700213560ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * InputHandler - glyph that handles input */ #ifndef iv_input_h #define iv_input_h #include class Event; class Handler; class InputHandlerImpl; class Style; class Transformer; class InputHandler : public MonoGlyph { public: InputHandler(Glyph*, Style*); virtual ~InputHandler(); virtual Handler* handler() const; virtual InputHandler* parent() const; virtual Style* style() const; virtual void append_input_handler(InputHandler*); virtual void remove_input_handler(GlyphIndex); virtual void remove_all_input_handlers(); virtual GlyphIndex input_handler_count() const; virtual InputHandler* input_handler(GlyphIndex) const; virtual void focus(InputHandler*); virtual void next_focus(); virtual void prev_focus(); virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual void undraw(); virtual void move(const Event&); virtual void press(const Event&); virtual void drag(const Event&); virtual void release(const Event&); virtual void keystroke(const Event&); virtual void double_click(const Event&); virtual void selection_notify(const Event&); virtual InputHandler* focus_in(); virtual void focus_out(); virtual void allocation_changed(Canvas*, const Allocation&); virtual boolean inside(const Event&); virtual Canvas* canvas() const; virtual const Transformer& transformer() const; virtual const Allocation& allocation() const; virtual void redraw() const; virtual void repick(int depth, Hit&); private: friend class InputHandlerImpl; InputHandlerImpl* impl_; }; class ActiveHandler : public InputHandler { protected: ActiveHandler(Glyph*, Style*); public: virtual ~ActiveHandler(); virtual void undraw(); virtual void move(const Event&); virtual void drag(const Event&); virtual void enter(); virtual void leave(); private: boolean inside_; }; #endif ivtools-1.2.11a1/src/include/InterViews/iv.h000066400000000000000000000027031214471147700206270ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _lib_iv_h #define _lib_iv_h #if defined(__STDC__) || defined(__ANSI_CPP__) #define _lib_iv(name) iv##name #define _lib_iv2_6(name) iv2_6_##name #else #define _lib_iv(name) iv/**/name #define _lib_iv2_6(name) iv2_6_/**/name #endif #endif ivtools-1.2.11a1/src/include/InterViews/label.h000066400000000000000000000041371214471147700212730ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Label - ASCII text glyph with font */ #ifndef iv_label_h #define iv_label_h #include #include class Color; class Font; class String; class Label : public Glyph { public: Label(const String&, const Font*, const Color*); Label(const char*, const Font*, const Color*); Label(const char*, int len, const Font*, const Color*); virtual ~Label(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); private: String* text_; const Font* font_; const Color* color_; Coord left_; Coord right_; Coord ascent_; Coord descent_; Coord width_; Coord* char_widths_; void compute_metrics(); }; #include #endif ivtools-1.2.11a1/src/include/InterViews/layout.h000066400000000000000000000324461214471147700215350ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Layout - structured layout */ #ifndef iv_layout_h #define iv_layout_h #include // too avoid confusion with IV-2_6 #include #include #include class Layout { protected: Layout(); public: virtual ~Layout(); virtual void request( GlyphIndex count, const Requisition*, Requisition& result ); virtual void allocate( const Allocation& given, GlyphIndex count, const Requisition*, Allocation* result ); }; class Color; class Font; class PolyGlyph; //: factory object for layout glyphs. // in reference manual class LayoutKit { protected: LayoutKit(); public: virtual ~LayoutKit(); static LayoutKit* instance(); protected: static void instance(LayoutKit*); public: virtual PolyGlyph* box(Layout*, GlyphIndex size = 10) const; virtual PolyGlyph* hbox(GlyphIndex size) const; virtual PolyGlyph* hbox( Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil ) const; virtual PolyGlyph* vbox(GlyphIndex size) const; virtual PolyGlyph* vbox( Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil ) const; virtual PolyGlyph* hbox_first_aligned(GlyphIndex size) const; virtual PolyGlyph* hbox_first_aligned( Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil ) const; virtual PolyGlyph* vbox_first_aligned(GlyphIndex size) const; virtual PolyGlyph* vbox_first_aligned( Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil ) const; virtual ScrollBox* vscrollbox(GlyphIndex size = 10) const; virtual PolyGlyph* overlay( Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil ) const; virtual Deck* deck(GlyphIndex size) const; virtual Deck* deck( Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil ) const; virtual MonoGlyph* back(Glyph*, Glyph* under) const; virtual MonoGlyph* front(Glyph*, Glyph* over) const; virtual MonoGlyph* between(Glyph*, Glyph* under, Glyph* over) const; virtual Glyph* glue( DimensionName, Coord natural, Coord stretch, Coord shrink, float alignment ) const; virtual Glyph* glue(const Requisition&) const; virtual Glyph* hglue() const; virtual Glyph* hglue(Coord natural) const; virtual Glyph* hglue(Coord natural, Coord stretch, Coord shrink) const; virtual Glyph* hglue( Coord natural, Coord stretch, Coord shrink, float alignment ) const; virtual Glyph* hspace(Coord natural) const; virtual Glyph* vglue() const; virtual Glyph* vglue(Coord natural) const; virtual Glyph* vglue(Coord natural, Coord stretch, Coord shrink) const; virtual Glyph* vglue( Coord natural, Coord stretch, Coord shrink, float alignment ) const; virtual Glyph* vspace(Coord natural) const; virtual Glyph* shape_of(Glyph*) const; virtual Glyph* shape_of_xy(Glyph*, Glyph*) const; virtual Glyph* discretionary(int penalty, Glyph*) const; virtual Glyph* discretionary( int penalty, Glyph* no, Glyph* before, Glyph* in, Glyph* after ) const; virtual Glyph* strut( const Font*, Coord natural = 0, Coord stretch = 0, Coord shrink = 0 ) const; virtual Glyph* hstrut( Coord right_bearing, Coord left_bearing = 0, Coord natural = 0, Coord stretch = 0, Coord shrink = 0 ) const; virtual Glyph* vstrut( Coord ascent, Coord descent = 0, Coord natural = 0, Coord stretch = 0, Coord shrink = 0 ) const; virtual Glyph* spaces( int count, Coord each, const Font*, const Color* ) const; virtual MonoGlyph* center(Glyph*, float x = 0.5, float y = 0.5) const; virtual MonoGlyph* center_dimension( Glyph*, DimensionName, float align ) const; virtual MonoGlyph* hcenter(Glyph*, float x = 0.5) const; virtual MonoGlyph* vcenter(Glyph*, float y = 0.5) const; virtual MonoGlyph* fixed(Glyph*, Coord x, Coord y) const; virtual MonoGlyph* fixed_dimension( Glyph*, DimensionName, Coord ) const; virtual MonoGlyph* hfixed(Glyph*, Coord x) const; virtual MonoGlyph* vfixed(Glyph*, Coord y) const; virtual MonoGlyph* flexible( Glyph*, Coord stretch = fil, Coord shrink = fil ) const; virtual MonoGlyph* flexible_dimension( Glyph*, DimensionName, Coord stretch = fil, Coord shrink = fil ) const; virtual MonoGlyph* hflexible( Glyph*, Coord stretch = fil, Coord shrink = fil ) const; virtual MonoGlyph* vflexible( Glyph*, Coord stretch = fil, Coord shrink = fil ) const; virtual MonoGlyph* natural(Glyph*, Coord x, Coord y) const; virtual MonoGlyph* natural_dimension( Glyph*, DimensionName, Coord ) const; virtual MonoGlyph* hnatural(Glyph*, Coord x) const; virtual MonoGlyph* vnatural(Glyph*, Coord y) const; virtual MonoGlyph* margin(Glyph*, Coord) const; virtual MonoGlyph* margin(Glyph*, Coord hmargin, Coord vmargin) const; virtual MonoGlyph* margin( Glyph*, Coord lmargin, Coord rmargin, Coord bmargin, Coord tmargin ) const; virtual MonoGlyph* margin( Glyph*, Coord lmargin, Coord lstretch, Coord lshrink, Coord rmargin, Coord rstretch, Coord rshrink, Coord bmargin, Coord bstretch, Coord bshrink, Coord tmargin, Coord tstretch, Coord tshrink ) const; virtual MonoGlyph* hmargin(Glyph*, Coord) const; virtual MonoGlyph* hmargin(Glyph*, Coord lmargin, Coord rmargin) const; virtual MonoGlyph* hmargin( Glyph*, Coord lmargin, Coord lstretch, Coord lshrink, Coord rmargin, Coord rstretch, Coord rshrink ) const; virtual MonoGlyph* vmargin(Glyph*, Coord) const; virtual MonoGlyph* vmargin(Glyph*, Coord bmargin, Coord tmargin) const; virtual MonoGlyph* vmargin( Glyph*, Coord bmargin, Coord bstretch, Coord bshrink, Coord tmargin, Coord tstretch, Coord tshrink ) const; virtual MonoGlyph* lmargin(Glyph*, Coord) const; virtual MonoGlyph* lmargin( Glyph*, Coord, Coord stretch, Coord shrink ) const; virtual MonoGlyph* rmargin(Glyph*, Coord) const; virtual MonoGlyph* rmargin( Glyph*, Coord, Coord stretch, Coord shrink ) const; virtual MonoGlyph* bmargin(Glyph*, Coord) const; virtual MonoGlyph* bmargin( Glyph*, Coord, Coord stretch, Coord shrink ) const; virtual MonoGlyph* tmargin(Glyph*, Coord) const; virtual MonoGlyph* tmargin( Glyph*, Coord, Coord stretch, Coord shrink ) const; /* backward compatibility */ MonoGlyph* fixed_span(Glyph*, Coord x, Coord y) const; MonoGlyph* fixed_span_dimension(Glyph*, DimensionName, Coord) const; MonoGlyph* h_fixed_span(Glyph*, Coord x) const; MonoGlyph* v_fixed_span(Glyph*, Coord y) const; MonoGlyph* variable_span( Glyph*, Coord stretch = fil, Coord shrink = fil ) const; MonoGlyph* variable_span_dimension( Glyph*, DimensionName, Coord stretch = fil, Coord shrink = fil ) const; MonoGlyph* h_variable_span( Glyph*, Coord stretch = fil, Coord shrink = fil ) const; MonoGlyph* v_variable_span( Glyph*, Coord stretch = fil, Coord shrink = fil ) const; MonoGlyph* natural_span(Glyph*, Coord x, Coord y) const; MonoGlyph* natural_span_dimension( Glyph*, DimensionName, Coord ) const; MonoGlyph* h_natural_span(Glyph*, Coord x) const; MonoGlyph* v_natural_span(Glyph*, Coord y) const; MonoGlyph* h_margin(Glyph*, Coord) const; MonoGlyph* h_margin(Glyph*, Coord lmargin, Coord rmargin) const; MonoGlyph* h_margin( Glyph*, Coord lmargin, Coord lstretch, Coord lshrink, Coord rmargin, Coord rstretch, Coord rshrink ) const; MonoGlyph* v_margin(Glyph*, Coord) const; MonoGlyph* v_margin(Glyph*, Coord bmargin, Coord tmargin) const; MonoGlyph* v_margin( Glyph*, Coord bmargin, Coord bstretch, Coord bshrink, Coord tmargin, Coord tstretch, Coord tshrink ) const; MonoGlyph* l_margin(Glyph*, Coord) const; MonoGlyph* l_margin( Glyph*, Coord, Coord stretch, Coord shrink ) const; MonoGlyph* r_margin(Glyph*, Coord) const; MonoGlyph* r_margin( Glyph*, Coord, Coord stretch, Coord shrink ) const; MonoGlyph* b_margin(Glyph*, Coord) const; MonoGlyph* b_margin( Glyph*, Coord, Coord stretch, Coord shrink ) const; MonoGlyph* t_margin(Glyph*, Coord) const; MonoGlyph* t_margin( Glyph*, Coord, Coord stretch, Coord shrink ) const; }; /* inline old names to new names */ inline MonoGlyph* LayoutKit::fixed_span(Glyph* g, Coord x, Coord y) const { return fixed(g, x, y); } inline MonoGlyph* LayoutKit::fixed_span_dimension( Glyph* g, DimensionName d, Coord c ) const { return fixed_dimension(g, d, c); } inline MonoGlyph* LayoutKit::h_fixed_span(Glyph* g, Coord x) const { return hfixed(g, x); } inline MonoGlyph* LayoutKit::v_fixed_span(Glyph* g, Coord y) const { return vfixed(g, y); } inline MonoGlyph* LayoutKit::variable_span( Glyph* g, Coord stretch, Coord shrink ) const { return flexible(g, stretch, shrink); } inline MonoGlyph* LayoutKit::variable_span_dimension( Glyph* g, DimensionName d, Coord stretch, Coord shrink ) const { return flexible_dimension(g, d, stretch, shrink); } inline MonoGlyph* LayoutKit::h_variable_span( Glyph* g, Coord stretch, Coord shrink ) const { return hflexible(g, stretch, shrink); } inline MonoGlyph* LayoutKit::v_variable_span( Glyph* g, Coord stretch, Coord shrink ) const { return vflexible(g, stretch, shrink); } inline MonoGlyph* LayoutKit::natural_span(Glyph* g, Coord x, Coord y) const { return natural(g, x, y); } inline MonoGlyph* LayoutKit::natural_span_dimension( Glyph* g, DimensionName d, Coord c ) const { return natural_dimension(g, d, c); } inline MonoGlyph* LayoutKit::h_natural_span(Glyph* g, Coord x) const { return hnatural(g, x); } inline MonoGlyph* LayoutKit::v_natural_span(Glyph* g, Coord y) const { return vnatural(g, y); } inline MonoGlyph* LayoutKit::h_margin(Glyph* g, Coord m) const { return hmargin(g, m); } inline MonoGlyph* LayoutKit::h_margin( Glyph* g, Coord lmargin, Coord rmargin ) const { return hmargin(g, lmargin, rmargin); } inline MonoGlyph* LayoutKit::h_margin( Glyph* g, Coord lmargin, Coord lstretch, Coord lshrink, Coord rmargin, Coord rstretch, Coord rshrink ) const { return hmargin(g, lmargin, lstretch, lshrink, rmargin, rstretch, rshrink); } inline MonoGlyph* LayoutKit::v_margin(Glyph* g, Coord m) const { return vmargin(g, m); } inline MonoGlyph* LayoutKit::v_margin( Glyph* g, Coord bmargin, Coord tmargin ) const { return vmargin(g, bmargin, tmargin); } inline MonoGlyph* LayoutKit::v_margin( Glyph* g, Coord bmargin, Coord bstretch, Coord bshrink, Coord tmargin, Coord tstretch, Coord tshrink ) const { return vmargin(g, bmargin, bstretch, bshrink, tmargin, tstretch, tshrink); } inline MonoGlyph* LayoutKit::l_margin(Glyph* g, Coord m) const { return lmargin(g, m); } inline MonoGlyph* LayoutKit::l_margin( Glyph* g, Coord natural, Coord stretch, Coord shrink ) const { return lmargin(g, natural, stretch, shrink); } inline MonoGlyph* LayoutKit::r_margin(Glyph* g, Coord m) const { return rmargin(g, m); } inline MonoGlyph* LayoutKit::r_margin( Glyph* g, Coord natural, Coord stretch, Coord shrink ) const { return rmargin(g, natural, stretch, shrink); } inline MonoGlyph* LayoutKit::b_margin(Glyph* g, Coord m) const { return bmargin(g, m); } inline MonoGlyph* LayoutKit::b_margin( Glyph* g, Coord natural, Coord stretch, Coord shrink ) const { return bmargin(g, natural, stretch, shrink); } inline MonoGlyph* LayoutKit::t_margin(Glyph* g, Coord m) const { return tmargin(g, m); } inline MonoGlyph* LayoutKit::t_margin( Glyph* g, Coord natural, Coord stretch, Coord shrink ) const { return tmargin(g, natural, stretch, shrink); } #endif ivtools-1.2.11a1/src/include/InterViews/leave-scope.h000066400000000000000000000026551214471147700224220ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifdef iv__scope_h #undef iv__scope_h #ifdef iv__current_h #undef iv__current_h #endif #ifdef iv__2_6_h #undef iv__2_6_h #endif #ifndef MAKEDEPEND #include #undef nil #undef String #endif #endif ivtools-1.2.11a1/src/include/InterViews/lrmarker.h000066400000000000000000000037741214471147700220410ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * LRMarker - mark text region */ #ifndef iv_lrmarker_h #define iv_lrmarker_h #include class Color; class LRMarker : public MonoGlyph { public: LRMarker(Glyph* body, const Color* overlay, const Color* underlay); virtual ~LRMarker(); void bound(Coord left, Coord bottom, Coord right, Coord top); void mark(Coord x1, Coord y1, Coord h1, Coord x2, Coord y2, Coord h2); void unmark(); virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void undraw(); private: Canvas* canvas_; const Color* overlay_; const Color* underlay_; boolean marked_; boolean bounded_; Coord left_, right_, bottom_, top_; Coord x1_, y1_, h1_; Coord x2_, y2_, h2_; }; #endif ivtools-1.2.11a1/src/include/InterViews/monoglyph.h000066400000000000000000000044451214471147700222320ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * MonoGlyph */ #ifndef iv_monoglyph_h #define iv_monoglyph_h #include #include class MonoGlyph : public Glyph { public: virtual ~MonoGlyph(); virtual void body(Glyph*); virtual Glyph* body() const; void bodyclear(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual void undraw(); virtual void append(Glyph*); virtual void prepend(Glyph*); virtual void insert(GlyphIndex, Glyph*); virtual void remove(GlyphIndex); virtual void replace(GlyphIndex, Glyph*); virtual void change(GlyphIndex); virtual GlyphIndex count() const; virtual Glyph* component(GlyphIndex) const; virtual void allotment(GlyphIndex, DimensionName, Allotment&) const; protected: MonoGlyph(Glyph* = nil); private: Glyph* body_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/observe.h000066400000000000000000000037051214471147700216610ustar00rootroot00000000000000/* * Copyright (c) 1992 Stanford University * Copyright (c) 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Observable - object to observe */ #ifndef iv_observe_h #define iv_observe_h #include #include class Observer; class ObserverList; //: observable mixin. // in reference manual. class Observable { public: Observable(); virtual ~Observable(); virtual void attach(Observer*); virtual void detach(Observer*); virtual void notify(); private: ObserverList* observers_; }; //: observer mixin. // in reference manual. class Observer { protected: Observer(); public: virtual ~Observer(); virtual void update(Observable*); virtual void disconnect(Observable*); }; #include #endif ivtools-1.2.11a1/src/include/InterViews/page.h000066400000000000000000000051601214471147700211250ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Page - arbitrary placements */ #ifndef iv_page_h #define iv_page_h #include class PageInfo_List; //: glyph for arbitrary placements // man page class Page : public Glyph { public: Page(Glyph* background); virtual ~Page(); Coord left() const; Coord right() const; Coord bottom() const; Coord top() const; Coord x() const; Coord y() const; void move(GlyphIndex, Coord x, Coord y); void location(GlyphIndex, Coord& x, Coord& y); void show(GlyphIndex, boolean); boolean showing(GlyphIndex) const; virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual void undraw(); virtual void append(Glyph*); virtual void prepend(Glyph*); virtual void insert(GlyphIndex, Glyph*); virtual void remove(GlyphIndex); virtual void replace(GlyphIndex, Glyph*); virtual void change(GlyphIndex); virtual GlyphIndex count() const; virtual Glyph* component(GlyphIndex) const; virtual void allotment(GlyphIndex, DimensionName, Allotment&) const; private: PageInfo_List* info_; Glyph* background_; Canvas* canvas_; Allocation allocation_; }; #endif ivtools-1.2.11a1/src/include/InterViews/patch.h000066400000000000000000000045171214471147700213150ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Patch - for repairing glyphs */ #ifndef iv_patch_h #define iv_patch_h #include #include //: glyph able to redraw itself. // in reference manual. class Patch : public MonoGlyph { public: Patch(Glyph*); virtual ~Patch(); Canvas* canvas() const; const Transformer& transformer() const; const Allocation& allocation() const; const Extension& extension() const; virtual void redraw() const; virtual void reallocate(); virtual void repick(int depth, Hit&); virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void undraw(); private: Canvas* canvas_; Transformer transformer_; Allocation allocation_; Extension extension_; }; inline Canvas* Patch::canvas() const { return canvas_; } inline const Transformer& Patch::transformer() const { return transformer_; } inline const Allocation& Patch::allocation() const { return allocation_; } inline const Extension& Patch::extension() const { return extension_; } #endif ivtools-1.2.11a1/src/include/InterViews/pattern.h000066400000000000000000000040551214471147700216700ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * A pattern is a bit array describing where to fill. */ #ifndef iv_pattern_h #define iv_pattern_h #include #include class PatternRep; //: a pattern object // defines a pattern for rendering operations //

    pspaint(3). class Pattern : public Resource { public: enum { solid = 0xffff, clear = 0, lightgray = 0x8020, gray = 0xa5a5, darkgray = 0xfafa }; Pattern(); Pattern(const char*, unsigned int width, unsigned int height); Pattern(int); /* 4 x 4 */ Pattern(const int*); /* 16 x 16 */ virtual ~Pattern(); PatternRep* rep() const; private: PatternRep* rep_; void init(const char*, unsigned int width, unsigned int height); }; inline PatternRep* Pattern::rep() const { return rep_; } #include #endif ivtools-1.2.11a1/src/include/InterViews/place.h000066400000000000000000000106021214471147700212720ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Placement - monoglyph that positions its body using a layout */ #ifndef iv_place_h #define iv_place_h #include #include class Placement : public MonoGlyph { public: Placement(Glyph*, Layout*); virtual ~Placement(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); private: Layout* layout_; }; class CenterLayout : public Layout { public: CenterLayout(const DimensionName, float alignment = 0.5); virtual ~CenterLayout(); virtual void request( GlyphIndex count, const Requisition*, Requisition& result ); virtual void allocate( const Allocation& given, GlyphIndex count, const Requisition*, Allocation* result ); private: DimensionName dimension_; float alignment_; }; class FixedLayout : public Layout { public: FixedLayout(const DimensionName, Coord span); virtual ~FixedLayout(); virtual void request( GlyphIndex count, const Requisition*, Requisition& result ); virtual void allocate( const Allocation& given, GlyphIndex count, const Requisition*, Allocation* result ); private: DimensionName dimension_; Coord span_; }; class VariableLayout : public Layout { public: VariableLayout(const DimensionName, Coord stretch, Coord shrink); virtual ~VariableLayout(); virtual void request( GlyphIndex count, const Requisition*, Requisition& result ); virtual void allocate( const Allocation& given, GlyphIndex count, const Requisition*, Allocation* result ); private: DimensionName dimension_; Coord stretch_; Coord shrink_; }; class NaturalLayout : public Layout { public: NaturalLayout(const DimensionName, Coord natural); virtual ~NaturalLayout(); virtual void request( GlyphIndex count, const Requisition*, Requisition& result ); virtual void allocate( const Allocation& given, GlyphIndex count, const Requisition*, Allocation* result ); private: DimensionName dimension_; Coord natural_; }; class MarginLayout : public Layout { public: MarginLayout(Coord margin); MarginLayout(Coord hmargin, Coord vmargin); MarginLayout(Coord lmargin, Coord rmargin, Coord bmargin, Coord tmargin); MarginLayout( Coord lmargin, Coord lstretch, Coord lshrink, Coord rmargin, Coord rstretch, Coord rshrink, Coord bmargin, Coord bstretch, Coord bshrink, Coord tmargin, Coord tstretch, Coord tshrink ); virtual ~MarginLayout(); virtual void request( GlyphIndex count, const Requisition*, Requisition& result ); virtual void allocate( const Allocation& given, GlyphIndex count, const Requisition*, Allocation* result ); private: Coord lnatural_, lstretch_, lshrink_; Coord rnatural_, rstretch_, rshrink_; Coord bnatural_, bstretch_, bshrink_; Coord tnatural_, tstretch_, tshrink_; Requisition requisition_; static Coord span( Coord span, const Requirement& total, Coord natural, Coord stretch, Coord shrink ); }; #endif ivtools-1.2.11a1/src/include/InterViews/polyglyph.h000066400000000000000000000036411214471147700222420ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * PolyGlyph -- list of glyphs */ #ifndef iv_polyglyph_h #define iv_polyglyph_h #include #include class PolyGlyphImpl; class PolyGlyph : public Glyph { public: PolyGlyph(GlyphIndex initial_size = 10); virtual ~PolyGlyph(); virtual void undraw(); virtual void append(Glyph*); virtual void prepend(Glyph*); virtual void insert(GlyphIndex, Glyph*); virtual void remove(GlyphIndex); virtual void replace(GlyphIndex, Glyph*); virtual void change(GlyphIndex); virtual GlyphIndex count() const; virtual Glyph* component(GlyphIndex) const; virtual void modified(GlyphIndex); private: PolyGlyphImpl* impl_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/printer.h000066400000000000000000000052261214471147700216770ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Printer - generate output for a printer */ #ifndef iv_printer_h #define iv_printer_h #include #include class PrinterRep; class Printer : public Canvas { public: Printer(ostream*); virtual ~Printer(); virtual PixelCoord to_pixels(Coord) const; virtual Coord to_coord(PixelCoord) const; virtual Coord to_pixels_coord(Coord) const; virtual void resize(Coord left, Coord bottom, Coord right, Coord top); virtual void prolog(const char* creator = "InterViews"); virtual void epilog(); virtual void comment(const char*); virtual void page(const char*); virtual void push_transform(); virtual void transform(const Transformer&); virtual void pop_transform(); virtual void push_clipping(); virtual void clip(); virtual void pop_clipping(); virtual void new_path(); virtual void move_to(Coord x, Coord y); virtual void line_to(Coord x, Coord y); virtual void curve_to( Coord x, Coord y, Coord x1, Coord y1, Coord x2, Coord y2 ); virtual void close_path(); virtual void stroke(const Color*, const Brush*); virtual void fill(const Color*); virtual void character( const Font*, long c, Coord width, const Color*, Coord x, Coord y ); virtual void stencil(const Bitmap*, const Color*, Coord x, Coord y); virtual void image(const Raster*, Coord x, Coord y); protected: virtual void flush(); private: PrinterRep* rep_; }; #endif ivtools-1.2.11a1/src/include/InterViews/psfont.h000066400000000000000000000035111214471147700215200ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * iv_PSFont - use PostScript font metrics */ #ifndef iv_psfont_h #define iv_psfont_h #include #include class PSFontImpl; class PSFont31 : public Font { public: PSFont31(const char* psname, Coord size, const char* name, float scale); virtual ~PSFont31(); static boolean exists(const char* psname); virtual const char* name() const; virtual const char* encoding() const; virtual Coord size() const; virtual Coord width(long) const; virtual Coord width(const char*, int) const; private: PSFontImpl* impl_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/raster.h000066400000000000000000000056541214471147700215210ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Raster - rasterized image */ #ifndef iv_raster_h #define iv_raster_h #include #include #include #include class RasterRep; //: raster data object. // in reference manual class Raster : public Resource { public: Raster(unsigned long width, unsigned long height); Raster(const Raster&); virtual ~Raster(); virtual Coord width() const; virtual Coord height() const; virtual unsigned long pwidth() const; virtual unsigned long pheight() const; virtual Coord left_bearing() const; virtual Coord right_bearing() const; virtual Coord ascent() const; virtual Coord descent() const; virtual void peek( unsigned long x, unsigned long y, ColorIntensity& red, ColorIntensity& green, ColorIntensity& blue, float& alpha ) const; virtual void poke( unsigned long x, unsigned long y, ColorIntensity red, ColorIntensity green, ColorIntensity blue, float alpha ); virtual void flush() const; virtual void flushrect(IntCoord l, IntCoord b, IntCoord s, IntCoord t) const; // flush rectangular region of internal XImage data structure // to a pixmap on the X server. RasterRep* rep() const; protected: Raster(RasterRep*); boolean init_shared_memory(); private: RasterRep* rep_; /* anachronisms */ public: unsigned int Width() const; unsigned int Height() const; }; inline RasterRep* Raster::rep() const { return rep_; } inline unsigned int Raster::Width() const { return (unsigned int)pwidth(); } inline unsigned int Raster::Height() const { return (unsigned int)pheight(); } #include #endif ivtools-1.2.11a1/src/include/InterViews/regexp.h000066400000000000000000000050551214471147700215060ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Regexp - regular expression searching */ #ifndef iv_regexp_h #define iv_regexp_h #include /* * These definitions are from Henry Spencers public-domain regular * expression matching routines. * * Definitions etc. for regexp(3) routines. * * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], * not the System V one. */ #define NSUBEXP 10 struct regexp { char *startp[NSUBEXP]; char *endp[NSUBEXP]; char *textStart; char regstart; /* Internal use only. */ char reganch; /* Internal use only. */ char *regmust; /* Internal use only. */ int regmlen; /* Internal use only. */ char program[1]; /* Unwarranted chumminess with compiler. */ }; /* * The first byte of the regexp internal "program" is actually this magic * number; the start node begins in the second byte. */ #define REGEXP_MAGIC 0234 //: regular expression searching // man page class Regexp { public: Regexp(const char*); Regexp(const char*, int length); ~Regexp(); const char* pattern() const; int Search(const char* text, int length, int index, int range); int Match(const char* text, int length, int index); int BeginningOfMatch(int subexp = 0); int EndOfMatch(int subexp = 0); private: char* pattern_; regexp* c_pattern; }; #endif ivtools-1.2.11a1/src/include/InterViews/reqerr.h000066400000000000000000000033061214471147700215110ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Handling errors from window server. */ #ifndef iv_reqerr_h #define iv_reqerr_h #include #include //: Handling errors from window server. // man page class ReqErr { public: unsigned long msgid; int code; int request; int detail; void* id; char message[256]; ReqErr(); virtual ~ReqErr(); ReqErr* Install(); virtual void Error(); }; #include #endif ivtools-1.2.11a1/src/include/InterViews/resource.h000066400000000000000000000043201214471147700220350ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Resources are shared objects. */ #ifndef iv_resource_h #define iv_resource_h #include //: shared reference-counted objects. // man page class Resource { public: Resource(); virtual ~Resource(); virtual void ref() const; virtual void unref() const; virtual void unref_deferred() const; virtual void cleanup(); /* nops for nil pointers */ static void ref(const Resource*); static void unref(const Resource*); static void unref_deferred(const Resource*); /* postpone unref deletes */ static boolean defer(boolean); static void flush(); /* for backward compatibility */ virtual void Reference() const { ref(); } virtual void Unreference() const { unref(); } unsigned refcount_; private: /* prohibit default assignment */ Resource& operator =(const Resource&); }; /* * For backward compatibility */ static inline void Unref(const Resource* r) { Resource::unref(r); } #endif ivtools-1.2.11a1/src/include/InterViews/rule.h000066400000000000000000000036251214471147700211640ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Rule - visible filling */ #ifndef ivlook_rule_h #define ivlook_rule_h #include class Color; class Rule : public Glyph { public: Rule(DimensionName, const Color*, Coord thickness); virtual ~Rule(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; private: DimensionName dimension_; const Color* color_; Coord thickness_; }; class HRule : public Rule { public: HRule(const Color*, Coord thickness); virtual ~HRule(); }; class VRule : public Rule { public: VRule(const Color*, Coord thickness); virtual ~VRule(); }; #endif ivtools-1.2.11a1/src/include/InterViews/scrbox.h000066400000000000000000000060111214471147700215050ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * ScrollBox - scrollable list of glyphs */ #ifndef iv_scrbox_h #define iv_scrbox_h #include #include #include class ScrollBox : public PolyGlyph, public Adjustable { protected: ScrollBox(GlyphIndex size = 10); virtual ~ScrollBox(); virtual boolean shown(GlyphIndex) const; virtual GlyphIndex first_shown() const; virtual GlyphIndex last_shown() const; }; class TBScrollBoxImpl; class TBScrollBox : public ScrollBox { public: TBScrollBox(GlyphIndex size = 10); virtual ~TBScrollBox(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); virtual void undraw(); virtual void modified(GlyphIndex); virtual boolean shown(GlyphIndex) const; virtual GlyphIndex first_shown() const; virtual GlyphIndex last_shown() const; virtual void allotment(GlyphIndex, DimensionName, Allotment&) const; virtual Coord lower(DimensionName) const; virtual Coord upper(DimensionName) const; virtual Coord length(DimensionName) const; virtual Coord cur_lower(DimensionName) const; virtual Coord cur_upper(DimensionName) const; virtual Coord cur_length(DimensionName) const; virtual void scroll_forward(DimensionName); virtual void scroll_backward(DimensionName); virtual void page_forward(DimensionName); virtual void page_backward(DimensionName); virtual void scroll_to(DimensionName, Coord lower); private: TBScrollBoxImpl* impl_; TBScrollBoxImpl& impl() const; void scroll_by(DimensionName, long); void do_scroll(DimensionName, GlyphIndex new_start, GlyphIndex new_end); }; #include #endif ivtools-1.2.11a1/src/include/InterViews/selection.h000066400000000000000000000065111214471147700221770ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_selection_h #define iv_selection_h #include #include class Display; class SelectionHandler; class SelectionManagerRep; class String; class SelectionManager : public Resource { public: SelectionManager(Display*, const char*); SelectionManager(Display*, const String&); virtual ~SelectionManager(); virtual void own( SelectionHandler* convert, SelectionHandler* lose = nil, SelectionHandler* done = nil ); virtual void put_value(const void*, int length, int format = 8); virtual void retrieve( const String& type, SelectionHandler* ok, SelectionHandler* fail = nil ); virtual void get_value(String*& type, void*&, int&, int& format); SelectionManagerRep* rep() const; private: SelectionManagerRep* rep_; }; class SelectionHandler : public Resource { protected: SelectionHandler(); public: virtual ~SelectionHandler(); virtual void handle(SelectionManager*) = 0; }; #if defined(__STDC__) || defined(__ANSI_CPP__) #define __SelectionCallback(T) T##_SelectionCallback #define SelectionCallback(T) __SelectionCallback(T) #define __SelectionMemberFunction(T) T##_SelectionMemberFunction #define SelectionMemberFunction(T) __SelectionMemberFunction(T) #else #define __SelectionCallback(T) T/**/_SelectionCallback #define SelectionCallback(T) __SelectionCallback(T) #define __SelectionMemberFunction(T) T/**/_SelectionMemberFunction #define SelectionMemberFunction(T) __SelectionMemberFunction(T) #endif #define declareSelectionCallback(T) \ typedef void (T::*SelectionMemberFunction(T))(SelectionManager*); \ class SelectionCallback(T) : public SelectionHandler { \ public: \ SelectionCallback(T)(T*, SelectionMemberFunction(T)); \ \ virtual void handle(SelectionManager*); \ private: \ T* obj_; \ SelectionMemberFunction(T) func_; \ }; #define implementSelectionCallback(T) \ SelectionCallback(T)::SelectionCallback(T)( \ T* obj, SelectionMemberFunction(T) func \ ) { \ obj_ = obj; \ func_ = func; \ } \ \ void SelectionCallback(T)::handle(SelectionManager* s) { (obj_->*func_)(s); } #endif ivtools-1.2.11a1/src/include/InterViews/session.h000066400000000000000000000063411214471147700216760ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Session -- coordinate control flow and display management */ #ifndef iv_session_h #define iv_session_h #include #include class Display; class Event; class Handler; class SessionRep; class String; class Style; class Window; class PropertyData { public: const char* path; /* class/instance(s) property name */ const char* value; /* property value */ #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif }; enum OptionStyle { OptionPropertyNext, /* Property and value are in argv[i+1] */ OptionValueNext, /* argv[i+1] */ OptionValueImplicit, /* OptionDesc.value */ OptionValueIsArg, /* argv[i] */ OptionValueAfter /* &argv[i][strlen(OptionDesc.name)] */ }; class OptionDesc { public: const char* name; const char* path; OptionStyle style; const char* value; #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif }; class Session { public: Session( const char*, int& argc, char** argv, const OptionDesc* = nil, const PropertyData* = nil, Display* = nil ); virtual ~Session(); const char* name() const; const char* classname() const; int argc() const; char** argv() const; Style* style() const; void default_display(Display*); Display* default_display() const; virtual Display* connect(const String&); virtual Display* connect(const char*); virtual void disconnect(Display*); virtual int run(); virtual int run_window(Window*); virtual void quit(); virtual boolean done() const; virtual void undone(); /* added by ro2m to permit use of other event loops */ virtual boolean pending() const; virtual void read(Event&, boolean (*test)() = nil); virtual boolean read(long sec, long usec, Event&, boolean (*test)() = nil); virtual boolean read(long* sec, long* usec, Event&, boolean (*test)() = nil); virtual void unread(Event&); virtual void poll(Event&); static Session* instance(); private: SessionRep* rep_; }; #include #endif ivtools-1.2.11a1/src/include/InterViews/shadow.h000066400000000000000000000042171214471147700215000ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Shadow - a drop shadowing Glyph */ #ifndef iv_shadow_h #define iv_shadow_h #include class Color; class Shadow : public MonoGlyph { public: Shadow(Glyph*, Coord x, Coord y, const Color*, boolean single = false); virtual ~Shadow(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); private: Coord x_offset_; Coord y_offset_; const Color* color_; boolean single_; void compute_requirement(Requirement&, Coord offset) const; void compute_allocation(Allocation&) const; void compute_allotment(Allotment&, Coord offset) const; void draw_shadow(Canvas*, const Allocation&) const; void draw_body(Canvas*, const Allocation&) const; }; #endif ivtools-1.2.11a1/src/include/InterViews/simplecomp.h000066400000000000000000000032461214471147700223640ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_simplecomp_h #define iv_simplecomp_h #include class SimpleCompositor : public Compositor { public: SimpleCompositor(); virtual ~SimpleCompositor(); virtual CompositorIndex compose( Coord* natural, Coord* stretch, Coord* shrink, int* penalites, CompositorIndex component_count, Coord* spans, CompositorIndex span_count, CompositorIndex* breaks, CompositorIndex break_count ); }; #endif ivtools-1.2.11a1/src/include/InterViews/stencil.h000066400000000000000000000032541214471147700216540ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Stencil - mask Glyph */ #ifndef iv_stencil_h #define iv_stencil_h #include class Bitmap; class Color; class Stencil : public Glyph { public: Stencil(const Bitmap*, const Color*); virtual ~Stencil(); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; private: const Bitmap* mask_; const Color* color_; }; #endif ivtools-1.2.11a1/src/include/InterViews/style.h000066400000000000000000000073541214471147700213600ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Style - style information */ #ifndef iv_style_h #define iv_style_h #include #include #include class Action; class Brush; class Color; class Font; class String; class StyleRep; //: user interface attribute object. // in reference manual class Style : public Resource { public: Style(); Style(const String& name); Style(Style* parent); Style(const String& name, Style* parent); Style(const Style&); virtual ~Style(); virtual void name(const String&); virtual const String* name() const; virtual void alias(const String&); virtual long alias_count() const; virtual const String* alias(long) const; void name(const char*); void alias(const char*); virtual Style* parent() const; virtual void append(Style*); virtual void remove(Style*); virtual long children() const; virtual Style* child(long) const; virtual void attribute(const String& name, const String& value, int = 0); virtual void remove_attribute(const String& name); virtual long attribute_count() const; virtual boolean attribute(long, String& name, String& value) const; void attribute(const char* name, const char* value, int = 0); void remove_attribute(const char*); virtual void load_file(const String& filename, int = 0); virtual void load_list(const String&, int = 0); virtual void load_property(const String&, int = 0); virtual void add_trigger(const String& name, Action*); virtual void remove_trigger(const String& name, Action* = nil); virtual void add_trigger_any(Action*); virtual void remove_trigger_any(Action*); void add_trigger(const char*, Action*); void remove_trigger(const char*, Action* = nil); virtual boolean find_attribute(const String& name, String& value) const; boolean find_attribute(const char* name, String& value) const; boolean find_attribute(const String& name, long&) const; boolean find_attribute(const char* name, long&) const; boolean find_attribute(const String& name, double&) const; boolean find_attribute(const char* name, double&) const; boolean find_attribute(const String& name, Coord&) const; boolean find_attribute(const char* name, Coord&) const; boolean value_is_on(const String& name) const; boolean value_is_on(const char* name) const; private: friend class StyleRep; StyleRep* rep_; private: /* not implemented */ Style& operator =(const Style&); }; #include #endif ivtools-1.2.11a1/src/include/InterViews/superpose.h000066400000000000000000000033761214471147700222450ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Superpose - composite layout */ #ifndef iv_superpose_h #define iv_superpose_h #include class Superpose : public Layout { public: Superpose( Layout*, Layout*, Layout* = nil, Layout* = nil, Layout* = nil ); virtual ~Superpose(); virtual void request( GlyphIndex count, const Requisition*, Requisition& result ); virtual void allocate( const Allocation& given, GlyphIndex count, const Requisition*, Allocation* result ); private: Layout** layout_; int count_; }; #endif ivtools-1.2.11a1/src/include/InterViews/target.h000066400000000000000000000032671214471147700215050ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Target - pick sensitivity control */ #ifndef iv_target_h #define iv_target_h #include enum TargetSensitivity { TargetNeverHit, TargetAlwaysHit, TargetPrimitiveHit, TargetCharacterHit, TargetBodyHit }; class Target : public MonoGlyph { public: Target(Glyph* body, TargetSensitivity); virtual ~Target(); virtual void pick(Canvas*, const Allocation&, int depth, Hit&); private: TargetSensitivity sensitivity_; }; #endif ivtools-1.2.11a1/src/include/InterViews/telltale.h000066400000000000000000000071521214471147700220220ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Telltale - glyph with a state that may affect appearance */ #ifndef ivlook_telltale_h #define ivlook_telltale_h #include #include class TelltaleGroup; typedef unsigned int TelltaleFlags; class TelltaleState : public Resource, public Observable { public: TelltaleState(const TelltaleFlags = 0); virtual ~TelltaleState(); enum { is_enabled = 0x1, is_visible = 0x2, is_enabled_visible = 0x3, is_active = 0x4, is_enabled_active = 0x5, is_visible_active = 0x6, is_enabled_visible_active = 0x7, is_chosen = 0x8, is_enabled_chosen = 0x9, is_visible_chosen = 0xa, is_enabled_visible_chosen = 0xb, is_active_chosen = 0xc, is_enabled_active_chosen = 0xd, is_visible_active_chosen = 0xe, is_enabled_visible_active_chosen = 0xf, is_running = 0x10, is_choosable = 0x20, is_toggle = 0x40, max_flags = 0x80 }; TelltaleFlags flags() const; TelltaleGroup* group() const; virtual void set(const TelltaleFlags, boolean); virtual boolean test(const TelltaleFlags) const; virtual void join(TelltaleGroup*); virtual void leave_group(); private: TelltaleFlags flags_; TelltaleGroup* group_; }; inline TelltaleFlags TelltaleState::flags() const { return flags_; } inline TelltaleGroup* TelltaleState::group() const { return group_; } class Telltale : public MonoGlyph, public Observer { protected: Telltale(Glyph*, TelltaleState* = nil); public: virtual ~Telltale(); virtual void state(TelltaleState*); virtual TelltaleState* state() const; virtual void disconnect(Observable*); private: TelltaleState* state_; /* backward compatibility */ public: void highlight(boolean); boolean highlighted() const; void choose(boolean); boolean chosen() const; void enable(boolean); boolean enabled() const; }; #define Telltale_access(writer,reader,flag) \ inline void Telltale::writer(boolean b) { state()->set(flag, b); } \ inline boolean Telltale::reader() const { return state()->test(flag); } Telltale_access(highlight,highlighted,TelltaleState::is_active) Telltale_access(choose,chosen,TelltaleState::is_chosen) Telltale_access(enable,enabled,TelltaleState::is_enabled) class TelltaleGroup : public Resource { public: TelltaleGroup(); virtual ~TelltaleGroup(); virtual void update(TelltaleState*); virtual void remove(TelltaleState*); private: TelltaleState* current_; }; #endif ivtools-1.2.11a1/src/include/InterViews/texcomp.h000066400000000000000000000032751214471147700216750ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_texcomp_h #define iv_texcomp_h #include class TeXCompositor : public Compositor { public: TeXCompositor(int penalty); virtual ~TeXCompositor(); virtual CompositorIndex compose( Coord* natural, Coord* stretch, Coord* shrink, int* penalites, CompositorIndex component_count, Coord* spans, CompositorIndex span_count, CompositorIndex* breaks, CompositorIndex break_count ); private: int penalty_; }; #endif ivtools-1.2.11a1/src/include/InterViews/tformsetter.h000066400000000000000000000046561214471147700226000ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_tformsetter_h #define iv_tformsetter_h #include #include class TransformSetter : public MonoGlyph { public: TransformSetter(Glyph*); TransformSetter(Glyph*, const Transformer&); virtual ~TransformSetter(); virtual const Transformer& transformer() const; virtual Transformer& transformer(); virtual void transformer(const Transformer&); virtual void request(Requisition&) const; virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void print(Printer*, const Allocation&) const; virtual void pick(Canvas*, const Allocation&, int depth, Hit&); protected: virtual void transform( Transformer&, const Allocation&, const Allocation& natural ) const; private: Transformer transformer_; Allocation natural_allocation_; void push_transform( Canvas*, const Allocation&, const Allocation& natural ) const; }; class TransformFitter : public TransformSetter { public: TransformFitter(Glyph*); virtual ~TransformFitter(); protected: virtual void transform( Transformer&, const Allocation&, const Allocation& natural ) const; }; #endif ivtools-1.2.11a1/src/include/InterViews/tiff.h000066400000000000000000000027421214471147700211440ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF to Raster conversion */ #ifndef iv_tiff_h #define iv_tiff_h #include #include class Raster; class TIFFRaster { public: static Raster* load(const char* filename, boolean make_gray = false); }; #include #endif ivtools-1.2.11a1/src/include/InterViews/tile.h000066400000000000000000000056431214471147700211540ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Tile - tiled layout */ #ifndef iv_tile_h #define iv_tile_h #include class Tile : public Layout { public: Tile(DimensionName); virtual ~Tile(); virtual void request( GlyphIndex count, const Requisition*, Requisition& result ); virtual void allocate( const Allocation& given, GlyphIndex count, const Requisition*, Allocation* result ); private: DimensionName dimension_; Requisition requisition_; }; class TileReversed : public Layout { public: TileReversed(DimensionName); virtual ~TileReversed(); virtual void request( GlyphIndex count, const Requisition*, Requisition& result ); virtual void allocate( const Allocation& given, GlyphIndex count, const Requisition*, Allocation* result ); private: DimensionName dimension_; Requisition requisition_; }; class TileFirstAligned : public Layout { public: TileFirstAligned(DimensionName); virtual ~TileFirstAligned(); virtual void request( GlyphIndex count, const Requisition*, Requisition& result ); virtual void allocate( const Allocation& given, GlyphIndex count, const Requisition*, Allocation* result ); private: DimensionName dimension_; Requisition requisition_; }; class TileReversedFirstAligned : public Layout { public: TileReversedFirstAligned(DimensionName); virtual ~TileReversedFirstAligned(); virtual void request( GlyphIndex count, const Requisition*, Requisition& result ); virtual void allocate( const Allocation& given, GlyphIndex count, const Requisition*, Allocation* result ); private: DimensionName dimension_; Requisition requisition_; }; #endif ivtools-1.2.11a1/src/include/InterViews/transformer.h000066400000000000000000000146621214471147700225620ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Interface to transformation matrices. */ #ifndef iv_transformer_h #define iv_transformer_h #if defined(PSTOEDIT) typedef IntCoord int; #else #include #include #include #endif //: a 3x2 matrix for use in translating 2d coordinates. // in reference manual //

    man page class Transformer #if !defined(PSTOEDIT) : public Resource #endif { public: Transformer(); /* identity */ Transformer(const Transformer&); Transformer(const Transformer*); Transformer( float a00, float a01, float a10, float a11, float a20, float a21 ); virtual ~Transformer(); boolean identity() const; boolean invertible() const; boolean operator ==(const Transformer&) const; boolean operator !=(const Transformer&) const; Transformer& operator =(const Transformer&); virtual void premultiply(const Transformer&); virtual void postmultiply(const Transformer&); virtual void invert(); virtual void translate(float dx, float dy); virtual void scale(float sx, float sy); virtual void rotate(float angle); virtual void skew(float sx, float sy); virtual void transform(float& x, float& y) const; virtual void transform(float x, float y, float& tx, float& ty) const; virtual void inverse_transform(float& tx, float& ty) const; virtual void inverse_transform( float tx, float ty, float& x, float& y ) const; float det() const; virtual void matrix( float& a00, float& a01, float& a10, float& a11, float& a20, float& a21 ) const; void flipx() {mat00 *= -1.0;} void flipy() {mat11 *= -1.0;} boolean xflipped(float = 1e-6) const; boolean yflipped(float = 1e-6) const; private: boolean identity_; float mat00, mat01, mat10, mat11, mat20, mat21; void update(); public: /* * Old definitions for backward compatibility. */ void GetEntries( float& a00, float& a01, float& a10, float& a11, float& a20, float& a21 ) const; void Premultiply(Transformer* t); void Postmultiply(Transformer* t); void Invert(); void Translate(float dx, float dy); void Scale(float sx, float sy); void Rotate(float angle); boolean Translated(float = 1e-6) const; boolean Scaled(float = 1e-6) const; boolean Stretched (float = 1e-6) const; boolean Rotated(float = 1e-6) const; boolean Rotated90(float = 1e-6) const; void Transform(IntCoord& x, IntCoord& y) const; void Transform(IntCoord x, IntCoord y, IntCoord& tx, IntCoord& ty) const; void Transform(float x, float y, float& tx, float& ty) const; void TransformList(IntCoord x[], IntCoord y[], int n) const; void TransformList( IntCoord x[], IntCoord y[], int n, IntCoord tx[], IntCoord ty[] ) const; void TransformRect(IntCoord&, IntCoord&, IntCoord&, IntCoord&) const; void TransformRect(float&, float&, float&, float&) const; void InvTransform(IntCoord& tx, IntCoord& ty) const; void InvTransform( IntCoord tx, IntCoord ty, IntCoord& x, IntCoord& y ) const; void InvTransform(float tx, float ty, float& x, float& y) const; void InvTransformList(IntCoord tx[], IntCoord ty[], int n) const; void InvTransformList( IntCoord tx[], IntCoord ty[], int n, IntCoord x[], IntCoord y[] ) const; void InvTransformRect(IntCoord&, IntCoord&, IntCoord&, IntCoord&) const; void InvTransformRect(float&, float&, float&, float&) const; }; inline float Transformer::det() const { return mat00*mat11 - mat01*mat10; } inline boolean Transformer::identity() const { return identity_; } inline boolean Transformer::invertible() const { return det() != 0; } inline boolean Transformer::Translated(float tol) const { return -tol > mat20 || mat20 > tol || -tol > mat21 || mat21 > tol; } inline boolean Transformer::Scaled(float tol) const { float l = 1 - tol, u = 1 + tol; return l > mat00 || mat00 > u || l > mat11 || mat11 > u; } inline boolean Transformer::Stretched(float tol) const { float diff = mat00 - mat11; return -tol > diff || diff > tol; } inline boolean Transformer::Rotated(float tol) const { return -tol > mat01 || mat01 > tol || -tol > mat10 || mat10 > tol; } inline boolean Transformer::Rotated90(float tol) const { return Rotated(tol) && -tol <= mat00 && mat00 <= tol && -tol <= mat11 && mat11 <= tol; } inline boolean Transformer::xflipped(float tol) const { return Rotated90(tol) ? mat10 > 0.0 : mat00 < 0.0; } inline boolean Transformer::yflipped(float tol) const { return Rotated90(tol) ? mat01 < 0.0 : mat11 < 0.0; } inline void Transformer::GetEntries( float& a00, float& a01, float& a10, float& a11, float& a20, float& a21 ) const { matrix(a00, a01, a10, a11, a20, a21); } inline void Transformer::Translate(float dx, float dy) { translate(dx, dy); } inline void Transformer::Scale(float sx, float sy) { scale(sx, sy); } inline void Transformer::Rotate(float angle) { rotate(angle); } inline void Transformer::Premultiply(Transformer* t) { premultiply(*t); } inline void Transformer::Postmultiply(Transformer* t) { postmultiply(*t); } inline void Transformer::Invert() { invert(); } #if !defined(PSTOEDIT) #include #endif #endif ivtools-1.2.11a1/src/include/InterViews/window.h000066400000000000000000000122001214471147700215110ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Window - top-level object for interfacing with window managers */ #ifndef iv_window_h #define iv_window_h #include #include #include class Bitmap; class Canvas; class Cursor; class Display; class Event; class Glyph; class Handler; class ManagedWindowRep; class String; class Style; class WindowRep; //: object that can be mapped onto a screen. // in reference manual. class Window { protected: Window(Glyph*); public: virtual ~Window(); virtual Glyph* glyph() const; virtual void style(Style*); Style* style() const; virtual void display(Display*); virtual Display* display() const; virtual Canvas* canvas() const; virtual void cursor(Cursor*); virtual Cursor* cursor() const; virtual void push_cursor(); virtual void pop_cursor(); virtual void place(Coord left, Coord bottom); virtual void pplace(IntCoord left, IntCoord bottom); virtual void align(float x, float y); virtual Coord left() const; virtual Coord bottom() const; virtual Coord width() const; virtual Coord height() const; virtual void map(); virtual void unmap(); virtual boolean is_mapped() const; virtual void bind(); virtual void unbind(); virtual boolean bound() const; virtual void raise(); virtual void lower(); virtual void move(Coord left, Coord bottom); virtual void resize(); virtual void receive(const Event&); virtual Handler* target(const Event&) const; virtual void grab_pointer(Cursor* = nil) const; virtual void ungrab_pointer() const; virtual void repair(); virtual void offset_from_toplevel(PixelCoord& dx, PixelCoord& dy); WindowRep* rep() const; protected: Window(WindowRep*); virtual void configure(); virtual void default_geometry(); virtual void compute_geometry(); virtual void set_attributes(); virtual void set_props(); virtual void do_map(); private: friend class WindowRep; WindowRep* rep_; }; inline WindowRep* Window::rep() const { return rep_; } class ManagedWindow : public Window { protected: ManagedWindow(Glyph*); public: virtual ~ManagedWindow(); virtual void icon(ManagedWindow*); virtual ManagedWindow* icon() const; virtual void icon_bitmap(Bitmap*); virtual Bitmap* icon_bitmap() const; virtual void icon_mask(Bitmap*); virtual Bitmap* icon_mask() const; virtual void iconify(); virtual void deiconify(); virtual void focus_event(Handler* in, Handler* out); virtual void wm_delete(Handler*); virtual void resize(); ManagedWindowRep* rep() const; protected: virtual void compute_geometry(); virtual void set_props(); private: ManagedWindowRep* rep_; }; inline ManagedWindowRep* ManagedWindow::rep() const { return rep_; } class ApplicationWindow : public ManagedWindow { public: ApplicationWindow(Glyph*); ApplicationWindow(Glyph*, const char* display); ~ApplicationWindow(); protected: virtual void compute_geometry(); virtual void set_props(); const char* _otherdisplay; }; class TopLevelWindow : public ManagedWindow { public: TopLevelWindow(Glyph*); ~TopLevelWindow(); virtual void group_leader(Window*); virtual Window* group_leader() const; protected: virtual void set_props(); }; class TransientWindow : public TopLevelWindow { public: TransientWindow(Glyph*); ~TransientWindow(); virtual void transient_for(Window*); virtual Window* transient_for() const; protected: virtual void configure(); virtual void set_attributes(); }; class PopupWindow : public Window { public: PopupWindow(Glyph*); ~PopupWindow(); protected: virtual void set_attributes(); }; class IconWindow : public ManagedWindow { public: IconWindow(Glyph*); ~IconWindow(); protected: virtual void do_map(); }; #include #endif ivtools-1.2.11a1/src/include/InterViews/xymarker.h000066400000000000000000000035571214471147700220630ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * XYMarker - mark rectangular region */ #ifndef iv_xymarker_h #define iv_xymarker_h #include class Color; class XYMarker : public MonoGlyph { public: XYMarker(Glyph* body, const Color* overlay, const Color* underlay); virtual ~XYMarker(); void mark(Coord left, Coord bottom, Coord right, Coord top); void unmark(); virtual void allocate(Canvas*, const Allocation&, Extension&); virtual void draw(Canvas*, const Allocation&) const; virtual void undraw(); private: Canvas* canvas_; const Color* overlay_; const Color* underlay_; boolean marked_; Coord left_, right_, top_, bottom_; }; #endif ivtools-1.2.11a1/src/include/Makefile.am000066400000000000000000000161061214471147700177770ustar00rootroot00000000000000nobase_include_HEADERS = InterViews/patch.h InterViews/texcomp.h \ InterViews/superpose.h InterViews/boolean.h InterViews/geometry.h \ InterViews/deck.h InterViews/raster.h InterViews/session.h \ InterViews/tiff.h InterViews/simplecomp.h InterViews/monoglyph.h \ InterViews/iv.h InterViews/style.h InterViews/selection.h \ InterViews/scrbox.h InterViews/_names.h InterViews/tile.h \ InterViews/leave-scope.h InterViews/printer.h InterViews/shadow.h \ InterViews/action.h InterViews/debug.h InterViews/aggr.h \ InterViews/event.h InterViews/psfont.h InterViews/adjust.h \ InterViews/border.h InterViews/drag.h InterViews/rule.h \ InterViews/page.h InterViews/reqerr.h InterViews/character.h \ InterViews/enter-scope.h InterViews/place.h InterViews/tformsetter.h \ InterViews/hit.h InterViews/layout.h InterViews/observe.h \ InterViews/telltale.h InterViews/brush.h InterViews/alloctbl.h \ InterViews/input.h InterViews/xymarker.h InterViews/transformer.h \ InterViews/align.h InterViews/pattern.h InterViews/_undefs.h \ InterViews/_leave.h InterViews/font.h InterViews/dialog.h \ InterViews/label.h InterViews/group.h InterViews/polyglyph.h \ InterViews/regexp.h InterViews/compositor.h InterViews/target.h \ InterViews/glyph.h InterViews/color.h InterViews/composition.h \ InterViews/cursor.h InterViews/box.h InterViews/arraycomp.h \ InterViews/_enter.h InterViews/display.h InterViews/handler.h \ InterViews/glue.h InterViews/_defines.h InterViews/background.h \ InterViews/lrmarker.h InterViews/coord.h InterViews/glcontext.h \ InterViews/stencil.h InterViews/image.h InterViews/resource.h \ InterViews/canvas.h InterViews/window.h InterViews/bitmap.h OS/table.h \ OS/directory.h OS/string.h OS/os.h OS/host.h OS/types.h \ OS/leave-scope.h OS/memory.h OS/enter-scope.h OS/table2.h OS/_undefs.h \ OS/math.h OS/list.h OS/ustring.h OS/_defines.h OS/file.h \ IV-look/browser.h IV-look/smf_kit.h IV-look/ol_dialogs.h \ IV-look/dialogs.h IV-look/bevel.h IV-look/mf_dialogs.h \ IV-look/mono_kit.h IV-look/fbrowser.h IV-look/slider.h \ IV-look/button.h IV-look/stepper.h IV-look/menu.h IV-look/telltale.h \ IV-look/mf_kit.h IV-look/ol_kit.h IV-look/fchooser.h IV-look/field.h \ IV-look/choice.h IV-look/kit.h TIFF/tiff.h TIFF/tiffio.h TIFF/format.h \ Dispatch/iostreamb.h Dispatch/rpcpeer.h Dispatch/dp.h \ Dispatch/rpcwriter.h Dispatch/leave-scope.h Dispatch/iohandler.h \ Dispatch/enter-scope.h Dispatch/_undefs.h Dispatch/rpcstream.h \ Dispatch/iocallback.h Dispatch/rpcbuf.h Dispatch/rpcservice.h \ Dispatch/_defines.h Dispatch/rpcregistry.h Dispatch/rpcreader.h \ Dispatch/rpchdr.h Dispatch/dispatcher.h Unidraw/Graphic/lines.h \ Unidraw/Graphic/polygons.h Unidraw/Graphic/damage.h \ Unidraw/Graphic/rasterrect.h Unidraw/Graphic/ulabel.h \ Unidraw/Graphic/splines.h Unidraw/Graphic/util.h \ Unidraw/Graphic/verts.h Unidraw/Graphic/picture.h \ Unidraw/Graphic/geomobjs.h Unidraw/Graphic/ellipses.h \ Unidraw/Graphic/pspaint.h Unidraw/Graphic/graphic.h \ Unidraw/Graphic/ustencil.h Unidraw/Graphic/grblock.h \ Unidraw/ctrlinfo.h Unidraw/uformat.h Unidraw/Components/grview.h \ Unidraw/Components/pin.h Unidraw/Components/rect.h \ Unidraw/Components/grcomp.h Unidraw/Components/connector.h \ Unidraw/Components/component.h Unidraw/Components/psformat.h \ Unidraw/Components/link.h Unidraw/Components/csolver.h \ Unidraw/Components/line.h Unidraw/Components/text.h \ Unidraw/Components/externview.h Unidraw/Components/psview.h \ Unidraw/Components/slot.h Unidraw/Components/pad.h \ Unidraw/Components/cglue.h Unidraw/Components/polygon.h \ Unidraw/Components/rastercomp.h Unidraw/Components/spline.h \ Unidraw/Components/gvupdater.h Unidraw/Components/vertices.h \ Unidraw/Components/stencilcomp.h Unidraw/Components/ellipse.h \ Unidraw/Components/compview.h Unidraw/statevars.h Unidraw/transfns.h \ Unidraw/selection.h Unidraw/dialogs.h Unidraw/leave-scope.h \ Unidraw/grid.h Unidraw/classes.h Unidraw/iterator.h \ Unidraw/Commands/macro.h Unidraw/Commands/catcmds.h \ Unidraw/Commands/viewcmds.h Unidraw/Commands/brushcmd.h \ Unidraw/Commands/datas.h Unidraw/Commands/edit.h \ Unidraw/Commands/patcmd.h Unidraw/Commands/struct.h \ Unidraw/Commands/nop.h Unidraw/Commands/align.h \ Unidraw/Commands/font.h Unidraw/Commands/transforms.h \ Unidraw/Commands/import.h Unidraw/Commands/dirty.h \ Unidraw/Commands/command.h Unidraw/Commands/data.h \ Unidraw/Commands/colorcmd.h Unidraw/uctrl.h Unidraw/enter-scope.h \ Unidraw/stateview.h Unidraw/ulist.h Unidraw/clipboard.h \ Unidraw/upage.h Unidraw/editor.h Unidraw/Tools/scale.h \ Unidraw/Tools/move.h Unidraw/Tools/connect.h Unidraw/Tools/rotate.h \ Unidraw/Tools/stretch.h Unidraw/Tools/select.h \ Unidraw/Tools/grcomptool.h Unidraw/Tools/reshape.h \ Unidraw/Tools/magnify.h Unidraw/Tools/tool.h Unidraw/_undefs.h \ Unidraw/statevar.h Unidraw/path.h Unidraw/manips.h Unidraw/uctrls.h \ Unidraw/uarray.h Unidraw/transfn.h Unidraw/viewer.h Unidraw/manip.h \ Unidraw/unidraw.h Unidraw/keymap.h Unidraw/kybd.h Unidraw/catalog.h \ Unidraw/creator.h Unidraw/umap.h Unidraw/_defines.h \ Unidraw/stateviews.h Unidraw/uhash.h Unidraw/editorinfo.h \ Unidraw/globals.h IV-2_6/InterViews/shape.h \ IV-2_6/InterViews/streditor.h IV-2_6/InterViews/rubcurve.h \ IV-2_6/InterViews/textdisplay.h IV-2_6/InterViews/viewport.h \ IV-2_6/InterViews/filechooser.h IV-2_6/InterViews/scroller.h \ IV-2_6/InterViews/deck.h IV-2_6/InterViews/rubline.h \ IV-2_6/InterViews/rubgroup.h IV-2_6/InterViews/textstyle.h \ IV-2_6/InterViews/textbuffer.h IV-2_6/InterViews/iwindow.h \ IV-2_6/InterViews/rubverts.h IV-2_6/InterViews/panner.h \ IV-2_6/InterViews/strbrowser.h IV-2_6/InterViews/banner.h \ IV-2_6/InterViews/alignment.h IV-2_6/InterViews/sensor.h \ IV-2_6/InterViews/button.h IV-2_6/InterViews/border.h \ IV-2_6/InterViews/message.h IV-2_6/InterViews/world.h \ IV-2_6/InterViews/frame.h IV-2_6/InterViews/matcheditor.h \ IV-2_6/InterViews/menu.h IV-2_6/InterViews/defs.h \ IV-2_6/InterViews/compeditor.h IV-2_6/InterViews/perspective.h \ IV-2_6/InterViews/scrollbar.h IV-2_6/InterViews/filebrowser.h \ IV-2_6/InterViews/minmax.h IV-2_6/InterViews/texteditor.h \ IV-2_6/InterViews/rubrect.h IV-2_6/InterViews/dialog.h \ IV-2_6/InterViews/subject.h IV-2_6/InterViews/interactor.h \ IV-2_6/InterViews/scene.h IV-2_6/InterViews/box.h \ IV-2_6/InterViews/strchooser.h IV-2_6/InterViews/ihandler.h \ IV-2_6/InterViews/adjuster.h IV-2_6/InterViews/tray.h \ IV-2_6/InterViews/paint.h IV-2_6/InterViews/glue.h \ IV-2_6/InterViews/control.h IV-2_6/InterViews/painter.h \ IV-2_6/InterViews/rubband.h IV-2_6/_names.h IV-2_6/_leave.h \ IV-2_6/_enter.h IV-X11/xdisplay.h IV-X11/xcanvas.h IV-X11/xcolor.h \ IV-X11/Xdefs.h IV-X11/Xext.h IV-X11/xpainter.h IV-X11/xbrush.h \ IV-X11/Xundefs.h IV-X11/xevent.h IV-X11/xpattern.h IV-X11/xwindow.h \ IV-X11/xraster.h IV-X11/xdrag.h IV-X11/xfont.h IV-X11/xcursor.h \ IV-X11/Xlib.h IV-X11/xbitmap.h IV-X11/xselection.h IV-X11/Xutil.h \ ivstd/iosfwd ivstd/signal.h ivstd/string.h ivstd/leakchecker.h \ ivstd/version.h ivstd/malloc.h ivstd/stdio.h ivstd/math.h ivstd/nan.h \ ivstd/iostream.h ivstd/fstream.h ivstd/osfcn.h ivstd/stdlib.h \ ivstd/stream.h ivtools-1.2.11a1/src/include/OS/000077500000000000000000000000001214471147700162605ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/OS/_defines.h000066400000000000000000000016461214471147700202140ustar00rootroot00000000000000#undef boolean #undef true #undef false #define boolean _lib_os(boolean) #define true _lib_os(true) #define false _lib_os(false) #define u_char _lib_os(u_char) #define CopyString _lib_os(CopyString) #define Directory _lib_os(Directory) #define DirectoryImpl _lib_os(DirectoryImpl) #define File _lib_os(File) #define FileInfo _lib_os(FileInfo) #define Host _lib_os(Host) #define InputFile _lib_os(InputFile) #define List _lib_os(List) #define Math _lib_os(Math) #define Memory _lib_os(Memory) #define NullTerminatedString _lib_os(NullTerminatedString) #define OutputFile _lib_os(OutputFile) #define PtrList _lib_os(PtrList) #define StdInput _lib_os(StdInput) #define StdOutput _lib_os(StdOutput) #define String _lib_os(String) #define Table _lib_os(Table) #define Table2 _lib_os(Table2) #define UniqueString _lib_os(UniqueString) #define UniqueStringPool _lib_os(UniqueStringPool) #define UniqueStringTable _lib_os(UniqueStringTable) ivtools-1.2.11a1/src/include/OS/_undefs.h000066400000000000000000000006311214471147700200540ustar00rootroot00000000000000#undef boolean #undef true #undef false #undef u_char #undef CopyString #undef Directory #undef DirectoryImpl #undef File #undef FileInfo #undef Host #undef InputFile #undef List #undef Math #undef Memory #undef NullTerminatedString #undef OutputFile #undef PtrList #undef StdInput #undef StdOutput #undef String #undef Table #undef Table2 #undef UniqueString #undef UniqueStringPool #undef UniqueStringTable ivtools-1.2.11a1/src/include/OS/directory.h000066400000000000000000000036731214471147700204460ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef os_directory_h #define os_directory_h #include class DirectoryImpl; class String; class Directory { protected: Directory(); public: virtual ~Directory(); static Directory* current(); static Directory* open(const String&); virtual void close(); virtual const String* path() const; virtual int count() const; virtual const String* name(int index) const; virtual int index(const String&) const; virtual boolean is_directory(int index) const; static String* canonical(const String&); static boolean match(const String& name, const String& pattern); private: DirectoryImpl* impl_; private: /* not allowed */ Directory(const Directory&); void operator =(const Directory&); }; #endif ivtools-1.2.11a1/src/include/OS/enter-scope.h000066400000000000000000000032331214471147700206560ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef iv_os__scope_h #define iv_os__scope_h #include #undef boolean #undef String #undef u_char #include #ifndef nil #define nil 0 #endif #if !defined(iv_os_boolean) && !defined(os_boolean) #define iv_os_boolean #define os_boolean os_bool typedef unsigned boolean; static const unsigned false = 0; static const unsigned true = 1; #endif #ifndef iv_os_u_char #define iv_os_u_char typedef unsigned char u_char; #endif #endif ivtools-1.2.11a1/src/include/OS/file.h000066400000000000000000000037601214471147700173560ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef os_file_h #define os_file_h #include class FileInfo; class String; class File { protected: File(FileInfo*); public: virtual ~File(); virtual const String* name() const; virtual long length() const; virtual void close(); virtual void limit(unsigned int buffersize); protected: FileInfo* rep() const; private: FileInfo* rep_; private: /* not allowed */ void operator =(const File&); }; class InputFile : public File { protected: InputFile(FileInfo*); public: virtual ~InputFile(); static InputFile* open(const String& name); virtual int read(const char*& start); }; class StdInput : public InputFile { public: StdInput(); virtual ~StdInput(); virtual long length() const; virtual int read(const char*& start); }; #endif ivtools-1.2.11a1/src/include/OS/host.h000066400000000000000000000025321214471147700174100ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef os_host_h #define os_host_h #include class Host { public: static const char* name(); private: static char name_[100]; }; #endif ivtools-1.2.11a1/src/include/OS/leave-scope.h000066400000000000000000000024311214471147700206340ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifdef iv_os__scope_h #undef iv_os__scope_h #include #endif ivtools-1.2.11a1/src/include/OS/list.h000066400000000000000000000210651214471147700174100ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Generic list implemented as dynamic array */ #ifndef os_list_h #define os_list_h #include extern void ListImpl_range_error(long index); extern long ListImpl_best_new_count(long count, unsigned size); #if defined(__STDC__) || defined(__ANSI_CPP__) #define __ListItr(List) List##_Iterator #define ListItr(List) __ListItr(List) #define __ListUpdater(List) List##_Updater #define ListUpdater(List) __ListUpdater(List) #else #define __ListItr(List) List/**/_Iterator #define ListItr(List) __ListItr(List) #define __ListUpdater(List) List/**/_Updater #define ListUpdater(List) __ListUpdater(List) #endif #define declareList(List,T) \ class List { \ public: \ List(long size = 0); \ ~List(); \ \ long count() const; \ T item(long index) const; \ T& item_ref(long index) const; \ \ void prepend(const T&); \ void append(const T&); \ void insert(long index, const T&); \ void remove(long index); \ void remove_all(); \ private: \ T* items_; \ long size_; \ long count_; \ long free_; \ }; \ \ inline long List::count() const { return count_; } \ \ inline T List::item(long index) const { \ if (index < 0 || index >= count_) { \ ListImpl_range_error(index); \ } \ long i = index < free_ ? index : index + size_ - count_; \ return items_[i]; \ } \ inline T& List::item_ref(long index) const { \ if (index < 0 || index >= count_) { \ ListImpl_range_error(index); \ } \ long i = index < free_ ? index : index + size_ - count_; \ return items_[i]; \ } \ \ inline void List::append(const T& item) { insert(count_, item); } \ inline void List::prepend(const T& item) { insert(0, item); } \ \ class ListItr(List) { \ public: \ ListItr(List)(const List&); \ \ boolean more() const; \ T cur() const; \ T& cur_ref() const; \ void next(); \ private: \ const List* list_; \ long cur_; \ }; \ \ inline boolean ListItr(List)::more() const { return cur_ < list_->count(); } \ inline T ListItr(List)::cur() const { return list_->item(cur_); } \ inline T& ListItr(List)::cur_ref() const { \ return list_->item_ref(cur_); \ } \ inline void ListItr(List)::next() { ++cur_; } \ \ class ListUpdater(List) { \ public: \ ListUpdater(List)(List&); \ \ boolean more() const; \ T cur() const; \ T& cur_ref() const; \ void remove_cur(); \ void next(); \ private: \ List* list_; \ long cur_; \ }; \ \ inline boolean ListUpdater(List)::more() const { \ return cur_ < list_->count(); \ } \ inline T ListUpdater(List)::cur() const { return list_->item(cur_); } \ inline T& ListUpdater(List)::cur_ref() const { \ return list_->item_ref(cur_); \ } \ inline void ListUpdater(List)::remove_cur() { list_->remove(cur_); } \ inline void ListUpdater(List)::next() { ++cur_; } /* * Lists of pointers * * Don't ask me to explain the AnyPtr nonsense. C++ compilers * have a hard time deciding between (const void*)& and const (void*&). * Typedefs help, though still keep me guessing. */ typedef void* __AnyPtr; declareList(__AnyPtrList,__AnyPtr) #define declarePtrList(PtrList,T) \ class PtrList { \ public: \ PtrList(long size = 0); \ \ long count() const; \ T* item(long index) const; \ \ void prepend(T*); \ void append(T*); \ void insert(long index, T*); \ void remove(long index); \ void remove_all(); \ private: \ __AnyPtrList impl_; \ }; \ \ inline PtrList::PtrList(long size) : impl_(size) { } \ inline long PtrList::count() const { return impl_.count(); } \ inline T* PtrList::item(long index) const { return (T*)impl_.item(index); } \ inline void PtrList::append(T* item) { insert(impl_.count(), item); } \ inline void PtrList::prepend(T* item) { insert(0, item); } \ inline void PtrList::remove(long index) { impl_.remove(index); } \ inline void PtrList::remove_all() { impl_.remove_all(); } \ \ class ListItr(PtrList) { \ public: \ ListItr(PtrList)(const PtrList&); \ \ boolean more() const; \ T* cur() const; \ void next(); \ private: \ const PtrList* list_; \ long cur_; \ }; \ \ inline boolean ListItr(PtrList)::more() const { \ return cur_ < list_->count(); \ } \ inline T* ListItr(PtrList)::cur() const { return list_->item(cur_); } \ inline void ListItr(PtrList)::next() { ++cur_; } \ \ class ListUpdater(PtrList) { \ public: \ ListUpdater(PtrList)(PtrList&); \ \ boolean more() const; \ T* cur() const; \ void remove_cur(); \ void next(); \ private: \ PtrList* list_; \ long cur_; \ }; \ \ inline boolean ListUpdater(PtrList)::more() const { \ return cur_ < list_->count(); \ } \ inline T* ListUpdater(PtrList)::cur() const { return list_->item(cur_); } \ inline void ListUpdater(PtrList)::remove_cur() { list_->remove(cur_); } \ inline void ListUpdater(PtrList)::next() { ++cur_; } /* * List implementation */ #define implementList(List,T) \ List::List(long size) { \ if (size > 0) { \ size_ = ListImpl_best_new_count(size, sizeof(T)); \ items_ = new T[size_]; \ } else { \ size_ = 0; \ items_ = 0; \ } \ count_ = 0; \ free_ = 0; \ } \ \ List::~List() { \ delete [] items_; \ } \ \ void List::insert(long index, const T& item) { \ if (count_ == size_) { \ long size = ListImpl_best_new_count(size_ + 1, sizeof(T)); \ T* items = new T[size]; \ if (items_ != 0) { \ register long i; \ for (i = 0; i < free_; ++i) { \ items[i] = items_[i]; \ } \ for (i = 0; i < count_ - free_; ++i) { \ items[free_ + size - count_ + i] = \ items_[free_ + size_ - count_ + i]; \ } \ delete [] items_; \ } \ items_ = items; \ size_ = size; \ } \ if (index >= 0 && index <= count_) { \ if (index < free_) { \ for (register long i = free_ - index - 1; i >= 0; --i) { \ items_[index + size_ - count_ + i] = items_[index + i]; \ } \ } else if (index > free_) { \ for (register long i = 0; i < index - free_; ++i) { \ items_[free_ + i] = items_[free_ + size_ - count_ + i]; \ } \ } \ free_ = index + 1; \ count_ += 1; \ items_[index] = item; \ } \ } \ \ void List::remove(long index) { \ if (index >= 0 && index <= count_) { \ if (index < free_) { \ for (register long i = free_ - index - 2; i >= 0; --i) { \ items_[size_ - count_ + index + 1 + i] = \ items_[index + 1 + i]; \ } \ } else if (index > free_) { \ for (register long i = 0; i < index - free_; ++i) { \ items_[free_ + i] = items_[free_ + size_ - count_ + i]; \ } \ } \ free_ = index; \ count_ -= 1; \ } \ } \ \ void List::remove_all() { \ count_ = 0; \ free_ = 0; \ } \ \ ListItr(List)::ListItr(List)(const List& list) { \ list_ = &list; \ cur_ = 0; \ } \ \ ListUpdater(List)::ListUpdater(List)(List& list) { \ list_ = &list; \ cur_ = 0; \ } #define implementPtrList(PtrList,T) \ void PtrList::insert(long index, T* item) { \ const __AnyPtr p = item; \ impl_.insert(index, p); \ } \ ListItr(PtrList)::ListItr(PtrList)(const PtrList& list) { \ list_ = &list; \ cur_ = 0; \ } \ \ ListUpdater(PtrList)::ListUpdater(PtrList)(PtrList& list) { \ list_ = &list; \ cur_ = 0; \ } #endif ivtools-1.2.11a1/src/include/OS/math.h000066400000000000000000000065211214471147700173660ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef os_math_h #define os_math_h #include /* * Common math operations on built-in types. */ #undef min #undef max #define declare_binary_minmax(Type) \ static Type min(Type a, Type b); \ static Type max(Type a, Type b) #define implement_binary_minmax(Type) \ inline Type Math::min(Type a, Type b) { return a < b ? a : b; } \ inline Type Math::max(Type a, Type b) { return a > b ? a : b; } #define declare_4_minmax(Type) \ static Type min(Type a, Type b, Type c, Type d); \ static Type max(Type a, Type b, Type c, Type d) /* * Compiler isn't smart enough to figure out how to do a 4-way min inline * with single nested if-then-else. */ #define implement_4_minmax(Type) \ inline Type Math::min(Type a, Type b, Type c, Type d) { \ Type r1 = min(a, b), r2 = min(c, d); \ return min(r1, r2); \ } \ \ inline Type Math::max(Type a, Type b, Type c, Type d) { \ Type r1 = max(a, b), r2 = max(c, d); \ return max(r1, r2); \ } class Math { public: declare_binary_minmax(int); declare_binary_minmax(unsigned); declare_binary_minmax(long); declare_binary_minmax(unsigned long); declare_binary_minmax(float); declare_binary_minmax(double); declare_4_minmax(int); declare_4_minmax(float); declare_4_minmax(double); static int abs(int); static long abs(long); static double abs(double); static int round(float); static int round(double); static boolean equal(float x, float y, float e); static boolean equal(double x, double y, double e); }; implement_binary_minmax(int) implement_binary_minmax(unsigned) implement_binary_minmax(long) implement_binary_minmax(unsigned long) implement_binary_minmax(float) implement_binary_minmax(double) implement_4_minmax(int) implement_4_minmax(float) implement_4_minmax(double) inline int Math::round(float x) { return x > 0 ? int(x+0.5) : -int(-x+0.5); } inline int Math::round(double x) { return x > 0 ? int(x+0.5) : -int(-x+0.5); } inline boolean Math::equal(float x, float y, float e) { return x - y < e && y - x < e; } inline boolean Math::equal(double x, double y, double e) { return x - y < e && y - x < e; } #endif ivtools-1.2.11a1/src/include/OS/memory.h000066400000000000000000000027341214471147700177470ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef os_memory_h #define os_memory_h #include class Memory { public: static void copy(const void* from, void* to, unsigned int nbytes); static int compare(const void*, const void*, unsigned int nbytes); static void zero(void*, unsigned int nbytes); }; #endif ivtools-1.2.11a1/src/include/OS/os.h000066400000000000000000000025351214471147700170570ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _lib_os_h #define _lib_os_h #if defined(__STDC__) || defined(__ANSI_CPP__) #define _lib_os(name) os##name #else #define _lib_os(name) os/**/name #endif #endif ivtools-1.2.11a1/src/include/OS/string.h000066400000000000000000000124111214471147700177360ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport Inc. * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef os_string_h #define os_string_h /* * String - simple (non-copying) string class */ #include #include class String { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif String(); String(const char*); String(const char*, int length); String(const String&); virtual ~String(); const char* string() const; int length() const; virtual unsigned long hash() const; virtual String& operator =(const String&); virtual String& operator =(const char*); virtual boolean operator ==(const String&) const; virtual boolean operator ==(const char*) const; virtual boolean operator !=(const String&) const; virtual boolean operator !=(const char*) const; virtual boolean operator >(const String&) const; virtual boolean operator >(const char*) const; virtual boolean operator >=(const String&) const; virtual boolean operator >=(const char*) const; virtual boolean operator <(const String&) const; virtual boolean operator <(const char*) const; virtual boolean operator <=(const String&) const; virtual boolean operator <=(const char*) const; virtual boolean case_insensitive_equal(const String&) const; virtual boolean case_insensitive_equal(const char*) const; u_char operator [](int index) const; virtual String substr(int start, int length) const; String left(int length) const; String right(int start) const; virtual void set_to_substr(int start, int length); void set_to_left(int length); void set_to_right(int start); virtual int search(int start, u_char) const; int index(u_char) const; int rindex(u_char) const; virtual boolean convert(int&) const; virtual boolean convert(long&) const; virtual boolean convert(float&) const; virtual boolean convert(double&) const; virtual boolean null_terminated() const; virtual boolean contains(const char*, int start=0) const; String before(const char*) const; String from(const char*) const; int freq(const char* t) const; operator const char*() const; friend ostream& operator << (ostream& s, const String&); protected: virtual void set_value(const char*); virtual void set_value(const char*, int); private: const char* data_; int length_; }; class CopyString : public String { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif CopyString(); CopyString(const char*); CopyString(const char*, int length); CopyString(const String&); CopyString(const CopyString&); virtual ~CopyString(); virtual String& operator =(const String&); virtual String& operator =(const char*); virtual boolean null_terminated() const; protected: virtual void set_value(const char*); virtual void set_value(const char*, int); private: void free(); }; class NullTerminatedString : public String { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif NullTerminatedString(); NullTerminatedString(const String&); NullTerminatedString(const NullTerminatedString&); virtual ~NullTerminatedString(); virtual String& operator =(const String&); virtual String& operator =(const char*); virtual boolean null_terminated() const; private: boolean allocated_; void assign(const String&); void free(); }; inline const char* String::string() const { return data_; } inline int String::length() const { return length_; } inline u_char String::operator [](int index) const { return ((u_char*)data_)[index]; } inline String String::left(int length) const { return substr(0, length); } inline String String::right(int start) const { return substr(start, -1); } inline void String::set_to_left(int length) { set_to_substr(0, length); } inline void String::set_to_right(int start) { set_to_substr(start, -1); } inline int String::index(u_char c) const { return search(0, c); } inline int String::rindex(u_char c) const { return search(-1, c); } extern char* strnew(const char*); /* return a copy of the given string */ #endif ivtools-1.2.11a1/src/include/OS/strtable.h000066400000000000000000000147371214471147700202650ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * Copyright (c) 2010 Wave Semiconductor Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * String to object association table. */ #ifndef os_strtable_h #define os_strtable_h #include #if defined(__STDC__) || defined(__ANSI_CPP__) #define __StrTableEntry(StrTable) StrTable##_Entry #define StrTableEntry(StrTable) __StrTableEntry(StrTable) #define __StrTableIterator(StrTable) StrTable##_Iterator #define StrTableIterator(StrTable) __StrTableIterator(StrTable) #else #define __StrTableEntry(StrTable) StrTable/**/_Entry #define StrTableEntry(StrTable) __StrTableEntry(StrTable) #define __StrTableIterator(StrTable) StrTable/**/_Iterator #define StrTableIterator(StrTable) __StrTableIterator(StrTable) #endif #define declareStrTable(StrTable,Value) \ struct StrTableEntry(StrTable); \ \ class StrTable { \ public: \ StrTable(int); \ ~StrTable(); \ \ void insert(const char*, Value); \ boolean find(Value&, const char*); \ boolean find_and_remove(Value&, const char*); \ void remove(const char*); \ private: \ friend class StrTableIterator(StrTable); \ \ int size_; \ StrTableEntry(StrTable)** first_; \ StrTableEntry(StrTable)** last_; \ \ StrTableEntry(StrTable)*& probe(const char*); \ }; \ \ struct StrTableEntry(StrTable) { \ private: \ friend class StrTable; \ friend class StrTableIterator(StrTable); \ \ const char* key_; \ Value value_; \ StrTableEntry(StrTable)* chain_; \ }; \ \ class StrTableIterator(StrTable) { \ public: \ StrTableIterator(StrTable)(StrTable&); \ \ StrTableEntry(StrTable)* cur_entry(); \ const char*& cur_key(); \ Value& cur_value(); \ boolean more(); \ boolean next(); \ private: \ StrTableEntry(StrTable)* cur_; \ StrTableEntry(StrTable)** entry_; \ StrTableEntry(StrTable)** last_; \ }; \ \ inline StrTableEntry(StrTable)* StrTableIterator(StrTable)::cur_entry() { return cur_; } \ inline const char*& StrTableIterator(StrTable)::cur_key() { return cur_->key_; } \ inline Value& StrTableIterator(StrTable)::cur_value() { return cur_->value_; } \ inline boolean StrTableIterator(StrTable)::more() { return entry_ <= last_; } /* * Predefined hash functions */ inline unsigned long skey_to_hash(const char* str) { int len = strlen(str); int numbytes = sizeof(unsigned long); int maxbytes = numbytes > len ? len : numbytes; unsigned char retval[numbytes]; unsigned long *retvalptr = (unsigned long*)retval; *retvalptr = 0; for(int i=0; ikey_ = k; \ e->value_ = v; \ register StrTableEntry(StrTable)** a = &probe(k); \ e->chain_ = *a; \ *a = e; \ } \ \ boolean StrTable::find(Value& v, const char* k) { \ for (register StrTableEntry(StrTable)* e = probe(k); e != nil; e = e->chain_) { \ if (strcmp(e->key_,k)==0) { \ v = e->value_; \ return true; \ } \ } \ return false; \ } \ \ boolean StrTable::find_and_remove(Value& v, const char* k) { \ StrTableEntry(StrTable)** a = &probe(k); \ register StrTableEntry(StrTable)* e = *a; \ if (e != nil) { \ if (strcmp(e->key_, k)==0) { \ v = e->value_; \ *a = e->chain_; \ delete e; \ return true; \ } else { \ register StrTableEntry(StrTable)* prev; \ do { \ prev = e; \ e = e->chain_; \ } while (e != nil && strcmp(e->key_,k)!=0 ); \ if (e != nil) { \ v = e->value_; \ prev->chain_ = e->chain_; \ delete e; \ return true; \ } \ } \ } \ return false; \ } \ \ void StrTable::remove(const char* k) { \ StrTableEntry(StrTable)** a = &probe(k); \ register StrTableEntry(StrTable)* e = *a; \ if (e != nil) { \ if (strcmp(e->key_,k)==0) { \ *a = e->chain_; \ delete e; \ } else { \ register StrTableEntry(StrTable)* prev; \ do { \ prev = e; \ e = e->chain_; \ } while (e != nil && strcmp(e->key_,k)!=0 ); \ if (e != nil) { \ prev->chain_ = e->chain_; \ delete e; \ } \ } \ } \ } \ \ StrTableIterator(StrTable)::StrTableIterator(StrTable)(StrTable& t) { \ last_ = t.last_; \ for (entry_ = t.first_; entry_ <= last_; entry_++) { \ cur_ = *entry_; \ if (cur_ != nil) { \ break; \ } \ } \ } \ \ boolean StrTableIterator(StrTable)::next() { \ cur_ = cur_->chain_; \ if (cur_ != nil) { \ return true; \ } \ for (++entry_; entry_ <= last_; entry_++) { \ cur_ = *entry_; \ if (cur_ != nil) { \ return true; \ } \ } \ return false; \ } #endif ivtools-1.2.11a1/src/include/OS/table.h000066400000000000000000000132321214471147700175210ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Generic object association table. */ #ifndef os_table_h #define os_table_h #include #if defined(__STDC__) || defined(__ANSI_CPP__) #define __TableEntry(Table) Table##_Entry #define TableEntry(Table) __TableEntry(Table) #define __TableIterator(Table) Table##_Iterator #define TableIterator(Table) __TableIterator(Table) #else #define __TableEntry(Table) Table/**/_Entry #define TableEntry(Table) __TableEntry(Table) #define __TableIterator(Table) Table/**/_Iterator #define TableIterator(Table) __TableIterator(Table) #endif #define declareTable(Table,Key,Value) \ struct TableEntry(Table); \ \ class Table { \ public: \ Table(int); \ ~Table(); \ \ void insert(Key, Value); \ boolean find(Value&, Key); \ boolean find_and_remove(Value&, Key); \ void remove(Key); \ private: \ friend class TableIterator(Table); \ \ int size_; \ TableEntry(Table)** first_; \ TableEntry(Table)** last_; \ \ TableEntry(Table)*& probe(Key); \ }; \ \ struct TableEntry(Table) { \ private: \ friend class Table; \ friend class TableIterator(Table); \ \ Key key_; \ Value value_; \ TableEntry(Table)* chain_; \ }; \ \ class TableIterator(Table) { \ public: \ TableIterator(Table)(Table&); \ \ TableEntry(Table)* cur_entry(); \ Key& cur_key(); \ Value& cur_value(); \ boolean more(); \ boolean next(); \ private: \ TableEntry(Table)* cur_; \ TableEntry(Table)** entry_; \ TableEntry(Table)** last_; \ }; \ \ inline TableEntry(Table)* TableIterator(Table)::cur_entry() { return cur_; } \ inline Key& TableIterator(Table)::cur_key() { return cur_->key_; } \ inline Value& TableIterator(Table)::cur_value() { return cur_->value_; } \ inline boolean TableIterator(Table)::more() { return entry_ <= last_; } /* * Predefined hash functions */ #ifndef os_table2_h inline unsigned long key_to_hash(long k) { return (unsigned long)k; } inline unsigned long key_to_hash(const void* k) { return (unsigned long)k; } #endif /* * Table implementation */ #define implementTable(Table,Key,Value) \ Table::Table(int n) { \ for (size_ = 32; size_ < n; size_ <<= 1); \ first_ = new TableEntry(Table)*[size_]; \ --size_; \ last_ = &first_[size_]; \ for (register TableEntry(Table)** e = first_; e <= last_; e++) { \ *e = nil; \ } \ } \ \ Table::~Table() { \ for (register TableEntry(Table)** e = first_; e <= last_; e++) { \ TableEntry(Table)* t = *e; \ delete t; \ } \ delete[] first_; \ } \ \ inline TableEntry(Table)*& Table::probe(Key i) { \ return first_[key_to_hash(i) & size_]; \ } \ \ void Table::insert(Key k, Value v) { \ register TableEntry(Table)* e = new TableEntry(Table); \ e->key_ = k; \ e->value_ = v; \ register TableEntry(Table)** a = &probe(k); \ e->chain_ = *a; \ *a = e; \ } \ \ boolean Table::find(Value& v, Key k) { \ for (register TableEntry(Table)* e = probe(k); e != nil; e = e->chain_) { \ if (e->key_ == k) { \ v = e->value_; \ return true; \ } \ } \ return false; \ } \ \ boolean Table::find_and_remove(Value& v, Key k) { \ TableEntry(Table)** a = &probe(k); \ register TableEntry(Table)* e = *a; \ if (e != nil) { \ if (e->key_ == k) { \ v = e->value_; \ *a = e->chain_; \ delete e; \ return true; \ } else { \ register TableEntry(Table)* prev; \ do { \ prev = e; \ e = e->chain_; \ } while (e != nil && e->key_ != k); \ if (e != nil) { \ v = e->value_; \ prev->chain_ = e->chain_; \ delete e; \ return true; \ } \ } \ } \ return false; \ } \ \ void Table::remove(Key k) { \ TableEntry(Table)** a = &probe(k); \ register TableEntry(Table)* e = *a; \ if (e != nil) { \ if (e->key_ == k) { \ *a = e->chain_; \ delete e; \ } else { \ register TableEntry(Table)* prev; \ do { \ prev = e; \ e = e->chain_; \ } while (e != nil && e->key_ != k); \ if (e != nil) { \ prev->chain_ = e->chain_; \ delete e; \ } \ } \ } \ } \ \ TableIterator(Table)::TableIterator(Table)(Table& t) { \ last_ = t.last_; \ for (entry_ = t.first_; entry_ <= last_; entry_++) { \ cur_ = *entry_; \ if (cur_ != nil) { \ break; \ } \ } \ } \ \ boolean TableIterator(Table)::next() { \ cur_ = cur_->chain_; \ if (cur_ != nil) { \ return true; \ } \ for (++entry_; entry_ <= last_; entry_++) { \ cur_ = *entry_; \ if (cur_ != nil) { \ return true; \ } \ } \ return false; \ } #endif ivtools-1.2.11a1/src/include/OS/table2.h000066400000000000000000000123271214471147700176070ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Object association table with 2 keys. */ #ifndef os_table2_h #define os_table2_h #include #if defined(__STDC__) || defined(__ANSI_CPP__) #define __Table2Entry(Table2) Table2##_Entry #define Table2Entry(Table2) __Table2Entry(Table2) #define __Table2Iterator(Table2) Table2##_Iterator #define Table2Iterator(Table2) __Table2Iterator(Table2) #else #define __Table2Entry(Table2) Table2/**/_Entry #define Table2Entry(Table2) __Table2Entry(Table2) #define __Table2Iterator(Table2) Table2/**/_Iterator #define Table2Iterator(Table2) __Table2Iterator(Table2) #endif #define declareTable2(Table2,Key1,Key2,Value) \ struct Table2Entry(Table2); \ \ class Table2 { \ public: \ Table2(int); \ ~Table2(); \ \ void insert(Key1, Key2, Value); \ boolean find(Value&, Key1, Key2); \ void remove(Key1, Key2); \ protected: \ friend class Table2Iterator(Table2); \ \ int size_; \ Table2Entry(Table2)** first_; \ Table2Entry(Table2)** last_; \ \ Table2Entry(Table2)*& probe(Key1, Key2); \ }; \ \ struct Table2Entry(Table2) { \ public: \ \ Key1 key1_; \ Key2 key2_; \ Value value_; \ Table2Entry(Table2)* chain_; \ }; \ \ class Table2Iterator(Table2) { \ public: \ Table2Iterator(Table2)(Table2&); \ \ Key1& cur_key1(); \ Key2& cur_key2(); \ Value& cur_value(); \ boolean more(); \ boolean next(); \ protected: \ Table2Entry(Table2)* cur_; \ Table2Entry(Table2)** entry_; \ Table2Entry(Table2)** last_; \ }; \ \ inline Key1& Table2Iterator(Table2)::cur_key1() { return cur_->key1_; } \ inline Key2& Table2Iterator(Table2)::cur_key2() { return cur_->key2_; } \ inline Value& Table2Iterator(Table2)::cur_value() { return cur_->value_; } \ inline boolean Table2Iterator(Table2)::more() { return entry_ <= last_; } /* * Predefined hash functions */ #ifndef os_table_h inline unsigned long key_to_hash(long k) { return (unsigned long)k; } inline unsigned long key_to_hash(const void* k) { return (unsigned long)k; } #endif /* * Table2 implementation */ #define implementTable2(Table2,Key1,Key2,Value) \ Table2::Table2(int n) { \ for (size_ = 32; size_ < n; size_ <<= 1); \ first_ = new Table2Entry(Table2)*[size_]; \ --size_; \ last_ = &first_[size_]; \ for (register Table2Entry(Table2)** e = first_; e <= last_; e++) { \ *e = nil; \ } \ } \ \ Table2::~Table2() { \ delete first_; \ } \ \ inline Table2Entry(Table2)*& Table2::probe(Key1 k1, Key2 k2) { \ return first_[(key_to_hash(k1) ^ key_to_hash(k2)) & size_]; \ } \ \ void Table2::insert(Key1 k1, Key2 k2, Value v) { \ register Table2Entry(Table2)* e = new Table2Entry(Table2); \ e->key1_ = k1; \ e->key2_ = k2; \ e->value_ = v; \ register Table2Entry(Table2)** a = &probe(k1, k2); \ e->chain_ = *a; \ *a = e; \ } \ \ boolean Table2::find(Value& v, Key1 k1, Key2 k2) { \ for ( \ register Table2Entry(Table2)* e = probe(k1, k2); \ e != nil; \ e = e->chain_ \ ) { \ if (e->key1_ == k1 && e->key2_ == k2) { \ v = e->value_; \ return true; \ } \ } \ return false; \ } \ \ void Table2::remove(Key1 k1, Key2 k2) { \ Table2Entry(Table2)** a = &probe(k1, k2); \ register Table2Entry(Table2)* e = *a; \ if (e != nil) { \ if (e->key1_ == k1 && e->key2_ == k2) { \ *a = e->chain_; \ delete e; \ } else { \ register Table2Entry(Table2)* prev; \ do { \ prev = e; \ e = e->chain_; \ } while (e != nil && (e->key1_ != k1 || e->key2_ != k2)); \ if (e != nil) { \ prev->chain_ = e->chain_; \ delete e; \ } \ } \ } \ } \ \ Table2Iterator(Table2)::Table2Iterator(Table2)(Table2& t) { \ last_ = t.last_; \ for (entry_ = t.first_; entry_ <= last_; entry_++) { \ cur_ = *entry_; \ if (cur_ != nil) { \ break; \ } \ } \ } \ \ boolean Table2Iterator(Table2)::next() { \ cur_ = cur_->chain_; \ if (cur_ != nil) { \ return true; \ } \ for (++entry_; entry_ <= last_; entry_++) { \ cur_ = *entry_; \ if (cur_ != nil) { \ return true; \ } \ } \ return false; \ } #endif ivtools-1.2.11a1/src/include/OS/types.h000066400000000000000000000026341214471147700176020ustar00rootroot00000000000000/* * Copyright (c) 1992 Stanford University * Copyright (c) 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef os_types_h #define os_types_h #include #undef boolean #include #ifdef __linux__ /* restore to non-void* NULL */ #undef NULL #define NULL 0 #endif #define boolean _lib_os(boolean) #endif ivtools-1.2.11a1/src/include/OS/ustring.h000066400000000000000000000037071214471147700201330ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef os_ustring_h #define os_ustring_h /* * UniqueString - unique string using hash table */ #include class UniqueStringPool; class UniqueStringTable; class UniqueString : public String { public: #ifdef _DELTA_EXTENSIONS #pragma __static_class #endif UniqueString(); UniqueString(const char*); UniqueString(const char*, int length); UniqueString(const String&); UniqueString(const UniqueString&); virtual ~UniqueString(); virtual unsigned long hash() const; virtual boolean operator ==(const String&) const; virtual boolean operator ==(const char*) const; virtual boolean null_terminated() const; private: static UniqueStringTable* table_; static UniqueStringPool* pool_; void init(const String&); }; #endif ivtools-1.2.11a1/src/include/TIFF/000077500000000000000000000000001214471147700164675ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/TIFF/format.h000066400000000000000000000040261214471147700201320ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef tiff_format_h #define tiff_format_h /* * Define constants for identifying different file formats. */ #define COMPRESS_MAGIC_NUM 0x1f9d #define TIFF1_MAGIC_NUM 0x4d4d /* TIFF with BIGENDIAN byte order */ #define TIFF2_MAGIC_NUM 0x4949 /* TIFF with LITLEENDIAN byte order */ #define SUN_MAGIC_NUM 0x59a6 /* Sun rasterfile (0x59a66a95) */ #define BM_MAGIC_NUM '!' /* bm format (!!) */ #define PBM_MAGIC_NUM 'P' /* pbm file (P1) */ #define ATK_MAGIC_NUM '\\' /* ATK file (\begindata{raster,length}) */ #define MP_MAGIC_NUM '\0' /* MacPaint (titlength in short) */ #define X11_MAGIC_NUM '#' /* X bitmaps (#define) */ #define PCX_MAGIC_NUM 0xa /* PCX, PC Paintbrush files */ #define IFF_MAGIC_NUM 'F' /* Amiga IFF format ("FORM") */ #define GIF_MAGIC_NUM 'G' /* GIF format (CompuServe) */ #define RLE_MAGIC_NUM 0x52 /* Utah RLE file (0x52 0xcc) */ #endif ivtools-1.2.11a1/src/include/TIFF/tiff.h000066400000000000000000000312011214471147700175650ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFF_ #define _TIFF_ /* * Tag Image File Format (TIFF) * * Based on Rev 6.0 from: * Developer's Desk * Aldus Corporation * 411 First Ave. South * Suite 200 * Seattle, WA 98104 * 206-622-5500 */ #define TIFF_VERSION 42 #define TIFF_BIGENDIAN 0x4d4d #define TIFF_LITTLEENDIAN 0x4949 typedef struct { unsigned short tiff_magic; /* magic number (defines byte order) */ unsigned short tiff_version; /* TIFF version number */ unsigned long tiff_diroff; /* byte offset to first directory */ } TIFFHeader; /* * TIFF Image File Directories are comprised of * a table of field descriptors of the form shown * below. The table is sorted in ascending order * by tag. The values associated with each entry * are disjoint and may appear anywhere in the file * (so long as they are placed on a word boundary). * * If the value is 4 bytes or less, then it is placed * in the offset field to save space. If the value * is less than 4 bytes, it is left-justified in the * offset field. */ typedef struct { unsigned short tdir_tag; /* see below */ unsigned short tdir_type; /* data type; see below */ unsigned long tdir_count; /* number of items; length in spec */ unsigned long tdir_offset; /* byte offset to field data */ } TIFFDirEntry; /* * NB: In the comments below, * - items marked with a + are obsoleted by revision 5.0, * - items marked with a ! are introduced in revision 6.0. * - items marked with a $ are obsoleted by revision 6.0. */ /* * Tag data type information. * * Note: RATIONALs are the ratio of two 32-bit integer values. */ typedef enum { TIFF_NOTYPE = 0, /* placeholder */ TIFF_BYTE = 1, /* 8-bit unsigned integer */ TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ TIFF_SHORT = 3, /* 16-bit unsigned integer */ TIFF_LONG = 4, /* 32-bit unsigned integer */ TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ TIFF_SBYTE = 6, /* !8-bit signed integer */ TIFF_UNDEFINED = 7, /* !8-bit untyped data */ TIFF_SSHORT = 8, /* !16-bit signed integer */ TIFF_SLONG = 9, /* !32-bit signed integer */ TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ TIFF_DOUBLE = 12 /* !64-bit IEEE floating point */ } TIFFDataType; /* * TIFF Tag Definitions. */ #define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ #define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ #define FILETYPE_PAGE 0x2 /* one page of many */ #define FILETYPE_MASK 0x4 /* transparency mask */ #define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ #define OFILETYPE_IMAGE 1 /* full resolution image data */ #define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ #define OFILETYPE_PAGE 3 /* one page of many */ #define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ #define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ #define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ #define TIFFTAG_COMPRESSION 259 /* data compression technique */ #define COMPRESSION_NONE 1 /* dump mode */ #define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ #define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ #define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ #define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ #define COMPRESSION_JPEG 6 /* !JPEG compression */ #define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ #define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ #define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ #define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ #define PHOTOMETRIC_RGB 2 /* RGB color model */ #define PHOTOMETRIC_PALETTE 3 /* color map indexed */ #define PHOTOMETRIC_MASK 4 /* $holdout mask */ #define PHOTOMETRIC_SEPARATED 5 /* !color separations */ #define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ #define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ #define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ #define THRESHHOLD_BILEVEL 1 /* b&w art scan */ #define THRESHHOLD_HALFTONE 2 /* or dithered scan */ #define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ #define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ #define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ #define TIFFTAG_FILLORDER 266 /* data order within a byte */ #define FILLORDER_MSB2LSB 1 /* most significant -> least */ #define FILLORDER_LSB2MSB 2 /* least significant -> most */ #define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ #define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ #define TIFFTAG_MAKE 271 /* scanner manufacturer name */ #define TIFFTAG_MODEL 272 /* scanner model name/number */ #define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ #define TIFFTAG_ORIENTATION 274 /* +image orientation */ #define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ #define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ #define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ #define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ #define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ #define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ #define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ #define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ #define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ #define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ #define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ #define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ #define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ #define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ #define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ #define TIFFTAG_PLANARCONFIG 284 /* storage organization */ #define PLANARCONFIG_CONTIG 1 /* single image plane */ #define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ #define TIFFTAG_PAGENAME 285 /* page name image is from */ #define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ #define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ #define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ #define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ #define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ #define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ #define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ #define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ #define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ #define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ #define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ #define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ #define RESUNIT_NONE 1 /* no meaningful units */ #define RESUNIT_INCH 2 /* english */ #define RESUNIT_CENTIMETER 3 /* metric */ #define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ #define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ #define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ #define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ #define TIFFTAG_SOFTWARE 305 /* name & release */ #define TIFFTAG_DATETIME 306 /* creation date and time */ #define TIFFTAG_ARTIST 315 /* creator of image */ #define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ #define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ #define TIFFTAG_WHITEPOINT 318 /* image white point */ #define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ #define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ #define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ #define TIFFTAG_TILEWIDTH 322 /* !rows/data tile */ #define TIFFTAG_TILELENGTH 323 /* !cols/data tile */ #define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ #define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ #define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ #define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ #define CLEANFAXDATA_CLEAN 0 /* no errors detected */ #define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ #define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ #define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ #define TIFFTAG_INKSET 332 /* !inks in separated image */ #define INKSET_CMYK 1 /* !cyan-magenta-yellow-black */ #define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ #define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ #define TIFFTAG_TARGETPRINTER 337 /* !separation target */ #define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ #define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ #define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ #define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ #define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ #define SAMPLEFORMAT_INT 1 /* !signed integer data */ #define SAMPLEFORMAT_UINT 2 /* !unsigned integer data */ #define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ #define SAMPLEFORMAT_VOID 4 /* !untyped data */ #define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ #define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ #define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ #define JPEGPROC_BASELINE 1 /* !baseline sequential */ #define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ #define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ #define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ #define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ #define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ #define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ #define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ #define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ #define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ #define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ #define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ #define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ #define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ #define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ #define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ /* tags 32995-32999 are private tags registered to SGI */ #define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ #define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ #define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ #define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ #endif /* _TIFF_ */ ivtools-1.2.11a1/src/include/TIFF/tiffio.h000066400000000000000000000204651214471147700201270ustar00rootroot00000000000000/* * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFFIO_ #define _TIFFIO_ /* * TIFF I/O Library Definitions. */ #include "tiff.h" /* * TIFF is defined as an incomplete type to hide the * library's internal data structures from clients. */ typedef struct tiff TIFF; #ifndef NULL #define NULL 0 #endif /* * Flags to pass to TIFFPrintDirectory to control * printing of data structures that are potentially * very large. Bit-or these flags to enable printing * multiple items. */ #define TIFFPRINT_NONE 0x0 /* no extra info */ #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ #define TIFFPRINT_COLORMAP 0x4 /* colormap */ #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ #if defined(__STDC__) || defined(__EXTENDED__) || USE_CONST extern const char TIFFVersion[]; extern const unsigned char TIFFBitRevTable[256]; extern const unsigned char TIFFNoBitRevTable[256]; #else extern char TIFFVersion[]; extern unsigned char TIFFBitRevTable[256]; extern unsigned char TIFFNoBitRevTable[256]; #endif /* * Macros for extracting components from the * packed ABGR form returned by TIFFReadRGBAImage. */ #define TIFFGetR(abgr) ((abgr) & 0xff) #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) #if defined(c_plusplus) || defined(__cplusplus) || defined(__STDC__) || defined(__EXTENDED__) || USE_PROTOTYPES #include #include typedef void (*TIFFErrorHandler)(char* module, char* fmt, va_list ap); #if defined(__cplusplus) extern "C" { #endif extern void TIFFClose(TIFF*); extern int TIFFFlush(TIFF*); extern int TIFFFlushData(TIFF*); extern int TIFFGetField(TIFF*, int, ...); extern int TIFFVGetField(TIFF*, int, va_list); extern int TIFFGetFieldDefaulted(TIFF*, int, ...); extern int TIFFVGetFieldDefaulted(TIFF*, int, va_list); extern int TIFFReadDirectory(TIFF*); extern int TIFFScanlineSize(TIFF*); extern unsigned long TIFFStripSize(TIFF*); extern unsigned long TIFFVStripSize(TIFF*, unsigned long); extern unsigned long TIFFTileRowSize(TIFF*); extern unsigned long TIFFTileSize(TIFF*); extern unsigned long TIFFVTileSize(TIFF*, unsigned long); extern int TIFFFileno(TIFF*); extern int TIFFGetMode(TIFF*); extern int TIFFIsTiled(TIFF*); extern long TIFFCurrentRow(TIFF*); extern int TIFFCurrentDirectory(TIFF*); extern int TIFFCurrentStrip(TIFF*); extern int TIFFCurrentTile(TIFF*); extern int TIFFReadBufferSetup(TIFF*, char*, unsigned); extern int TIFFSetDirectory(TIFF*, int); extern int TIFFSetField(TIFF*, int, ...); extern int TIFFVSetField(TIFF*, int, va_list); extern int TIFFWriteDirectory(TIFF *); #if defined(c_plusplus) || defined(__cplusplus) extern TIFF* TIFFOpen(const char*, const char*); extern TIFF* TIFFFdOpen(const int, const char*, const char*); extern const char* TIFFFileName(TIFF*); extern void TIFFError(const char*, const char*, ...); extern void TIFFWarning(const char*, const char*, ...); extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); extern int TIFFReadScanline(TIFF*, unsigned char*, unsigned, unsigned = 0); extern int TIFFWriteScanline(TIFF*, unsigned char*, unsigned, unsigned = 0); extern int TIFFReadRGBAImage(TIFF*, unsigned long, unsigned long, unsigned long*, int stop = 0); #else extern TIFF* TIFFOpen(char*, char*); extern TIFF* TIFFFdOpen(int, char*, char*); extern char* TIFFFileName(TIFF*); extern void TIFFError(char*, char*, ...); extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler); extern void TIFFWarning(char*, char*, ...); extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler handler); extern void TIFFPrintDirectory(TIFF*, FILE*, long); extern int TIFFReadScanline(TIFF*, unsigned char*, unsigned, unsigned); extern int TIFFWriteScanline(TIFF*, unsigned char*, unsigned, unsigned); extern int TIFFReadRGBAImage(TIFF*, unsigned long, unsigned long, unsigned long*, int stop); #endif extern unsigned int TIFFComputeTile(TIFF*, unsigned long, unsigned long, unsigned int, unsigned long); extern int TIFFCheckTile(TIFF*, unsigned long, unsigned long, unsigned long, unsigned); extern unsigned int TIFFNumberOfTiles(TIFF*); extern int TIFFReadTile(TIFF*, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned); extern unsigned int TIFFComputeStrip(TIFF*, unsigned long, unsigned int); extern unsigned int TIFFNumberOfStrips(TIFF*); extern int TIFFReadEncodedStrip(TIFF*, unsigned, unsigned char*, unsigned); extern int TIFFReadRawStrip(TIFF*, unsigned, unsigned char*, unsigned); extern int TIFFReadEncodedTile(TIFF*, unsigned, unsigned char*, unsigned); extern int TIFFReadRawTile(TIFF*, unsigned, unsigned char*, unsigned); extern int TIFFWriteEncodedStrip(TIFF*, unsigned, unsigned char*, unsigned); extern int TIFFWriteRawStrip(TIFF*, unsigned, unsigned char*, unsigned); extern int TIFFWriteEncodedTile(TIFF*, unsigned, unsigned char*, unsigned); extern int TIFFWriteRawTile(TIFF*, unsigned, unsigned char*, unsigned); extern int TIFFSwabShort(unsigned short *); extern int TIFFSwabLong(unsigned long *); extern int TIFFSwabArrayOfShort(unsigned short *, int); extern int TIFFSwabArrayOfLong(unsigned long *, int); extern int TIFFReverseBits(unsigned char *, int); #if defined(__cplusplus) } #endif #else typedef void (*TIFFErrorHandler)(); extern void TIFFClose(); extern TIFF *TIFFOpen(); extern TIFF *TIFFFdOpen(); extern char* TIFFFileName(); extern int TIFFFileno(); extern int TIFFGetMode(); extern int TIFFIsTiled(); extern unsigned int TIFFComputeTile(); extern long TIFFCurrentRow(); extern int TIFFCurrentDirectory(); extern int TIFFCurrentStrip(); extern int TIFFCurrentTile(); extern void TIFFError(); extern TIFFErrorHandler TIFFSetErrorHandler(); extern int TIFFFlush(); extern int TIFFFlushData(); extern int TIFFGetField(); extern int TIFFVGetField(); extern int TIFFGetFieldDefaulted(); extern int TIFFVGetFieldDefaulted(); extern unsigned int TIFFNumberOfTiles(); extern void TIFFPrintDirectory(); extern int TIFFReadDirectory(); extern int TIFFReadBufferSetup(); extern int TIFFReadScanline(); extern int TIFFReadTile(); extern unsigned int TIFFComputeStrip(); extern unsigned int TIFFNumberOfStrips(); extern int TIFFReadEncodedStrip(); extern int TIFFReadRawStrip(); extern int TIFFReadEncodedTile(); extern int TIFFReadRGBAImage(); extern int TIFFReadRawTile(); extern int TIFFScanlineSize(); extern unsigned long TIFFStripSize(); extern unsigned long TIFFVStripSize(); extern unsigned long TIFFTileRowSize(); extern unsigned long TIFFTileSize(); extern unsigned long TIFFVTileSize(); extern int TIFFSetDirectory(); extern int TIFFSetField(); extern int TIFFVSetField(); extern void TIFFWarning(); extern TIFFErrorHandler TIFFSetWarningHandler(); extern int TIFFWriteDirectory(); extern int TIFFWriteScanline(); extern int TIFFWriteEncodedStrip(); extern int TIFFWriteRawStrip(); extern int TIFFWriteEncodedTile(); extern int TIFFWriteRawTile(); extern int TIFFSwabShort(); extern int TIFFSwabLong(); extern int TIFFSwabArrayOfShort(); extern int TIFFSwabArrayOfLong(); extern int TIFFReverseBits(); extern int TIFFCheckTile(); #endif #endif /* _TIFFIO_ */ ivtools-1.2.11a1/src/include/Unidraw/000077500000000000000000000000001214471147700173505ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/Unidraw/Commands/000077500000000000000000000000001214471147700211115ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/Unidraw/Commands/align.h000066400000000000000000000046611214471147700223630ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * AlignCmd - aligns components relative to one another. * AlignToGridCmd - aligns components relative to a grid. */ #ifndef unidraw_commands_align_h #define unidraw_commands_align_h #include class GraphicComp; class GraphicView; //: align command // man page class AlignCmd : public Command { public: AlignCmd(ControlInfo*, Alignment = Left, Alignment = Left); AlignCmd(Editor* = nil, Alignment = Left, Alignment = Left); void GetAlignment(Alignment&, Alignment&); GraphicComp* GetReference(GraphicComp*); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Alignment _align1, _align2; }; //: align-to-grid command // man page class AlignToGridCmd : public Command { public: AlignToGridCmd(ControlInfo*); AlignToGridCmd(Editor* = nil); virtual void Execute(); virtual void Unexecute(); virtual void Align(GraphicView*, float, float); virtual void Unalign(GraphicView*); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: void Move(GraphicComp*); void Unmove(GraphicComp*); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/brushcmd.h000066400000000000000000000035051214471147700230740ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Brush command. */ #ifndef unidraw_commands_brushcmd_h #define unidraw_commands_brushcmd_h #include class PSBrush; //: command to change brush of editor and current selection // man page class BrushCmd : public Command { public: BrushCmd(ControlInfo*, PSBrush* = nil); BrushCmd(Editor* = nil, PSBrush* = nil); virtual void Execute(); PSBrush* GetBrush(); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PSBrush* _br; }; inline PSBrush* BrushCmd::GetBrush () { return _br; } #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/catcmds.h000066400000000000000000000105511214471147700227020ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Cataloging commands. */ #ifndef unidraw_commands_catcmds_h #define unidraw_commands_catcmds_h #include #undef FileChooser #define FileChooser _lib_iv(FileChooser) class CatalogChooser; class FileChooser; class PrintDialog; //: new component command // man page class NewCompCmd : public Command { public: NewCompCmd(ControlInfo*, Component* prototype = nil); NewCompCmd(Editor* = nil, Component* prototype = nil); virtual ~NewCompCmd(); virtual void Execute(); virtual boolean Reversible(); Component* GetPrototype(); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Component* prototype_; }; inline Component* NewCompCmd::GetPrototype () { return prototype_; } //: revert command // man page class RevertCmd : public Command { public: RevertCmd(ControlInfo*); RevertCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: view component command // man page class ViewCompCmd : public Command { public: ViewCompCmd(ControlInfo*, FileChooser* = nil); ViewCompCmd(Editor* = nil, FileChooser* = nil); virtual ~ViewCompCmd(); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: FileChooser* chooser_; }; //: save component command // man page class SaveCompCmd : public Command { public: SaveCompCmd(ControlInfo*); SaveCompCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: save-as component command // man page class SaveCompAsCmd : public Command { public: SaveCompAsCmd(ControlInfo*, FileChooser* = nil); SaveCompAsCmd(Editor* = nil, FileChooser* = nil); virtual ~SaveCompAsCmd(); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: FileChooser* chooser_; }; //: print command // man page class PrintCmd : public Command { public: PrintCmd(ControlInfo*, PrintDialog* = nil); PrintCmd(Editor* = nil, PrintDialog* = nil); virtual ~PrintCmd(); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: int print(const char* print_cmd, const char* file); protected: PrintDialog* _dialog; }; //: quit command // man page class QuitCmd : public Command { public: QuitCmd(ControlInfo*); QuitCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/colorcmd.h000066400000000000000000000037161214471147700230730ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Color command. */ #ifndef unidraw_commands_colorcmd_h #define unidraw_commands_colorcmd_h #include class PSColor; //: command to change color of current selection and editor // man page class ColorCmd : public Command { public: ColorCmd(ControlInfo*, PSColor* fg = nil, PSColor* bg = nil); ColorCmd(Editor* = nil, PSColor* fg = nil, PSColor* bg = nil); virtual void Execute(); PSColor* GetFgColor(); PSColor* GetBgColor(); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PSColor* _fg, *_bg; }; inline PSColor* ColorCmd::GetFgColor () { return _fg; } inline PSColor* ColorCmd::GetBgColor () { return _bg; } #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/command.h000066400000000000000000000060031214471147700226770ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Command - an object that operates on selected components, an editor, * or unidraw itself. */ #ifndef unidraw_commands_command_h #define unidraw_commands_command_h #include #include class Clipboard; class Component; class ControlInfo; class Data; class DataCache; class Editor; class GraphicComp; class Iterator; class Selection; #include //: base class for command objects. // man page class Command { public: virtual void Execute(); virtual void Unexecute(); virtual boolean Reversible(); virtual void Store(Component*, Data* = nil); virtual Data* Recall(Component*); virtual void Log(); virtual void SetControlInfo(ControlInfo*); virtual void SetEditor(Editor*); virtual void SetClipboard(Clipboard*); virtual ControlInfo* GetControlInfo(); virtual Editor* GetEditor(); virtual Clipboard* GetClipboard(); virtual void First(Iterator&); virtual void Last(Iterator&); virtual void Next(Iterator&); virtual void Prev(Iterator&); virtual boolean Done(Iterator&); virtual ~Command(); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual ClassId GetSubstId(const char*& delim); virtual boolean IsA(ClassId); protected: Command(ControlInfo*, Clipboard* = nil); Command(Editor* = nil, Clipboard* = nil); void InitCopy(Command*); ControlInfo* CopyControlInfo(); Clipboard* CopyClipboard(); Clipboard* DeepCopyClipboard(); GraphicComp* GetGraphicComp(); protected: ControlInfo* _ctrlInfo; Editor* _editor; Clipboard* _clipboard; protected: DataCache* CopyData(); void SetData(DataCache*); protected: DataCache* _cache; #ifdef LEAKCHECK public: static LeakChecker* _leakchecker; #endif }; #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/data.h000066400000000000000000000031171214471147700221750ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Data - encapsulates undo information that components store in commands they * interpret. */ #ifndef unidraw_commands_data_h #define unidraw_commands_data_h #include #include //: undo information object // encapsulates undo information that components store in commands they // interpret. //

    man page class Data : public Resource { protected: Data(); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/datas.h000066400000000000000000000054731214471147700223670ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * VoidData - stores a void*; its destructor does nothing. * MoveData - stores two floating point values for distance moved. * ColorData - stores foreground and background colors. * GSData - stores a complete set of graphics state. * MobilityData - stores mobility information. */ #ifndef unidraw_commands_datas_h #define unidraw_commands_datas_h #include #include class Graphic; class PSColor; class FullGraphic; //: void data for command undo // man page class VoidData : public Data { public: VoidData(void*); public: void* _void; }; //: move data for command undo // man page class MoveData : public Data { public: MoveData(float, float); public: float _dx, _dy; }; //: color data for command undo // man page class ColorData : public Data { public: ColorData(PSColor*, PSColor*); public: PSColor* _fg, *_bg; }; //: graphic state data for command undo // man page class GSData : public Data { public: GSData(Graphic*); virtual ~GSData(); public: FullGraphic* _gs; }; //: mobility state data for command undo // man page class MobilityData : public Data { public: MobilityData(Mobility, Graphic*); virtual ~MobilityData(); public: Mobility _mobility; FullGraphic* _gs; }; class GraphicComp; //: ungroup data for command undo // man page class UngroupData : public Data { public: UngroupData(GraphicComp* parent, Graphic*); virtual ~UngroupData(); public: GraphicComp* _parent; FullGraphic* _gs; }; #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/dirty.h000066400000000000000000000031531214471147700224170ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * DirtyCmd - command that sets the modified flag on a drawing */ #ifndef dirty_h #define dirty_h #include class DirtyCmd : public Command { public: DirtyCmd(ControlInfo*); DirtyCmd(Editor* = nil); virtual void Execute(); virtual void Unexecute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); boolean& reverse() { return _reverse; } protected: boolean _reverse; }; #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/edit.h000066400000000000000000000132671214471147700222200ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Editing commands. */ #ifndef unidraw_commands_edit_h #define unidraw_commands_edit_h #include class Connector; class GraphicComp; //: undo command // man page class UndoCmd : public Command { public: UndoCmd(ControlInfo*); UndoCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: redo command // man page class RedoCmd : public Command { public: RedoCmd(ControlInfo*); RedoCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: cut command // man page class CutCmd : public Command { public: CutCmd(ControlInfo*, Clipboard* = nil); CutCmd(Editor* = nil, Clipboard* = nil); virtual ~CutCmd(); virtual void Execute(); virtual void Unexecute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: boolean _executed; }; //: copy command // man page class CopyCmd : public Command { public: CopyCmd(ControlInfo*, Clipboard* = nil); CopyCmd(Editor* = nil, Clipboard* = nil); virtual ~CopyCmd(); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: paste command // man page class PasteCmd : public Command { public: PasteCmd(ControlInfo*, Clipboard* = nil); PasteCmd(Editor* = nil, Clipboard* = nil); virtual ~PasteCmd(); virtual void Execute(); virtual void Unexecute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: boolean _executed; }; //: replace command // man page class ReplaceCmd : public MacroCmd { public: ReplaceCmd(ControlInfo*, GraphicComp* = nil); ReplaceCmd(Editor* = nil, GraphicComp* = nil); GraphicComp* GetReplacement(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: void Init(GraphicComp*); }; //: duplicate command // man page class DupCmd : public Command { public: DupCmd(ControlInfo*, Clipboard* = nil); DupCmd(Editor* = nil, Clipboard* = nil); virtual ~DupCmd(); virtual void Execute(); virtual void Unexecute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: boolean _executed; }; //: delete command // man page class DeleteCmd : public Command { public: DeleteCmd(ControlInfo*, Clipboard* = nil); DeleteCmd(Editor* = nil, Clipboard* = nil); virtual ~DeleteCmd(); virtual void Execute(); virtual void Unexecute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: boolean _executed; }; //: select-all command // man page class SlctAllCmd : public Command { public: SlctAllCmd(ControlInfo*); SlctAllCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: connect command // man page class ConnectCmd : public Command { public: ConnectCmd(ControlInfo*, Connector* = nil, Connector* = nil); ConnectCmd(Editor* = nil, Connector* = nil, Connector* = nil); virtual void Execute(); virtual void Unexecute(); virtual boolean Reversible(); void GetConnectors(Connector*&, Connector*&); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Connector* _source, *_target; }; //: mobility command // man page class MobilityCmd : public Command { public: MobilityCmd(ControlInfo*, Mobility = Fixed); MobilityCmd(Editor* = nil, Mobility = Fixed); Mobility GetMobility(); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Mobility _mobility; }; #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/font.h000066400000000000000000000034651214471147700222400ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Font command. */ #ifndef unidraw_commands_font_h #define unidraw_commands_font_h #include class PSFont; //: command for changing font in current selection and editor // man page class FontCmd : public Command { public: FontCmd(ControlInfo*, PSFont* = nil); FontCmd(Editor* = nil, PSFont* = nil); virtual void Execute(); PSFont* GetFont(); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PSFont* _font; }; inline PSFont* FontCmd::GetFont () { return _font; } #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/import.h000066400000000000000000000042111214471147700225720ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ImportCmd - a command for importing graphical objects */ #ifndef unidraw_commands_import_h #define unidraw_commands_import_h #include #undef FileChooser #define FileChooser _lib_iv(FileChooser) class FileChooser; //: command for importing graphical objects // man page class ImportCmd : public Command { public: ImportCmd(ControlInfo*, FileChooser* = nil); ImportCmd(Editor* = nil, FileChooser* = nil); virtual ~ImportCmd(); virtual void Execute(); virtual boolean Reversible(); virtual GraphicComp* PostDialog(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); static GraphicComp* Import(const char*); static GraphicComp* TIFF_Image(const char*); static GraphicComp* PGM_Image(const char*); static GraphicComp* PPM_Image(const char*); static GraphicComp* XBitmap_Image(const char*); protected: FileChooser* chooser_; void Init(FileChooser*); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/macro.h000066400000000000000000000051311214471147700223630ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * MacroCmd - a command containing a sequence of other commands to execute. */ #ifndef unidraw_commands_macro_h #define unidraw_commands_macro_h #include class UList; //: command containing a sequence of other commands to execute // man page class MacroCmd : public Command { public: MacroCmd(ControlInfo*); MacroCmd( Editor* = nil, Command* = nil, Command* = nil, Command* = nil, Command* = nil ); virtual ~MacroCmd(); virtual void Execute(); virtual void Unexecute(); virtual boolean Reversible(); virtual void SetEditor(Editor*); virtual void First(Iterator&); virtual void Last(Iterator&); virtual void Next(Iterator&); virtual void Prev(Iterator&); virtual boolean Done(Iterator&); virtual Command* GetCommand(Iterator&); virtual void SetCommand(Command*, Iterator&); void Append(Command*, Command* = nil, Command* = nil, Command* = nil); void Prepend(Command*, Command* = nil, Command* = nil, Command* = nil); void InsertBefore(Iterator&, Command*); void InsertAfter(Iterator&, Command*); void Remove(Command*); void Remove(Iterator&); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Command* Cmd(UList*); UList* Elem(Iterator&); protected: UList* _cmds; }; #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/nop.h000066400000000000000000000031031214471147700220530ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Null command. */ #ifndef unidraw_commands_nop_h #define unidraw_commands_nop_h #include //: null command // man page class NOPCmd : public Command { public: NOPCmd(ControlInfo*); NOPCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/patcmd.h000066400000000000000000000035421214471147700225360ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Pattern command. */ #ifndef unidraw_commands_patcmd_h #define unidraw_commands_patcmd_h #include class PSPattern; //: command to change pattern of current selection and editor. // man page class PatternCmd : public Command { public: PatternCmd(ControlInfo*, PSPattern* = nil); PatternCmd(Editor* = nil, PSPattern* = nil); virtual void Execute(); PSPattern* GetPattern(); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PSPattern* _pat; }; inline PSPattern* PatternCmd::GetPattern () { return _pat; } #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/struct.h000066400000000000000000000065671214471147700226240ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Structuring commands. */ #ifndef unidraw_commands_struct_h #define unidraw_commands_struct_h #include class GraphicComp; class Iterator; class Selection; //: group command // man page class GroupCmd : public Command { public: GroupCmd(ControlInfo*, GraphicComp* dest = nil); GroupCmd(Editor* = nil, GraphicComp* dest = nil); virtual ~GroupCmd(); virtual void Execute(); virtual void Unexecute(); virtual boolean Reversible(); GraphicComp* GetGroup(); void SetGroup(GraphicComp*); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: boolean _executed; protected: void Init(GraphicComp*); protected: GraphicComp* _group; }; inline GraphicComp* GroupCmd::GetGroup () { return _group; } inline void GroupCmd::SetGroup (GraphicComp* g) { _group = g; } //: ungroup command // man page class UngroupCmd : public Command { public: UngroupCmd(ControlInfo*); UngroupCmd(Editor* = nil); virtual ~UngroupCmd(); virtual void Execute(); virtual void Unexecute(); Clipboard* GetKids(); void SetKids(Clipboard*); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: boolean _executed; protected: void Init(); protected: Clipboard* _kids; }; inline Clipboard* UngroupCmd::GetKids () { return _kids; } inline void UngroupCmd::SetKids (Clipboard* k) { _kids = k; } //: move-to-front command // man page class FrontCmd : public Command { public: FrontCmd(ControlInfo*); FrontCmd(Editor* = nil); virtual void Execute(); virtual void Unexecute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: move-to-back command // man page class BackCmd : public Command { public: BackCmd(ControlInfo*); BackCmd(Editor* = nil); virtual void Execute(); virtual void Unexecute(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/transforms.h000066400000000000000000000063541214471147700234700ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Transformation commands. */ #ifndef unidraw_commands_transforms_h #define unidraw_commands_transforms_h #include #include //: move command // man page class MoveCmd : public Command { public: MoveCmd(ControlInfo*, float = 0, float = 0); MoveCmd(Editor* = nil, float = 0, float = 0); void GetMovement(float&, float&); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: float _dx, _dy; }; //: scale command // man page class ScaleCmd : public Command { public: ScaleCmd(ControlInfo*, float = 1, float = 1, Alignment = Center); ScaleCmd(Editor* = nil, float = 1, float = 1, Alignment = Center); void GetScaling(float&, float&); Alignment GetAlignment(); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: float _sx, _sy; Alignment _align; }; inline Alignment ScaleCmd::GetAlignment () { return _align; } //: rotate command // man page class RotateCmd : public Command { public: RotateCmd(ControlInfo*, float = 0); RotateCmd(Editor* = nil, float = 0); float GetRotation(); virtual Command* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: float _angle; }; inline float RotateCmd::GetRotation () { return _angle; } class Transformer; //: transform command // man page class TransformCmd : public Command { public: TransformCmd(ControlInfo*, Transformer* = nil); TransformCmd(Editor* = nil, Transformer* = nil); Transformer* GetTransformer(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Transformer* _t; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Commands/viewcmds.h000066400000000000000000000101571214471147700231070ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * View commands. */ #ifndef unidraw_commands_viewcmds_h #define unidraw_commands_viewcmds_h #include class ControlInfo; class GridDialog; //: normal-size command // man page class NormSizeCmd : public Command { public: NormSizeCmd(ControlInfo*); NormSizeCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: reduce-to-fit command // man page class RedToFitCmd : public Command { public: RedToFitCmd(ControlInfo*); RedToFitCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: center command // man page class CenterCmd : public Command { public: CenterCmd(ControlInfo*); CenterCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: enable/disable grid command // man page class GridCmd : public Command { public: GridCmd(ControlInfo*); GridCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: grid-spacing command // man page class GridSpacingCmd : public Command { public: GridSpacingCmd(ControlInfo*); GridSpacingCmd(Editor* = nil); virtual ~GridSpacingCmd(); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: GridDialog* _dialog; }; //: enable/disable gravity command // man page class GravityCmd : public Command { public: GravityCmd(ControlInfo*); GravityCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: landscape/portrait orientation command // man page class OrientationCmd : public Command { public: OrientationCmd(ControlInfo*); OrientationCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; //: editor close command // man page class CloseEditorCmd : public Command { public: CloseEditorCmd(ControlInfo*); CloseEditorCmd(Editor* = nil); virtual void Execute(); virtual boolean Reversible(); virtual Command* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Components/000077500000000000000000000000001214471147700214755ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/Unidraw/Components/cglue.h000066400000000000000000000036531214471147700227540ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * CGlue - connector glue for specifying connection behavior */ #ifndef unidraw_components_cglue_h #define unidraw_components_cglue_h #include #include class Shape; //: connector glue for specifying connection behavior // man page class CGlue { public: CGlue( float hnat = 0, float vnat = 0, float hshr = 0, float hstr = 0, float vshr = 0, float vstr = 0, float hshrlim = 0, float hstrlim = 0, float vshrlim = 0, float vstrlim = 0 ); CGlue(const Shape&); CGlue* Copy(); void Rigid(); void Interpose(CGlue*); public: float _width, _height; float _hshrink, _hstretch, _vshrink, _vstretch; float _hshrlim, _hstrlim, _vshrlim, _vstrlim; }; #endif ivtools-1.2.11a1/src/include/Unidraw/Components/component.h000066400000000000000000000057741214471147700236650ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Component - class of objects that are edited to * form domain-specific drawings. Component subjects contain structural, * connectivity, constraint, and transfer function information. */ #ifndef unidraw_components_component_h #define unidraw_components_component_h #include #ifndef UnidrawCommon class Command; #endif class ComponentView; class Iterator; #ifndef UnidrawCommon class StateVar; class TransferFunct; #endif class UList; #include //: base class for objects that model domain specific elements. // man page class Component { public: virtual void Update(); virtual void Notify(); #ifndef UnidrawCommon virtual void Interpret(Command*); virtual void Uninterpret(Command*); #endif virtual Component* GetParent(); virtual Component* GetRoot(); #ifndef UnidrawCommon virtual StateVar* GetState(const char*); virtual TransferFunct* GetTransferFunct(); #endif virtual void First(Iterator&); virtual void Last(Iterator&); virtual void Next(Iterator&); virtual void Prev(Iterator&); virtual boolean Done(Iterator); virtual void Attach(ComponentView*); virtual void Detach(ComponentView*); #ifndef UnidrawCommon ComponentView* Create(ClassId); #endif virtual ~Component(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual ClassId GetSubstId(const char*& delim); virtual boolean IsA(ClassId); static boolean use_unidraw() { return _use_unidraw; } static void use_unidraw(boolean flag) { _use_unidraw = flag; } UList* ViewList() { return _views; } ComponentView* View(UList*); protected: Component(); virtual void SetParent(Component* child, Component* parent); protected: UList* _views; static boolean _use_unidraw; }; #endif ivtools-1.2.11a1/src/include/Unidraw/Components/compview.h000066400000000000000000000045561214471147700235110ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ComponentView - base class for views of Components. */ #ifndef unidraw_components_compview_h #define unidraw_components_compview_h #include #include #ifndef UnidrawCommon class Command; #endif class Component; class Iterator; //: base class for views of objects that model domain-specific elements. // man page class ComponentView : public Resource { public: virtual void Update(); #ifndef UnidrawCommon virtual void Interpret(Command*); virtual void Uninterpret(Command*); #endif virtual ComponentView* GetParent(); virtual void First(Iterator&); virtual void Last(Iterator&); virtual void Next(Iterator&); virtual void Prev(Iterator&); virtual boolean Done(Iterator); Component* GetSubject(); virtual ~ComponentView(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); ComponentView(Component* subject = nil); virtual ComponentView* Duplicate() { return new ComponentView(); } protected: friend class Component; public: virtual void SetSubject(Component*); protected: virtual void SetParent(ComponentView* child, ComponentView* parent); Component* _subject; }; #endif ivtools-1.2.11a1/src/include/Unidraw/Components/connector.h000066400000000000000000000056611214471147700236500ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Connector - object for defining and maintaining connectivity between * components. */ #ifndef unidraw_components_connector_h #define unidraw_components_connector_h #include #include class CGlue; class CSolver; class CSolverInfo; class Path; class StateVar; //: for defining and maintaining connectivity between components. // man page class Connector : public GraphicComp { public: virtual ~Connector(); virtual void Connect(Connector*, CGlue* = nil); virtual void Disconnect(Connector*); virtual boolean ConnectedTo(Connector*); void DisconnectAll(); virtual void GetCenter(float&, float&); virtual void SetBinding(StateVar*); virtual StateVar* GetBinding(); virtual void SetTransMethod(TransMethod); virtual TransMethod GetTransMethod(); virtual void Transmit(Path* = nil); virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Connector(Graphic* = nil); Connector* Conn(UList*); virtual void ConnectMe(Connector*); virtual void DisconnectMe(Connector*); void Retransmit(Path*); void Retransmit(Connector* peer, Path*); boolean Transferable(Connector* peer); protected: UList* _cnxns; /* list of connections */ StateVar* _stateVar; TransMethod _transMethod; protected: friend class CSolver; CSolverInfo* _csinfo; }; class ConnectorView : public GraphicView { public: Connector* GetConnector(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: ConnectorView(Connector* = nil); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Components/csolver.h000066400000000000000000000117461214471147700233340ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * CSolver - connector constraint solver. */ #ifndef unidraw_csolver_h #define unidraw_csolver_h #include class CCnxn; class CCnxn_HashTable; class CGlue; class CNet; class ConnInfo; class Connector; class CSolverState; #include //: connector constraint solver // man page class CSolver { public: CSolver(); ~CSolver(); void Connect(Connector*, Connector*, CGlue* = nil); void Disconnect(Connector*, Connector*); void Disconnect(Connector*); void Solve(); void Print(); // for debugging only CSolverState* GetState(Connector*); void SetState(CSolverState*); void Read(istream&); void Write(ostream&); protected: friend class Connector; void Wrote(Connector*); CNet* Network(UList*); ConnInfo* Info(Connector*, Orientation); void SolveAll(UList*, Orientation); void Solve(CNet*, Orientation); void DestroyCnxns(); void DestroyCnxns(CNet*); void GetState(Connector*, ConnInfo*, Orientation, CSolverState*); void Update(); void UpdateInfo(CCnxn*, Orientation); void UpdateInfo(CCnxn*, ConnInfo*, ConnInfo*, UList*); void CreateNetwork(CCnxn*, ConnInfo*, ConnInfo*, UList*); void MergeNetworks(CNet*, CNet*, UList*); void DeleteCnxnsTo(Connector*, CNet*, UList*); void DeleteCnxnsBetween(Connector*, Connector*, CNet*); void DeletePeerInfo(Connector*, ConnInfo*); void DeletePeerInfo(Connector*, ConnInfo*, Connector*); void InitInfo(Connector*); void ReadConnectors(istream&, CNet*); void InitConnectors(CNet*, CNet*); void WriteConnectors(ostream&, CCnxn_HashTable*); void Wrote(Connector*, CNet* cl, CCnxn_HashTable* written); boolean FoundFixed(CNet*, CNet*&); boolean FoundSeries(CNet*, CNet*&, CNet*&, Orientation); boolean FoundParallel(CNet*, CNet*&, CNet*&, Orientation); boolean FoundY(CNet*, CNet*&, CNet*&, CNet*&, Orientation); boolean Found2Fixed(CNet* net, Connector*& c1, Connector*& c2); void SubstFixedEquiv(CNet*, CNet*, CNet*&, Orientation); void SubstSeriesEquiv( CNet*, CNet*, CNet*, CNet*&, boolean&, boolean&, Orientation ); void SubstParallelEquiv(CNet*, CNet*, CNet*, CNet*&, boolean&,Orientation); void SubstYEquiv( CNet*, CNet*, CNet*, CNet*, CNet*&, CNet*&, CNet*&, boolean&, boolean&, boolean&, Orientation ); void SubstPseudoFixed(CNet*, Connector*, Connector*, CNet*&, Orientation); void ReplaceFixed(CNet*, CNet*, CNet*&, Orientation); void ReplaceSeries( CNet*, CNet*, CNet*, CNet*&, boolean, boolean, Orientation ); void ReplaceParallel(CNet*, CNet*, CNet*, CNet*&, boolean, Orientation); void ReplaceY( CNet*, CNet*, CNet*, CNet*, CNet*&, CNet*&, CNet*&, boolean, boolean, boolean, Orientation ); void ReplacePseudoFixed(CNet*, Connector*, Connector*, CNet*&,Orientation); void SubstFixedInfo(CNet*, Orientation); void SubstSeriesInfo(CNet*, CNet*, Orientation); void SubstParallelInfo(CNet*, Orientation); void SubstYInfo(CNet*, CNet*, CNet*, Orientation); void SubstPseudoFixedInfo(CNet*, Orientation); void ReplaceFixedInfo(CNet*, Orientation); void ReplaceSeriesInfo(CNet*, CNet*, Orientation); void ReplaceParallelInfo(CNet*, Orientation); void ReplaceYInfo(CNet*, CNet*, CNet*, Orientation); void ReplacePseudoFixedInfo(CNet*, Orientation); void DefaultPosition(CNet*); protected: UList* _hnets, *_vnets; CCnxn_HashTable* _hwritten, *_vwritten; }; class CSolverState { public: ~CSolverState(); protected: friend class CSolver; CSolverState(CCnxn* = nil, Orientation = Horizontal); CSolverState* First(); CSolverState* Next(); void Append(CSolverState*); protected: CCnxn* _cnxn; Orientation _orient; CSolverState* _next; }; #endif ivtools-1.2.11a1/src/include/Unidraw/Components/ellipse.h000066400000000000000000000046361214471147700233140ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Ellipse component declarations. */ #ifndef unidraw_components_ellipse_h #define unidraw_components_ellipse_h #include #include #include #include class SF_Ellipse; //: ellipse component // man page class EllipseComp : public GraphicComp { public: EllipseComp(SF_Ellipse* = nil); SF_Ellipse* GetEllipse(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class EllipseView : public GraphicView { public: EllipseView(EllipseComp* = nil); virtual void Interpret(Command*); virtual void Update(); virtual Manipulator* CreateManipulator(Viewer*, Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); EllipseComp* GetEllipseComp(); virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class PSEllipse : public PostScriptView { public: PSEllipse(EllipseComp* = nil); virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Components/externview.h000066400000000000000000000050541214471147700240520ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ExternView - external representation of component. */ #ifndef unidraw_components_externview_h #define unidraw_components_externview_h #include #include //: base class for external representation objects. with traversal subclasses. // base class for external representation objects and subclasses for // common traversals (PreorderView, InorderView, PostorderView). //

    man page class ExternView : public ComponentView { public: virtual boolean Emit(ostream&); virtual boolean Definition(ostream&); virtual ExternView* GetView(Iterator); virtual void SetView(ExternView*, Iterator&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: ExternView(Component* = nil); }; class PreorderView : public ExternView { public: virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PreorderView(Component* = nil); }; class InorderView : public ExternView { public: virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: InorderView(Component* = nil); }; class PostorderView : public ExternView { public: virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PostorderView(Component* = nil); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Components/grcomp.h000066400000000000000000000120311214471147700231320ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * GraphicComp - a component that has a graphical representation. * GraphicComps - class for GraphicComp composition. */ #ifndef unidraw_components_grcomp_h #define unidraw_components_grcomp_h #include #include class Bitmap; class Clipboard; class Connector; class Editor; class Graphic; class Iterator; class PSBrush; class PSColor; class PSFont; class PSPattern; class Picture; class Raster; class Transformer; //: base classes for graphical component subjects. // man page class GraphicComp : public Component { public: virtual ~GraphicComp(); virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual Graphic* GetGraphic(); virtual Component* GetParent(); virtual GraphicComp* GetComp(Iterator); virtual void SetComp(GraphicComp*, Iterator&); virtual void Bequeath(); virtual void Append(GraphicComp*); virtual void Prepend(GraphicComp*); virtual void InsertBefore(Iterator, GraphicComp*); virtual void InsertAfter(Iterator, GraphicComp*); virtual void Remove(GraphicComp*); virtual void Remove(Iterator&); virtual Mobility GetMobility(); virtual void SetMobility(Mobility); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual void SetGraphic(Graphic*); protected: GraphicComp(Graphic* = nil); virtual GraphicComp* GetGraphicComp(Graphic*); void Skip(istream&); void Mark(ostream&); int ReadBgFilled(istream&); PSBrush* ReadBrush(istream&); PSColor* ReadColor(istream&); PSFont* ReadFont(istream&); PSPattern* ReadPattern(istream&); Transformer* ReadTransformer(istream&); char* ReadString(istream&); Bitmap* ReadBitmap(istream&); Raster* ReadGraymap(istream&); Raster* ReadRaster(istream&); void ReadVertices(istream&, Coord*&, Coord*&, int&); void WriteBgFilled(boolean, ostream&); void WriteBrush(PSBrush*, ostream&); void WriteColor(PSColor*, ostream&); void WriteFont(PSFont*, ostream&); void WritePattern(PSPattern*, ostream&); void WriteTransformer(Transformer*, ostream&); void WriteString(const char*, ostream&); void WriteBitmap(Bitmap*, ostream&); void WriteGraymap(Raster*, ostream&); void WriteRaster(Raster*, ostream&); void WriteVertices(const Coord*, const Coord*, int, ostream&); protected: Graphic* _gr; static UList* _brushes; static UList* _colors; static UList* _fonts; static UList* _patterns; }; class GraphicComps : public GraphicComp { public: GraphicComps(); GraphicComps(Graphic*); virtual ~GraphicComps(); virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual void First(Iterator&); virtual void Last(Iterator&); virtual void Next(Iterator&); virtual void Prev(Iterator&); virtual boolean Done(Iterator); virtual GraphicComp* GetComp(Iterator); virtual void SetComp(GraphicComp*, Iterator&); virtual void Bequeath(); virtual void Append(GraphicComp*); virtual void Prepend(GraphicComp*); virtual void InsertBefore(Iterator, GraphicComp*); virtual void InsertAfter(Iterator, GraphicComp*); virtual void Remove(GraphicComp*); virtual void Remove(Iterator&); virtual void SetMobility(Mobility); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: GraphicComp* Comp(UList*); UList* Elem(Iterator); void SelectViewsOf(GraphicComp*, Editor*); void SelectClipboard(Clipboard*, Editor*); void StorePosition(GraphicComp*, Command*); void RestorePosition(GraphicComp*, Command*); void Group(Clipboard*, GraphicComp*, Command*); void Ungroup(GraphicComp*, Clipboard*, Command*); protected: UList* _comps; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Components/grview.h000066400000000000000000000122401214471147700231500ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * GraphicView - view of a GraphicComp. * GraphicViews - class for GraphicView Composition. */ #ifndef unidraw_components_grview_h #define unidraw_components_grview_h #include #include class ConnectorView; class Event; class Manipulator; class Graphic; class GraphicComp; class GraphicComps; class Picture; class Rubberband; class Selection; class Tool; class Transformer; class Viewer; //: base classes for graphical component views. // man page class GraphicView : public ComponentView { public: virtual ~GraphicView(); virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual void DrawHandles(); virtual void RedrawHandles(); virtual void InitHandles(); virtual void EraseHandles(); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); virtual ComponentView* GetParent(); virtual Graphic* GetGraphic(); virtual Viewer* GetViewer(); GraphicComp* GetGraphicComp(); boolean Includes(GraphicView*); virtual GraphicView* GetGraphicView(Component*); virtual GraphicView* GetView(Iterator); virtual void SetView(GraphicView*, Iterator&); virtual Selection* SelectAll(); virtual Selection* ViewContaining(Coord, Coord); virtual Selection* ViewsContaining(Coord, Coord); virtual Selection* ViewIntersecting(Coord, Coord, Coord, Coord); virtual Selection* ViewsIntersecting(Coord, Coord, Coord, Coord); virtual Selection* ViewsWithin(Coord, Coord, Coord, Coord); virtual ConnectorView* ConnectorIntersecting(Coord, Coord, Coord, Coord); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); virtual ComponentView* Duplicate() { return new GraphicView(); } protected: GraphicView(GraphicComp* = nil); virtual void SetGraphic(Graphic*); virtual void CreateHandles(); virtual int ClosestPoint(Coord x[], Coord y[], int n, Coord px, Coord py); GraphicView* View(UList*); GraphicView* GetGraphicView(Graphic*); Manipulator* CreateGraphicCompManip(Viewer*, Event&, Transformer*, Tool*); Manipulator* CreateStretchManip(Viewer*, Event&, Transformer*, Tool*); Command* InterpretGraphicCompManip(Manipulator*); Command* InterpretStretchManip(Manipulator*); friend class GVUpdater; void AddDamage(Graphic*); void IncurDamage(Graphic*); void Unselect(GraphicView*); virtual void Add(GraphicView*); virtual void Append(GraphicView*); virtual void InsertBefore(Iterator, GraphicView*); virtual void Remove(Iterator&); virtual void DeleteView(Iterator&); protected: Graphic* _gr; Rubberband* _handles; }; class GraphicViews : public GraphicView { public: GraphicViews(GraphicComps* = nil); virtual ~GraphicViews(); virtual void Interpret(Command*); virtual void Update(); virtual Graphic* GetGraphic(); GraphicComps* GetGraphicComps(); virtual void First(Iterator&); virtual void Last(Iterator&); virtual void Next(Iterator&); virtual void Prev(Iterator&); virtual boolean Done(Iterator); virtual GraphicView* GetView(Iterator); virtual void SetView(GraphicView*, Iterator&); virtual Selection* SelectAll(); virtual Selection* ViewContaining(Coord, Coord); virtual Selection* ViewsContaining(Coord, Coord); virtual Selection* ViewIntersecting(Coord, Coord, Coord, Coord); virtual Selection* ViewsIntersecting(Coord, Coord, Coord, Coord); virtual Selection* ViewsWithin(Coord, Coord, Coord, Coord); virtual ConnectorView* ConnectorIntersecting(Coord, Coord, Coord, Coord); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: UList* Elem(Iterator); virtual void Add(GraphicView*); virtual void Append(GraphicView*); virtual void InsertBefore(Iterator, GraphicView*); virtual void Remove(Iterator&); virtual void DeleteView(Iterator&); protected: UList* _views; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Components/gvupdater.h000066400000000000000000000043041214471147700236500ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * GVUpdater - class for reconciling a GraphicView's state and structure * with its subject's. */ #ifndef unidraw_components_gvupdater_h #define unidraw_components_gvupdater_h #include class GraphicView; class GVU_HashTable; class Iterator; //: GraphicView updater // class for reconciling a GraphicView's state and structure // with its subject's. //

    man page class GVUpdater { public: GVUpdater(GraphicView*); virtual void Update(); protected: void UpdateStructure(); void UpdateState(); void AddDamage(Graphic*); void IncurDamage(Graphic*); void Unselect(GraphicView*); void Add(GraphicView*); void Append(GraphicView*); void InsertBefore(Iterator, GraphicView*); void Remove(Iterator&); void DeleteView(Iterator&); virtual ClassId ViewCategory(); protected: GraphicView* _gv; protected: void RegisterSubjects(GVU_HashTable*); void InitViews(GVU_HashTable*); void RearrangeViews(GVU_HashTable*); void DamageViews(GVU_HashTable*); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Components/line.h000066400000000000000000000065031214471147700226010ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Line and MultiLine component declarations. */ #ifndef unidraw_components_line_h #define unidraw_components_line_h #include #include class Line; class SF_MultiLine; //: line component // man page class LineComp : public GraphicComp { public: LineComp(Line* = nil); virtual void Interpret(Command*); Line* GetLine(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class LineView : public GraphicView { public: LineView(LineComp* = nil); virtual void Interpret(Command*); virtual void Update(); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); virtual void GetEndpoints(Coord&, Coord&, Coord&, Coord&); LineComp* GetLineComp(); virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual void CreateHandles(); }; class PSLine : public PostScriptView { public: PSLine(LineComp* = nil); virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class MultiLineComp : public VerticesComp { public: MultiLineComp(SF_MultiLine* = nil); SF_MultiLine* GetMultiLine(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class MultiLineView : public VerticesView { public: MultiLineView(MultiLineComp* = nil); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); MultiLineComp* GetMultiLineComp(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual boolean VertexChanged(); }; class PSMultiLine : public PSVertices { public: PSMultiLine(MultiLineComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual const char* Name(); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Components/link.h000066400000000000000000000067451214471147700226170ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Link component declarations. */ #ifndef unidraw_components_link_h #define unidraw_components_link_h #include #include #include #include class Connector; class Line; //: link component // man page class LinkComp : public GraphicComp { public: LinkComp(Line* = nil); virtual ~LinkComp(); virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual void Update(); virtual void First(Iterator&); virtual void Last(Iterator&); virtual void Next(Iterator&); virtual void Prev(Iterator&); virtual boolean Done(Iterator); virtual GraphicComp* GetComp(Iterator); virtual void SetComp(GraphicComp*, Iterator&); virtual void SetMobility(Mobility); Line* GetLine(); void GetConnectors(Connector*&, Connector*&); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Connector* _conn1, *_conn2; }; class LinkView : public GraphicView { public: LinkView(LinkComp* = nil); virtual ~LinkView(); virtual void Update(); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); virtual void First(Iterator&); virtual void Last(Iterator&); virtual void Next(Iterator&); virtual void Prev(Iterator&); virtual boolean Done(Iterator); virtual GraphicView* GetView(Iterator); virtual void SetView(GraphicView*, Iterator&); virtual void GetEndpoints(Coord&, Coord&, Coord&, Coord&); LinkComp* GetLinkComp(); virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual void CreateHandles(); Line* GetLine(); virtual LinkComp* NewSubject(Line*); Manipulator* CreateLinkCompManip(Viewer*, Event&, Transformer*, Tool*); Command* InterpLinkCompManip(Manipulator*); protected: ConnectorView* _connView1, *_connView2; }; class PSLink : public PostScriptView { public: PSLink(LinkComp* = nil); virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Components/pad.h000066400000000000000000000067061214471147700224230ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Pad component declarations. */ #ifndef unidraw_components_pad_h #define unidraw_components_pad_h #include #include #include #include class PadGraphic; //: pad component // man page class PadComp : public Connector { public: PadComp(PadGraphic* = nil); virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual void Connect(Connector*, CGlue* = nil); virtual Mobility GetMobility(); virtual void SetMobility(Mobility); PadGraphic* GetPad(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Mobility _mobility; }; class PadView : public ConnectorView { public: PadView(PadComp* = nil); virtual void Interpret(Command*); virtual void Update(); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); PadComp* GetPadComp(); virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PadGraphic* GetPad(); virtual PadComp* NewSubject(PadGraphic*); Manipulator* CreateGraphicCompManip(Viewer*,Event&,Transformer*,Tool*); Manipulator* CreateConnectManip(Viewer*,Event&,Transformer*,Tool*); Command* InterpGraphicCompManip(Manipulator*); Command* InterpConnectManip(Manipulator*); }; class PadGraphic : public Graphic { public: PadGraphic(Coord = 0, Coord = 0, Coord = 0, Coord = 0, Graphic* = nil); virtual ~PadGraphic(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); void GetOriginal(Coord&, Coord&, Coord&, Coord&); virtual Graphic* Copy(); protected: virtual void concatGS(Graphic*, Graphic*, Graphic*); virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: Coord _l, _b, _r, _t; PSBrush* _br; }; class PSPad : public PostScriptView { public: PSPad(PadComp* = nil); virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Components/pin.h000066400000000000000000000102001214471147700224250ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Pin component declarations. */ #ifndef unidraw_components_pin_h #define unidraw_components_pin_h #include #include #include #include #include class PinGraphic; //: pin component // man page class PinComp : public Connector { public: PinComp(PinGraphic* = nil); virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual void Connect(Connector*, CGlue* = nil); virtual Mobility GetMobility(); virtual void SetMobility(Mobility); PinGraphic* GetPin(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: Mobility _mobility; }; class PinView : public ConnectorView { public: PinView(PinComp* = nil); virtual void Interpret(Command*); virtual void Update(); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); PinComp* GetPinComp(); virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PinGraphic* GetPin(); virtual PinComp* NewSubject(PinGraphic*); Manipulator* CreateGraphicCompManip(Viewer*,Event&,Transformer*,Tool*); Manipulator* CreateConnectManip(Viewer*,Event&,Transformer*,Tool*); Command* InterpGraphicCompManip(Manipulator*); Command* InterpConnectManip(Manipulator*); }; class PinGraphic : public Graphic { public: PinGraphic(Coord = 0, Coord = 0, Graphic* = nil); virtual ~PinGraphic(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); void GetOriginal(Coord&, Coord&); virtual Graphic* Copy(); protected: virtual void concatGS(Graphic*, Graphic*, Graphic*); virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: Coord _x, _y; PSBrush* _br; }; class PSPin : public PostScriptView { public: PSPin(PinComp* = nil); virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class SlidingPin : public SlidingEllipse { public: SlidingPin( Painter*, Canvas*, Coord cx, Coord cy, int, Coord rfx, Coord rfy ); virtual ClassId GetClassId() { return SLIDINGPIN; } virtual boolean IsA (ClassId id) { return SLIDINGPIN == id || SlidingEllipse::IsA(id); } virtual void Draw(); }; class FixedPin : public Rubberband { public: FixedPin(Painter*, Canvas*, Coord, Coord, int); virtual ClassId GetClassId() { return FIXEDPIN; } virtual boolean IsA (ClassId id) { return FIXEDPIN == id || Rubberband::IsA(id); } virtual void GetOriginal(Coord&, Coord&, int&); virtual void Draw(); protected: Coord _cx, _cy; int _rad; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Components/polygon.h000066400000000000000000000043461214471147700233440ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Polygon component declarations. */ #ifndef unidraw_components_polygon_h #define unidraw_components_polygon_h #include class SF_Polygon; //: polygon component // man page class PolygonComp : public VerticesComp { public: PolygonComp(SF_Polygon* = nil); SF_Polygon* GetPolygon(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class PolygonView : public VerticesView { public: PolygonView(PolygonComp* = nil); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); PolygonComp* GetPolygonComp(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual boolean VertexChanged(); }; class PSPolygon : public PSVertices { public: PSPolygon(PolygonComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual const char* Name(); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Components/psformat.h000066400000000000000000000061631214471147700235070ustar00rootroot00000000000000/* * Copyright (c) 1998,1999 Vectaport Inc. * Copyright (c) 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * PostScript external representation format changes. */ #ifndef unidraw_components_psformat_h #define unidraw_components_psformat_h #include static const float PSV_CAPJOINSTYLE = 14; // support for capstyle/joinstyle // (probably won't be backward compatible) static const float PSV_LOADFONT = 13; // support for executable fonts static const float PSV_FLOATWIDTH = 12; // floating point line width // (not backward compatible if utilized) static const float PSV_CLOSEPATH = 11; // addition of "closepath" to ellipse // and circle PostScript fragments. static const float PSV_UNIDRAW = 10; // 1st Unidraw-based version static const float PSV_ISOLATIN1 = 9; // removed '/' from PostScript fonts // (they're def'ed in IdrawDict now) static const float PSV_EIGHTBIT = 8; // encoded 8-bit characters as \ddd static const float PSV_TEXTOFFSET = 7; // changed text positions on screen // and improved accuracy of // text positions on prfloatout static const float PSV_NONROTATED = 6; // replaced rotation of drawing with // rotation of view for landscape static const float PSV_GRIDSPACING = 5; // added grid spacing static const float PSV_FGANDBGCOLOR = 4; // added background color and // RGB values for overriding names; // used graylevel to eliminate // redundant patternfill data static const float PSV_NONREDUNDANT = 3; // eliminated unnecessary text // pattern and duplication of // font name, transformation matrix, // poly pofloats, and text data static const float PSV_FGCOLOR = 2; // added foreground color static const float PSV_ORIGINAL = 1; // original format #define PSV_LATEST PSV_LOADFONT #endif ivtools-1.2.11a1/src/include/Unidraw/Components/psview.h000066400000000000000000000113501214471147700231630ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * PostScriptView - idraw-compatible PostScript external representation * for graphical components. */ #ifndef unidraw_components_psview_h #define unidraw_components_psview_h #include #include //: PostScript serialization // idraw-compatible PostScript external representation // for graphical components. //

    man page class PostScriptView : public PreorderView { public: virtual boolean Emit(ostream&); GraphicComp* GetGraphicComp(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PostScriptView(GraphicComp* = nil); virtual void Comments(ostream&); virtual void PSVersion(ostream&); virtual void Creator(ostream&); virtual void FontNames(ostream&); virtual void Pages(ostream&); virtual void BoundingBox(ostream&); virtual void Prologue(ostream&); virtual void Version(ostream&); virtual void GridSpacing(ostream&); virtual void Trailer(ostream&); virtual void MinGS(ostream&); virtual void FullGS(ostream&); virtual void TextGS(ostream&); virtual void Brush(ostream&); virtual void FgColor(ostream&); virtual void BgColor(ostream&); virtual void Font(ostream&); virtual void Pattern(ostream&); virtual void Transformation(ostream&); virtual void SetPSFonts(UList* = nil); virtual UList* GetPSFonts(); virtual void GetBox(Coord&, Coord&, Coord&, Coord&); virtual void GetGridSpacing(float&, float&); virtual void ConstProcs(ostream&); virtual void BeginProc(ostream&); virtual void EndProc(ostream&); virtual void SetGSProcs(ostream&); virtual void SetBrushProc(ostream&); virtual void SetFgColorProc(ostream&); virtual void SetBgColorProc(ostream&); virtual void SetFontProc(ostream&); virtual void SetPatternProc(ostream&); virtual void ObjectProcs(ostream&); virtual void BSplineProc(ostream&); virtual void CircleProc(ostream&); virtual void ClosedBSplineProc(ostream&); virtual void EllipseProc(ostream&); virtual void LineProc(ostream&); virtual void MultiLineProc(ostream&); virtual void PolygonProc(ostream&); virtual void RectangleProc(ostream&); virtual void TextProc(ostream&); virtual void MiscProcs(ostream&); virtual void DefinitionProc(ostream&); virtual void FillProc(ostream&); virtual void StrokeProc(ostream&); virtual void ShowProc(ostream&); virtual void PatternProc(ostream&); virtual void MinMaxProcs(ostream&); virtual void MidpointProc(ostream&); virtual void ThirdpointProc(ostream&); virtual void SubsplineProc(ostream&); virtual void StoreVerticesProc(ostream&); PSFont* GetFont(UList*); PostScriptView* View(UList*); PostScriptView* CreatePSView(GraphicComp*); protected: UList* _fonts; }; class PostScriptViews : public PostScriptView { public: PostScriptViews(GraphicComps* = nil); virtual ~PostScriptViews(); virtual boolean Emit(ostream&); virtual boolean Definition(ostream&); virtual void Update(); GraphicComps* GetGraphicComps(); virtual ExternView* GetView(Iterator); virtual void SetView(ExternView*, Iterator&); virtual void First(Iterator&); virtual void Last(Iterator&); virtual void Next(Iterator&); virtual void Prev(Iterator&); virtual boolean Done(Iterator); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: UList* Elem(Iterator); void DeleteView(Iterator&); void DeleteViews(); protected: UList* _views; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Components/rastercomp.h000066400000000000000000000044471214471147700240360ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Raster component declarations. */ #ifndef unidraw_components_rastercomp_h #define unidraw_components_rastercomp_h #include #include #include class RasterRect; //: raster component // man page class RasterComp : public GraphicComp { public: RasterComp(RasterRect* = nil, const char* filename = nil); virtual ~RasterComp(); RasterRect* GetRasterRect(); const char* GetFileName(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: char* _filename; }; class RasterView : public GraphicView { public: RasterView(RasterComp* = nil); virtual void Update(); RasterComp* GetRasterComp(); virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class PSRaster : public PostScriptView { public: PSRaster(RasterComp* = nil); virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Components/rect.h000066400000000000000000000047541214471147700226150ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Rect component declarations. */ #ifndef unidraw_components_rect_h #define unidraw_components_rect_h #include #include #include #include class SF_Rect; //: rectangle component // man page class RectComp : public GraphicComp { public: RectComp(SF_Rect* = nil); SF_Rect* GetRect(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class RectView : public GraphicView { public: RectView(RectComp* = nil); virtual void Interpret(Command*); virtual void Update(); virtual Manipulator* CreateManipulator(Viewer*, Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); virtual void GetCorners(Coord*, Coord*); RectComp* GetRectComp(); virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual void CreateHandles(); protected: int _reshapeCorner; }; class PSRect : public PostScriptView { public: PSRect(RectComp* = nil); virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Components/slot.h000066400000000000000000000107261214471147700226350ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Slot component declarations. */ #ifndef unidraw_components_slot_h #define unidraw_components_slot_h #include #include #include #include class SlotGraphic; //: slot component // man page class SlotComp : public Connector { public: virtual void Interpret(Command*); virtual void Uninterpret(Command*); virtual Mobility GetMobility(); virtual void SetMobility(Mobility); SlotGraphic* GetSlot(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: SlotComp(SlotGraphic* = nil); void SetOrientation(SlotGraphic*, Orientation); protected: Mobility _mobility; }; class SlotView : public ConnectorView { public: virtual void Interpret(Command*); virtual void Update(); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); SlotComp* GetSlotComp(); virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: SlotView(SlotComp* = nil); SlotGraphic* GetSlot(); virtual SlotComp* NewSubject(SlotGraphic*); Manipulator* CreateGraphicCompManip(Viewer*,Event&,Transformer*,Tool*); Manipulator* CreateConnectManip(Viewer*,Event&,Transformer*,Tool*); Command* InterpGraphicCompManip(Manipulator*); Command* InterpConnectManip(Manipulator*); }; class SlotGraphic : public Graphic { public: SlotGraphic(Coord, Coord, Coord, Graphic* = nil); virtual ~SlotGraphic(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); void GetOriginal(Coord&, Coord&, Coord&); Orientation GetOrientation(); virtual Graphic* Copy(); protected: virtual void concatGS(Graphic*, Graphic*, Graphic*); virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: Coord _x, _y, _length; PSBrush* _br; protected: friend class SlotComp; void SetOrientation(Orientation); }; class HSlotComp : public SlotComp { public: HSlotComp(SlotGraphic* = nil); virtual void Connect(Connector*, CGlue* = nil); virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class HSlotView : public SlotView { public: HSlotView(HSlotComp* = nil); HSlotComp* GetHSlotComp(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual SlotComp* NewSubject(SlotGraphic*); }; class VSlotComp : public SlotComp { public: VSlotComp(SlotGraphic* = nil); virtual void Connect(Connector*, CGlue* = nil); virtual Component* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class VSlotView : public SlotView { public: VSlotView(VSlotComp* = nil); VSlotComp* GetVSlotComp(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual SlotComp* NewSubject(SlotGraphic*); }; class PSSlot : public PostScriptView { public: PSSlot(SlotComp* = nil); virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Components/spline.h000066400000000000000000000062461214471147700231500ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Spline component declarations. */ #ifndef unidraw_components_spline_h #define unidraw_components_spline_h #include class SFH_OpenBSpline; class SFH_ClosedBSpline; //: spline component // man page class SplineComp : public VerticesComp { public: SplineComp(SFH_OpenBSpline* = nil); SFH_OpenBSpline* GetSpline(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class SplineView : public VerticesView { public: SplineView(SplineComp* = nil); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); SplineComp* GetSplineComp(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual boolean VertexChanged(); }; class PSSpline : public PSVertices { public: PSSpline(SplineComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual const char* Name(); }; class ClosedSplineComp : public VerticesComp { public: ClosedSplineComp(SFH_ClosedBSpline* = nil); SFH_ClosedBSpline* GetClosedSpline(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class ClosedSplineView : public VerticesView { public: ClosedSplineView(ClosedSplineComp* = nil); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); ClosedSplineComp* GetClosedSplineComp(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual boolean VertexChanged(); }; class PSClosedSpline : public PSVertices { public: PSClosedSpline(ClosedSplineComp* = nil); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual const char* Name(); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Components/stencilcomp.h000066400000000000000000000044561214471147700241770ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Stencil component declarations. */ #ifndef unidraw_components_stencilcomp_h #define unidraw_components_stencilcomp_h #include #include #include class UStencil; //: stencil component // man page class StencilComp : public GraphicComp { public: StencilComp(UStencil* = nil, const char* filename = nil); virtual ~StencilComp(); UStencil* GetStencil(); const char* GetFileName(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: char* _filename; }; class StencilView : public GraphicView { public: StencilView(StencilComp* = nil); virtual void Update(); StencilComp* GetStencilComp(); virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class PSStencil : public PostScriptView { public: PSStencil(StencilComp* = nil); virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Components/text.h000066400000000000000000000065561214471147700226460ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Text component declarations. */ #ifndef unidraw_components_text_h #define unidraw_components_text_h #include #include #include #include #include class TextGraphic; class TextManip; class TextComp : public GraphicComp { public: TextComp(TextGraphic* = nil); virtual void Interpret(Command*); virtual void Uninterpret(Command*); TextGraphic* GetText(); virtual Component* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; class TextView : public GraphicView { public: TextView(TextComp* = nil); virtual void Interpret(Command*); virtual void Update(); virtual Manipulator* CreateManipulator(Viewer*,Event&,Transformer*,Tool*); virtual Command* InterpretManipulator(Manipulator*); TextComp* GetTextComp(); virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual boolean TextChanged(); }; class TextGraphic : public ULabel { public: TextGraphic(const char*, int h, Graphic* = nil); TextGraphic(const char*, Graphic*); void SetLineHeight(int); int GetLineHeight(); virtual boolean operator == (TextGraphic&); virtual boolean operator != (TextGraphic&); virtual Graphic* Copy(); virtual ClassId CompId(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: void CalcBox(Coord&, Coord&, Coord&, Coord&, PSFont*); boolean RotatedIntersects(BoxObj&, Graphic*); boolean TransformedIntersects(BoxObj&, Graphic*); boolean UntransformedIntersects(BoxObj&, Graphic*); protected: int _lineHt; }; class PSText : public PostScriptView { public: PSText(TextComp* = nil); virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: const char* Filter(const char*, int); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Components/vertices.h000066400000000000000000000046271214471147700235030ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Vertices component declarations. A vertices component's * geometry is defined by a set of vertices. */ #ifndef unidraw_components_vertices_h #define unidraw_components_vertices_h #include #include #include #include class Vertices; class VerticesComp : public GraphicComp { public: Vertices* GetVertices(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: VerticesComp(Vertices* = nil); }; class VerticesView : public GraphicView { public: virtual void Interpret(Command*); virtual void Update(); virtual void GetVertices(Coord*&, Coord*&, int&); VerticesComp* GetVerticesComp(); virtual Graphic* GetGraphic(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: VerticesView(VerticesComp* = nil); virtual void CreateHandles(); virtual boolean VertexChanged(); protected: int _reshapePt; }; class PSVertices : public PostScriptView { public: virtual boolean Definition(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PSVertices(VerticesComp* = nil); virtual const char* Name(); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/000077500000000000000000000000001214471147700207255ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/Unidraw/Graphic/damage.h000066400000000000000000000054311214471147700223170ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Damage - maintains an array of non-overlapping rectangles representing * damaged areas of of a canvas, used for smart redraw. */ #ifndef unidraw_graphic_damage_h #define unidraw_graphic_damage_h #include #include #include class BoxObj; class Canvas; class Graphic; class Iterator; class Painter; class UList; //: damage-repair mechanism // maintains an array of non-overlapping rectangles representing // damaged areas of of a canvas, used for smart redraw. //

    man page class Damage { public: Damage(Canvas* = nil, Painter* = nil, Graphic* = nil); virtual ~Damage(); virtual boolean Incurred(); virtual void Added(Graphic*); virtual void Incur(Graphic*); virtual void Incur(BoxObj&); virtual void Incur(Coord, Coord, Coord, Coord); virtual void Repair(); virtual void Reset(); void SetCanvas(Canvas*); void SetPainter(Painter*); void SetGraphic(Graphic*); Canvas* GetCanvas(); Painter* GetPainter(); Graphic* GetGraphic(); protected: int Area(BoxObj&); virtual void DrawAreas(); virtual void DrawAdditions(); virtual void Merge(BoxObj&); BoxObj* GetArea(Iterator); Graphic* GetAddition(Iterator); void FirstArea(Iterator&); void FirstAddition(Iterator&); void Next(Iterator&); boolean Done(Iterator); UList* Elem(Iterator); void DeleteArea(BoxObj*); void DeleteAreas(); protected: UList* _additions; UList* _areas; protected: Canvas* _canvas; Painter* _output; Graphic* _graphic; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/ellipses.h000066400000000000000000000112651214471147700227230ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Interface to Ellipses and Circles, objects derived from Graphic. */ #ifndef unidraw_graphic_ellipses_h #define unidraw_graphic_ellipses_h #include #include class MultiLineObj; //: ellipse graphic // man page class Ellipse : public Graphic { public: void GetOriginal(Coord&, Coord&, int&, int&); void SetOriginal(Coord, Coord, int, int); Ellipse(Coord x0, Coord y0, int r1, int r2, Graphic* gr = nil); MultiLineObj* ellipse_to_polygon(Transformer* t = nil); protected: void s_getExtent(float&, float&, float&, float&, float&, Graphic*); void f_getExtent(float&, float&, float&, float&, float&, Graphic*); boolean s_contains(PointObj&, Graphic*); boolean f_contains(PointObj&, Graphic*); boolean s_intersects(BoxObj&, Graphic*); boolean f_intersects(BoxObj&, Graphic*); protected: Coord _x0, _y0; int _r1, _r2; static Coord _x[8], _y[8]; protected: void CalcControlPts(Transformer*); }; //: stroked ellipse graphic // man page class S_Ellipse : public Ellipse { public: S_Ellipse(Coord x0, Coord y0, int r1, int r2, Graphic* gr = nil); virtual ~S_Ellipse(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSBrush* _br; }; //: filled ellipse graphic // man page class F_Ellipse : public Ellipse { public: F_Ellipse(Coord x0, Coord y0, int r1, int r2, Graphic* gr = nil); virtual ~F_Ellipse(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSPattern* _pat; }; //: stroke-filled ellipse graphic // man page class SF_Ellipse : public Ellipse { public: SF_Ellipse(Coord x0, Coord y0, int r1, int r2, Graphic* gr = nil); virtual ~SF_Ellipse(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual Graphic* Copy(); virtual ClassId CompId(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSBrush* _br; PSPattern* _pat; }; //: stroked circle graphic // man page class S_Circle : public S_Ellipse { public: S_Circle(Coord x0, Coord y0, int radius, Graphic* gr = nil); virtual Graphic* Copy(); }; //: filled circle graphic // man page class F_Circle : public F_Ellipse { public: F_Circle(Coord x0, Coord y0, int radius, Graphic* gr = nil); virtual Graphic* Copy(); }; //: stroked-filled circle graphic // man page class SF_Circle : public SF_Ellipse { public: SF_Circle(Coord x0, Coord y0, int radius, Graphic* gr = nil); virtual Graphic* Copy(); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/geomobjs.h000066400000000000000000000117451214471147700227130ustar00rootroot00000000000000/* * Copyright (c) 1994 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Interface to geometrical objects used to implement Graphic primitives. */ #ifndef unidraw_graphic_geomobjs_h #define unidraw_graphic_geomobjs_h #include #include #include #include #define GEOMOBJS_DEFINED #include class UList; #include //: point geometric object // man page class PointObj { public: PointObj(Coord = 0, Coord = 0); PointObj(PointObj*); float Distance(PointObj&); public: Coord _x, _y; }; //: line geometric object // man page class LineObj { public: LineObj(Coord = 0, Coord = 0, Coord = 0, Coord = 0); LineObj(LineObj*); boolean Contains(PointObj&); int Same(PointObj& p1, PointObj& p2); boolean Intersects(LineObj&); public: PointObj _p1, _p2; }; //: box geometric object // man page class BoxObj { public: BoxObj(Coord = 0, Coord = 0, Coord = 0, Coord = 0); BoxObj(BoxObj*); boolean Contains(PointObj&); boolean Intersects(BoxObj&); boolean Intersects(LineObj&); BoxObj operator-(BoxObj&); BoxObj operator+(BoxObj&); boolean Within(BoxObj&); public: Coord _left, _right; Coord _bottom, _top; }; //: multi-line geometric object // man page class MultiLineObj : public Resource { public: MultiLineObj(Coord* = nil, Coord* = nil, int = 0); virtual ~MultiLineObj(); void GetBox(BoxObj& b); boolean Contains(PointObj&); boolean Intersects(LineObj&); boolean Intersects(BoxObj&); boolean Within(BoxObj&); void SplineToMultiLine(Coord* cpx, Coord* cpy, int cpcount); void ClosedSplineToPolygon(Coord* cpx, Coord* cpy, int cpcount); protected: void GrowBuf(); boolean CanApproxWithLine( double x0, double y0, double x2, double y2, double x3, double y3 ); void AddLine(double x0, double y0, double x1, double y1); void AddBezierArc( double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3 ); void CalcSection( Coord cminus1x, Coord cminus1y, Coord cx, Coord cy, Coord cplus1x, Coord cplus1y, Coord cplus2x, Coord cplus2y ); public: Coord* _x, *_y; int _count; UList* _ulist; int _pts_made; Coord* x() {return _x;} Coord* y() {return _y;} int count() {return _count;} virtual boolean operator == (MultiLineObj&); virtual boolean operator != (MultiLineObj&); static MultiLineObj* make_pts(const Coord* x, const Coord*y, int npts); static void CompactPoints(boolean flag) {_pts_by_n_enabled=flag;} protected: static UList** _pts_by_n; static int _pts_by_n_size; static boolean _pts_by_n_enabled; #ifdef LEAKCHECK public: static LeakChecker* _leakchecker; #endif }; //: filled polygon geometric object // man page class FillPolygonObj : public MultiLineObj { public: FillPolygonObj(Coord* = nil, Coord* = nil, int = 0); virtual ~FillPolygonObj(); boolean Contains(PointObj&); boolean Intersects(LineObj&); boolean Intersects(BoxObj&); protected: void Normalize(); protected: Coord* _normx, *_normy; int _normCount; }; //: geometric extent object // man page class Extent { public: Extent(float = 0, float = 0, float = 0, float = 0, float = 0); Extent(Extent&); boolean Undefined(); boolean Within(Extent& e); void Merge(Extent&); public: /* defines lower left and center of an object */ float _left, _bottom, _cx, _cy, _tol; }; /* * inlines */ inline boolean Extent::Undefined () { return _left == _cx && _bottom == _cy; } #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/graphic.h000066400000000000000000000335111214471147700225160ustar00rootroot00000000000000/* * Copyright (c) 1994 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Interface to Graphic base class and FullGraphic, a subclass of Graphic * for which all graphics state is defined. */ #ifndef unidraw_graphic_graphic_h #define unidraw_graphic_graphic_h #include #include #include #include #include static const int UNDEF = -1; class Canvas; class Iterator; class Painter; class Transformer; //: graphic base-classe // interface to Graphic base class and FullGraphic, a subclass of Graphic // for which all graphics state is defined. //

    man page class Graphic { public: virtual ~Graphic(); virtual void Draw(Canvas*); virtual void Draw(Canvas*, Coord, Coord, Coord, Coord); virtual void DrawClipped(Canvas*, Coord, Coord, Coord, Coord); virtual void Erase(Canvas*); virtual void Erase(Canvas*, Coord, Coord, Coord, Coord); virtual void EraseClipped(Canvas*, Coord, Coord, Coord, Coord); virtual void FillBg(int); virtual int BgFilled(); virtual void SetColors(PSColor* f, PSColor* b); virtual PSColor* GetFgColor(); virtual PSColor* GetBgColor(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual void SetFont(PSFont*); virtual PSFont* GetFont(); void Translate(float dx, float dy); void Scale(float sx, float sy, float ctrx = 0.0, float ctry = 0.0); void Rotate(float angle, float ctrx = 0.0, float ctry = 0.0); void Align(Alignment, Graphic*, Alignment); void SetTransformer(Transformer*); Transformer* GetTransformer(); void TotalTransformation(Transformer&); void GetBounds(float&, float&, float&, float&); void GetBox(Coord&, Coord&, Coord&, Coord&); void GetBox(BoxObj&); virtual void GetCenter(float&, float&); virtual boolean Contains(PointObj&); virtual boolean Intersects(BoxObj&); void SetTag(void*); void* GetTag(); Graphic* Parent(); virtual void First(Iterator&); virtual void Last(Iterator&); virtual void Next(Iterator&); virtual void Prev(Iterator&); virtual boolean Done(Iterator); virtual Graphic* GetGraphic(Iterator); virtual void SetGraphic(Graphic*, Iterator&); virtual void Append(Graphic*, Graphic* =nil, Graphic* =nil, Graphic* =nil); virtual void Prepend(Graphic*,Graphic* =nil, Graphic* =nil, Graphic* =nil); virtual void InsertBefore(Iterator, Graphic*); virtual void InsertAfter(Iterator, Graphic*); virtual void Remove(Graphic*); virtual void Remove(Iterator&); virtual void Bequeath(); virtual Graphic* FirstGraphicContaining(PointObj&); virtual Graphic* LastGraphicContaining(PointObj&); virtual Graphic* FirstGraphicIntersecting(BoxObj&); virtual Graphic* LastGraphicIntersecting(BoxObj&); virtual Graphic* FirstGraphicWithin(BoxObj&); virtual Graphic* LastGraphicWithin(BoxObj&); virtual Graphic& operator = (Graphic&); virtual Graphic* Copy(); virtual ClassId CompId(); static boolean use_iv() { return _use_iv; } static void use_iv(boolean flag) { _use_iv = flag; } protected: Graphic(Graphic* gr = nil); /* * Member functions that declare a "Graphic* gs" parameter * take into account that graphic's graphic state information when * performing their function. This is useful in hierarchical graphic objects * (such as Pictures) where higher-level graphics' graphics state influences * lower (and ultimately leaf) graphics'. */ void update(Graphic* gs); /* updates painter w/gs' state */ virtual void draw(Canvas*, Graphic* gs); virtual void drawClipped(Canvas*, Coord, Coord, Coord, Coord, Graphic* gs); virtual void erase(Canvas*, Graphic* gs); virtual void eraseClipped(Canvas*, Coord, Coord, Coord, Coord,Graphic* gs); /* * Bounding box operations. */ virtual void getExtent(float&, float&, float&, float&, float&,Graphic* gs); /* Returns lower-left and center coordinates, and a tolerance (tol) * (in canvas coordinates) by which the final extent will be grown * in each direction (i.e. l-=tol, b-=tol, r+=tol, t+=tol). */ void GetExtent(Extent& e); void getBounds(float&, float&, float&, float&, Graphic* gs); void getBox(Coord&, Coord&, Coord&, Coord&, Graphic* gs); void getBox(BoxObj&, Graphic* gs); virtual boolean contains(PointObj&, Graphic* gs); virtual boolean intersects(BoxObj&, Graphic* gs); /* * Parent-related operations. */ Graphic* getRoot(); /* top level parent */ void totalGS(Graphic& p); void parentXform(Transformer& t); /* parents' transformation */ void setParent(Graphic*, Graphic* parent); void unsetParent(Graphic*); /* * Bounding box caching operations. */ public: void cachingOn(); void cachingOff(); virtual boolean extentCached(); virtual void uncacheExtent(); virtual void uncacheParents(); virtual void uncacheChildren(); virtual void invalidateCaches(); /* * Graphics state concatentation operations. */ public: virtual void concatGS(Graphic* a, Graphic* b, Graphic* dest); virtual void concatTransformer( Transformer* a, Transformer* b, Transformer* dest ); virtual void concat(Graphic* a, Graphic* b, Graphic* dest); /* * Convenient transformations that check first if there's a transformer and * then perform the (inverse) transformation. The functions use the * transformer of the supplied Graphic if there is one; otherwise this' * transformer is used. */ protected: void transform(Coord& x, Coord& y, Graphic* = nil); void transform(Coord x, Coord y, Coord& tx, Coord& ty, Graphic* = nil); void transform(float x, float y, float& tx, float& ty, Graphic* = nil); void transformList( Coord x[], Coord y[], int n, Coord tx[], Coord ty[], Graphic* = nil ); void transformRect( float, float, float, float, float&, float&, float&, float&, Graphic* = nil ); void invTransform(Coord& tx, Coord& ty, Graphic* = nil); void invTransform(Coord tx, Coord ty, Coord& x, Coord& y, Graphic* = nil); void invTransform(float tx, float ty, float& x, float& y, Graphic* = nil); void invTransformList( Coord tx[], Coord ty[], int n, Coord x[], Coord y[], Graphic* = nil ); void invTransformRect( float, float, float, float, float&, float&, float&, float&, Graphic* = nil ); /* * "Helper" functions that allow graphic subclasses to call * the protected member functions redefined by other graphic subclasses. */ void drawGraphic(Graphic*, Canvas*, Graphic*); void drawClippedGraphic(Graphic*,Canvas*,Coord,Coord,Coord,Coord,Graphic*); void eraseGraphic(Graphic*, Canvas*, Graphic*); void eraseClippedGraphic( Graphic*, Canvas*, Coord, Coord, Coord, Coord, Graphic* ); void getExtentGraphic( Graphic*, float&, float&, float&, float&, float&, Graphic* gs ); boolean containsGraphic(Graphic*, PointObj&, Graphic* gs); boolean intersectsGraphic(Graphic*, BoxObj&, Graphic* gs); boolean extentCachedGraphic(Graphic*); void uncacheExtentGraphic(Graphic*); void uncacheParentsGraphic(Graphic*); void uncacheChildrenGraphic(Graphic*); void invalidateCachesGraphic(Graphic*); void concatGSGraphic(Graphic*, Graphic*, Graphic*, Graphic*); void concatTransformerGraphic( Graphic*,Transformer*, Transformer*, Transformer* ); void concatGraphic(Graphic*, Graphic*, Graphic*, Graphic*); protected: static Transformer* _identity; /* identity matrix */ static boolean _caching; /* state of bounding box caching */ static Painter* _p; static BoxObj* _clipping; /* current painter clipping, if any */ Graphic* _parent; int _fillBg; PSColor* _fg; PSColor* _bg; void* _tag; Transformer* _t; /* extensions required by OverlayUnidraw */ public: void Hide(boolean hide=true); void Show(boolean show=true); boolean Hidden(); void Desensitize(boolean desensitize=true); void Sensitize(boolean sensitize=true); boolean Desensitized(); void OverrideGS(boolean overide_flag=true); boolean OverriddenGS(); void ToggleHide(); void ToggleDesensitize(); void ToggleOverrideGS(); protected: unsigned int _flags; static unsigned int _hide_mask; static unsigned int _desensitize_mask; static unsigned int _overridegs_mask; static boolean _use_iv; #ifdef LEAKCHECK public: static LeakChecker* _leakchecker; #endif }; class FullGraphic : public Graphic { public: FullGraphic(Graphic* = nil); virtual ~FullGraphic(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual void SetFont(PSFont*); virtual PSFont* GetFont(); virtual Graphic* Copy(); protected: PSPattern* _pat; PSBrush* _br; PSFont* _font; }; /* * inlines */ inline Transformer* Graphic::GetTransformer () { return _t; } inline Graphic* Graphic::Parent () { return _parent; } inline void Graphic::SetTag (void* tag) { _tag = tag; } inline void* Graphic::GetTag () { return _tag; } inline void Graphic::GetBox (BoxObj& b) { GetBox(b._left, b._bottom, b._right, b._top); } inline void Graphic::getBox (BoxObj& b, Graphic* p) { getBox(b._left, b._bottom, b._right, b._top, p); } inline void Graphic::getBounds ( float& l, float& b, float& r, float& t, Graphic* gs ) { float tol; getExtent(l, b, r, t, tol, gs); r += r - l; t += t - b; l -= tol; b -= tol; r += tol; t += tol; } inline void Graphic::Hide(boolean hide) { if (hide) _flags |= _hide_mask; else _flags &= ~_hide_mask; } inline void Graphic::Show(boolean show) { if (show) _flags &= ~_hide_mask; else _flags |= _hide_mask; } inline boolean Graphic::Hidden( ) { return _flags & _hide_mask; } inline void Graphic::Desensitize(boolean desensitize) { if (desensitize) _flags |= _desensitize_mask; else _flags &= ~_desensitize_mask; } inline void Graphic::Sensitize(boolean sensitize) { if (sensitize) _flags &= ~_desensitize_mask; else _flags |= _desensitize_mask; } inline boolean Graphic::Desensitized( ) { return _flags & _desensitize_mask; } inline void Graphic::OverrideGS(boolean override_flag) { if (override_flag) _flags |= _overridegs_mask; else _flags &= ~_overridegs_mask; } inline boolean Graphic::OverriddenGS() { return _flags & _overridegs_mask; } inline void Graphic::ToggleHide() { if (Hidden()) Show(); else Hide(); } inline void Graphic::ToggleDesensitize() { if (Desensitized()) Sensitize(); else Desensitize(); } inline void Graphic::ToggleOverrideGS() { OverrideGS(!OverriddenGS()); } inline void Graphic::drawGraphic (Graphic* g, Canvas* c, Graphic* gs) { if (!g->Hidden()) g->draw(c, gs); } inline void Graphic::eraseGraphic (Graphic* g, Canvas* c, Graphic* gs) { if (!g->Hidden()) g->erase(c, gs); } inline void Graphic::drawClippedGraphic ( Graphic* g, Canvas* c, Coord l, Coord b, Coord r, Coord t, Graphic* gs ) { if (!g->Hidden()) g->drawClipped(c, l, b, r, t, gs); } inline void Graphic::eraseClippedGraphic ( Graphic* g, Canvas* c, Coord l, Coord b, Coord r, Coord t, Graphic* gs ) { if (!g->Hidden()) g->eraseClipped(c, l, b, r, t, gs); } inline void Graphic::getExtentGraphic ( Graphic* g, float& l, float& b, float& r, float& t, float& tol, Graphic* gs ) { g->getExtent(l, b, r, t, tol, gs); } inline boolean Graphic::containsGraphic (Graphic* g, PointObj& p, Graphic* gs){ return g->Desensitized() ? nil : g->contains(p, gs); } inline boolean Graphic::intersectsGraphic (Graphic* g, BoxObj& b, Graphic* gs){ return g->Desensitized() ? nil : g->intersects(b, gs); } inline boolean Graphic::extentCachedGraphic (Graphic* g) { return g->extentCached(); } inline void Graphic::uncacheExtentGraphic (Graphic* g) { g->uncacheExtent(); } inline void Graphic::uncacheParentsGraphic (Graphic* g) { g->uncacheParents();} inline void Graphic::uncacheChildrenGraphic (Graphic* g) { g->uncacheChildren(); } inline void Graphic::invalidateCachesGraphic (Graphic* g) { g->invalidateCaches(); } inline void Graphic::concatGSGraphic ( Graphic* g, Graphic* a, Graphic* b, Graphic* d ) { g->concatGS(a, b, d); } inline void Graphic::concatTransformerGraphic ( Graphic* g, Transformer* a, Transformer* b, Transformer* dest ) { g->concatTransformer(a, b, dest); } inline void Graphic::concatGraphic ( Graphic* g, Graphic* a, Graphic* b, Graphic* d ) { g->concat(a, b, d); } #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/grblock.h000066400000000000000000000060561214471147700225300ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * GraphicBlock - an interactor that contains a picture. */ #ifndef unidraw_graphic_grblock_h #define unidraw_graphic_grblock_h #include #include #include enum Zooming { Continuous, Binary }; class Graphic; class Perspective; //: an Interactor that contains a Picture. // man page class GraphicBlock : public Interactor { public: GraphicBlock( Graphic*, Coord pad = 0, Alignment = Center, Zooming = Continuous ); GraphicBlock( const char*, Graphic*, Coord pad = 0, Alignment = Center, Zooming = Continuous ); virtual ~GraphicBlock(); virtual void Update(); virtual void Draw(); virtual void Adjust(Perspective&); virtual void Highlight(boolean); virtual Graphic* GetGraphic(); virtual float GetMagnification(); virtual void SetGraphic(Graphic*); virtual void SetMagnification(float); protected: virtual void Resize(); virtual void Redraw(Coord, Coord, Coord, Coord); void Init(); void UpdatePerspective(); /* recalc based on graphic's bbox */ void GrabScroll(Event&); void RateScroll(Event&); virtual void GetGraphicBox(Coord&, Coord&, Coord&, Coord&); virtual void Zoom(Perspective&); virtual void Scroll(Perspective&); virtual float LimitMagnification(float); protected: Graphic* _graphic; protected: void Normalize(Perspective&); /* normalize units */ void Align(); /* align graphic */ void Fix(); /* keep alignment fixed during resize */ float NearestPow2(float); /* convert to nearest power of 2 */ float ScaleFactor(Perspective&); protected: Coord _pad; Alignment _align; Zooming _zooming; Coord _x0, _y0; /* graphic offset */ float _mag; /* total magnification */ boolean _highlighted; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/lines.h000066400000000000000000000105451214471147700222150ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Interface to Points, Lines, and MultiLines, objects derived from Graphic. */ #ifndef unidraw_graphic_lines_h #define unidraw_graphic_lines_h #include #include //: point graphic // man page class Point : public Graphic { public: Point(Coord x, Coord y, Graphic* gr = nil); virtual ~Point(); void GetOriginal(Coord&, Coord&); void SetOriginal(Coord, Coord); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: Coord _x, _y; PSBrush* _br; }; //: line graphic // man page class Line : public Graphic { public: Line(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* gr = nil); virtual ~Line(); void GetOriginal(Coord& x0, Coord& y0, Coord& x1, Coord& y1); void SetOriginal(Coord x0, Coord y0, Coord x1, Coord y1); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual Graphic* Copy(); virtual ClassId CompId(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: Coord _x0, _y0, _x1, _y1; PSBrush* _br; }; //: multi-line graphic // man page class MultiLine : public Vertices { protected: MultiLine(Coord* x, Coord* y, int count, Graphic* gr = nil) ; boolean s_contains(PointObj&, Graphic*); boolean f_contains(PointObj&, Graphic*); boolean s_intersects(BoxObj&, Graphic*); boolean f_intersects(BoxObj&, Graphic*); }; //: stroked multi-line graphic // man page class S_MultiLine : public MultiLine { public: S_MultiLine(Coord* x, Coord* y, int count, Graphic* gr = nil); virtual ~S_MultiLine(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSBrush* _br; }; //: stroked-filled multi-line graphic // man page class SF_MultiLine : public MultiLine { public: SF_MultiLine(Coord* x, Coord* y, int count, Graphic* = nil); virtual ~SF_MultiLine(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual Graphic* Copy(); virtual ClassId CompId(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSBrush* _br; PSPattern* _pat; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/picture.h000066400000000000000000000063231214471147700225550ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Interface to Picture, a composite of one or more Graphics. */ #ifndef unidraw_graphic_picture_h #define unidraw_graphic_picture_h #include #include //: composite Graphic // man page class Picture : public FullGraphic { public: Picture(Graphic* gr = nil); virtual ~Picture(); virtual void First(Iterator&); virtual void Last(Iterator&); virtual void Next(Iterator&); virtual void Prev(Iterator&); virtual boolean Done(Iterator); boolean IsEmpty(); virtual Graphic* GetGraphic(Iterator); virtual void SetGraphic(Graphic*, Iterator&); virtual void Append(Graphic*, Graphic* =nil, Graphic* =nil, Graphic* =nil); virtual void Prepend(Graphic*,Graphic* =nil, Graphic* =nil, Graphic* =nil); virtual void InsertBefore(Iterator, Graphic*); virtual void InsertAfter(Iterator, Graphic*); virtual void Remove(Graphic*); virtual void Remove(Iterator&); virtual void Bequeath(); virtual Graphic* FirstGraphicContaining(PointObj&); virtual Graphic* LastGraphicContaining(PointObj&); virtual Graphic* FirstGraphicIntersecting(BoxObj&); virtual Graphic* LastGraphicIntersecting(BoxObj&); virtual Graphic* FirstGraphicWithin(BoxObj&); virtual Graphic* LastGraphicWithin(BoxObj&); virtual Graphic* Copy(); virtual ClassId CompId(); protected: Graphic* graphic(class UList*); UList* Elem(Iterator); virtual void draw(Canvas*, Graphic*); virtual void drawClipped(Canvas*, Coord, Coord, Coord, Coord, Graphic*); virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); void getCachedExtent(float&, float&, float&, float&, float&); virtual boolean extentCached(); virtual void cacheExtent(float, float, float, float, float); virtual void uncacheExtent(); virtual void uncacheChildren(); protected: UList* _kids; protected: Extent* _extent; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/polygons.h000066400000000000000000000140171214471147700227530ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Interface to Rects and Polygons, objects derived from Graphic. */ #ifndef unidraw_graphic_polygons_h #define unidraw_graphic_polygons_h #include #include //: rectangle graphic // man page class Rect : public Graphic { public: void GetOriginal(Coord&, Coord&, Coord&, Coord&); void SetOriginal(Coord, Coord, Coord, Coord); protected: Rect(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* = nil); void s_getExtent(float&, float&, float&, float&, float&, Graphic*); void f_getExtent(float&, float&, float&, float&, float&, Graphic*); boolean s_contains(PointObj&, Graphic*); boolean f_contains(PointObj&, Graphic*); boolean s_intersects(BoxObj&, Graphic*); boolean f_intersects(BoxObj&, Graphic*); protected: Coord _x0, _y0, _x1, _y1; }; //: stroked rectangle graphic // man page class S_Rect : public Rect { public: S_Rect(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* = nil); virtual ~S_Rect(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSBrush* _br; }; //: filled rectangle graphic // man page class F_Rect : public Rect { public: F_Rect(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* = nil); virtual ~F_Rect(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSPattern* _pat; }; //: stroked-filled rectangle graphic // man page class SF_Rect : public Rect { public: SF_Rect(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* = nil); virtual ~SF_Rect(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual Graphic* Copy(); virtual ClassId CompId(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSBrush* _br; PSPattern* _pat; }; //: polygon graphic // man page class Polygon : public Vertices { protected: Polygon(Coord* x, Coord* y, int count, Graphic* gr = nil) ; boolean s_contains(PointObj&, Graphic*); boolean f_contains(PointObj&, Graphic*); boolean s_intersects(BoxObj&, Graphic*); boolean f_intersects(BoxObj&, Graphic*); }; //: stroked polygon graphic // man page class S_Polygon : public Polygon { public: S_Polygon(Coord* x, Coord* y, int count, Graphic* = nil); virtual ~S_Polygon(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSBrush* _br; }; //: filled polygon graphic // man page class F_Polygon : public Polygon { public: F_Polygon(Coord* x, Coord* y, int count, Graphic* = nil); virtual ~F_Polygon(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSPattern* _pat; }; //: stroked-filled polygon graphic // man page class SF_Polygon : public Polygon { public: SF_Polygon(Coord* x, Coord* y, int count, Graphic* = nil); virtual ~SF_Polygon(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual Graphic* Copy(); virtual ClassId CompId(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSBrush* _br; PSPattern* _pat; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/pspaint.h000066400000000000000000000113361214471147700225600ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Persistent paint subclasses that incorporate additional information * needed to generate idraw-compatible PostScript. */ #ifndef unidraw_graphic_pspaint_h #define unidraw_graphic_pspaint_h #include #include #include static const int patternWidth = 16; static const int patternHeight = 16; #undef None //: "PostScript" brush object // man page class PSBrush : public Brush { public: PSBrush(); PSBrush(int, int); PSBrush(int, float); int GetLinePattern(); int Width(); float width(); boolean None(); const int* GetDashPattern(); int GetDashPatternSize(); int GetDashOffset(); protected: void CalcDashPat(int); protected: boolean _none; int _linepat; int _dashpat[patternWidth]; // stores dash pattern int _dashpatsize; // stores number of defined elements in dashpat int _dashoffset; // stores dash pattern's offset }; inline boolean PSBrush::None () { return _none; } inline int PSBrush::GetLinePattern () { return _linepat; } inline const int* PSBrush::GetDashPattern () { return _dashpat; } inline int PSBrush::GetDashPatternSize () { return _dashpatsize; } inline int PSBrush::GetDashOffset () { return _dashoffset; } //: "PostScript" color object // man page class PSColor : public Color { public: PSColor(); PSColor(ColorIntensity, ColorIntensity, ColorIntensity, const char*); virtual ~PSColor(); boolean None(); const char* GetName(); void GetIntensities(ColorIntensity&, ColorIntensity&, ColorIntensity&); protected: boolean _none; char* _name; // stores name passed into constructor ColorIntensity _r, _g, _b; // stores intensities passed to ctor }; inline boolean PSColor::None () { return _none; } inline const char* PSColor::GetName () { return _none ? "None" : _name; } //: "PostScript" font object // man page class PSFont : public Font { public: PSFont(const char*, const char*, const char*); virtual ~PSFont(); const char* GetName(); const char* GetPrintFont(); const char* GetPrintSize(); const char* GetPrintFontAndSize(); int GetLineHt(); protected: char* _name; // name used by window system char* _printfont; // name used by printer char* _printsize; // scale used by printer char* _printfontandsize; // name and size separated by a blank int _lineHt; // printsize converted to int }; inline const char* PSFont::GetName () { return _name ? _name : "fixed"; } inline const char* PSFont::GetPrintFont () { return _printfont; } inline const char* PSFont::GetPrintSize () { return _printsize; } inline const char* PSFont::GetPrintFontAndSize () { return _printfontandsize; } inline int PSFont::GetLineHt () { return _lineHt; } //: "PostScript" pattern object // man page class PSPattern : public Pattern { public: PSPattern(); PSPattern(int, float); PSPattern(const int* pattern, int); boolean None(); float GetGrayLevel(); const int* GetData(); int GetSize(); protected: boolean _none; int _data[patternHeight]; float _graylevel; // stores gray level for grayscale patterns int _size; // stores pat's orig size (4x4, 8x8, or 16x16) }; inline boolean PSPattern::None () { return _none; } inline float PSPattern::GetGrayLevel () { return _graylevel; } inline const int* PSPattern::GetData () { return _data; } inline int PSPattern::GetSize () { return _size; } #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/rasterrect.h000066400000000000000000000037361214471147700232650ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Interface to RasterRect, an object derived from Graphic. */ #ifndef unidraw_graphic_rasterrect_h #define unidraw_graphic_rasterrect_h #include #include class Raster; //: raster graphic // man page class RasterRect : public Graphic { public: RasterRect(Raster*, Graphic* = nil); virtual ~RasterRect(); Raster* GetOriginal(); virtual Graphic* Copy(); virtual ClassId CompId(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: Raster* _raster; }; inline Raster* RasterRect::GetOriginal () { return _raster; } #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/splines.h000066400000000000000000000153721214471147700225630ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Interface to BSplines, objects derived from Graphic. */ #ifndef unidraw_graphic_splines_h #define unidraw_graphic_splines_h #include #include //: open b-spline graphic // man page class OpenBSpline : public Vertices { public: virtual int GetOriginal(const Coord*&, const Coord*&); protected: OpenBSpline(Coord* x, Coord* y, int count, Graphic* gr = nil) ; boolean s_contains(PointObj&, Graphic*); boolean f_contains(PointObj&, Graphic*); boolean s_intersects(BoxObj&, Graphic*); boolean f_intersects(BoxObj&, Graphic*); }; //: stroked open b-spline graphic // man page class S_OpenBSpline : public OpenBSpline { public: S_OpenBSpline(Coord* x, Coord* y, int count, Graphic* gr =nil); virtual ~S_OpenBSpline(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSBrush* _br; }; //: filled open b-spline graphic // man page class F_OpenBSpline : public OpenBSpline { public: F_OpenBSpline(Coord* x, Coord* y, int count, Graphic* = nil); virtual ~F_OpenBSpline(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSPattern* _pat; }; //: stroked-filled open b-spline graphic // man page class SF_OpenBSpline : public OpenBSpline { public: SF_OpenBSpline(Coord* x, Coord* y, int count, Graphic* = nil); virtual ~SF_OpenBSpline(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSBrush* _br; PSPattern* _pat; }; //: stroked-filled open b-spline graphic with control-point hit detection. // man page class SFH_OpenBSpline : public SF_OpenBSpline { public: SFH_OpenBSpline(Coord* x, Coord* y, int count, Graphic* = nil); virtual Graphic* Copy(); virtual ClassId CompId(); protected: virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); }; //: closed b-spline graphic // man page class ClosedBSpline : public Vertices { protected: ClosedBSpline(Coord* x, Coord* y, int count, Graphic* gr = nil) ; boolean s_contains(PointObj&, Graphic*); boolean f_contains(PointObj&, Graphic*); boolean s_intersects(BoxObj&, Graphic*); boolean f_intersects(BoxObj&, Graphic*); }; //: stroked closed b-spline graphic // man page class S_ClosedBSpline : public ClosedBSpline { public: S_ClosedBSpline(Coord* x, Coord* y, int count, Graphic* gr =nil); virtual ~S_ClosedBSpline(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSBrush* _br; }; //: filled closed b-spline graphic // man page class F_ClosedBSpline : public ClosedBSpline { public: F_ClosedBSpline(Coord* x, Coord* y, int count, Graphic* gr =nil); virtual ~F_ClosedBSpline(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSPattern* _pat; }; //: stroked-filled closed b-spline graphic // man page class SF_ClosedBSpline : public ClosedBSpline { public: SF_ClosedBSpline(Coord* x, Coord* y, int count, Graphic* = nil); virtual ~SF_ClosedBSpline(); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual void SetPattern(PSPattern*); virtual PSPattern* GetPattern(); virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: PSBrush* _br; PSPattern* _pat; }; //: stroked-filled closed b-spline graphic with control-point hit detection // man page class SFH_ClosedBSpline : public SF_ClosedBSpline { public: SFH_ClosedBSpline(Coord* x, Coord* y, int count, Graphic* = nil); virtual Graphic* Copy(); virtual ClassId CompId(); protected: virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/ulabel.h000066400000000000000000000041511214471147700223430ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Interface to ULabel, an object derived from Graphic. */ #ifndef unidraw_graphic_ulabel_h #define unidraw_graphic_ulabel_h #include #include class ULabel : public Graphic { public: ULabel(const char*, Graphic* = nil); virtual ~ULabel(); const char* GetOriginal(); void SetOriginal(const char *); virtual void SetFont(PSFont*); virtual PSFont* GetFont(); virtual PSPattern* GetPattern(); // diallows patterned text // to work around IV botch virtual Graphic* Copy(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: char* _string; PSFont* _font; }; inline const char* ULabel::GetOriginal () { return _string; } #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/ustencil.h000066400000000000000000000041121214471147700227220ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Interface to UStencil, an object derived from Graphic. */ #ifndef unidraw_graphic_ustencil_h #define unidraw_graphic_ustencil_h #include #include class Bitmap; class UStencil : public Graphic { public: UStencil(Bitmap* image, Bitmap* mask = nil, Graphic* = nil); virtual ~UStencil(); void GetOriginal(Bitmap*&, Bitmap*&); void SetOriginal(Bitmap*, Bitmap*); virtual PSPattern* GetPattern(); // disallows patterned bitmaps // to work around IV botch virtual Graphic* Copy(); virtual ClassId CompId(); protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual boolean contains(PointObj&, Graphic*); virtual boolean intersects(BoxObj&, Graphic*); virtual void draw(Canvas*, Graphic*); protected: Bitmap* _image; Bitmap* _mask; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/util.h000066400000000000000000000050531214471147700220560ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Various useful types and functions. */ #ifndef unidraw_graphic_util_h #define unidraw_util_h #include #include #include #include #include inline void exch (int& a, int& b) { int temp = a; a = b; b = temp; } inline int square(int a) { return a *= a; } inline float square(float a) { return a *= a; } inline float degrees(float rad) { return rad * 180.0 / M_PI; } inline float radians(float deg) { return deg * M_PI / 180.0; } inline float Distance(Coord x0, Coord y0, Coord x1, Coord y1) { return sqrt(float(square(x0 - x1) + square(y0 - y1))); } inline void ArrayCopy ( const Coord* x, const Coord* y, int n, Coord* newx, Coord* newy ) { Memory::copy(x, newx, n * sizeof(Coord)); Memory::copy(y, newy, n * sizeof(Coord)); } inline void ArrayDup ( const Coord* x, const Coord* y, int n, Coord*& newx, Coord*& newy ) { newx = new Coord[n]; newy = new Coord[n]; Memory::copy(x, newx, n * sizeof(Coord)); Memory::copy(y, newy, n * sizeof(Coord)); } inline void Midpoint ( double x0, double y0, double x1, double y1, double& mx, double& my ) { mx = (x0 + x1) / 2.0; my = (y0 + y1) / 2.0; } inline void ThirdPoint ( double x0, double y0, double x1, double y1, double& tx, double& ty ) { tx = (2*x0 + x1) / 3.0; ty = (2*y0 + y1) / 3.0; } #include #endif ivtools-1.2.11a1/src/include/Unidraw/Graphic/verts.h000066400000000000000000000047431214471147700222510ustar00rootroot00000000000000/* * Copyright (c) 1994 Vectaport Inc. * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Vertices is a base class for graphics that are characterized by a set * of vertices. */ #ifndef unidraw_graphic_verts_h #define unidraw_graphic_verts_h #include #include class TopoElement; class Vertices : public Graphic { public: virtual ~Vertices(); virtual int GetOriginal(const Coord*&, const Coord*&); virtual int SetOriginal(const Coord*, const Coord*); virtual MultiLineObj* GetOriginal(); virtual void SetOriginal(MultiLineObj*); boolean GetPoint(int index, Coord& x, Coord& y); virtual boolean operator == (Vertices&); virtual boolean operator != (Vertices&); int count(); Coord* x(); Coord* y(); virtual Graphic* Copy(); protected: Vertices(Graphic* gr = nil); Vertices(Coord* x, Coord* y, int count, Graphic* gr = nil); virtual boolean extentCached(); void cacheExtent(float, float, float, float, float); virtual void uncacheExtent(); void getCachedExtent(float&, float&, float&, float&, float&); void s_getExtent(float&, float&, float&, float&, float&, Graphic*); void f_getExtent(float&, float&, float&, float&, float&, Graphic*); protected: Extent* _extent; MultiLineObj* _pts; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/Tools/000077500000000000000000000000001214471147700204505ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/Unidraw/Tools/connect.h000066400000000000000000000033161214471147700222550ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Connect tool declarations. */ #ifndef unidraw_tools_connect_h #define unidraw_tools_connect_h #include class ConnectorView; //: connect tool // man page class ConnectTool : public Tool { public: ConnectTool(ControlInfo* = nil); virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer* =nil); virtual Command* InterpretManipulator(Manipulator*); virtual Tool* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: ConnectorView* _source; }; #endif ivtools-1.2.11a1/src/include/Unidraw/Tools/grcomptool.h000066400000000000000000000041101214471147700230020ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Graphic component tool declarations. */ #ifndef unidraw_tools_grcomptool_h #define unidraw_tools_grcomptool_h #include class Command; class GraphicComp; //: graphic component tool // man page class GraphicCompTool : public Tool { public: GraphicCompTool(); GraphicCompTool(ControlInfo*, GraphicComp* prototype); virtual ~GraphicCompTool(); virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer* =nil); virtual Command* InterpretManipulator(Manipulator*); GraphicComp* GetPrototype(); virtual Tool* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: void Init(GraphicComp*); protected: GraphicComp* _prototype; class GraphicView* _protoview; }; inline GraphicComp* GraphicCompTool::GetPrototype () { return _prototype; } #endif ivtools-1.2.11a1/src/include/Unidraw/Tools/magnify.h000066400000000000000000000032401214471147700222520ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Magnify tool declarations. */ #ifndef unidraw_tools_magnify_h #define unidraw_tools_magnify_h #include //: zoom in to specified region // man page class MagnifyTool : public Tool { public: MagnifyTool(ControlInfo* = nil); virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer* =nil); virtual Command* InterpretManipulator(Manipulator*); virtual Tool* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Tools/move.h000066400000000000000000000032131214471147700215660ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Move tool declarations. */ #ifndef unidraw_tools_move_h #define unidraw_tools_move_h #include //: tool for moving graphics // man page class MoveTool : public Tool { public: MoveTool(ControlInfo* = nil); virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer* =nil); virtual Command* InterpretManipulator(Manipulator*); virtual Tool* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Tools/reshape.h000066400000000000000000000032221214471147700222470ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Reshape tool declarations. */ #ifndef unidraw_tools_reshape_h #define unidraw_tools_reshape_h #include //: reshape tool // man page class ReshapeTool : public Tool { public: ReshapeTool(ControlInfo* = nil); virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer* =nil); virtual Command* InterpretManipulator(Manipulator*); virtual Tool* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Tools/rotate.h000066400000000000000000000032121214471147700221150ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Rotate tool declarations. */ #ifndef unidraw_tools_rotate_h #define unidraw_tools_rotate_h #include //: rotate tool // man page class RotateTool : public Tool { public: RotateTool(ControlInfo* = nil); virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer* =nil); virtual Command* InterpretManipulator(Manipulator*); virtual Tool* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Tools/scale.h000066400000000000000000000032031214471147700217060ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Scale tool declarations. */ #ifndef unidraw_tools_scale_h #define unidraw_tools_scale_h #include //: scale tool // man page class ScaleTool : public Tool { public: ScaleTool(ControlInfo* = nil); virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer* =nil); virtual Command* InterpretManipulator(Manipulator*); virtual Tool* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Tools/select.h000066400000000000000000000033271214471147700221050ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Select tool declarations. */ #ifndef unidraw_tools_select_h #define unidraw_tools_select_h #include class Selection; //: select tool // man page class SelectTool : public Tool { public: SelectTool(ControlInfo* = nil); virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer* =nil); virtual Command* InterpretManipulator(Manipulator*); virtual Tool* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual void Localize(Selection*, Viewer*); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Tools/stretch.h000066400000000000000000000032211214471147700222730ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Stretch tool declarations. */ #ifndef unidraw_tools_stretch_h #define unidraw_tools_stretch_h #include //: stretch tool // man page class StretchTool : public Tool { public: StretchTool(ControlInfo* = nil); virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer* =nil); virtual Command* InterpretManipulator(Manipulator*); virtual Tool* Copy(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); }; #endif ivtools-1.2.11a1/src/include/Unidraw/Tools/tool.h000066400000000000000000000041001214471147700215710ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Tool - supports direct manipulation of components. */ #ifndef unidraw_tools_tool_h #define unidraw_tools_tool_h #include class Command; class ControlInfo; class Viewer; class Event; class Manipulator; class Transformer; #include //: base class for tool objects. // man page class Tool { public: virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer* =nil); virtual Command* InterpretManipulator(Manipulator*); virtual void SetControlInfo(ControlInfo*); virtual ControlInfo* GetControlInfo(); virtual ~Tool(); virtual Tool* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual ClassId GetSubstId(const char*& delim); virtual boolean IsA(ClassId); protected: Tool(ControlInfo* = nil); ControlInfo* CopyControlInfo(); protected: ControlInfo* _ctrlInfo; }; #endif ivtools-1.2.11a1/src/include/Unidraw/_defines.h000066400000000000000000000236001214471147700212760ustar00rootroot00000000000000#define ClassId _lib_iv(ClassId) #define Orientation _lib_iv(Orientation) #define Zooming _lib_iv(Zooming) #define AcknowledgeDialog _lib_iv(AcknowledgeDialog) #define AlignCmd _lib_iv(AlignCmd) #define AlignToGridCmd _lib_iv(AlignToGridCmd) #define BackCmd _lib_iv(BackCmd) #define BasicDialog _lib_iv(BasicDialog) #define BoxObj _lib_iv(BoxObj) #define BrushCmd _lib_iv(BrushCmd) #define BrushVar _lib_iv(BrushVar) #define BrushVarView _lib_iv(BrushVarView) #define CCnxn _lib_iv(CCnxn) #define CCnxn_HashTable _lib_iv(CCnxn_HashTable) #define CGlue _lib_iv(CGlue) #define CNet _lib_iv(CNet) #define CSolver _lib_iv(CSolver) #define CSolverInfo _lib_iv(CSolverInfo) #define CSolverState _lib_iv(CSolverState) #define Catalog _lib_iv(Catalog) #define CatalogChooser _lib_iv(CatalogChooser) #define CenterCmd _lib_iv(CenterCmd) #define Clipboard _lib_iv(Clipboard) #define CloseEditorCmd _lib_iv(CloseEditorCmd) #define ClosedBSpline _lib_iv(ClosedBSpline) #define ClosedSplineComp _lib_iv(ClosedSplineComp) #define ClosedSplineView _lib_iv(ClosedSplineView) #define ColorCmd _lib_iv(ColorCmd) #define ColorData _lib_iv(ColorData) #define ColorVar _lib_iv(ColorVar) #define Command _lib_iv(Command) #define CommandControl _lib_iv(CommandControl) #define CommandInteractor _lib_iv(CommandInteractor) #define CompNameVar _lib_iv(CompNameVar) #define CompNameVarView _lib_iv(CompNameVarView) #define Component _lib_iv(Component) #define ComponentView _lib_iv(ComponentView) #define ConfirmDialog _lib_iv(ConfirmDialog) #define ConnInfo _lib_iv(ConnInfo) #define ConnectCmd _lib_iv(ConnectCmd) #define ConnectManip _lib_iv(ConnectManip) #define ConnectTool _lib_iv(ConnectTool) #define Connector _lib_iv(Connector) #define ConnectorView _lib_iv(ConnectorView) #define ControlInfo _lib_iv(ControlInfo) #define CopyCmd _lib_iv(CopyCmd) #define Creator _lib_iv(Creator) #define CutCmd _lib_iv(CutCmd) #define Damage _lib_iv(Damage) #define Data _lib_iv(Data) #define DataCache _lib_iv(DataCache) #define DeleteCmd _lib_iv(DeleteCmd) #define DragManip _lib_iv(DragManip) #define DupCmd _lib_iv(DupCmd) #define Editor _lib_iv(Editor) #define EditorImpl _lib_iv(EditorImpl) #define EditorInfo _lib_iv(EditorInfo) #define Ellipse _lib_iv(Ellipse) #define EllipseComp _lib_iv(EllipseComp) #define EllipseView _lib_iv(EllipseView) #define Extent _lib_iv(Extent) #define ExternView _lib_iv(ExternView) #define F_Circle _lib_iv(F_Circle) #define F_ClosedBSpline _lib_iv(F_ClosedBSpline) #define F_Ellipse _lib_iv(F_Ellipse) #define F_OpenBSpline _lib_iv(F_OpenBSpline) #define F_Polygon _lib_iv(F_Polygon) #define F_Rect _lib_iv(F_Rect) #define FileNameVarView _lib_iv(FileNameVarView) #define FillPolygonObj _lib_iv(FillPolygonObj) #define FixedPin _lib_iv(FixedPin) #define FontCmd _lib_iv(FontCmd) #define FontVar _lib_iv(FontVar) #define FontVarView _lib_iv(FontVarView) #define FrontCmd _lib_iv(FrontCmd) #define FullGraphic _lib_iv(FullGraphic) #define GSData _lib_iv(GSData) #define GVU_HashTable _lib_iv(GVU_HashTable) #define GVUpdater _lib_iv(GVUpdater) #define Graphic _lib_iv(Graphic) #define GraphicBlock _lib_iv(GraphicBlock) #define GraphicComp _lib_iv(GraphicComp) #define GraphicCompTool _lib_iv(GraphicCompTool) #define GraphicComps _lib_iv(GraphicComps) #define GraphicView _lib_iv(GraphicView) #define GraphicViews _lib_iv(GraphicViews) #define GravityCmd _lib_iv(GravityCmd) #define GravityVar _lib_iv(GravityVar) #define GravityVarView _lib_iv(GravityVarView) #define Grid _lib_iv(Grid) #define GridCmd _lib_iv(GridCmd) #define GridDialog _lib_iv(GridDialog) #define GridSpacingCmd _lib_iv(GridSpacingCmd) #define GroupCmd _lib_iv(GroupCmd) #define HPanelControl _lib_iv(HPanelControl) #define HSlotComp _lib_iv(HSlotComp) #define HSlotView _lib_iv(HSlotView) #define HistoryMap _lib_iv(HistoryMap) #define ImportCmd _lib_iv(ImportCmd) #define InorderView _lib_iv(InorderView) #define Iterator _lib_iv(Iterator) #define KeyMap _lib_iv(KeyMap) #define Line _lib_iv(Line) #define LineComp _lib_iv(LineComp) #define LineObj _lib_iv(LineObj) #define LineView _lib_iv(LineView) #define LinkComp _lib_iv(LinkComp) #define LinkView _lib_iv(LinkView) #define MacroCmd _lib_iv(MacroCmd) #define MagnifVar _lib_iv(MagnifVar) #define MagnifVarView _lib_iv(MagnifVarView) #define MagnifyTool _lib_iv(MagnifyTool) #define ManagedWindow _lib_iv(ManagedWindow) #define ManipGroup _lib_iv(ManipGroup) #define Manipulator _lib_iv(Manipulator) #define MatchEditor _lib_iv(MatchEditor) #define MobilityCmd _lib_iv(MobilityCmd) #define MobilityData _lib_iv(MobilityData) #define ModifStatusVar _lib_iv(ModifStatusVar) #define ModifStatusVarView _lib_iv(ModifStatusVarView) #define MoveCmd _lib_iv(MoveCmd) #define MoveData _lib_iv(MoveData) #define MoveTool _lib_iv(MoveTool) #define MultiLine _lib_iv(MultiLine) #define MultiLineComp _lib_iv(MultiLineComp) #define MultiLineObj _lib_iv(MultiLineObj) #define MultiLineView _lib_iv(MultiLineView) #define NOPCmd _lib_iv(NOPCmd) #define NameMap _lib_iv(NameMap) #define NameVar _lib_iv(NameVar) #define NameVarView _lib_iv(NameVarView) #define NewCompCmd _lib_iv(NewCompCmd) #define NormSizeCmd _lib_iv(NormSizeCmd) #define ObjectMap _lib_iv(ObjectMap) #define ObjectMapElem _lib_iv(ObjectMapElem) #define OpenBSpline _lib_iv(OpenBSpline) #define OrientationCmd _lib_iv(OrientationCmd) #define PSBrush _lib_iv(PSBrush) #define PSClosedSpline _lib_iv(PSClosedSpline) #define PSColor _lib_iv(PSColor) #define PSEllipse _lib_iv(PSEllipse) #define PSLine _lib_iv(PSLine) #define PSLink _lib_iv(PSLink) #define PSMultiLine _lib_iv(PSMultiLine) #define PSPad _lib_iv(PSPad) #define PSPattern _lib_iv(PSPattern) #define PSPin _lib_iv(PSPin) #define PSPolygon _lib_iv(PSPolygon) #define PSRaster _lib_iv(PSRaster) #define PSRect _lib_iv(PSRect) #define PSSlot _lib_iv(PSSlot) #define PSSpline _lib_iv(PSSpline) #define PSStencil _lib_iv(PSStencil) #define PSText _lib_iv(PSText) #define PSVertices _lib_iv(PSVertices) #define PadComp _lib_iv(PadComp) #define PadGraphic _lib_iv(PadGraphic) #define PadView _lib_iv(PadView) #define Page _lib_iv(Page) #define PanelControl _lib_iv(PanelControl) #define PanelInteractor _lib_iv(PanelInteractor) #define PasteCmd _lib_iv(PasteCmd) #define Path _lib_iv(Path) #define PatternCmd _lib_iv(PatternCmd) #define PatternVar _lib_iv(PatternVar) #define PatternVarView _lib_iv(PatternVarView) #define Picture _lib_iv(Picture) #define PinComp _lib_iv(PinComp) #define PinGraphic _lib_iv(PinGraphic) #define PinView _lib_iv(PinView) #define Point _lib_iv(Point) #define PointObj _lib_iv(PointObj) #define Polygon _lib_iv(Polygon) #define PolygonComp _lib_iv(PolygonComp) #define PolygonView _lib_iv(PolygonView) #define PostScriptView _lib_iv(PostScriptView) #define PostScriptViews _lib_iv(PostScriptViews) #define PostorderView _lib_iv(PostorderView) #define PreorderView _lib_iv(PreorderView) #define PrintBS _lib_iv(PrintBS) #define PrintCmd _lib_iv(PrintCmd) #define PrintDialog _lib_iv(PrintDialog) #define QuitCmd _lib_iv(QuitCmd) #define RasterComp _lib_iv(RasterComp) #define RasterRect _lib_iv(RasterRect) #define RasterView _lib_iv(RasterView) #define RectComp _lib_iv(RectComp) #define RectView _lib_iv(RectView) #define RedToFitCmd _lib_iv(RedToFitCmd) #define RedoCmd _lib_iv(RedoCmd) #define ReplaceCmd _lib_iv(ReplaceCmd) #define ReshapeTool _lib_iv(ReshapeTool) #define RevertCmd _lib_iv(RevertCmd) #define RotateCmd _lib_iv(RotateCmd) #define RotateTool _lib_iv(RotateTool) #define SFH_ClosedBSpline _lib_iv(SFH_ClosedBSpline) #define SFH_OpenBSpline _lib_iv(SFH_OpenBSpline) #define SF_Circle _lib_iv(SF_Circle) #define SF_ClosedBSpline _lib_iv(SF_ClosedBSpline) #define SF_Ellipse _lib_iv(SF_Ellipse) #define SF_MultiLine _lib_iv(SF_MultiLine) #define SF_OpenBSpline _lib_iv(SF_OpenBSpline) #define SF_Polygon _lib_iv(SF_Polygon) #define SF_Rect _lib_iv(SF_Rect) #define S_Circle _lib_iv(S_Circle) #define S_ClosedBSpline _lib_iv(S_ClosedBSpline) #define S_Ellipse _lib_iv(S_Ellipse) #define S_MultiLine _lib_iv(S_MultiLine) #define S_OpenBSpline _lib_iv(S_OpenBSpline) #define S_Polygon _lib_iv(S_Polygon) #define S_Rect _lib_iv(S_Rect) #define SaveCompAsCmd _lib_iv(SaveCompAsCmd) #define SaveCompCmd _lib_iv(SaveCompCmd) #define ScaleCmd _lib_iv(ScaleCmd) #define ScaleTool _lib_iv(ScaleTool) #define SelectTool _lib_iv(SelectTool) #define SlctAllCmd _lib_iv(SlctAllCmd) #define SlidingPin _lib_iv(SlidingPin) #define SlotComp _lib_iv(SlotComp) #define SlotGraphic _lib_iv(SlotGraphic) #define SlotView _lib_iv(SlotView) #define SplineComp _lib_iv(SplineComp) #define SplineView _lib_iv(SplineView) #define StateVar _lib_iv(StateVar) #define StateVarView _lib_iv(StateVarView) #define StencilComp _lib_iv(StencilComp) #define StencilView _lib_iv(StencilView) #define StretchTool _lib_iv(StretchTool) #define TF_2Port _lib_iv(TF_2Port) #define TF_Direct _lib_iv(TF_Direct) #define TextBuffer _lib_iv(TextBuffer) #define TextComp _lib_iv(TextComp) #define TextGraphic _lib_iv(TextGraphic) #define TextInteractor _lib_iv(TextInteractor) #define TextManip _lib_iv(TextManip) #define TextView _lib_iv(TextView) #define Tool _lib_iv(Tool) #define TransferFunct _lib_iv(TransferFunct) #define UArray _lib_iv(UArray) #define UChooser _lib_iv(UChooser) #define UControl _lib_iv(UControl) #define UControlInteractor _lib_iv(UControlInteractor) #define UHashElem _lib_iv(UHashElem) #define UHashTable _lib_iv(UHashTable) #define ULabel _lib_iv(ULabel) #define UList _lib_iv(UList) #define UMap _lib_iv(UMap) #define UMapElem _lib_iv(UMapElem) #define UPage _lib_iv(UPage) #define UStencil _lib_iv(UStencil) #define UndoCmd _lib_iv(UndoCmd) #define UngroupCmd _lib_iv(UngroupCmd) #define Unidraw _lib_iv(Unidraw) #define VPanelControl _lib_iv(VPanelControl) #define VSlotComp _lib_iv(VSlotComp) #define VSlotView _lib_iv(VSlotView) #define VertexManip _lib_iv(VertexManip) #define Vertices _lib_iv(Vertices) #define VerticesComp _lib_iv(VerticesComp) #define VerticesView _lib_iv(VerticesView) #define ViewCompCmd _lib_iv(ViewCompCmd) #define Viewer _lib_iv(Viewer) #define ViewerView _lib_iv(ViewerView) #define VoidData _lib_iv(VoidData) ivtools-1.2.11a1/src/include/Unidraw/_undefs.h000066400000000000000000000111011214471147700211360ustar00rootroot00000000000000#undef ClassId #undef Orientation #undef Zooming #undef AcknowledgeDialog #undef AlignCmd #undef AlignToGridCmd #undef BackCmd #undef BasicDialog #undef BoxObj #undef BrushCmd #undef BrushVar #undef BrushVarView #undef CCnxn #undef CCnxn_HashTable #undef CGlue #undef CNet #undef CSolver #undef CSolverInfo #undef CSolverState #undef Catalog #undef CatalogChooser #undef CenterCmd #undef Clipboard #undef CloseEditorCmd #undef ClosedBSpline #undef ClosedSplineComp #undef ClosedSplineView #undef ColorCmd #undef ColorData #undef ColorVar #undef Command #undef CommandControl #undef CommandInteractor #undef CompNameVar #undef CompNameVarView #undef Component #undef ComponentView #undef ConfirmDialog #undef ConnInfo #undef ConnectCmd #undef ConnectManip #undef ConnectTool #undef Connector #undef ConnectorView #undef ControlInfo #undef CopyCmd #undef Creator #undef CutCmd #undef Damage #undef Data #undef DataCache #undef DeleteCmd #undef DragManip #undef DupCmd #undef Editor #undef EditorImpl #undef EditorInfo #undef Ellipse #undef EllipseComp #undef EllipseView #undef Extent #undef ExternView #undef F_Circle #undef F_ClosedBSpline #undef F_Ellipse #undef F_OpenBSpline #undef F_Polygon #undef F_Rect #undef FileNameVarView #undef FillPolygonObj #undef FixedPin #undef FontCmd #undef FontVar #undef FontVarView #undef FrontCmd #undef FullGraphic #undef GSData #undef GVU_HashTable #undef GVUpdater #undef Graphic #undef GraphicBlock #undef GraphicComp #undef GraphicCompTool #undef GraphicComps #undef GraphicView #undef GraphicViews #undef GravityCmd #undef GravityVar #undef GravityVarView #undef Grid #undef GridCmd #undef GridDialog #undef GridSpacingCmd #undef GroupCmd #undef HPanelControl #undef HSlotComp #undef HSlotView #undef HistoryMap #undef ImportCmd #undef InorderView #undef Iterator #undef KeyMap #undef Line #undef LineComp #undef LineObj #undef LineView #undef LinkComp #undef LinkView #undef MacroCmd #undef MagnifVar #undef MagnifVarView #undef MagnifyTool #undef ManagedWindow #undef ManipGroup #undef Manipulator #undef MatchEditor #undef MobilityCmd #undef MobilityData #undef ModifStatusVar #undef ModifStatusVarView #undef MoveCmd #undef MoveData #undef MoveTool #undef MultiLine #undef MultiLineComp #undef MultiLineObj #undef MultiLineView #undef NOPCmd #undef NameMap #undef NameVar #undef NameVarView #undef NewCompCmd #undef NormSizeCmd #undef ObjectMap #undef ObjectMapElem #undef OpenBSpline #undef OrientationCmd #undef PSBrush #undef PSClosedSpline #undef PSColor #undef PSEllipse #undef PSLine #undef PSLink #undef PSMultiLine #undef PSPad #undef PSPattern #undef PSPin #undef PSPolygon #undef PSRaster #undef PSRect #undef PSSlot #undef PSSpline #undef PSStencil #undef PSText #undef PSVertices #undef PadComp #undef PadGraphic #undef PadView #undef Page #undef PanelControl #undef PanelInteractor #undef PasteCmd #undef Path #undef PatternCmd #undef PatternVar #undef PatternVarView #undef Picture #undef PinComp #undef PinGraphic #undef PinView #undef Point #undef PointObj #undef Polygon #undef PolygonComp #undef PolygonView #undef PostScriptView #undef PostScriptViews #undef PostorderView #undef PreorderView #undef PrintBS #undef PrintCmd #undef PrintDialog #undef QuitCmd #undef RasterComp #undef RasterRect #undef RasterView #undef RectComp #undef RectView #undef RedToFitCmd #undef RedoCmd #undef ReplaceCmd #undef ReshapeTool #undef RevertCmd #undef RotateCmd #undef RotateTool #undef SFH_ClosedBSpline #undef SFH_OpenBSpline #undef SF_Circle #undef SF_ClosedBSpline #undef SF_Ellipse #undef SF_MultiLine #undef SF_OpenBSpline #undef SF_Polygon #undef SF_Rect #undef S_Circle #undef S_ClosedBSpline #undef S_Ellipse #undef S_MultiLine #undef S_OpenBSpline #undef S_Polygon #undef S_Rect #undef SaveCompAsCmd #undef SaveCompCmd #undef ScaleCmd #undef ScaleTool #undef SelectTool #undef SlctAllCmd #undef SlidingPin #undef SlotComp #undef SlotGraphic #undef SlotView #undef SplineComp #undef SplineView #undef State #undef StateVar #undef StateVarView #undef StencilComp #undef StencilView #undef StretchTool #undef TF_2Port #undef TF_Direct #undef TextBuffer #undef TextComp #undef TextGraphic #undef TextInteractor #undef TextManip #undef TextView #undef Tool #undef TransferFunct #undef UArray #undef UChooser #undef UControl #undef UControlInteractor #undef UHashElem #undef UHashTable #undef ULabel #undef UList #undef UMap #undef UMapElem #undef UPage #undef UStencil #undef UndoCmd #undef UngroupCmd #undef Unidraw #undef VPanelControl #undef VSlotComp #undef VSlotView #undef VertexManip #undef Vertices #undef VerticesComp #undef VerticesView #undef ViewCompCmd #undef Viewer #undef ViewerView #undef VoidData ivtools-1.2.11a1/src/include/Unidraw/catalog.h000066400000000000000000000207341214471147700211410ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Catalog - manages persistent information. */ #ifndef unidraw_catalog_h #define unidraw_catalog_h #include #include #include #include class Bitmap; class Clipboard; class Command; class Component; class ControlInfo; class Creator; class EditorInfo; class NameMap; class ObjectMap; class ObjectMapElem; class PSBrush; class PSColor; class PSFont; class PSPattern; class Raster; class StateVar; class Tool; class TransferFunct; class Transformer; class UArray; class UHashTable; class Unidraw; class UList; class World; #include //: stores and retrieves named objects. // man page class Catalog { public: Catalog(const char*, Creator*, float version = UV_LATEST); virtual ~Catalog(); virtual boolean Save(EditorInfo*, const char*); virtual boolean Save(Component*, const char*); virtual boolean Save(Command*, const char*); virtual boolean Save(Tool*, const char*); virtual boolean Retrieve(const char*, EditorInfo*&); virtual boolean Retrieve(const char*, Component*&); virtual boolean Retrieve(const char*, Command*&); virtual boolean Retrieve(const char*, Tool*&); virtual void Forget(EditorInfo*, const char* = nil); virtual void Forget(Component*, const char* = nil); virtual void Forget(Command*, const char* = nil); virtual void Forget(Tool*, const char* = nil); virtual const char* GetName(EditorInfo*); virtual const char* GetName(Component*); virtual const char* GetName(Command*); virtual const char* GetName(Tool*); virtual boolean Valid(const char*, EditorInfo*&); virtual boolean Valid(const char*, Component*&); virtual boolean Valid(const char*, Command*&); virtual boolean Valid(const char*, Tool*&); virtual Component* Copy(Component*); virtual Command* Copy(Command*); virtual Tool* Copy(Tool*); virtual boolean Exists(const char*); virtual boolean Writable(const char*); void SetClipboard(Clipboard*); void SetEditorInfo(EditorInfo*); Clipboard* GetClipboard(); EditorInfo* GetEditorInfo(); const char* GetName(); Creator* GetCreator(); float GetVersion(); float FileVersion(); const char* GetAttribute(const char*); virtual float ReadVersion(istream&); virtual Component* ReadComponent(istream&); virtual Command* ReadCommand(istream&); virtual Tool* ReadTool(istream&); virtual StateVar* ReadStateVar(istream&); virtual TransferFunct* ReadTransferFunct(istream&); virtual void WriteVersion(float, ostream&); virtual void WriteComponent(Component*, ostream&); virtual void WriteCommand(Command*, ostream&); virtual void WriteTool(Tool*, ostream&); virtual void WriteStateVar(StateVar*, ostream&); virtual void WriteTransferFunct(TransferFunct*, ostream&); PSBrush* ReadBrush(const char*, int index); // read from Xdefaults PSColor* ReadColor(const char*, int index); PSFont* ReadFont(const char*, int index); PSPattern* ReadPattern(const char*, int index); void Skip(istream&); void Mark(ostream&); int ReadBgFilled(istream&); PSBrush* ReadBrush(istream&); PSColor* ReadColor(istream&); PSFont* ReadFont(istream&); PSPattern* ReadPattern(istream&); Transformer* ReadTransformer(istream&); char* ReadString(istream&); ControlInfo* ReadControlInfo(istream&); EditorInfo* ReadEditorInfo(istream&); Bitmap* ReadBitmap(istream&); void ReadBitmapData(Bitmap*, istream&); Raster* ReadGraymap(istream&); void ReadGraymapData(Raster*, istream&); Raster* ReadRaster(istream&); void ReadRasterData(Raster*, istream&); void WriteBgFilled(int, ostream&); void WriteBrush(PSBrush*, ostream&); void WriteColor(PSColor*, ostream&); void WriteFont(PSFont*, ostream&); void WritePattern(PSPattern*, ostream&); void WriteTransformer(Transformer*, ostream&); void WriteString(const char*, ostream&); void WriteControlInfo(ControlInfo*, ostream&); void WriteEditorInfo(EditorInfo*, ostream&); void WriteBitmap(Bitmap*, ostream&); void WriteBitmapData(Bitmap*, ostream&); void WriteGraymap(Raster*, ostream&); void WriteGraymapData(Raster*, ostream&); void WriteRaster(Raster*, ostream&); void WriteRasterData(Raster*, ostream&); PSBrush* FindNoneBrush(); PSBrush* FindBrush(int, int); PSBrush* FindBrush(int, float); PSColor* FindColor(const char*, int = 0, int = 0, int = 0); PSColor* FindNoneColor(); PSFont* FindFont(const char*, const char* = "", const char* = ""); PSPattern* FindNonePattern(); PSPattern* FindGrayLevel(float); PSPattern* FindPattern(int[], int); void Register(EditorInfo*, const char*); void Register(Component*, const char*); void Register(Command*, const char*); void Register(Tool*, const char*); int GetToken(istream& in, char* buf, int buf_size); protected: friend class Unidraw; void Init(World*); public: const char* Name(const char*, int); protected: ClassId ReadClassId(istream&, int& inst_id, ClassId&, const char*&); void* ReadObject(istream&); void* ReadSubstObject( istream&, int inst_id, ClassId orig_id, ClassId subst_id, const char* delim ); void ReadExtraData(istream&, const char* delim, UArray*); void WriteClassId( ClassId, ostream&, int inst_id = 0, ClassId subst_id = UNDEFINED_CLASS, const char* delim = "" ); void WriteClassId(void*, ClassId, ostream&, int id = 0); void WriteObject(void*, ClassId, ostream&); void WriteIt(void*, ClassId, ostream&); void* CopyObject(void*, ClassId); void Forget(void*, const char* name, NameMap*); boolean SaveObject(void*, ClassId, ostream&); boolean RetrieveObject(istream&, void*&); boolean FileSave(void*, ClassId, const char*); boolean FileRetrieve(const char*, void*&); protected: char* _name; Creator* _creator; float _version; Clipboard* _clipboard; EditorInfo* _edInfo; World* _world; UList* _brs; UList* _colors; UList* _fonts; UList* _pats; ObjectMap* _curMap; ObjectMap* _substMap; float _fileVersion; #ifdef __GNUC__ char* _tmpfile; #endif NameMap* _edInfoMap; NameMap* _compMap; NameMap* _cmdMap; NameMap* _toolMap; }; inline const char* Catalog::GetName () { return _name; } inline Creator* Catalog::GetCreator () { return _creator; } inline float Catalog::GetVersion () { return _version; } inline float Catalog::FileVersion () { return _fileVersion; } inline Clipboard* Catalog::GetClipboard () { return _clipboard; } inline EditorInfo* Catalog::GetEditorInfo () { return _edInfo; } class ObjectMap : public UMap { public: ObjectMap(void* client, ClassId clientId); void Register(void* obj, int id); void Register( void* obj, int id, ClassId orig_id, const char* delim, UArray* extra_data ); void Unregister(void* obj); void Unregister(int id); void* GetClient(); ClassId GetClientId(); void* GetObject(int id); unsigned long GetId(void* obj); ClassId GetOrigClassId(void* obj); const char* GetDelim(void* obj); UArray* GetExtraData(void* obj); protected: ObjectMapElem* Find(void*); ObjectMapElem* Find(int); protected: UHashTable _objKeys, _idKeys; void* _client; ClassId _id; }; #endif ivtools-1.2.11a1/src/include/Unidraw/classes.h000066400000000000000000000160001214471147700211530ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Unique unidraw class identifiers. */ #ifndef unidraw_classes_h #define unidraw_classes_h #include inline ClassId Combine (ClassId subj, ClassId view) {return 10000*subj + view;} #define UNDEFINED_CLASS 0 #define ALIGN_CMD 9001 #define BACK_CMD 9002 #define BRUSH_CMD 9003 #define CENTER_CMD 9004 #define COMMAND 9006 #define COMPONENT 9007 #define COMPONENT_VIEW 9008 #define COMPONENT_VIEWS 9009 #define CONNECT_CMD 9010 #define CONNECT_TOOL 9011 #define CONNECTOR 9012 #define CONNECTOR_VIEW 9013 #define COPY_CMD 9015 #define CUT_CMD 9016 #define DELETE_CMD 9017 #define DUP_CMD 9018 #define EXTERN_VIEW 9020 #define FONT_CMD 9021 #define FRONT_CMD 9023 #define GRAPHIC_COMP 9024 #define GRAPHIC_COMPS 9025 #define GRAPHIC_COMP_TOOL 9026 #define GRID_CMD 9027 #define GROUP_CMD 9028 #define GROUP_COMP 9029 #define LINE_COMP 9030 #define MACRO_CMD 9031 #define MAGNIFY_TOOL 9032 #define MOVE_TOOL 9033 #define MOBILITY_CMD 9034 #define MOVE_CMD 9035 #define NEWCOMP_CMD 9036 #define NORMSIZE_CMD 9037 #define PAD_COMP 9038 #define PASTE_CMD 9039 #define PATTERN_CMD 9040 #define PIN_COMP 9041 #define STATE_VAR 9042 #define NAME_VAR 9043 #define QUIT_CMD 9044 #define RECT_COMP 9045 #define MODIFSTATUS_VAR 9046 #define REDTOFIT_CMD 9047 #define REVERT_CMD 9048 #define ROTATE_CMD 9049 #define ROTATE_TOOL 9050 #define SAVECOMP_CMD 9051 #define SCALE_CMD 9052 #define SCALE_TOOL 9053 #define SELECT_TOOL 9054 #define SLCTALL_CMD 9055 #define SLOT_COMP 9056 #define MAGNIF_VAR 9057 #define TOOL 9058 #define UNDO_CMD 9059 #define UNGROUP_CMD 9060 #define VIEWCOMP_CMD 9061 #define VIEWER_VIEW 9062 #define FONT_VAR 9063 #define SAVECOMPAS_CMD 9064 #define BRUSH_VAR 9065 #define PATTERN_VAR 9066 #define COMPONENT_MAP 9067 #define COMMAND_MAP 9068 #define TOOL_MAP 9069 #define COMPNAME_VAR 9070 #define ALIGNTOGRID_CMD 9071 #define PERSPECTIVE_INFO 9072 #define TRANSFER_FUNCT 9073 #define STRUCT_CMD 9074 #define TF_2PORT 9075 #define ELLIPSE_COMP 9076 #define TF_DIRECT 9077 #define POLYGON_COMP 9078 #define VERTICES_COMP 9079 #define CLOSEEDITOR_CMD 9080 #define SPLINE_COMP 9081 #define PRINT_CMD 9082 #define CLOSEDSPLINE_COMP 9083 #define COLOR_VAR 9084 #define COLOR_CMD 9085 #define GRAVITY_VAR 9086 #define GRAVITY_CMD 9087 #define ORIENTATION_CMD 9088 #define GRIDSPACING_CMD 9089 #define TEXT_COMP 9090 #define MULTILINE_COMP 9091 #define DIRTY_CMD 9092 #define RESHAPE_TOOL 9093 #define STRETCH_TOOL 9094 #define HSLOT_COMP 9095 #define VSLOT_COMP 9096 #define RASTER_COMP 9097 #define REPLACE_CMD 9098 #define REDO_CMD 9099 #define PREORDER_VIEW 9100 #define INORDER_VIEW 9101 #define POSTORDER_VIEW 9102 #define POSTSCRIPT_VIEW 9103 #define LINK_COMP 9104 #define STENCIL_COMP 9105 #define IMPORT_CMD 9106 #define NOP_CMD 9107 #define TRANSFORM_CMD 9108 /* Composite ids associating subjects with their views */ #define CLOSEDSPLINE_VIEW Combine(CLOSEDSPLINE_COMP, COMPONENT_VIEW) #define ELLIPSE_VIEW Combine(ELLIPSE_COMP, COMPONENT_VIEW) #define GRAPHIC_VIEW Combine(GRAPHIC_COMP, COMPONENT_VIEW) #define GRAPHIC_VIEWS Combine(GRAPHIC_COMPS, COMPONENT_VIEW) #define GROUP_VIEW Combine(GROUP_COMP, COMPONENT_VIEW) #define HSLOT_VIEW Combine(HSLOT_COMP, COMPONENT_VIEW) #define LINE_VIEW Combine(LINE_COMP, COMPONENT_VIEW) #define LINK_VIEW Combine(LINK_COMP, COMPONENT_VIEW) #define MULTILINE_VIEW Combine(MULTILINE_COMP, COMPONENT_VIEW) #define PAD_VIEW Combine(PAD_COMP, COMPONENT_VIEW) #define PIN_VIEW Combine(PIN_COMP, COMPONENT_VIEW) #define POLYGON_VIEW Combine(POLYGON_COMP, COMPONENT_VIEW) #define POSTSCRIPT_VIEWS Combine(GRAPHIC_COMPS, POSTSCRIPT_VIEW) #define PS_CLOSEDSPLINE Combine(CLOSEDSPLINE_COMP, POSTSCRIPT_VIEW) #define PS_ELLIPSE Combine(ELLIPSE_COMP, POSTSCRIPT_VIEW) #define PS_GROUP Combine(GROUP_COMP, POSTSCRIPT_VIEW) #define PS_HSLOT Combine(HSLOT_COMP, POSTSCRIPT_VIEW) #define PS_LINE Combine(LINE_COMP, POSTSCRIPT_VIEW) #define PS_LINK Combine(LINK_COMP, POSTSCRIPT_VIEW) #define PS_MULTILINE Combine(MULTILINE_COMP, POSTSCRIPT_VIEW) #define PS_PAD Combine(PAD_COMP, POSTSCRIPT_VIEW) #define PS_PIN Combine(PIN_COMP, POSTSCRIPT_VIEW) #define PS_POLYGON Combine(POLYGON_COMP, POSTSCRIPT_VIEW) #define PS_RASTER Combine(RASTER_COMP, POSTSCRIPT_VIEW) #define PS_RECT Combine(RECT_COMP, POSTSCRIPT_VIEW) #define PS_SLOT Combine(SLOT_COMP, POSTSCRIPT_VIEW) #define PS_SPLINE Combine(SPLINE_COMP, POSTSCRIPT_VIEW) #define PS_STENCIL Combine(STENCIL_COMP, POSTSCRIPT_VIEW) #define PS_TEXT Combine(TEXT_COMP, POSTSCRIPT_VIEW) #define PS_VERTICES Combine(VERTICES_COMP, POSTSCRIPT_VIEW) #define PS_VSLOT Combine(VSLOT_COMP, POSTSCRIPT_VIEW) #define RASTER_VIEW Combine(RASTER_COMP, COMPONENT_VIEW) #define RECT_VIEW Combine(RECT_COMP, COMPONENT_VIEW) #define SLOT_VIEW Combine(SLOT_COMP, COMPONENT_VIEW) #define STENCIL_VIEW Combine(STENCIL_COMP, COMPONENT_VIEW) #define SPLINE_VIEW Combine(SPLINE_COMP, COMPONENT_VIEW) #define TEXT_VIEW Combine(TEXT_COMP, COMPONENT_VIEW) #define VERTICES_VIEW Combine(VERTICES_COMP, COMPONENT_VIEW) #define VSLOT_VIEW Combine(VSLOT_COMP, COMPONENT_VIEW) #endif ivtools-1.2.11a1/src/include/Unidraw/clipboard.h000066400000000000000000000045641214471147700214710ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Clipboard - contains a list of component subjects. */ #ifndef unidraw_clipboard_h #define unidraw_clipboard_h #include #include #include class GraphicComp; class Iterator; class UList; class Selection; //: contains a list of component subjects // man page class Clipboard { public: Clipboard(GraphicComp* = nil); virtual ~Clipboard(); void Init(Selection*); void CopyInit(Selection*); void Clear(); void DeleteComps(); void Append(GraphicComp*); void Prepend(GraphicComp*); void InsertAfter(Iterator, GraphicComp*); void InsertBefore(Iterator, GraphicComp*); void Remove(GraphicComp*); void Remove(Iterator&); GraphicComp* GetComp(Iterator); void SetComp(GraphicComp*, Iterator&); void First(Iterator&); void Last(Iterator&); void Next(Iterator&); void Prev(Iterator&); boolean Done(Iterator); boolean IsEmpty(); boolean Includes(GraphicComp*); virtual Clipboard* Copy(); virtual Clipboard* DeepCopy(); protected: UList* Elem(Iterator); GraphicComp* Comp(UList*); protected: UList* _comps; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/creator.h000066400000000000000000000035751214471147700211720ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Object creator class. */ #ifndef unidraw_creator_h #define unidraw_creator_h #include #define CREATE(classname, instream, objmap, objid) { \ classname* o = new classname; \ if (objmap != nil) objmap->Register(o, objid); \ o->Read(instream); \ return o; \ } class ObjectMap; #include //: component factory class // man page class Creator { public: Creator(); virtual void* Create( // for subjects ClassId, istream&, ObjectMap* = nil, int = 0 ); virtual void* Create(ClassId); // for views static Creator* instance(); static void instance(Creator*); protected: static Creator* _instance; }; #endif ivtools-1.2.11a1/src/include/Unidraw/ctrlinfo.h000066400000000000000000000050221214471147700213400ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ControlInfo - manages persistent information contained in a Control. */ #ifndef unidraw_ctrlinfo_h #define unidraw_ctrlinfo_h #include #include #include class GraphicComp; //: manages persistent information contained in a Control // man page class ControlInfo { public: ControlInfo( GraphicComp*, const char* = "", const char* = "", void* = nil ); ControlInfo( const char*, const char* = "", const char* = "", void* = nil ); virtual ~ControlInfo(); void SetLabel(GraphicComp*); void SetLabel(const char*); void SetKeyLabel(const char*); void SetKeyCode(const char*); void SetOwner(void*); GraphicComp* GetLabel(); const char* GetKeyLabel(); const char* GetKeyCode(); void* GetOwner(); virtual ControlInfo* Copy(); protected: void Init(const char*, const char*, void*); protected: GraphicComp* _label; char* _keyLabel; char* _keyCode; void* _owner; }; inline void ControlInfo::SetOwner (void* o) { _owner = o; } inline GraphicComp* ControlInfo::GetLabel () { return _label; } inline const char* ControlInfo::GetKeyLabel () { return _keyLabel; } inline const char* ControlInfo::GetKeyCode () { return _keyCode; } inline void* ControlInfo::GetOwner() { return _owner; } #include #endif ivtools-1.2.11a1/src/include/Unidraw/dialogs.h000066400000000000000000000074651214471147700211570ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Various dialog boxes. */ #ifndef unidraw_dialogs_h #define unidraw_dialogs_h #include #include #include #include class MarginFrame; class MatchEditor; class PrintBS; //: base class for simple, common dialog boxes (Unidraw). // man page class BasicDialog : public Dialog { public: void SetTitle(const char*); void SetSubtitle(const char*); protected: BasicDialog( ButtonState*, const char* title = "", const char* subtitle = "", Alignment = Center ); BasicDialog( const char* name, ButtonState*, const char* = "", const char* = "", Alignment = Center ); virtual void Forward(Event&); boolean IsAChild(Interactor*); protected: MarginFrame* _title, *_subtitle; protected: void Init(const char*, const char*); }; class AcknowledgeDialog : public BasicDialog { public: AcknowledgeDialog(const char* title, const char* subtitle = ""); virtual void Acknowledge(); protected: Interactor* Interior(); }; class ConfirmDialog : public BasicDialog { public: ConfirmDialog(const char* title, const char* subtitle = ""); virtual char Confirm(); protected: Interactor* Interior(); }; class UChooser : public StringChooser { public: UChooser( const char* title, const char* subtitle, const char* acceptLabel, const char* sample ); void Clear(); void Include(const char*); void Exclude(const char*); void SetTitle(const char*); void SetSubtitle(const char*); virtual void Reconfig(); protected: UChooser(ButtonState*, int rows, int cols, Alignment); void Init(const char* title, const char* subtitle); Interactor* Interior(const char* acptlbl); Interactor* AddScroller(Interactor*); virtual int Position(const char*); protected: MarginFrame* _title, *_subtitle; }; class PrintDialog : public FileChooser { public: PrintDialog(boolean to_printer = true); virtual ~PrintDialog(); void ToPrinter(boolean); boolean ToPrinter(); protected: virtual void UpdateEditor(); virtual void UpdateBrowser(); protected: Interactor* Interior(); protected: PrintBS* _dest; char* _last_print_cmd; char* _last_file_name; int _to_printer; }; class GridDialog : public BasicDialog { public: GridDialog(); virtual boolean Accept(); virtual void Handle(Event&); virtual void GetValues(float& xincr, float& yincr); void SelectMessage(); protected: Interactor* Interior(); protected: MatchEditor* _medit; ButtonState* _units; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/editor.h000066400000000000000000000056411214471147700210150ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Editor class from which domain-specific editors are derived. * An editor defines the interface to editing GraphicViews; it typically * consists of a viewer, command menus, and tool palettes. */ #ifndef unidraw_editor_h #define unidraw_editor_h #include #include #include class Component; class EditorImpl; class KeyMap; class Interactor; class ManagedWindow; class Selection; class StateVar; class Tool; class Viewer; //: base class for top-level windows in an application. // man page class Editor : public InputHandler { public: virtual ~Editor(); virtual void Open(); virtual void Close(); virtual void Update(); virtual void SetWindow(ManagedWindow*); virtual ManagedWindow* GetWindow() const; virtual Component* GetComponent(); virtual Viewer* GetViewer(int = 0); virtual KeyMap* GetKeyMap(); virtual Tool* GetCurTool(); virtual Selection* GetSelection(); virtual void SetComponent(Component*); virtual void SetViewer(Viewer*, int = 0); virtual void SetKeyMap(KeyMap*); virtual void SetCurTool(Tool*); virtual void SetSelection(Selection*); virtual StateVar* GetState(const char*); virtual boolean DependsOn(Component*); virtual void InsertDialog(Glyph*); virtual void RemoveDialog(Glyph*); virtual void SetClassName(const char*); virtual void SetInstance(const char*); virtual void keystroke(const Event&); protected: Editor(); void Insert(Interactor*); protected: ManagedWindow* _window; EditorImpl* _impl; }; inline void Editor::SetWindow(ManagedWindow* w) { _window = w; } inline ManagedWindow* Editor::GetWindow() const { return _window; } #include #endif ivtools-1.2.11a1/src/include/Unidraw/editorinfo.h000066400000000000000000000040121214471147700216600ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * EditorInfo - manages persistent information contained in an editor. */ #ifndef unidraw_editorinfo_h #define unidraw_editorinfo_h #include #include #include //: manages persistent information contained in an editor // man page class EditorInfo : public UMap { public: EditorInfo(); virtual ~EditorInfo(); void Register(const char* name, const char* info = ""); void UnregisterName(const char* name); void UnregisterInfo(const char* info); boolean Registered(const char* name); const char* GetName(const char* info); const char* GetName(int index); const char* GetInfo(const char* name); const char* GetInfo(int index); protected: virtual UMapElem* FindId(void*); virtual UMapElem* FindTag(void*); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/enter-scope.h000066400000000000000000000025671214471147700217570ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef ud__scope_h #define ud__scope_h #include #ifndef MAKEDEPEND #include #include #endif #endif ivtools-1.2.11a1/src/include/Unidraw/globals.h000066400000000000000000000066311214471147700211520ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Global constants, objects, and classes. */ #ifndef unidraw_globals_h #define unidraw_globals_h #include #include #include #undef None class CSolver; class Graphic; class PSBrush; class PSColor; class PSFont; class PSPattern; class Resource; class UList; class Unidraw; /* * global types */ typedef unsigned long ClassId; enum DragConstraint { None = 0x0, XFixed = 0x1, YFixed = 0x2, XYEqual = 0x4, HorizOrVert = 0x8, Gravity = 0x10 }; enum Mobility { Fixed = 0, Floating = 1, Undef = 2 }; typedef unsigned Orientation; enum { Normal = 0, Rotated = 1 }; enum { Portrait = 0, Landscape = 1 }; enum { Vertical = 0, Horizontal = 1 }; enum TransMethod { In = 0, Out = 1, InOut = 2 }; /* * global data */ extern CSolver* csolver; extern Unidraw* unidraw; extern PSColor* psblack; extern PSColor* pswhite; extern PSPattern* pssolid; extern PSPattern* psclear; extern PSPattern* psnonepat; extern PSColor* psnonecolor; extern PSBrush* pssingle; extern PSBrush* psnonebr; extern PSFont* psstdfont; extern Graphic* stdgraphic; /* like default painter */ static const int CHARBUFSIZE = 256; /* size of char buffers used internally */ static const int HANDLE_SIZE = 4; /* length of selection handle edge */ static const char MARK[] = "%I"; /* marks beginning of input */ static const int PIN_RAD = 5; /* radius of pin connector view */ static const int SLOP = 2; /* hit detection tolerance */ static const int SBUFSIZE = 10000; /* size of large super buffer */ extern char sbuf[SBUFSIZE]; /* super buffer */ /* * global functions */ extern void NormalRect(Coord& left, Coord& bottom, Coord& right, Coord& top); /* assures left < right, bottom < top */ extern void GetLine(const char*, int, int beg,int& end,int& size,int& nextBeg); /* extract lines from a string */ extern void GetAlignmentPoint(Graphic*, Alignment, float&, float&); /* return alignment point on graphic */ extern void Ref(Resource*); /* calls Reference if resource is nonnil */ #include /* for strnew */ #include #endif ivtools-1.2.11a1/src/include/Unidraw/grid.h000066400000000000000000000041401214471147700204450ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Grid - constrains points to lie on a grid and provides a corresponding * visual representation of the grid. */ #ifndef unidraw_grid_h #define unidraw_grid_h #include #include #include class Graphic; //: drawing editor grid // constrains points to lie on a grid and provides a corresponding // visual representation of the grid. //

    man page class Grid { public: Grid(float w, float h, float xincr, float yincr); virtual ~Grid(); virtual Graphic* GetGraphic(); // redefine all virtuals virtual void Constrain(Coord&, Coord&); // if you redefine GetGraphic virtual void Visibility(boolean); virtual boolean IsVisible(); virtual void SetSpacing(float incr, float yincr); virtual void GetSpacing(float& incr, float& yincr); protected: Grid(Graphic*); protected: Graphic* _graphic; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/iterator.h000066400000000000000000000032631214471147700213560ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Iterator - an object that marks a position in a data structure. */ #ifndef unidraw_iterator_h #define unidraw_iterator_h #include #include #include //: marks a position in a data structure. // man page class Iterator { public: Iterator(); Iterator(Iterator&); Iterator& operator =(Iterator&); virtual void* GetValue(); virtual void SetValue(void*); protected: void* _value; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/keymap.h000066400000000000000000000033661214471147700210170ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * KeyMap - maintains a keycode-to-UControl mapping. */ #ifndef unidraw_keymap_h #define unidraw_keymap_h #include class UControl; //: maintains a keycode-to-UControl mapping // man page class KeyMap { public: KeyMap(); virtual ~KeyMap(); void Register(UControl*); void Register(KeyMap*); void Unregister(UControl*); void Unregister(KeyMap*); void Execute(const char* keyCode); protected: KeyMap(UControl*); KeyMap(KeyMap*); void Init(); protected: KeyMap* _next; KeyMap* _submap; UControl* _ctrl; }; #endif ivtools-1.2.11a1/src/include/Unidraw/kybd.h000066400000000000000000000107331214471147700204560ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Keycode equivalents for controls. */ #ifndef unidraw_kybd_h #define unidraw_kybd_h #include /* * components */ extern const char* KLBL_LINE, *CODE_LINE; extern const char* KLBL_ELLIPSE, *CODE_ELLIPSE; extern const char* KLBL_RECT, *CODE_RECT; extern const char* KLBL_POLY, *CODE_POLY; extern const char* KLBL_MULTILINE, *CODE_MULTILINE; extern const char* KLBL_SPLINE, *CODE_SPLINE; extern const char* KLBL_CSPLINE, *CODE_CSPLINE; extern const char* KLBL_TEXT, *CODE_TEXT; extern const char* KLBL_PIN, *CODE_PIN; extern const char* KLBL_SLOT, *CODE_SLOT; extern const char* KLBL_PAD, *CODE_PAD; extern const char* KLBL_LINK, *CODE_LINK; /* * commands */ extern const char* KLBL_NEWCOMP, *CODE_NEWCOMP; /* catalog */ extern const char* KLBL_REVERT, *CODE_REVERT; extern const char* KLBL_VIEWCOMP, *CODE_VIEWCOMP; extern const char* KLBL_SAVECOMP, *CODE_SAVECOMP; extern const char* KLBL_SAVECOMPAS, *CODE_SAVECOMPAS; extern const char* KLBL_PRINT, *CODE_PRINT; extern const char* KLBL_IMPORT, *CODE_IMPORT; extern const char* KLBL_QUIT, *CODE_QUIT; extern const char* KLBL_UNDO, *CODE_UNDO; /* edit */ extern const char* KLBL_REDO, *CODE_REDO; extern const char* KLBL_CUT, *CODE_CUT; extern const char* KLBL_COPY, *CODE_COPY; extern const char* KLBL_PASTE, *CODE_PASTE; extern const char* KLBL_DUP, *CODE_DUP; extern const char* KLBL_DEL, *CODE_DEL; extern const char* KLBL_SLCTALL, *CODE_SLCTALL; extern const char* KLBL_HFLIP, *CODE_HFLIP; extern const char* KLBL_VFLIP, *CODE_VFLIP; extern const char* KLBL_CW90, *CODE_CW90; extern const char* KLBL_CCW90, *CODE_CCW90; extern const char* KLBL_GROUP, *CODE_GROUP; /* structure */ extern const char* KLBL_UNGROUP, *CODE_UNGROUP; extern const char* KLBL_SHOWSTRUCT, *CODE_SHOWSTRUCT; extern const char* KLBL_FRONT, *CODE_FRONT; extern const char* KLBL_BACK, *CODE_BACK; extern const char* KLBL_INSTANCE, *CODE_INSTANCE; extern const char* KLBL_ALGNLEFT, *CODE_ALGNLEFT; /* align */ extern const char* KLBL_ALGNRIGHT, *CODE_ALGNRIGHT; extern const char* KLBL_ALGNTOP, *CODE_ALGNTOP; extern const char* KLBL_ALGNBOT, *CODE_ALGNBOT; extern const char* KLBL_ALGNHCTR, *CODE_ALGNHCTR; extern const char* KLBL_ALGNVCTR, *CODE_ALGNVCTR; extern const char* KLBL_ALGNCTR, *CODE_ALGNCTR; extern const char* KLBL_ABUTLEFT, *CODE_ABUTLEFT; extern const char* KLBL_ABUTRIGHT, *CODE_ABUTRIGHT; extern const char* KLBL_ABUTUP, *CODE_ABUTUP; extern const char* KLBL_ABUTDOWN, *CODE_ABUTDOWN; extern const char* KLBL_ALGNTOGRID, *CODE_ALGNTOGRID; extern const char* KLBL_NORMSIZE, *CODE_NORMSIZE; /* view */ extern const char* KLBL_REDTOFIT, *CODE_REDTOFIT; extern const char* KLBL_CENTER, *CODE_CENTER; extern const char* KLBL_GRID, *CODE_GRID; extern const char* KLBL_GRIDSPC, *CODE_GRIDSPC; extern const char* KLBL_GRAVITY, *CODE_GRAVITY; extern const char* KLBL_ORIENTATION, *CODE_ORIENTATION; extern const char* KLBL_CLOSEEDITOR, *CODE_CLOSEEDITOR; /* * tools */ extern const char* KLBL_SELECT, *CODE_SELECT; extern const char* KLBL_MOVE, *CODE_MOVE; extern const char* KLBL_CONNECT, *CODE_CONNECT; extern const char* KLBL_DETACH, *CODE_DETACH; extern const char* KLBL_SCALE, *CODE_SCALE; extern const char* KLBL_STRETCH, *CODE_STRETCH; extern const char* KLBL_ROTATE, *CODE_ROTATE; extern const char* KLBL_RESHAPE, *CODE_RESHAPE; extern const char* KLBL_MAGNIFY, *CODE_MAGNIFY; #endif ivtools-1.2.11a1/src/include/Unidraw/leave-scope.h000066400000000000000000000025271214471147700217320ustar00rootroot00000000000000/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifdef ud__scope_h #undef ud__scope_h #ifndef MAKEDEPEND #include #endif #include #endif ivtools-1.2.11a1/src/include/Unidraw/manip.h000066400000000000000000000035641214471147700206350ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Manipulator - base class for defining direct manipulation semantcs. */ #ifndef unidraw_manip_h #define unidraw_manip_h #include #include #include class Event; class Tool; class Viewer; //: base class for defining direct-manipulation semantics. // man page class Manipulator { public: virtual ~Manipulator(); virtual void Grasp(Event&); virtual boolean Manipulating(Event&); virtual void Effect(Event&); virtual void SetViewer(Viewer*); virtual void SetTool(Tool*); virtual Viewer* GetViewer(); virtual Tool* GetTool(); protected: Manipulator(); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/manips.h000066400000000000000000000173221214471147700210150ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ManipGroup - composition of Manipulators * DragManip - downclick-drag-upclick-style manipulation * VertexManip - multi-click DragManip * ConnectManip - DragManip that snaps to nearest connector * TextManip - creates and edits text */ #ifndef unidraw_manips_h #define unidraw_manips_h #include #include #include #include class ConnectorView; class GrowingVertices; class Iterator; class Painter; class Rubberband; class Selection; class TextBuffer; class TextDisplay; class Transformer; class UList; //: group manipulator // man page class ManipGroup : public Manipulator { public: ManipGroup(Viewer* = nil, Tool* = nil); virtual ~ManipGroup(); virtual void Grasp(Event&); virtual boolean Manipulating(Event&); virtual void Effect(Event&); virtual void SetViewer(Viewer*); virtual void SetTool(Tool*); virtual Viewer* GetViewer(); virtual Tool* GetTool(); virtual void First(Iterator&); virtual void Last(Iterator&); virtual void Next(Iterator&); virtual void Prev(Iterator&); virtual boolean Done(Iterator); virtual Manipulator* GetManip(Iterator); virtual void SetManip(Manipulator*, Iterator&); virtual void Append( Manipulator*, Manipulator* =nil, Manipulator* =nil, Manipulator* =nil ); virtual void Prepend( Manipulator*, Manipulator* =nil, Manipulator* =nil, Manipulator* =nil ); virtual void InsertBefore(Iterator, Manipulator*); virtual void InsertAfter(Iterator, Manipulator*); virtual void Remove(Manipulator*); virtual void Remove(Iterator&); protected: Manipulator* Manip(UList*); UList* Elem(Iterator); protected: UList* _kids; Viewer* _viewer; Tool* _tool; }; //: drag manipulator // man page class DragManip : public Manipulator { public: DragManip( Viewer*, Rubberband*, Transformer* = nil, Tool* = nil, DragConstraint = None ); DragManip( Viewer*, Rubberband*, Transformer*, Tool*, DragConstraint, Coord, Coord ); virtual ~DragManip(); virtual void Grasp(Event&); virtual boolean Manipulating(Event&); virtual void Effect(Event&); virtual void SetViewer(Viewer*); virtual void SetRubberband(Rubberband*); virtual void SetTransformer(Transformer*); virtual void SetTool(Tool*); virtual void SetConstraint(DragConstraint); virtual Viewer* GetViewer(); virtual Rubberband* GetRubberband(); virtual Transformer* GetTransformer(); virtual Tool* GetTool(); virtual DragConstraint GetConstraint(); const Event& GraspEvent(); protected: void Init(Viewer*, Rubberband*, Transformer*, Tool*, DragConstraint); virtual void Constrain(Event&); protected: Viewer* _viewer; Rubberband* _r; Transformer* _relative; Tool* _tool; DragConstraint _constraint; boolean _origPreset; Coord _origx, _origy; Event _grasp_e; }; inline const Event& DragManip::GraspEvent () { return _grasp_e; } //: vertex manipulator // man page class VertexManip : public DragManip { public: VertexManip( Viewer*, GrowingVertices*, Transformer* = nil, Tool* = nil, DragConstraint = None ); virtual boolean Manipulating(Event&); GrowingVertices* GetGrowingVertices(); }; //: continuous vertex manipulator // man page class ScribbleVertexManip : public VertexManip { public: ScribbleVertexManip( Viewer*, GrowingVertices*, Transformer* = nil, Tool* = nil, DragConstraint = None ); virtual boolean Manipulating(Event&); protected: boolean _first; }; //: connection manipulator // man page class ConnectManip : public DragManip { public: ConnectManip(Viewer*, Rubberband*, Transformer* = nil, Tool* = nil); virtual boolean Manipulating(Event&); ConnectorView* GetTarget(); protected: ConnectorView* _target; }; //: text manipulator // man page class TextManip : public Manipulator { public: TextManip(Viewer*, Painter*, Coord tab, Tool* = nil); TextManip(Viewer*, Painter*, Coord h, Coord tab, Tool* = nil); TextManip( Viewer*, const char*, int, Coord, Coord, Painter*, Coord tab, Tool* = nil ); TextManip( Viewer*, const char*, int, Coord, Coord, Painter*, Coord h, Coord tab, Tool* = nil ); virtual ~TextManip(); virtual void Grasp(Event&); virtual boolean Manipulating(Event&); virtual void Effect(Event&); virtual void SetViewer(Viewer*); virtual void SetTool(Tool*); virtual Viewer* GetViewer(); virtual Tool* GetTool(); virtual Painter* GetPainter(); virtual Coord GetLineHeight(); virtual Coord GetTabWidth(); virtual const char* GetText(int&); virtual void GetPosition(Coord&, Coord&); const Event& GraspEvent(); virtual boolean HandleKey(Event&); int Dot(); int Mark(); void InsertCharacter(char); void DeleteCharacter(int); void InsertText(const char*, int); void DeleteText(int); void DeleteLine(); void DeleteSelection(); void BackwardCharacter(int = 1), ForwardCharacter(int = 1); void BackwardLine(int = 1), ForwardLine(int = 1); void BackwardWord(int = 1), ForwardWord(int = 1); void BeginningOfLine(), EndOfLine(); void BeginningOfWord(), EndOfWord(); void BeginningOfSelection(), EndOfSelection(); void BeginningOfText(), EndOfText(); void Select(int dot); void SelectMore(int mark); void SelectAll(); void Select(int dot, int mark); boolean Contains(Coord, Coord); int Locate(Coord, Coord); protected: void Init( Viewer*, Painter*, Coord, Coord, Tool*, boolean,const char* =nil,int =0 ); void InitTextDisplay(const char*, int); void PlaceTextDisplay (Coord, Coord); void CheckBuf(int more); protected: boolean _prepositioned; boolean _selecting; Coord _xpos, _ypos; Viewer* _viewer; Selection* _selection; Painter* _painter; Tool* _tool; PSFont* _font; Coord _lineHt, _tabWidth; boolean _multiline; TextBuffer* _text; TextDisplay* _display; char* _buf; int _bufsize; int _dot, _mark; Event _grasp_e; }; inline int TextManip::Dot () { return _dot; } inline int TextManip::Mark () { return _mark; } inline const Event& TextManip::GraspEvent () { return _grasp_e; } #include #endif ivtools-1.2.11a1/src/include/Unidraw/path.h000066400000000000000000000035461214471147700204650ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Path - accumulates information about the transmission path during * state variable propagation. */ #ifndef unidraw_path_h #define unidraw_path_h #include #include #include static const int SLOTS = 100; class Connector; class UList; //: transmission path for state variable propagation // accumulates information about the transmission path during // state variable propagation. //

    man page class Path { public: Path(Path* = nil); virtual ~Path(); virtual void Visit(Connector*); virtual boolean Visited(Connector*); protected: class UList* _slot[SLOTS]; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/selection.h000066400000000000000000000056271214471147700215200ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Selection - manages a set of selected components. */ #ifndef unidraw_selection_h #define unidraw_selection_h #include #include #include class GraphicView; class Iterator; class Painter; class UList; class Viewer; //: manages a set of selected components. // man page class Selection { public: Selection(Selection* = nil); virtual ~Selection(); virtual void Show(Viewer* = nil); /* inits and draws handles (in given viewer) */ virtual void Update(Viewer* = nil); /* draws newly-added handles */ virtual void Hide(Viewer* = nil); virtual void Init(Viewer* = nil); /* explicitly init handles */ virtual void Clear(Viewer* = nil); /* removes & clears all views */ void Append(GraphicView*); void Prepend(GraphicView*); void InsertAfter(Iterator, GraphicView*); void InsertBefore(Iterator, GraphicView*); void Remove(GraphicView*); void Remove(Iterator&); GraphicView* GetView(Iterator); void SetView(GraphicView*, Iterator&); void First(Iterator&); void Last(Iterator&); void Next(Iterator&); void Prev(Iterator&); boolean Done(Iterator); boolean IsEmpty(); boolean Includes(GraphicView*); int Number(); void Sort(GraphicView*); virtual void Exclusive(Selection*); /* union minus intersection */ virtual void Merge(Selection*); /* union of this's & Selection's */ /* GraphicViews */ void GetBox(Coord&, Coord&, Coord&, Coord&); /* box bounding selection */ protected: GraphicView* View(UList*); UList* Elem(Iterator); protected: UList* _ulist; int _count; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/statevar.h000066400000000000000000000037521214471147700213610ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * StateVar state variable subject. */ #ifndef unidraw_statevar_h #define unidraw_statevar_h #include class Connector; class StateVarView; #include //: state variable // man page class StateVar { public: Connector* GetBinding(); virtual void Attach(StateVarView*); virtual void Detach(StateVarView*); virtual void Notify(); virtual StateVar& operator = (StateVar&); virtual ~StateVar(); virtual StateVar* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual ClassId GetSubstId(const char*& delim); virtual boolean IsA(ClassId); protected: StateVar(); protected: friend class Connector; void SetBinding(Connector*); protected: class UList* _views; Connector* _conn; }; #endif ivtools-1.2.11a1/src/include/Unidraw/statevars.h000066400000000000000000000141031214471147700215340ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * State variable subclasses. */ #ifndef unidraw_statevars_h #define unidraw_statevars_h #include class Component; class PSBrush; class PSColor; class PSPattern; class PSFont; //: name state variable // man page class NameVar : public StateVar { public: NameVar(const char* = nil); virtual const char* GetName(); virtual void SetName(const char*); virtual StateVar& operator = (StateVar&); virtual StateVar* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); private: char* _name; }; //: component name state variable // man page class CompNameVar : public NameVar { public: CompNameVar(Component* = nil); virtual Component* GetComponent(); virtual void SetComponent(Component*); virtual void UpdateName(); virtual const char* PartOf(); virtual StateVar& operator = (StateVar&); virtual StateVar* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: const char* CatalogName(Component*); protected: Component* _comp; }; //: modified-status state variable // man page class ModifStatusVar : public StateVar { public: ModifStatusVar(Component* = nil, boolean = false); ~ModifStatusVar(); virtual boolean GetModifStatus(); virtual void SetModifStatus(boolean); virtual Component* GetComponent(); virtual void SetComponent(Component*); virtual StateVar& operator = (StateVar&); virtual StateVar* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: void modified(int); protected: int _modified; Component* _component; static class UList* _vars; }; //: magnify factor state variable // man page class MagnifVar : public StateVar { public: MagnifVar(float = 1); virtual float GetMagnif(); virtual void SetMagnif(float); virtual StateVar& operator = (StateVar&); virtual StateVar* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: float _magnif; }; //: gravity-enabled state variable // man page class GravityVar : public StateVar { public: GravityVar(boolean = false); virtual boolean IsActive(); virtual void Activate(boolean); virtual StateVar& operator = (StateVar&); virtual StateVar* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: int _active; }; //: current font state variable // man page class FontVar : public StateVar { public: FontVar(PSFont* = nil); virtual ~FontVar(); virtual PSFont* GetFont(); virtual void SetFont(PSFont*); virtual StateVar& operator = (StateVar&); virtual StateVar* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PSFont* _psfont; }; //: current brush state variable // man page class BrushVar : public StateVar { public: BrushVar(PSBrush* = nil); virtual ~BrushVar(); virtual PSBrush* GetBrush(); virtual void SetBrush(PSBrush*); virtual StateVar& operator = (StateVar&); virtual StateVar* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PSBrush* _psbrush; }; //: current pattern state variable // man page class PatternVar : public StateVar { public: PatternVar(PSPattern* = nil); virtual ~PatternVar(); virtual PSPattern* GetPattern(); virtual void SetPattern(PSPattern*); virtual StateVar& operator = (StateVar&); virtual StateVar* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PSPattern* _pspattern; }; //: current color state variable // man page class ColorVar : public StateVar { public: ColorVar(PSColor* fg = nil, PSColor* bg = nil); virtual ~ColorVar(); virtual PSColor* GetFgColor(); virtual PSColor* GetBgColor(); virtual void SetColors(PSColor* fg, PSColor* bg); virtual StateVar& operator = (StateVar&); virtual StateVar* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: PSColor* _psfgcolor, *_psbgcolor; }; #endif ivtools-1.2.11a1/src/include/Unidraw/stateview.h000066400000000000000000000035011214471147700215330ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * StateVarView state variable view. */ #ifndef unidraw_stateview_h #define unidraw_stateview_h #include #include #include class StateVar; //: state variable view // man page class StateVarView : public MonoScene { public: virtual ~StateVarView(); virtual void Update(); StateVar* GetSubject(); protected: StateVarView(StateVar*); virtual void Init(); virtual boolean Stale(); virtual void Reconfig(); protected: StateVar* _subject; protected: friend class StateVar; virtual void SetSubject(StateVar*); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/stateviews.h000066400000000000000000000107211214471147700217200ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * StateVarView subclasses. */ #ifndef unidraw_stateviews_h #define unidraw_stateviews_h #include #include class BrushVar; class ColorVar; class FontVar; class GravityVar; class MagnifVar; class ModifStatusVar; class NameVar; class PatternVar; class PSBrush; class PSColor; class PSPattern; class PSFont; class TextInteractor; //: name state variable view // man page class NameVarView : public StateVarView { public: NameVarView(NameVar*, Alignment = Center, const char* sample = nil); protected: virtual void Init(); virtual boolean Stale(); }; //: file-name state variable view // man page class FileNameVarView : public StateVarView { public: FileNameVarView( NameVar*, Alignment = Center, boolean relative = true, const char* sample = nil ); protected: virtual void Init(); protected: boolean _relative; }; //: component-name state variable view // man page class CompNameVarView : public StateVarView { public: CompNameVarView( CompNameVar*, Alignment = Center, boolean relative = true, const char* sample = nil ); protected: virtual void Init(); protected: boolean _relative; }; //: modified-status state variable view // man page class ModifStatusVarView : public StateVarView { public: ModifStatusVarView(ModifStatusVar*, Alignment = Center); protected: virtual void Init(); virtual boolean Stale(); virtual void Reconfig(); boolean WriteProtected(); protected: boolean _prevVal, _prevProt; }; //: magnify-factor state variable view // man page class MagnifVarView : public StateVarView { public: MagnifVarView(MagnifVar*, Alignment = Center); protected: virtual void Init(); virtual boolean Stale(); protected: float _prevVal; }; //: gravity-enabled state variable view // man page class GravityVarView : public StateVarView { public: GravityVarView(GravityVar*, Alignment = Center); protected: virtual void Init(); virtual boolean Stale(); protected: boolean _prevVal; }; //: current-font state variable view // man page class FontVarView : public StateVarView { public: FontVarView(FontVar*, Alignment = Center, const char* sample = nil); protected: virtual void Init(); virtual boolean Stale(); protected: PSFont* _prevVal; }; //: current-brush state variable view // man page class BrushVarView : public StateVarView { public: BrushVarView(BrushVar*, ColorVar* = nil); virtual ~BrushVarView(); protected: virtual void Init(); virtual boolean Stale(); protected: PSBrush* _prevVal; PSColor* _prevFg, *_prevBg; ColorVar* _colorSubj; }; //: current-pattern state variable view // man page class PatternVarView : public StateVarView { public: PatternVarView(PatternVar*, ColorVar* = nil); virtual ~PatternVarView(); protected: virtual void Init(); virtual boolean Stale(); protected: PSPattern* _prevVal; PSColor* _prevFg, *_prevBg; ColorVar* _colorSubj; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/transfn.h000066400000000000000000000034341214471147700212000ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Transfer function base class. */ #ifndef unidraw_transfn_h #define unidraw_transfn_h #include class Connector; class Path; class StateVar; #include //: transfer function // man page class TransferFunct { public: virtual void Evaluate(Path* = nil); virtual ~TransferFunct(); virtual TransferFunct* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual ClassId GetSubstId(const char*& delim); virtual boolean IsA(ClassId); protected: TransferFunct(); Connector* GetBinding(StateVar*); }; #endif ivtools-1.2.11a1/src/include/Unidraw/transfns.h000066400000000000000000000051241214471147700213610ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Transfer function subclasses. */ #ifndef unidraw_transfns_h #define unidraw_transfns_h #include //: to-port transfer function // man page class TF_2Port : public TransferFunct { public: virtual void Evaluate(Path* = nil); virtual StateVar* GetInput(int index); virtual StateVar* GetOutput(int index); virtual void SetInput(StateVar*, int index); virtual void SetOutput(StateVar*, int index); virtual int Inputs(); virtual int Outputs(); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: TF_2Port(); virtual void Transfer(); virtual boolean ChangedOutput(int index = 0); }; //: direct transfer function // man page class TF_Direct : public TF_2Port { public: TF_Direct(StateVar* input = nil, StateVar* output = nil); virtual StateVar* GetInput(int index = 0); virtual StateVar* GetOutput(int index = 0); virtual void SetInput(StateVar*, int index = 0); virtual void SetOutput(StateVar*, int index = 0); virtual int Inputs(); virtual int Outputs(); virtual TransferFunct* Copy(); virtual void Read(istream&); virtual void Write(ostream&); virtual ClassId GetClassId(); virtual boolean IsA(ClassId); protected: virtual void Transfer(); virtual boolean ChangedOutput(int index = 0); protected: StateVar* _input, *_output; boolean _changed; }; #endif ivtools-1.2.11a1/src/include/Unidraw/uarray.h000066400000000000000000000032451214471147700210300ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * UArray - dynamic array object. */ #ifndef unidraw_uarray_h #define unidraw_uarray_h #include class UArray { public: UArray(int = 16); ~UArray(); void*& operator[](int index); void Insert(void*, int index); void Remove(int index); int Index(void*); int Count(); void Clear(); protected: void Check(int index); protected: void** _buf; int _bufsize; int _count; }; inline int UArray::Count () { return _count; } inline void UArray::Clear () { _count = 0; } #endif ivtools-1.2.11a1/src/include/Unidraw/uctrl.h000066400000000000000000000045201214471147700206530ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * UControl - base class for KeyMap-compatible controls. * UControlInteractor - base class for interactors that base their * appearance on ControlInfo information */ #ifndef unidraw_uctrl_h #define unidraw_uctrl_h #include #include #include class ControlInfo; class Graphic; class UControl : public Control { public: virtual void SetControlInfo(ControlInfo*); ControlInfo* GetControlInfo(); protected: UControl(ControlInfo*); UControl(const char*, ControlInfo*); protected: ControlInfo* _info; protected: void Init(ControlInfo*); }; class UControlInteractor : public Interactor { public: virtual ~UControlInteractor(); virtual void Highlight(boolean); virtual void SetControlInfo(ControlInfo*); ControlInfo* GetControlInfo(); protected: UControlInteractor(ControlInfo*); UControlInteractor(); virtual void Redraw(Coord, Coord, Coord, Coord); virtual void Invert(); Graphic* InitLabel(ControlInfo*); protected: ControlInfo* _info; Graphic* _picture; Graphic* _label; boolean _highlighted; protected: void Init(ControlInfo*); }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/uctrls.h000066400000000000000000000061111214471147700210340ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * UControl and UControlInteractor subclasses. */ #ifndef unidraw_uctrls_h #define unidraw_uctrls_h #include #include //: command control // man page class CommandControl : public UControl { public: CommandControl(ControlInfo*); CommandControl(const char*, ControlInfo*); virtual void Do(); protected: virtual void Busy(); virtual void Done(); protected: void Init(ControlInfo*); }; //: panel control // man page class PanelControl : public UControl { public: PanelControl(Interactor*, ControlInfo*, ControlState* = nil); PanelControl(const char*, Interactor*, ControlInfo*, ControlState* = nil); virtual void Do(); protected: virtual void Down(); virtual void Enter(); virtual void Leave(); virtual void Select(); protected: void Init(Interactor*, ControlState*); }; //: horizontal-panel control // man page class HPanelControl : public PanelControl { public: HPanelControl(ControlInfo*, ControlState* = nil); HPanelControl(const char*, ControlInfo*, ControlState* = nil); }; //: vertical-panel control // man page class VPanelControl : public PanelControl { public: VPanelControl(ControlInfo*, ControlState* = nil); VPanelControl(const char*, ControlInfo*, ControlState* = nil); }; //: command "interactor" control // man page class CommandInteractor : public UControlInteractor { public: CommandInteractor(ControlInfo*); protected: virtual void Reconfig(); virtual void Resize(); }; //: panel "interactor" control // man page class PanelInteractor : public UControlInteractor { public: PanelInteractor(ControlInfo*, Orientation); protected: virtual void Reconfig(); virtual void Resize(); protected: Orientation _orient; }; #endif ivtools-1.2.11a1/src/include/Unidraw/uformat.h000066400000000000000000000026411214471147700212010ustar00rootroot00000000000000/* * Copyright (c) 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Unidraw format version history. */ #ifndef unidraw_uformat_h #define unidraw_uformat_h #include static const float UV_ORIGINAL = 1; // original 3.0 release static const float UV_PRERELEASE = 0; // pre-3.0 release #define UV_LATEST UV_ORIGINAL #endif ivtools-1.2.11a1/src/include/Unidraw/uhash.h000066400000000000000000000043701214471147700206350ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * UHash - hash table. */ #ifndef unidraw_uhash_h #define unidraw_uhash_h #include #include #include class Iterator; class UList; class UHashElem { public: UHashElem(void* = nil); virtual ~UHashElem(); void* GetKey(); void SetKey(void*); protected: void* _key; }; inline void* UHashElem::GetKey () { return _key; } inline void UHashElem::SetKey (void* key) { _key = key; } class UHashTable { public: UHashTable(int nslots); virtual ~UHashTable(); virtual void Register(void* key, UHashElem* = nil); virtual void Unregister(void* key); void First(Iterator&); void Next(Iterator&); boolean Done(Iterator); UHashElem* GetElem(Iterator); UHashElem* Find(void* key); protected: virtual UHashElem* CreateElem(); virtual unsigned long Hash(void*); virtual boolean Equal(void* key1, void* key2); protected: int _nslots; protected: UList* UElem(Iterator); UHashElem* Elem(UList*); void DeleteSlot(UList*); protected: UList** _slot; }; #include #endif ivtools-1.2.11a1/src/include/Unidraw/ulist.h000066400000000000000000000041641214471147700206660ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * UList - list object. */ #ifndef unidraw_ulist_h #define unidraw_ulist_h #include #include #include class UList { public: UList(void* = nil); virtual ~UList(); boolean IsEmpty(); void Append(UList*); void Prepend(UList*); void Remove(UList*); void Delete(void*); UList* Find(void*); UList* First(); UList* Last(); UList* End(); UList* Next(); UList* Prev(); void* operator()(); UList* operator[](int count); protected: void* _object; UList* _next; UList* _prev; }; inline boolean UList::IsEmpty () { return _next == this; } inline UList* UList::First () { return _next; } inline UList* UList::Last () { return _prev; } inline UList* UList::End () { return this; } inline UList* UList::Next () { return _next; } inline UList* UList::Prev () { return _prev; } inline void* UList::operator() () { return _object; } #include #endif ivtools-1.2.11a1/src/include/Unidraw/umap.h000066400000000000000000000037011214471147700204640ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * UMap - maintains a void* <-> void* mapping (linear search by default). */ #ifndef unidraw_umap_h #define unidraw_umap_h #include class UMapElem { public: virtual ~UMapElem(); virtual void* id(); virtual void* tag(); protected: UMapElem(); }; class UMap { public: virtual ~UMap(); int Count(); void Clear(); protected: UMap(); void Register(UMapElem*); void Unregister(UMapElem*); int Index(UMapElem*); UMapElem* Elem(int index); virtual UMapElem* FindId(void*); virtual UMapElem* FindTag(void*); protected: UArray _elems; }; inline int UMap::Index (UMapElem* elem) { return _elems.Index(elem); } inline UMapElem* UMap::Elem (int index) { return (UMapElem*) _elems[index]; } inline int UMap::Count () { return _elems.Count(); } #endif ivtools-1.2.11a1/src/include/Unidraw/unidraw.h000066400000000000000000000074601214471147700212010ustar00rootroot00000000000000/* * Copyright (c) 2004 Scott E. Johnston * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Unidraw - performs top-level event handling, catalog initialization, and * manages multiple editors. */ #ifndef unidraw_h #define unidraw_h #include class Catalog; class Command; class Component; class Editor; class Event; class Iterator; class HistoryMap; class OptionDesc; class PropertyData; class UList; class World; //: singleton for coordinating and controlling a Unidraw application. // man page class Unidraw { public: Unidraw( Catalog*, int& argc, char** argv, OptionDesc* = nil, PropertyData* = nil ); Unidraw(Catalog*, World*); virtual ~Unidraw(); virtual void Run(); virtual void Update(boolean immediate = false); virtual void Quit(); virtual void Open(Editor*); virtual void Close(Editor*); // delete editor virtual void CloseDependents(Component*); virtual void CloseAll(); virtual boolean Opened(Editor*); void First(Iterator&); void Next(Iterator&); boolean Done(Iterator); Editor* GetEditor(Iterator); Editor* Find(Component*); Editor* FindAny(Component*); Catalog* GetCatalog(); World* GetWorld(); void SetHistoryLength(int); int GetHistoryLength(); virtual void Log(Command*); void Undo(Component*, int = 1); void Redo(Component*, int = 1); void ClearHistory(Component* = nil); void ClearHistory(Editor*); virtual void ExecuteCmd(Command*); // indirection for command execution, will delete object protected: virtual void Process(); boolean IsClean(Editor*); void Mark(Editor*); void Sweep(); void DoUpdate(); void GetHistory(Component*, UList*& past, UList*& future); void ClearHistory(UList*, int = 1); UList* elem(Iterator); Command* command(UList*); public: boolean alive(); boolean updated(); void alive(boolean); void updated(boolean); protected: void Init(Catalog*, World*); void InitAttributes(); void DeleteComponent(Component*); Editor* editor(UList*); Editor* FindAny(Component*, UList*); Editor* FindAnyDead(Component*); protected: Catalog* _catalog; World* _world; UList* _editors; UList* _deadEditors; boolean _alive; boolean _updated; HistoryMap* _histories; int _histlen; }; inline Catalog* Unidraw::GetCatalog () { return _catalog; } inline World* Unidraw::GetWorld () { return _world; } inline boolean Unidraw::alive () { return _alive; } inline boolean Unidraw::updated () { return _updated; } inline void Unidraw::alive (boolean a) { _alive = a; } inline void Unidraw::updated (boolean u) { _updated = u; } #endif ivtools-1.2.11a1/src/include/Unidraw/upage.h000066400000000000000000000040051214471147700206210ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * UPage - defines the viewer's page boundary. */ #ifndef unidraw_upage_h #define unidraw_upage_h #include #include class PSBrush; class PageGraphic : public Graphic { public: PageGraphic(float, float, Graphic* = nil); virtual ~PageGraphic(); void GetOriginal(float&, float&); virtual void SetBrush(PSBrush*); virtual PSBrush* GetBrush(); virtual Graphic* Copy(); float Width() { return _width; } float Height() { return _height; } protected: virtual void getExtent(float&, float&, float&, float&, float&, Graphic*); virtual void draw(Canvas*, Graphic*); private: float _width, _height; PSBrush* _br; }; class UPage { public: UPage(float w, float h); UPage(Graphic*); virtual ~UPage(); virtual Graphic* GetGraphic(); protected: Graphic* _graphic; }; #endif ivtools-1.2.11a1/src/include/Unidraw/viewer.h000066400000000000000000000105401214471147700210220ustar00rootroot00000000000000/* * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Stanford not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Stanford makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Viewer - a GraphicBlock that displays the graphic contributed by a * GraphicView. */ #ifndef unidraw_viewer_h #define unidraw_viewer_h #include #include #include #include class Damage; class Editor; class GraphicComp; class GraphicView; class Grid; class KeyMap; class Manipulator; class Rubberband; class Selection; class State; class TextDisplay; class Tool; class Transformer; class UPage; class ViewerGraphic; class ViewerView; //: displays a graphical component view hierarchy. // man page class Viewer : public GraphicBlock { public: Viewer( Editor*, GraphicView*, UPage*, Grid* = nil, Coord = 0, Coord = 0, Orientation = Normal, Alignment = Center, Zooming = Binary ); Viewer( const char*, Editor*, GraphicView*, UPage*, Grid* = nil, Coord = 0, Coord = 0, Orientation = Normal, Alignment = Center, Zooming = Binary ); virtual ~Viewer(); virtual void Update(); virtual void Adjust(Perspective&); virtual void Handle(Event&); virtual void Reconfig(); virtual void Draw(); virtual void SetGraphicView(GraphicView*); virtual void SetPage(UPage*); virtual void SetGrid(Grid*); virtual void SetMagnification(float); virtual void SetOrientation(Orientation); virtual Graphic* GetGraphic(); virtual GraphicView* GetGraphicView(); virtual UPage* GetPage(); virtual Grid* GetGrid(); virtual Orientation GetOrientation(); virtual Editor* GetEditor(); virtual Selection* GetSelection(); virtual Damage* GetDamage(); virtual void InitRubberband(Rubberband*); virtual void InitTextDisplay(TextDisplay*, Painter*); virtual void IncurTextDisplayDamage(TextDisplay*, Painter*); virtual void CenterOp(); virtual void Magnify(Coord, Coord, Coord, Coord); virtual void ReduceToFit(); virtual void Constrain(Coord&, Coord&); virtual void UseTool(Tool*); virtual void Align(GraphicComp*, Alignment); Transformer* GetRel(); Transformer* ComputeGravityRel(); protected: void Init(Editor*, GraphicView*, UPage*, Grid*, Coord, Coord, Orientation); void Init(Editor*, GraphicView*, UPage*, Grid*); Tool* CurTool(); Transformer* GetTransformer(); virtual void Manipulate(Manipulator*, Event&); // direct manipulation loop virtual void UseTool(Tool*, Event&); virtual void MomentaryUseTool(const char*, Event&); virtual void GetGraphicBox(Coord&, Coord&, Coord&, Coord&); virtual void Reorient(); virtual void UpdateMagnifVar(); virtual float LimitMagnification(float); virtual ClassId ViewCategory(); virtual void Redraw(Coord, Coord, Coord, Coord); virtual void Resize(); protected: Editor* _editor; Damage* _damage; GraphicView* _gview; UPage* _page; Grid* _grid; Orientation _orientation; ViewerView* _viewerView; }; class ViewerView : public GraphicView { public: ViewerView(GraphicView*, UPage*, Grid*, Viewer*); virtual ~ViewerView(); virtual void Update(); virtual Viewer* GetViewer(); protected: Viewer* _viewer; ViewerGraphic* _vg; }; #include #endif ivtools-1.2.11a1/src/include/ivstd/000077500000000000000000000000001214471147700170705ustar00rootroot00000000000000ivtools-1.2.11a1/src/include/ivstd/fstream.h000066400000000000000000000006251214471147700207050ustar00rootroot00000000000000#ifndef _iv_fstream_ #define _iv_fstream_ #include_next #if __GNUC__>=3 #define input ios_base::in #define output ios_base::out #if __GNUC__>3 || __GNUC__==3 && __GNUC_MINOR__>0 /* && !defined(__APPLE__) */ #include #define fileptr_filebuf __gnu_cxx::stdio_filebuf #else #define fileptr_filebuf filebuf #endif #else #define input "r" #define output "w" #endif #endif ivtools-1.2.11a1/src/include/ivstd/iosfwd000066400000000000000000000006161214471147700203110ustar00rootroot00000000000000#ifndef _iv_iosfwd_ #define _iv_iosfwd_ #if __GNUC__>=3 #include_next using std::ios_base; using std::filebuf; using std::istream; using std::ostream; #define out_form(ostr,format,value) \ { \ char buffer[1024]; \ snprintf(buffer, 1024, format, value); \ ostr << buffer; \ } #else class istream; class ostream; #define out_form(ostr,format,value) \ ostr.form(format,value); #endif #endif ivtools-1.2.11a1/src/include/ivstd/iostream.h000066400000000000000000000022171214471147700210660ustar00rootroot00000000000000#ifndef _iv_iostream_h_ #define _iv_iostream_h_ #include #include_next #if __GNUC__>=3 #if 0 #include // from a posting to libstdc++@gcc.gnu.org by Carlo Wood // Quick and dirty unbuffered file descriptor streambuf. class fdbuf : public std::basic_streambuf > { public: typedef std::char_traits traits_type; typedef traits_type::int_type int_type; private: int M_fd; public: fdbuf(int fd) : M_fd(fd) { } protected: virtual int_type overflow(int_type c = traits_type::eof()) { if (!traits_type::eq_int_type(c, traits_type::eof())) { char cp[1]; *cp = c; if (write(M_fd, cp, 1) != 1) return traits_type::eof(); } return 0; } // This would be needed if it was buffered. // virtual std::streamsize xsputn(char const* s, std::streamsize num) { return write(M_fd, s, num); } }; // Unbuffered file descriptor stream. class ofdstream : public std::ostream { private: mutable fdbuf M_fdbuf; public: explicit ofdstream(int fd) : std::ostream(&M_fdbuf), M_fdbuf(fd) { } fdbuf* rdbuf(void) const { return &M_fdbuf; } }; #endif #endif #endif ivtools-1.2.11a1/src/include/ivstd/leakchecker.h000066400000000000000000000044771214471147700215160ustar00rootroot00000000000000/* * Copyright (c) 1998-1999 Vectaport Inc. * Copyright (c) 1997 Vectaport Inc., R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef leak_checker_h #define leak_checker_h //#define LEAKCHECK #ifdef LEAKCHECK #include using std::cerr; //: utility for counting undestroyed instances of a class. // To use create a static instance initialized with the class name, i.e. // 'static LeakChecker checker("OverlayRaster")', then add a 'checker.create()' // call to each constructor and a 'checker.destroy()' call to each // destructor. When the program is terminated the static instance of the // leak checker will be destructed, and a count of un-destructed (alive) // instances will be printed to stderr. class LeakChecker { public: void create() { _alive++; } // increment count of instances, to be called from constructors. void destroy() { _alive--; } // decrement count of instances, to be called from destructors. LeakChecker(const char* c) : _alive(0), _class(c) {} ~LeakChecker(); int alive() {return _alive;} private: int _alive; const char* _class; }; inline LeakChecker::~LeakChecker() { cerr << "LEAKCHECKER: " << _class << ", " << _alive << "\n"; } #endif #endif ivtools-1.2.11a1/src/include/ivstd/malloc.h000066400000000000000000000000241214471147700205040ustar00rootroot00000000000000#include ivtools-1.2.11a1/src/include/ivstd/math.h000066400000000000000000000004441214471147700201740ustar00rootroot00000000000000#ifndef ivtools_math_h #define ivtools_math_h #if defined(__cplusplus) #include_next #else #if defined(__APPLE__) #define __DARWIN_UNIX03 1 #endif #include #endif #if defined(sun) && defined(__svr4__) #include #define isinf(n) IsINF(n) #endif #endif ivtools-1.2.11a1/src/include/ivstd/nan.h000066400000000000000000000013261214471147700200170ustar00rootroot00000000000000#ifndef ivtools_nan_h #define ivtools_nan_h #if defined(__GLIBC__) && (__GLIBC__==2 && __GLIBC_MINOR__>0 || __GLIBC__>2) #include #elif !defined(__CYGWIN__) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__APPLE__) #include_next #else #include #endif #if defined(__sun__) && defined(__svr4__) #include #endif #if defined(__sun__) && defined(__svr4__) || defined(__CYGWIN__) || defined(__linux__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__) #define isnanorinf(dval) (!finite(dval)) #elif defined(__alpha) #define isnanorinf(dval) (IsNANorINF(dval)) #else #define isnanorinf(dval) (!finite(dval)) /* (dval==NAN || dval==INF ) */ #endif #endif ivtools-1.2.11a1/src/include/ivstd/osfcn.h000066400000000000000000000004271214471147700203540ustar00rootroot00000000000000 #ifndef OSFCN_H #define OSFCN_H 1 #include #include #include #include #include #if _G_HAVE_SYS_SOCKET #include #endif #if _G_HAVE_SYS_RESOURCE #include #include #endif #endif ivtools-1.2.11a1/src/include/ivstd/signal.h000066400000000000000000000003741214471147700205220ustar00rootroot00000000000000#ifndef ivtools_signal_h #define ivtools_signal_h #if defined(__cplusplus) #if __linux #undef __need_sig_atomic_t #undef __need_sigset_t #endif #include_next #undef NULL #define NULL 0 #else #include #endif #endif ivtools-1.2.11a1/src/include/ivstd/stdio.h000066400000000000000000000005421214471147700203640ustar00rootroot00000000000000#ifndef ivtools_stdio_h #define ivtools_stdio_h #include /* to work-around RedHat 7.* problem */ #if defined(__cplusplus) #include_next #else #include #endif #if defined(__cplusplus) #if defined(sun) && !defined(solaris) extern "C" { int pclose(FILE*); } #endif #endif #else #include_next #endif ivtools-1.2.11a1/src/include/ivstd/stdlib.h000066400000000000000000000003151214471147700205210ustar00rootroot00000000000000#ifndef _ivstd_stdlib #define _ivstd_stdlib #if defined(__cplusplus) #include_next #else #include #endif #if defined(__APPLE__) && 0 typedef int socklen_t; #endif #endif ivtools-1.2.11a1/src/include/ivstd/stream.h000066400000000000000000000000271214471147700205330ustar00rootroot00000000000000#include ivtools-1.2.11a1/src/include/ivstd/string.h000066400000000000000000000011001214471147700205370ustar00rootroot00000000000000#ifndef ivtools_string_h #define ivtools_string_h #if defined(__cplusplus) #if defined(sun) && !defined(__svr4__) extern "C" { int strcasecmp(const char*, const char*); int strncasecmp(const char*, const char*,int); #undef size_t #define size_t long unsigned int } #endif #include inline char* strlower(char* str) { char* s = str; while (*s) { *s = tolower(*s); ++s; } return str; } #endif #if defined(__cplusplus) #include_next #undef NULL #define NULL 0 #else #include #endif #include #endif ivtools-1.2.11a1/src/include/ivstd/version.h000066400000000000000000000001441214471147700207250ustar00rootroot00000000000000#define IvtoolsVersion 1.2.11 #define VersionString "1.2.11" #define ReleaseString "ivtools-1.2.11" ivtools-1.2.11a1/src/iueserv_/000077500000000000000000000000001214471147700161355ustar00rootroot00000000000000ivtools-1.2.11a1/src/iueserv_/README000066400000000000000000000024331214471147700170170ustar00rootroot00000000000000NAME iueserv - experimental server for the IUE SYNOPSIS iueserv [portnum] DESCRIPTION iueserv is an experimental server built on top of the Image Understanding Environment (IUE) class libraries. The command syntax is a semi-colon separated list of commands with arbitrary number of parameters enclosed in parenthesis, with support for optional parameters and keyword arguments, i.e: command1(arg1 arg2 arg3 :key1 val1 :key2 val2); command2(arg1 arg2 arg3 :key1 val1 :key2 val2) The literals and operators of C are all supported except for the syntax of the conditional operator "?:". See the comterp documentation for more details. IMAGE HANDLING COMMANDS img=image(path|img :mem) -- load or convert image val=getpix(img x,y) -- get image pixel value of arbitrary type val=ncols(img) -- get number of columns in image val=nrows(img) -- get number of rows in image str=pixtype(img) -- get type of image pixels export(iueobj) -- export IUE object to host/port IMAGE FILTERING COMMANDS gaussian(img [sigma=3.0]) -- gaussian image filter threshold(img tval1[,tval2,...tvaln]) -- limit pixels at or above a threshold to that value OTHER COMMANDS iueserv inherits the entire command language of comterp. SEE ALSO comterp WEB PAGES http://www.ivtools.org/ivtools/iueserv.html ivtools-1.2.11a1/src/iueserv_/main.cc000066400000000000000000000061431214471147700173740ustar00rootroot00000000000000/* * Copyright (c) 1998 Vectaport, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representation about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #ifdef HAVE_ACE #include #include static u_short SERVER_PORT = 30001; static const char *const SERVER_HOST = "localhost"; #endif #include #include #include #include int main(int argc, char *argv[]) { #ifdef HAVE_ACE Component::use_unidraw(false); IueAcceptor* peer_acceptor = new IueAcceptor(); int portnum = argc > 1 ? atoi(argv[1]) : SERVER_PORT; if (peer_acceptor->open (ACE_INET_Addr (portnum)) == -1) cerr << "iueserv: unable to open port " << portnum << " with ACE\n"; else if (ComterpHandler::reactor_singleton()->register_handler (peer_acceptor, ACE_Event_Handler::READ_MASK) == -1) cerr << "iueserv: error registering acceptor with ACE reactor\n"; else cerr << "accepting iueserv port (" << portnum << ") connections\n"; // Register COMTERP_QUIT_HANDLER to receive SIGINT commands. When received, // COMTERP_QUIT_HANDLER becomes "set" and thus, the event loop below will // exit. if (ComterpHandler::reactor_singleton()->register_handler (SIGINT, COMTERP_QUIT_HANDLER::instance ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); // Start up one on stdin IueHandler* stdin_handler = new IueHandler(); #if 0 if (ACE::register_stdin_handler(stdin_handler, ComterpHandler::reactor_singleton(), nil) == -1) #else if (ComterpHandler::reactor_singleton()->register_handler(0, stdin_handler, ACE_Event_Handler::READ_MASK)==-1) #endif cerr << "iueserv: unable to open stdin with ACE\n"; // Perform logging service until COMTERP_QUIT_HANDLER receives SIGINT. while (COMTERP_QUIT_HANDLER::instance ()->is_set () == 0) ComterpHandler::reactor_singleton()->handle_events (); return 0; #endif } ivtools-1.2.11a1/src/ivtext/000077500000000000000000000000001214471147700156375ustar00rootroot00000000000000ivtools-1.2.11a1/src/ivtext/README000066400000000000000000000032161214471147700165210ustar00rootroot00000000000000 Simple InterViews Text Editor ----------------------------- This is my first version of an InterViews 3.1 texteditor class. I have tried to implement a simple text editor that can be used in IV 3.1 applications. The goal was _not_ to implement a full-featured editor (we have emacs, don't we (-; ). It uses the 2.6 TextEditor/TextBuffer classes and was inspired by some code posted by Frank Zenner (zenner@dfki.uni-sb.de) a few month ago. Even if I have not used any of his code directly it was very useful as an introduction of how 2.6 classes can be used. Some features are: - loads/saves buffer from/to files - dynamically allocates memory when buffer expands - supports selectons (both primary and clipboard) from the editor - have emacs-style (and Sun keyboard) key mappings - popup-menu to load/save files - Somewhat similar to Sun's Text Editor (left mouse button selects, middle mouse button expand selection, right mouse button gives a popup-menu) - double-click selects word, tripple-click selects line I do not consider my work as completed, but I believe the editor is usable. I have never used 2.6 classes before and I'm sure it could have been structured in a better way. Comments are welcome! Things plan to do (if I could find the time): - add text search popup - add at least one level of undo - enable definition of menus and key mappings from resources - add popup to enable specification of find patterns - I bet there are bugs, but not currently known by me... - add many more edit functions to the EivTextEditor class (the list could be much longer, but this is what I plan to implement) Have Fun! /Janne (janne@torpa.se) ivtools-1.2.11a1/src/ivtext/main.cc000066400000000000000000000037261214471147700171020ustar00rootroot00000000000000// // Simple Text Editor Buffer Implementation // // Copyright (C) 1993 Ellemtel Telecommunication Systems Labratories // // Permission is granted to any individual or institution to use, copy, // modify, and distribute this software, provided that this complete // copyright and permission notice is maintained, intact, in all copies // and supporting documentation. // // Ellemtel Telecommunication Systems Labratories make no representation // of the suitability of this software for any purpose. It is provided // "as is" without any expressed or implied warranty. // // Jan Andersson, Torpa Konsult AB // janne@torpa.se - 1993-08-29 #include #include #include #include #include #include #include class App { public: App(int, char**); int run(); private: Session* session_; EivTextEditor* text_edit_; TextEditAppWindow* base_; }; static PropertyData props[] = { { "TextEdit*iconName", "Text Editor" }, { "TextEdit*title", "InterViews Text Editor" }, { "TextEdit*TextEditor*rows", "30" }, { "TextEdit*TextEditor*columns", "80" }, // { "TextEdit*TextEditor*textFont", "lucidasanstypewriter-14" }, { "TextEdit*TextEditor*FileChooser*rows", "10" }, { nil } }; static OptionDesc options[] = { { "-rows", "TextEdit*TextEditor*rows", OptionValueNext }, { nil } }; int main(int argc, char** argv) { App* a = new App(argc, argv); return a->run(); } App::App(int argc, char** argv) { session_ = new Session("TextEdit", argc, argv, options, props); Display* display = session_->default_display(); WidgetKit& kit = *WidgetKit::instance(); const LayoutKit& layout = *LayoutKit::instance(); text_edit_ = new EivTextEditor(kit.style()); if (argc > 1) text_edit_->load(argv[argc-1]); base_ = new TextEditAppWindow(text_edit_); } int App::run() { return session_->run_window(base_); } ivtools-1.2.11a1/src/ivxt/000077500000000000000000000000001214471147700153065ustar00rootroot00000000000000ivtools-1.2.11a1/src/ivxt/Xd.h000066400000000000000000000024421214471147700160340ustar00rootroot00000000000000/* * Copyright (c) 1998 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #undef String // #undef Region #define String XString // #define Region XRegion ivtools-1.2.11a1/src/ivxt/Xud.h000066400000000000000000000024221214471147700162170ustar00rootroot00000000000000/* * Copyright (c) 1998 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include // #undef Region #undef String #define String _lib_os(String) ivtools-1.2.11a1/src/ivxt/glyphwidget.h000066400000000000000000000101231214471147700200030ustar00rootroot00000000000000/* * Copyright (c) 1998 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Copyright (c) 1993 2001 S.A. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the name of * 2001 S.A. may not be used in any advertising or publicity relating to the * software without the specific, prior written permission of 2001 S.A. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL 2001 S.A. BE LIABLE FOR ANY SPECIAL, INCIDENTAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef glyph_widget_h #define glyph_widget_h /*********************************************************************** * * Widget for InterViews Glyphs (including Interactors) * ***********************************************************************/ #include "Xd.h" #include #include "Xud.h" /* Parameters: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel white backingStore BackingStore BackingStore default border BorderColor Pixel Black borderWidth BorderWidth Dimension 1 destroyCallback Callback Pointer NULL font Font XFontStruct* fixed foreground Foreground Pixel black height Height Dimension 164 mappedWhenManaged MappedWhenManaged Boolean True width Width Dimension 164 x Position Position 0 y Position Position 0 fresco Fresco Fresco NULL glyph Glyph Glyph NULL viewer Viewer Viewer NULL */ /* #define XtNfresco "fresco" #define XtCFresco "Fresco" #define XtRFresco "Fresco" */ #define XtNglyph "glyph" #define XtCGlyph "Glyph" #define XtRGlyph "Glyph" /* #define XtNviewer "viewer" #define XtCViewer "Viewer" #define XtRViewer "Viewer" */ #define XtNfrescoWindow "frescoWindow" #define XtCFrescoWindow "FrescoWindow" #define XtRFrescoWindow "FrescoWindow" struct Glyph; typedef struct _GlyphWidgetRec* GlyphWidget; typedef struct _GlyphWidgetClassRec* GlyphWidgetClass; extern WidgetClass GlyphWidgetWidgetClass; /* * Creation entry points: */ #ifdef _NO_PROTO extern Widget XtCreateGlyphWidget(); #else /* _NO_PROTO */ #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif extern Widget XtCreateGlyphWidget( Widget p, ArgList args, Cardinal n ); #endif /* _NO_PROTO */ #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif ivtools-1.2.11a1/src/ivxt/glyphwidgetP.h000066400000000000000000000055471214471147700201410ustar00rootroot00000000000000/* * Copyright (c) 1998 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Copyright (c) 1993 2001 S.A. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the name of * 2001 S.A. may not be used in any advertising or publicity relating to the * software without the specific, prior written permission of 2001 S.A. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL 2001 S.A. BE LIABLE FOR ANY SPECIAL, INCIDENTAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef glyph_widget_p_h #define glyph_widget_p_h #include "glyphwidget.h" typedef struct { int dummy; } GlyphWidgetClassPart; /* Full class record declaration. */ typedef struct _GlyphWidgetClassRec { CoreClassPart core_class; GlyphWidgetClassPart GlyphWidget_class; } GlyphWidgetClassRec; extern GlyphWidgetClassRec GlyphwidgetClassRec; struct Glyph; struct WidgetWindow; typedef struct _GlyphWidgetPart { // struct Fresco* fresco; struct Glyph* glyph; struct WidgetWindow* window; } GlyphWidgetPart; typedef struct _GlyphWidgetRec { CorePart core; GlyphWidgetPart iv; } GlyphWidgetRec; #endif ivtools-1.2.11a1/src/ivxt/main.cc000066400000000000000000000164561214471147700165550ustar00rootroot00000000000000/* * Copyright 1990, 1991, 1992 O'Reilly and Associates, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * online documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice * appear in supporting documentation, and that the name of O'Reilly * and Associates, Inc. not be used in advertising or publicity * pertaining to distribution of the software without specific, * written prior permission. O'Reilly and Associates, Inc. makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * O'REILLY AND ASSOCIATES, INC. DISCLAIMS ALL WARRANTIES WITH REGARD * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL O'REILLY AND ASSOCIATES, INC. * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Adrian Nye of O'Reilly and Associates, Inc. */ #include // ** #include "Xd.h" // ** #include #include #include #include #include #include #include #include // ** #include "Xud.h" // ** // ** #include #include "xtudsession.h" // ** // -------------------------------------------------------------------------- // ** static PropertyData properties[] = { { "*IdrawEditor*name", "InterViews drawing editor" }, { "*IdrawEditor*iconName", "Idraw" }, { "*domain", "drawing" }, { "*initialbrush", "2" }, { "*initialfgcolor","1" }, { "*initialbgcolor","10" }, { "*initialfont", "4" }, { "*initialpattern","1" }, { "*initialarrow", "none" }, { "*pagewidth", "8.5" }, { "*pageheight", "11" }, { "*gridxincr", "8" }, { "*gridyincr", "8" }, { "*font1", "-*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8" }, { "*font2", "-*-courier-medium-r-normal-*-10-*-*-*-*-*-*-* Courier 10" }, { "*font3", "-*-courier-bold-r-normal-*-12-*-*-*-*-*-*-* Courier-Bold 12" }, { "*font4", "-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-* Helvetica 12" }, { "*font5", "-*-helvetica-medium-r-normal-*-14-*-*-*-*-*-*-* Helvetica 14" }, { "*font6", "-*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-* Helvetica-Bold 14" }, { "*font7", "-*-helvetica-medium-o-normal-*-14-*-*-*-*-*-*-* Helvetica-Oblique 14" }, { "*font8", "-*-times-medium-r-normal-*-12-*-*-*-*-*-*-* Times-Roman 12" }, { "*font9", "-*-times-medium-r-normal-*-14-*-*-*-*-*-*-* Times-Roman 14" } , { "*font10", "-*-times-bold-r-normal-*-14-*-*-*-*-*-*-* Times-Bold 14" }, { "*font11", "-*-times-medium-i-normal-*-14-*-*-*-*-*-*-* Times-Italic 14" }, { "*brush1", "none" }, { "*brush2", "ffff 0" }, { "*brush3", "ffff 1" }, { "*brush4", "ffff 2" }, { "*brush5", "ffff 3" }, { "*brush6", "fff0 0" }, { "*brush7", "fff0 1" }, { "*brush8", "fff0 2" }, { "*brush9", "fff0 3" }, { "*pattern1", "none" }, { "*pattern2", "0.0" }, { "*pattern3", "1.0" }, { "*pattern4", "0.75" }, { "*pattern5", "0.5" }, { "*pattern6", "0.25" }, { "*pattern7", "1248" }, { "*pattern8", "8421" }, { "*pattern9", "f000" }, { "*pattern10", "8888" }, { "*pattern11", "f888" }, { "*pattern12", "8525" }, { "*pattern13", "cc33" }, { "*pattern14", "7bed" }, { "*fgcolor1", "Black" }, { "*fgcolor2", "Brown 42240 10752 10752" }, { "*fgcolor3", "Red" }, { "*fgcolor4", "Orange" }, { "*fgcolor5", "Yellow" }, { "*fgcolor6", "Green" }, { "*fgcolor7", "Blue" }, { "*fgcolor8", "Indigo 48896 0 65280" }, { "*fgcolor9", "Violet 20224 12032 20224" }, { "*fgcolor10", "White" }, { "*fgcolor11", "LtGray 50000 50000 50000" }, { "*fgcolor12", "DkGray 33000 33000 33000" }, { "*bgcolor1", "Black" }, { "*bgcolor2", "Brown 42240 10752 10752" }, { "*bgcolor3", "Red" }, { "*bgcolor4", "Orange" }, { "*bgcolor5", "Yellow" }, { "*bgcolor6", "Green" }, { "*bgcolor7", "Blue" }, { "*bgcolor8", "Indigo 48896 0 65280" }, { "*bgcolor9", "Violet 20224 12032 20224" }, { "*bgcolor10", "White" }, { "*bgcolor11", "LtGray 50000 50000 50000" }, { "*bgcolor12", "DkGray 33000 33000 33000" }, { "*history", "20" }, { nil } }; static OptionDesc options[] = { { nil } }; // ** // -------------------------------------------------------------------------- void pressMe( Widget w, XtPointer client_data, XtPointer call_data ) { cerr << "Thankyou!\n"; } void quitProg( Widget w, XtPointer client_data, XtPointer call_data ) { cerr << "Bye!\n"; exit(0); } main(int argc, char** argv) { XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL); XtAppContext app_context; Widget topLevel = XtVaAppInitialize( &app_context, /* Application context */ "hey", /* Application class */ NULL, 0, /* command line option list */ &argc, argv, /* command line args */ NULL, /* for missing app-defaults file */ NULL); /* terminate varargs list */ Widget rowColumn = XtVaCreateManagedWidget( "rowColumn", /* widget name */ xmRowColumnWidgetClass, /* widget class */ topLevel, /* parent widget*/ NULL); /* terminate varargs list */ Widget quit = XtVaCreateManagedWidget( "quit", /* widget name */ xmPushButtonWidgetClass, /* widget class */ rowColumn, /* parent widget*/ NULL); /* terminate varargs list */ Widget pressme = XtVaCreateManagedWidget( "pressme", /* widget name */ xmPushButtonWidgetClass, /* widget class */ rowColumn, /* parent widget*/ NULL); /* terminate varargs list */ XtAddCallback(quit, XmNactivateCallback, quitProg, 0); XtAddCallback(pressme, XmNactivateCallback, pressMe, 0); Widget frame = XtVaCreateManagedWidget( "frame", /* widget name */ xmFrameWidgetClass, /* widget class */ rowColumn, /* parent widget*/ NULL); /* terminate varargs list */ // ** XtUdSession::initialize( "testing", argc, argv, XtDisplay(topLevel), options, properties ); IdrawEditor* ed = new OverlayEditor((const char*)nil); XtUnidraw::instance().Open(ed, frame); // ** XtRealizeWidget(topLevel); XtAppMainLoop(app_context); } ivtools-1.2.11a1/src/ivxt/widgetwindow.cc000066400000000000000000000277621214471147700203460ustar00rootroot00000000000000/* * Copyright (c) 1998 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Copyright (c) 1993 2001 S.A. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the name of * 2001 S.A. may not be used in any advertising or publicity relating to the * software without the specific, prior written permission of 2001 S.A. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL 2001 S.A. BE LIABLE FOR ANY SPECIAL, INCIDENTAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ // find out what we really need #include #include #include #include #include #include #include #include #include #include #include #include #include #include "widgetwindow.h" #include "glyphwidgetP.h" #include "xtintrinsic.h" #include #include #include #include // ### this is gross, but we can't access the header declareTable(WindowTable,XWindow,Window*) WidgetWindow::WidgetWindow( _GlyphWidgetRec* w, Glyph* g ) : ManagedWindow(g) { widget_ = w; } WidgetWindow::~WidgetWindow() { // Multiple destroys don't hurt under Xt since they are deferred if (widget_ != nil) { XtDestroyWidget((Widget)widget_); } widget_ = nil; } void WidgetWindow::map() { if (!is_mapped()) { XtRealizeWidget((Widget)widget_); XtMapWidget((Widget)widget_); } } void WidgetWindow::compute_geometry() { GlyphWidgetRec& w = *widget_; WindowRep& wr = *((Window*)this)->rep(); CanvasRep& c = *wr.canvas_->rep(); Display& d = *wr.display_; // ### what does the Placement corres to in IV 3.1 ? // wr.placed_ = true; if (w.core.width == 0) { w.core.width = XCoord(c.pwidth_); } else { c.pwidth_ = w.core.width; c.width_ = d.to_coord(c.pwidth_); // placement_.width = screen_->to_coord(pwidth_); } if (w.core.height == 0) { w.core.height = XCoord(c.pheight_); } else { c.pheight_ = w.core.height; c.height_ = d.to_coord(c.pheight_); // placement_.height = screen_->to_coord(pheight_); } } void WidgetWindow::bind() { /* WindowRep& wr = *rep(); Display& d = *wr.display_; if (xbound(xwindow_)) { display_->unbind(xwindow_); } set_attributes(); (*GlyphwidgetClassRec.core_class.superclass->core_class.realize)( (Widget)widget_, &xattrmask_, &xattrs_ ); xwindow_ = widget_->core.window; display_->bind(xwindow_, this); */ WindowRep& wr = *((Window*)this)->rep(); CanvasRep& c = *wr.canvas_->rep(); Display& d = *wr.display_; WindowTable& t = *d.rep()->wtable_; if (wr.xwindow_ != WindowRep::unbound) { t.remove(wr.xwindow_); } set_attributes(); (*GlyphwidgetClassRec.core_class.superclass->core_class.realize)( (Widget)widget_, &wr.xattrmask_, &wr.xattrs_ ); wr.xwindow_ = widget_->core.window; c.xdrawable_ = wr.xwindow_; t.insert(wr.xwindow_, this); wr.xtoplevel_ = wr.toplevel_->rep()->xwindow_; } void WidgetWindow::do_map() { WindowRep& wr = *((Window*)this)->rep(); wr.map_pending_ = true; } void WidgetWindow::xt_initialize(Widget, ArgList, Cardinal*) { default_geometry(); compute_geometry(); } void WidgetWindow::xt_realize(XtValueMask* mask, XSetWindowAttributes* attr) { WindowRep& wr = *((Window*)this)->rep(); wr.xattrs_ = *attr; wr.xattrmask_ = *mask; bind(); set_props(); do_map(); // ### why keep this? XtAddEventHandler( (Widget)widget_, StructureNotifyMask, FALSE, &WidgetWindow::xt_structure_event, this ); } void WidgetWindow::xt_destroy() { } XtGeometryResult WidgetWindow::xt_query_geometry( XtWidgetGeometry* intended, XtWidgetGeometry* preferred ) { WindowRep& wr = *((Window*)this)->rep(); Display& d = *wr.display_; Glyph* g = glyph(); if (!g) { *preferred = *intended; return XtGeometryYes; } Requisition req; // GlyphImpl::default_requisition(req); g->request(req); Coord w = req.requirement(Dimension_X).natural(); Coord h = req.requirement(Dimension_Y).natural(); // ### look into how the following works XtGeometryMask mode = CWWidth | CWHeight; preferred->request_mode = mode; preferred->width = XCoord(d.to_pixels(w)); preferred->height = XCoord(d.to_pixels(h)); if ((intended->request_mode & mode) == mode && intended->width == preferred->width && intended->height == preferred->height ) { return XtGeometryYes; } else if (preferred->width == widget_->core.width && preferred->height == widget_->core.height ) { return XtGeometryNo; } return XtGeometryAlmost; } XtfBoolean WidgetWindow::xt_set_values( Widget /* req */, Widget /* new_w */, ArgList, Cardinal* /* num_args */ ) { return False; } void WidgetWindow::xt_expose(XEvent* event, Region) { /* XExposeEvent& xe = event->xexpose; ScreenRef s = screen_; Coord left = s->to_coord(xe.x); Coord top = s->to_coord(pheight_ - xe.y); Coord h = s->to_coord(xe.height); redraw(left, top - h, s->to_coord(xe.width), h); */ WindowRep& wr = *((Window*)this)->rep(); wr.expose(this, event->xexpose); } void WidgetWindow::set_attributes() { /* if (visual_ == nil) { // This is wrong. We should use the visual contained in the widget. // For now, assume we don't mess with visuals. visual_ = screen_->find_visual((StyleImpl*)style_); } */ WindowRep& wr = *((Window*)this)->rep(); if (wr.visual_ == nil) { wr.visual_ = WindowVisual::find_visual(wr.display_, wr.style_); } wr.xattrmask_ |= CWEventMask; long events = ( KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask | OwnerGrabButtonMask ); wr.xattrs_.event_mask = events | ExposureMask | StructureNotifyMask; // ### move this XtAddEventHandler( (Widget)widget_, events, FALSE, &WidgetWindow::xt_events, this ); } void WidgetWindow::xt_events( Widget, XtPointer p, XEvent* xe, XtfBoolean* ) { WidgetWindow* w = (WidgetWindow*)p; WindowRep& wr = *((Window*)w)->rep(); Event event; EventRep& e = *(event.rep()); e.display_ = wr.display_; e.window_ = w; event.handle(); } void WidgetWindow::xt_structure_event( Widget, XtPointer p, XEvent* xe, XtfBoolean* ) { WidgetWindow* w = (WidgetWindow*)p; GlyphWidgetRec* ww = w->widget_; WindowRep& wr = *((Window*)w)->rep(); switch (xe->type) { case MapNotify: wr.map_notify(w, xe->xmap); break; case UnmapNotify: wr.unmap_notify(w, xe->xunmap); break; case ConfigureNotify: wr.configure_notify(w, xe->xconfigure); break; } } // -------------------------------------------------------------------------- void initWidget(Widget widget, Glyph* g) { _GlyphWidgetRec* w = (_GlyphWidgetRec*)widget; // init_window code WidgetWindow* xtw = new WidgetWindow(w, g); // ### should these next 2 lines be here? xtw->display(Session::instance()->default_display()); xtw->style(new Style(xtw->display()->style())); xtw->xt_initialize(widget, nil, nil); w->iv.window = xtw; } // -------------------------------------------------------------------------- /* Initialization of defaults */ /* Private Data */ #define offset(field) XtOffsetOf(GlyphWidgetRec, field) static XtResource resources[] = { /* {XtNfresco, XtCFresco, XtRFresco, sizeof(Fresco*), offset(iv.fresco), XtRImmediate, NULL}, */ {XtNglyph, XtCGlyph, XtRGlyph, sizeof(Glyph*), offset(iv.glyph), XtRImmediate, NULL}, {XtNfrescoWindow, XtCFrescoWindow, XtRFrescoWindow, sizeof(WidgetWindow*), offset(iv.window), XtRImmediate, NULL}, }; static void Realize(Widget, XtValueMask*, XSetWindowAttributes*); static void Resize(Widget); static void Destroy(Widget); static XtGeometryResult QueryGeometry( Widget,XtWidgetGeometry*,XtWidgetGeometry* ); static void ExposeProc(Widget, XEvent*, Region); static XtfBoolean SetValues(Widget, Widget, Widget, ArgList, Cardinal*); GlyphWidgetClassRec GlyphwidgetClassRec = { { /* core_class fields */ #ifndef SVR3SHLIB #define superclass (&widgetClassRec) #else #define superclass NULL #endif /* superclass */ (WidgetClass) superclass, /* class_name */ "Label", /* widget_size */ sizeof(GlyphWidgetRec), /* class_initialize */ NULL, /* class_part_initialize */ NULL, /* class_inited */ FALSE, /* initialize */ NULL, /* initialize_hook */ NULL, /* realize */ Realize, /* actions */ NULL, /* num_actions */ 0, /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave */ TRUE, /* visible_interest */ FALSE, /* destroy */ Destroy, /* resize */ NULL, /* expose */ ExposeProc, /* set_values */ SetValues, /* set_values_hook */ NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ NULL, /* query_geometry */ QueryGeometry, /* display_accelerator */ XtInheritDisplayAccelerator, /* extension */ NULL }, { /* window */ 0 } }; WidgetClass GlyphWidgetWidgetClass = (WidgetClass)&GlyphwidgetClassRec; static void Realize(Widget w, XtValueMask* mask, XSetWindowAttributes* attr) { ((GlyphWidgetRec*)w)->iv.window->xt_realize(mask, attr); } static void Destroy(Widget w) { ((GlyphWidgetRec*)w)->iv.window->xt_destroy(); } static XtGeometryResult QueryGeometry( Widget w, XtWidgetGeometry* req,XtWidgetGeometry* rep ) { return ((GlyphWidgetRec*)w)->iv.window->xt_query_geometry(req, rep); } static void ExposeProc(Widget w, XEvent* ev, Region reg) { ((GlyphWidgetRec*)w)->iv.window->xt_expose(ev, reg); } static XtfBoolean SetValues( Widget w, Widget req, Widget new_w, ArgList args, Cardinal* num_args ) { return ((GlyphWidgetRec*)w)->iv.window->xt_set_values( req, new_w, args, num_args ); } ivtools-1.2.11a1/src/ivxt/widgetwindow.h000066400000000000000000000064401214471147700201760ustar00rootroot00000000000000/* * Copyright (c) 1998 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Copyright (c) 1993 2001 S.A. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the name of * 2001 S.A. may not be used in any advertising or publicity relating to the * software without the specific, prior written permission of 2001 S.A. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL 2001 S.A. BE LIABLE FOR ANY SPECIAL, INCIDENTAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef xt_window_h #define xt_window_h #include "xtintrinsic.h" #include // ### good place? typedef int XCoord; struct _GlyphWidgetRec; class WidgetWindow : public ManagedWindow { public: WidgetWindow(_GlyphWidgetRec* w, Glyph* g); virtual ~WidgetWindow(); virtual void map(); virtual void set_attributes(); virtual void compute_geometry(); virtual void bind(); virtual void do_map(); virtual void xt_initialize(Widget req, ArgList, Cardinal*); virtual void xt_realize(XtValueMask* mask, XSetWindowAttributes* attr); virtual void xt_expose(XEvent*, Region); virtual XtGeometryResult xt_query_geometry( XtWidgetGeometry*, XtWidgetGeometry* ); virtual XtfBoolean xt_set_values(Widget, Widget, ArgList, Cardinal*); virtual void xt_destroy(); protected: struct _GlyphWidgetRec* widget_; static void xt_structure_event(Widget, XtPointer, XEvent*, XtfBoolean*); static void xt_events(Widget, XtPointer, XEvent*, XtfBoolean*); }; void initWidget(Widget, Glyph*); #endif ivtools-1.2.11a1/src/ivxt/xtintrinsic.h000066400000000000000000000046341214471147700200440ustar00rootroot00000000000000/* * Copyright (c) 1998 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * Copyright (c) 1993 2001 S.A. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the name of * 2001 S.A. may not be used in any advertising or publicity relating to the * software without the specific, prior written permission of 2001 S.A. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL 2001 S.A. BE LIABLE FOR ANY SPECIAL, INCIDENTAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef xt_intrinsic_h #define xt_intrinsic_h #include "Xd.h" #include #include typedef Boolean XtfBoolean; #include "Xud.h" #endif ivtools-1.2.11a1/src/ivxt/xtsession.cc000066400000000000000000000107351214471147700176620ustar00rootroot00000000000000/* * Copyright (c) 1998 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #include #include #include "Xd.h" #include #include #include #include "Xud.h" #include #include #include #include #include #include #include #include #include #include #include "xtsession.h" XtSession::XtSession( const char* name, int& argc, char** argv, const OptionDesc* options, const PropertyData* prop, XtAppContext app, Display* display ): Session(name, argc, argv, options, prop, display), _app_context(app) { #if 1 // this is a bit of a hack here // we don't want IV to get called back for the X connection events // let Xt handle this Dispatcher::instance().unlink( ConnectionNumber(default_display()->rep()->display_) ); #endif xt_init(); XtAppAddWorkProc(_app_context, &XtSession::doWorkProc, this); } XtfBoolean XtSession::doWorkProc(XtPointer p) { XtSession* s = (XtSession*)p; s->workProc(); return FALSE; } void XtSession::workProc() { default_display()->repair(); } XtAppContext XtSession::get() const { return _app_context; } void XtSession::set( XtAppContext app ) { _app_context = app; } void XtSession::loopHook() { } int XtSession::run() { Event e; do { read(e); e.handle(); loopHook(); } while (!done()); return 0; } static XtEventDispatchProc orig_procs[LASTEvent]; Boolean XtDispatchProc( XEvent* xe ) { // if the event is an IV event then process else let Xt process Session& session = *Session::instance(); Display* dpy = session.default_display(); DisplayRep* dpy_rep = dpy->rep(); XDisplay* xdpy = dpy_rep->display_; if (WindowRep::find(xe->xany.window, dpy_rep->wtable_)) { XPutBackEvent(xdpy, xe); // should always succeed, since there is an event pending Event e; if (dpy->get(e)) { e.handle(); } } else { // let the orig Xt routine handle it assert( (xe->type > 0) && (xe->type < LASTEvent) ); (*orig_procs[xe->type])(xe); } } void XtSession::xt_init() { Display* dpy = default_display(); DisplayRep* dpy_rep = dpy->rep(); XDisplay* xdpy = dpy_rep->display_; int i; for( i = 0; i < LASTEvent; i++ ) { orig_procs[i] = XtSetEventDispatcher(xdpy, i, XtDispatchProc); } } // ### too bad about this declarePtrList(DamageList,Window) void XtSession::read( Event& e, boolean (*test)() ) { // #### ignoring test XEvent xe; Display* dpy = default_display(); DisplayRep* dpy_rep = dpy->rep(); XDisplay* xdpy = dpy_rep->display_; boolean found = false; // note that we don't set rep_->readinput_ to false here because we are // assuming that the dispatcher only does timers and not input ready on a fd while (!done() && !found) { // check this to see if it really needs to be here if (dpy_rep->damaged_->count() != 0 && QLength(xdpy) == 0) { dpy->repair(); } XtAppNextEvent(_app_context, &xe); if (WindowRep::find(xe.xany.window, dpy_rep->wtable_)) { XPutBackEvent(xdpy, &xe); if (dpy->get(e)) { found = true; } } else { XtDispatchEvent(&xe); } } } ivtools-1.2.11a1/src/ivxt/xtsession.h000066400000000000000000000036151214471147700175230ustar00rootroot00000000000000/* * Copyright (c) 1998 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef xt_session_h #define xt_session_h #include // is there any other way to tell it what an AppContext is? #include "Xd.h" #include #include "Xud.h" // ### ugly #include "xtintrinsic.h" class XtSession : public Session { public: XtSession( const char*, int& argc, char** argv, const OptionDesc* = nil, const PropertyData* = nil, XtAppContext = nil, Display* = nil ); XtAppContext get() const; void set(XtAppContext); virtual void loopHook(); virtual int run(); virtual void read(Event&, boolean (*test)() = nil); void xt_init(); virtual void workProc(); static XtfBoolean doWorkProc(XtPointer); protected: XtAppContext _app_context; }; #endif ivtools-1.2.11a1/src/ivxt/xtudsession.cc000066400000000000000000000122231214471147700202050ustar00rootroot00000000000000/* * Copyright (c) 1998 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ // ### needed for Display constructor, we need to derive a subclass #define protected public #include "Xd.h" #include #include "Xud.h" #include #include #include "widgetwindow.h" #include "glyphwidgetP.h" #include "xtudsession.h" #include #include #include #include #include #include #include #include #include #include #include // ### // the way the World class was designed it makes no sense that _session and // _display are private :-( #define private public #include class XtWorld : public World { public: XtWorld(Session*, Display*); virtual ~XtWorld(); }; XtWorld::XtWorld( Session* s, Display* d ) : World() { session_ = s; display_ = d; make_current(); Sensor::init(); } XtWorld::~XtWorld() { session_ = nil; display_ = nil; } // -------------------------------------------------------------------------- XtUnidraw::XtUnidraw( Catalog* c, World* w ) : OverlayUnidraw(c, w) { } XtUnidraw& XtUnidraw::instance() { return *((XtUnidraw*)unidraw); } void XtUnidraw::Open(Editor* ed) { // we need a parent widget? // we should create a simple top level widget and use that } void XtUnidraw::Open(Editor* ed, Widget parent) { Widget widget = XtVaCreateManagedWidget( "default_name", /* widget name */ GlyphWidgetWidgetClass, /* widget class */ parent, /* parent widget*/ NULL); /* terminate varargs list */ initWidget(widget, ed); _GlyphWidgetRec* w = (_GlyphWidgetRec*)widget; ed->SetWindow(w->iv.window); // Xt handles mapping // w->map(); _editors->Append(new UList(ed)); Resource::ref(ed); ed->Open(); } void XtUnidraw::Close(Editor* ed) { // we probably don't want to call unmap here OverlayUnidraw::Close(ed); } void XtUnidraw::workProc() { // updated(false); // ### missing "updated" code Iterator it; for (_cmdq->First(it); !_cmdq->Done(it); _cmdq->First(it)) { unidraw->ExecuteCmd(_cmdq->GetCommand(it)->Copy()); _cmdq->Remove(_cmdq->GetCommand(it)); } Process(); Sweep(); if (updated()) { Update(true); } } // -------------------------------------------------------------------------- XtUdSession::XtUdSession( const char* name, int& argc, char** argv, XtAppContext app, Catalog* c, const OptionDesc* options, const PropertyData* prop, Display* dis ) :XtSession(name, argc, argv, options, prop, app, dis) { World* w = new XtWorld(this, default_display()); Unidraw* ud = new XtUnidraw(c, w); } #if 0 XtUdSession::~XtUdSession() { // delete the global unidraw; this will delete the World and Catalog delete unidraw; unidraw = nil; } #endif XtUdSession::initialize( const char* name, int& argc, char** argv, XDisplay* xdpy, const OptionDesc* options, const PropertyData* prop ) { OverlayCreator* creator = new OverlayCreator; DisplayRep* drep = new DisplayRep; drep->init(xdpy); Display* dpy = new Display(drep); XtUdSession* s = new XtUdSession( name, argc, argv, XtDisplayToApplicationContext(xdpy), new OverlayCatalog("drawtool", creator), options, prop, dpy ); // ### creator never get deleted in this case } XtUdSession::initialize( const char* name, int& argc, char** argv, XDisplay* xdpy, Catalog* c, const OptionDesc* options, const PropertyData* prop ) { XtUdSession* s = new XtUdSession( name, argc, argv, XtDisplayToApplicationContext(xdpy), c, options, prop ); } void XtUdSession::workProc() { XtSession::workProc(); XtUnidraw::instance().workProc(); } ivtools-1.2.11a1/src/ivxt/xtudsession.h000066400000000000000000000041601214471147700200500ustar00rootroot00000000000000/* * Copyright (c) 1998 R.B. Kissh & Associates * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef xt_ud_session_h #define xt_ud_session_h #include "xtsession.h" #include class Creator; class XtUnidraw : public OverlayUnidraw { public: XtUnidraw(Catalog*, World*); static XtUnidraw& instance(); virtual void Open(Editor*); virtual void Open(Editor*, Widget widget); virtual void Close(Editor*); virtual void workProc(); }; class XtUdSession : public XtSession { public: static initialize( const char*, int& argc, char** argv, XDisplay*, const OptionDesc* = nil, const PropertyData* = nil ); static initialize( const char*, int& argc, char** argv, XDisplay*, Catalog*, const OptionDesc* = nil, const PropertyData* = nil ); XtUdSession( const char*, int& argc, char** argv, XtAppContext, Catalog*, const OptionDesc* = nil, const PropertyData* = nil, Display* = nil ); virtual void workProc(); }; #endif ivtools-1.2.11a1/src/man/000077500000000000000000000000001214471147700150675ustar00rootroot00000000000000ivtools-1.2.11a1/src/man/man1/000077500000000000000000000000001214471147700157235ustar00rootroot00000000000000ivtools-1.2.11a1/src/man/man1/comdraw.1000066400000000000000000000170661214471147700174530ustar00rootroot00000000000000.TH COMDRAW 1 .SH COMDRAW comdraw \- drawtool with distributed command interpreter .SH SYNOPSIS .B comdraw [-port n] [-import n] ['X-params'] [file] .SH DESCRIPTION comdraw is a drawing editor with integrated command interpreter the user can interact with via stdin and stdout (or via telnet if ACE is built in). The command syntax is a semi-colon separated list of commands with arbitrary number of parameters enclosed in parenthesis, with support for optional parameters and keyword arguments, i.e: command1(arg1 arg2 arg3 :key1 val1 :key2 val2); command2(arg1 arg2 arg3 :key1 val1 :key2 val2) The literals and operators of C are all supported except for the syntax of the conditional operator "?:". See the comterp documentation for more details. All arguments to commands documented below are integers unless indicated by a suffix of str (which are strings embedded in quotes) or flt (which are conventional floating point numbers). "compview" is a graphical object assigned to an interpreter variable. .SH DRAWING COMMANDS compview=rect(x0,y0,x1,y1) -- create a rectangle compview=rectangle(x0,y0,x1,y1) -- same as rect compview=line(x0,y0,x1,y1) -- create a line compview=arrowline(x0,y0,x1,y1) -- create line with arrows compview=ellipse(x0,y0,r1,r2) -- create a rectangle compview=text(x0,y0 textstr) -- create a text string compview=multiline(x0,y0[,x1,y1,...]) -- create a multiline compview=arrowmultiline(x0,y0[,x1,y1,...]) -- create a multiline with arrows compview=openspline(x0,y0[,x1,y1,...]) -- create an open spline compview=arrowspline(x0,y0[,x1,y1,...]) -- create an open spline with arrows compview=polygon(x0,y0[,x1,y1,...]) -- create a polygon compview=closedspline(x0,y0[,x1,y1,...]) -- create a closed spline compview=raster(x0,y0,x1,y1) -- create an empty raster .SH GRAPHIC STATS COMMANDS xylist=center(compview :xy :yx :x :y :scrn) -- center of compview (dflt :xy) rectlist=mbr(compview :lbrt :lrbt :scrn) -- minimum bounding rectangle of compview (dflt :lbrt) ptlist=points(compview) -- return point list from compview graphic .SH GRAPHIC STATE COMMANDS font(fontnum) -- set current font from menu brush(brushnum) -- set current brush from menu pattern(patternnum) -- set current pattern from menu colors(fgcolornum bgcolornum) -- set current colors from menu colorsrgb(fgcolornum bgcolornum) -- set current colors by RGB name. The colorname format is "#RGB" for 4 bits, "#RRGGBB" for 8 bits, #RRRGGGBBB for 12 bits, #RRRRGGGGBBBB for 16 bits nfonts() -- return size of font menu nbrushes() -- return size of brush menu npatterns() -- return size of pattern menu ncolors() -- return size of color menus .SH DIRECT MANIPULATION COMMANDS select([compview ...] :all :clear) -- make these graphics the current selection delete(compview [compview ...]) -- delete graphic(s) move(dx dy) -- move current selection scale(xflt yflt) -- scale current selection rotate(degflt) -- rotate current selection fliph() -- horizontally flip current selection flipv() -- vertically flip current selection .SH GROUP/UNGROUP COMMANDS newgroup=growgroup(groupview compview) -- add graphic to existing group graphic newgroup=trimgroup(groupview compview) -- remove graphic from existing group graphic .SH COMPONENT AND ATTRIBUTE COMMANDS compview=setattr(compview [:keyword value [:keyword value [...]]]) -- set attributes of a graphic component attrlist(compview) -- return attribute list of component compview=frame([index]) -- return composite component for a frame, defaults to current val=at(list|attrlist|compview n :set val :ins val) -- return (or set or insert after) the nth item in a list. num=size(list|attrlist|compview) -- return size of a list. compview=parent(compview) -- get parent of graphic .SH VIEWER COMMANDS update() -- update viewer error=save([pathstr]) -- command to save document (to pathname) compview=import(pathstr :popen :next) -- import graphic file from pathname or URL, or from a command if :popen (:next imports next in numeric series) export(compview[,compview[,...compview]] [path] :host host_str :port port_int :socket :string|:str :eps :idraw) -- remote in drawtool (or other) format compview=paste(compview [xscale yscale xoff yoff | a00,a01,a10,a11,a20,a21]) -- paste graphic into the viewer val=pastemode([val] :get) -- toggle or set paste mode, default is 0, always paste new graphics ncols() -- onscreen horizontal extent in pixels nrows() -- onscreen vertical extent in pixels dx,dy=stod(sx,sy) -- convert from screen to drawing coordinates sx,sy=dtos(dx,dy) -- convert from drawing to screen coordinates dx,dy=gtod(compview gx,gy) -- convert from graphic to drawing coordinates gx,gy=dtog(compview dx,dy) -- convert from drawing to graphic coordinates handles(flag) -- enable/disable current selection tic marks and/or highlighting highlight(compview compviewgs) -- set the highlight graphic state for a graphic zoom(zoomflt) -- zoom by factor zoomin() -- zoom-in by 2 zoomout() -- zoom-out by 2 pan(px py) -- pan viewer smallpanup() -- small pan up smallpandown() -- small pan down smallpanleft() -- small pan left smallpanright() - small pan right largepanup() -- large pan up largepandown() -- large pan down largepanleft() -- large pan left largepanright() -- large pan right gravity([flag]) -- set/get drawing editor gravity gridspacing([xsize ysize]) -- set/get drawing editor grid spacing hide(compview) -- hide graphic component show(compview) -- show graphic component desensitize(compview) -- desensitize graphic component sensitize(compview) -- desensitize graphic component .SH IMAGING COMMANDS tilefile(inpath outpath [xsize] [ysiz]) -- tile pgm or ppm image file val=peek(compview x y) -- peek pixel value into raster poke(compview x y val) -- poke pixel value into raster pokeline(compview x y vallist) -- poke list of values into a raster line. pcols(compview) -- number of columns in a raster pcols(compview) -- number of rows in a raster pflush(compview) -- flush pixels poked into a raster pclip(compview x1,y1,x2,y2,x3,y3[,...,xn,yn]) -- clip raster with polygon alpha(compview [alphaval]) -- set/get alpha transparency .SH PLOTTING COMMANDS -- requires plotmtv and pstoedit -- barplot([var_str value_float] [...] :title title_str :xtitle xtitle_str :ytitle ytitle_str :valtitle valtitle_str :newview) -- display a barplot .SH OTHER COMMANDS acknowledgebox(msgstr) -- popup an acknowledge dialog box confirmbox(msgstr) -- popup a confirmation dialog box, and return 1, 0, or -1 if cancelled run(filename) -- run commands from file quit() -- quit this interpreter exit() -- exit entire application pause([msgstr] :usec num) -- pause script execution until C/R .SH OPTIONS .B \-port n, specifies the port number to accept command interpreter connections on. .B \-import n, specifies the port number run the import service on. The import service accepts connections over the net and reads drawtool format data. .B \-stripped n, brings up a comdraw without any menubar, toolbar, panner, slider, or zoomer. It can be controlled via stdin or telnet if built with ACE. .B \-rampsize n, selects the rampsize used for gray-level image processing. .B \-theight n, (or "-th n") selects the automatic raster tiling height. .B \-twidth n, (or "-tw n") selects the automatic raster tiling width. .B \-tile, enables the automatic raster tiling. .PP Also see the -help message and the drawtool and idraw man pages for further options. .SH SEE ALSO comterp, drawtool, idraw .SH WEB PAGES http://www.ivtools.org/ivtools/comdraw.html ivtools-1.2.11a1/src/man/man1/comterp.1000066400000000000000000000270301214471147700174600ustar00rootroot00000000000000.TH COMTERP 1 .SH COMTERP comterp \- distributed command interpreter demonstrator .SH SYNOPSIS .B comterp .br .B comterp remote .br .B comterp server 'portnum' .br .B comterp logger 'portnum' .br .B comterp client 'host' 'portnum' ['file'] .br .B comterp telcat 'host' 'portnum' ['file'] .br .B comterp run 'file' .br .SH DESCRIPTION comterp demonstrates the command interpreter incorporated into ivtools. A user (or client program) can interact with comterp via stdin and stdout or telnet (when ACE is built in). The command syntax is a semi-colon separated list of commands with arbitrary number of parameters enclosed in parenthesis, with support for optional parameters and keyword arguments, i.e: command2(arg1 arg2 arg3 :key1 val1 :key2 val2); command1(arg1 arg2 arg3 :key1 val1 :key2 val2) C-like binary expressions can be embedded anywhere in the command language, using the operators in the table below. Variables can be created on the fly with an assignment operator (i.e "ball=1" creates a integer "ball" variable set to 1). Unterminated expressions cause an automatic command line extension (until the parser determines the expression is complete). "(), "{}", and "[]" can all be used interchangeably. .SH COMMAND OPTIONS comterp Invoke a single command interpreter to interact with via stdin and stdout. comterp remote Invoke a single command interpreter, like the default, and include a remote command for accessing other comterp's in server mode. comterp server 'portnum' Listens for and accept connections on portnum, then setup a command interpreter to wait for and process commands from that connection. comterp logger 'portnum' Listens for and accept connections on portnum, then simply forward the incoming messages to stdout, while ack'ing back with newlines. For debugging purposes, not really a use of the interpreter. comterp client 'host' 'portnum' ['file'] Connect to a portnum on a host and send/receive new-line terminated text buffers. For debugging purposes, not really a use of the interpreter. comterp telcat 'host' 'portnum' ['file'] Connect to a portnum on a host, cat the file, then close the connection. Not really a use of the interpreter either. comterp run 'file' Run contents of file then exit. .SH OPERATOR TABLE .nf Operators Command Name Priority Order Type --------- ------------ -------- ----- ---- . dot 130 R-to-L binary ` bquote 125 R-to-L unary-prefix $ stream 125 R-to-L unary-prefix ! negate 110 R-to-L unary-prefix ~ bit_not 110 R-to-L unary-prefix ++ incr 110 R-to-L unary-prefix ++ incr_after 110 R-to-L unary-postfix - minus 110 R-to-L unary-prefix -- decr 110 R-to-L unary-prefix -- decr_after 110 R-to-L unary-postfix ** repeat 90 L-to-R binary .. iterate 80 L-to-R binary % mod 70 L-to-R binary * mpy 70 L-to-R binary / div 70 L-to-R binary + add 60 L-to-R binary - sub 60 L-to-R binary << lshift 55 L-to-R binary >> rshift 55 L-to-R binary < lt 50 L-to-R binary <= lt_or_eq 50 L-to-R binary > gt 50 L-to-R binary >= gt_or_eq 50 L-to-R binary != not_eq 45 L-to-R binary == eq 45 L-to-R binary & bit_and 44 L-to-R binary ^ bit_xor 43 L-to-R binary | bit_or 42 L-to-R binary && and 41 L-to-R binary || or 40 L-to-R binary , tuple 35 L-to-R binary ,, concat 33 L-to-R binary %= mod_assign 30 R-to-L binary *= mpy_assign 30 R-to-L binary += add_assign 30 R-to-L binary -= sub_assign 30 R-to-L binary /= div_assign 30 R-to-L binary = assign 30 R-to-L binary ; seq 10 L-to-R binary .fi .SH MATHEMATICAL COMMANDS: n=min(a b) -- return minimum of a and b n=max(a b) -- return maximum of a and b n=abs(a) -- return absolute value of a dbl=exp(x) -- returns the value e raised to the power of x dbl=log(x) -- returns the natural logarithm of x dbl=log10(x) -- returns the base-10 logarithm of x dbl=pow(x y) -- returns the value of x raised to the power of y dbl=acos(x) -- returns the arc cosine of x in radians dbl=asin(x) -- returns the arc sine of x in radians dbl=atan(x) -- returns the arc tangent of x in radians dbl=atan2(y x) -- returns the arc tangent of y over x dbl=cos(x) -- returns the cosine of x radians dbl=sin(x) -- returns the sine of x radians dbl=tan(x) -- returns the tangent of x radians dbl=sqrt(x) -- returns square root of x dbl=pi() -- returns the value of pi dbl=radtodeg(dbl) -- convert radians to degrees dbl=degtorad(dbl) -- convert degrees to radians num=floor(num) -- return closest integer value less than or equal to argument num=ceil(num) -- return closest integer value greater than or equal to argument num=round(num) -- return closest integer value .SH AFFINE TRANSFORM AND MATRIX COMMANDS: point=xform(x,y a00,a01,a10,a11,a20,a21) -- affine transform of x,y coordinates affine=invert(a00,a01,a10,a11,a20,a21) -- invert affine transform matrix=xpose(matrix) -- transpose an arbitrary matrix matrix=matrix*matrix -- matrix multiplication .SH STATISTICAL/RANDOM COMMANDS: sum(val1[,val2[,...,valn]]) -- return sum of values mean(val1[,val2[,...,valn]]) -- return mean of values var(val1[,val2[,...,valn]]) -- return variance of values stddev(val1[,val2[,...,valn]]) -- return standard deviation of values rand([minval,maxval]) -- return random number between 0 and 1 or minval,maxval srand(seedval) -- seed random number generator .SH LIST COMMANDS: lst=list([olst|strm|val] :strmlst :attr :size n) -- create list, copy list, or convert stream val=at(list|attrlist|str n :set val :ins val) -- return (or set or insert after) nth item in a list or string num=size(list|attrlist|str) -- return size of a list (or string) val=index(list|str val|char|str :last :all) -- return index of value (or char or string) in list (or string), nil if not found. .SH STREAM COMMANDS: val=next(stream) -- return next value from stream strm=stream(ostrm|list|attrlist) -- copy stream or convert list cnt=each(strm) -- traverse stream returning its length .SH CONTROL COMMANDS (using post evaluation): val=cond(testexpr trueexpr falseexpr) -- evaluate testexpr, and if true, evaluate and return trueexpr, otherwise evaluate and return falseexpr val=if(testexpr :then expr :else expr) -- evaluate testexpr and execute the :then expression if true, the :else expression if false. val=for(initexpr whileexpr [nextexpr [bodyexpr]] :body expr) -- for loop val=while([testexpr [bodyexpr]] :nilchk :until :body expr ) -- while loop val=switch(val key-body-pairs) -- switch statement (:casen for pos., :case_n for neg., otherwise :symbol) .SH OTHER COMMANDS help(cmdname [cmdname ...] :all :posteval) -- help for commands val=trace([flag] :get) -- toggle or set trace mode pause() -- pause script execution until C/R step() -- toggle stepwise script execution fileobj|pipeobj=open([filename [modestr]] :pipe :in :out :err) -- open file command close(fileobj|pipeobj) -- close file command [str]=print([fmtstr] [val [val1 [... valn]]] :string|:str :out :err :file fileobj|pipeobj :prefix str) -- print value with optional format string str=gets(fileobj|pipeobj) -- gets a new-line terminated string from a file val=global(symbol)|global(symbol)=val|global(symbol :clear)|global(:cnt) -- make symbol global int|lst=symid(symbol [symbol ...] | :max) -- return integer id(s) associated with symbol(s) sym|lst=symbol(symid [symid ...]) -- return symbol(s) associated with integer id(s) val|lst=symval(symbol [symbol ...]) -- return value(s) associated with symbol variables(s) sym|lst=symadd(sym|str [sym|str ...]) -- create symbol(s) and return without lookup. sym=symvar(sym) -- return symbol as-is str=symstr(sym) -- return string version of symbol n=strref(str|symid) -- return string reference count lst=split(symbol|string :tokstr [delim] :tokval [delim]) -- split symbol or string into list of characters (or tokens). str=join(clist :sym) -- join list of characters into string str=substr(str n|str :after) -- extract characters from a string bool=eq(str1 str2 :n len) -- partial string comparison bool=eq(sym1 sym2 :sym) -- symbol comparison postfix(arg1 [arg2 [arg3 ... [argn]]]) -- echo unevaluated postfix arguments (with [narg|nkey] after defined commands, {narg|nkey} after undefined commands, (narg) after keys, and a * following post-evaluation commands) arr=posteval(arg1 [arg2 [arg3 ... [argn]]]) -- post-evaluate every fixed argument (until nil) and return array sym=attrname(attribute) -- return name field of dotted pair val=attrval(attribute) -- return value field of dotted pair dotlst=dot(name) -- construct empty dotted pair list quit() -- quit the interpreter exit() -- exit entire application empty() -- empty statement val=run(filename :str :popen) -- run commands from file (or string) val=remote(hoststr portnum cmdstr :nowait) -- remotely evaluate command string then locally evaluate result string val=eval(cmdstr|funcobj [cmdstr|funcobj ...] :symret ) -- evaluate string (or funcobj) as commands, optionally return symbol instead of nil funcobj=func(body :echo) -- encapsulate a body of commands into an executable object val=shell(cmdstr) -- evaluate command in shell usleep(msec) -- sleep microseconds mute([flag]) -- set or toggle mute flag nil([...]) -- accept any arguments and return nil c=char(num :u) -- convert any numeric to a char s=short(num :u) -- convert any numeric to a short i=int(num :u) -- convert any numeric to an int l=long(num :u) -- convert any numeric to a long f=float(num) -- convert any numeric to a float d=double(num) -- convert any numeric to a double sym|lst=type(val [val ...]) -- return type symbol(s) for value(s) sym|lst=class(val [val ...]) -- return class symbol(s) for value(s) of object type int=ctoi(char) -- convert character to integer flag=isspace(char) -- return true if character is whitespace flag=isdigit(char) -- return true if character is a numeric digit flag=isspace(char) -- return true if character is alphabetical str=arg(n) -- return command line argument n=narg(n) -- return number of command line arguments num=nand(a b) -- bitwise NAND(negated AND) num=nor(a b) -- bitwise NOR (negated OR) num=xnor(a b) -- bitwise XNOR (negated XOR) .SH ONLY IN SERVER MODE str=timeexpr(comstr :sec n) -- command string to execute at intervals .SH SEE ALSO comdraw .SH WEB PAGES http://www.ivtools.org/ivtools/comterp.html ivtools-1.2.11a1/src/man/man1/dclock.1000066400000000000000000000035051214471147700172470ustar00rootroot00000000000000.TH dclock 1 .SH NAME dclock \- digital clock .SH SYNOPSIS \fBdclock\fP [ \fB\-cmjd\fP ] [ \fB\-s\fP\fIslant\fP ] [ \fB\-t\fP\fIthickness\fP ] [ \fB\-f\fP\fIrate\fP ] .SH DESCRIPTION \fIDclock\fP displays a scalable digital clock. The time is updated from the local host clock every minute as a background process. The current date is displayed across the top of the window in the format .TP 8 \ Sat Aug 16 1986 .PP (or some subset of such if there's not enough room). Options to control the clock's appearance, size and placement are as follows: .TP 16 \fB\-c\fP Display in 12-hour format (\*(lq\fIc\fPivilian\*(rq time) \(em the default. .TP \fB\-m\fP Display in 24-hour format (\*(lq\fIm\fPilitary\*(rq time). .TP \fB\-j\fP \*(lq\fIJ\fPohn's flag.\*(rq Puts a tail on the digit `9'. .TP \fB\-d\fP Do \fInot\fP display the current \fId\fPate across the top of the clock view. .TP \fB\-b\fP Display a \fIb\fPorder (horizontal line) between the date string and the time display. .TP \fB\-T\fP Do \fInot\fP display the \fIT\fPime in the clock view (leaving just the date). .TP \fB\-s\fP\fIslant\fP Set the \fIslant\fP of the digits. A \fIslant\fP of 100 (the maximum) corresponds to a slant of one digit width. A \fIslant\fP of 0 (the minimum) is vertical. Default is \fB\-s30\fP. A special form is \fB\-s\fP, which is equivalent to \fB\-s0\fP. .TP \fB\-t\fP\fIthickness\fP Set the \fIthickness\fP of the digit segments. Allowable values are between 5 and 25. A \fIthickness\fP of 25 results in segments which are one quarter (25%) of the digit width. Default is \fB\-t15\fP. .TP \fB\-f\fP\fIrate\fP Set the \fIrate\fP at which the segments fade when the time changes. A value of 0 is fastest and 4 is slowest. Default is \fB\-f4\fP. A special form is \fB\-f\fP, which is equivalent to \fB\-f0\fP. .PP To exit \fIdclock\fP, type a `q' in the window. ivtools-1.2.11a1/src/man/man1/drawtool.1000066400000000000000000000117371214471147700176510ustar00rootroot00000000000000.TH drawtool 1 .SH NAME drawtool \- idraw with extensions .SH SYNOPSIS .B drawtool .I -import n ['X-params'] [file] .SH DESCRIPTION drawtool is an extended version of idraw (originally from the InterViews 3.1). Based on the ivtools OverlayUnidraw library, it adds the following features: .IP - double-buffered graphics drawing - 3d Motif-like menus and buttons - readable text save/restore - polygon intersection and clipping tools - graphical object attribute annotations .PP drawtool is derived from idraw, and implements the same set of pulldown commands and pallette of toolbuttons. Read the idraw man page for details on that part of the drawtool user interace. This page lists only the extensions to idraw embodied in drawtool. .PP drawtool saves and restores documents in a readable text format. This allows for manual or programmatic creation of drawtool files. idraw-format documents can still be imported with the "Import Graphic" command, and exported with the Print command (both under the File menu). .PP In addition to idraw format, the "Import Graphic" command supports the importing of encapsulated drawtool files, and the following image file formats: TIFF, X11 Bitmap, PBM, PGM, and PPM. Compression via compress (.Z) and gzip (.gz) is recognized and handled for the script files themselves and the PBM, PGM, and PPM image formats. .PP There is also support for opening (via command line or dialog box) and importing via the net (to the -import port) any arbitrary PostScript file using the pstoedit filter, and any GIF, TIFF, or JPEG image, using respectively the giftopnm, tifftopnm, or djpeg filters. .PP The "Export Clipboard" command writes the contents of the clipboard out in idraw or drawtool format. .PP Commands have been added to the Edit menu for selecting by attributes (on the graphic objects) and clipping one polygon against another. .PP The View menu has been expanded with zoom and pan commands, plus commands to hide/show graphics and fix graphic sizes and locations. In addition the viewer's panning and zooming can be chained to other viewers, and the pointer device can be put into a continuous "scribble" mode useful when drawing multilines or polygons. .PP The tools have been extended with a possible six new tools: Annotate, Attribute, ClipRect, ClipPoly, ConvexHull, and GraphicLoc. Annotate brings up a text editor in which graphic-specific text can be entered and/or edited. Attribute brings up a dialog box to create/edit property lists for the selected graphic. ClipRect and ClipPoly clip polygons, rectangles, lines, and multilines if drawtool has been built with the clippoly library (otherwise just lines and rectangles). ConvexHull is a convex hull drawing tool available if qhull can be found in your path. GraphicLoc displays the coordinates of a mouse-click relative to the graphic that has been clicked on. This is relative to the original screen coordinates of the graphic when created (or the origin of the raster if an image). Subsequent rotations and transformations can give this a non-obvious value. .SH OPTIONS .TP "-import n" specifies the port number to run the import service on. The import service accepts connections over the net and reads drawtool or idraw documents and pbmplus image formats (PBM/PGM/PPM), plus JPEG, GIF, TIFF, and the non-raster portions of arbitrary PostScript if appropriate filters are available (djpeg, giftopnm, tifftopnm, pstoedit). "-color5" selects a colormap with 5 values per color or 125 entries (5 cubed). .PP "-nocolor6" overrides the selection of a colormap with 6 values per color or 216 entries (6 cubed). .PP "-gray5" selects a colormap with 5 bits of gray-level intensity (32 gray-levels) arranged to maximize rubberband visibility. .PP "-gray6" selects a colormap with 6 bits of gray-level intensity (64 gray-levels) arranged to maximize rubberband visibility. .PP "-gray7" selects a colormap with 7 bits of gray-level intensity (128 gray-levels) arranged to maximize rubberband visibility. .PP "-dithermap" causes imported JPEG rasters to be mapped to the standard colormap (the default without -nocolor6) and dithered to avoid color banding. .PP "-opaque_off" (or "-opoff") disables the opaque (visible) interactive transformations of graphics. .PP "-pagecols" (or "-ncols") sets the horizontal page extent in pixels. .PP "-pagerows" (or "-nrows") sets the vertical page extent in pixels. .PP "-panner_align tl|tc|tr|cl|c|cr|cl|bl|br|l|r|t|b|hc|vc" (or "-pal ...") selects the alignment of the panner display. .PP "-panner_off" (or "-poff") disables the panner display. .PP "-slider_off" (or "-soff") disables the slider display. .PP "-zoomer_off" (or "-zoff") disables the zoomer display. .PP "-ptrloc" enables display of the current pointer location. .PP "-scribble_pointer (or "-scrpt") enables continuous line drawing. .PP "-toolbarloc r|l" (or "-tbl ...") selects the toolbar location. .PP Also see "-help" and the idraw man page for more options. .SH SEE ALSO idraw(1) .SH WEB PAGE http://www.ivtools.org/ivtools/drawtool.html ivtools-1.2.11a1/src/man/man1/flipbook.1000066400000000000000000000054131214471147700176150ustar00rootroot00000000000000.TH flipbook 1 .SH NAME flipbook \- multi-frame editor and viewer derived from drawtool .SH SYNOPSIS .B flipbook .I [-bookgeom] [-slideshow sec] ['X-params'] [file] .SH DESCRIPTION flipbook is a program derived from idraw/drawtool that supports multi-frame graphic display. The zeroth frame is always visible as the background frame, and in front of it is displayed the current frame (1 thru n). .PP The Frame menu controls the frame display mechanism. The operations are: .PP .nf Menu Item Keyboard Description -------------- -------- ----------- Move Forward ^F move forward one frame Move Backward ^B move backward one frame Goto First Frame move to the first frame Goto Last Frame move to the last frame New Forward F create new frame in front of the current frame and make it the current frame New Backward B create new frame in back of the current frame and make it the current frame Copy Forward X copy current frame in front of itself Copy Backward Y copy current frame in back of itself Delete D delete current frame (the zeroth frame can never be deleted) .fi By default a flipbook document is positioned on the first frame when opened (if one exists). "Move Backward" can be used to move to the background frame when positioned on the first frame. "Move Forward" then returns to the first frame. The New command creates a document with only a background frame. The "New After" command can then be used to initialize the first frame ("New Before" does not work when the current frame is the background frame). flipbook save/restores its documents with a document format specific to flipbook (and possibly programs derived from flipbook). Idraw format drawings can be imported via the "Import Graphic" command (under the File menu). The rest of the flexibile import mechanism of drawtool is supported as well. "Export Graphic" exports currently selected graphics in idraw or drawtool format. The Print command (under the File menu) generates a multi-page Postscript document, one page per frame except for the zeroth frame which is always the background. .SH OPTIONS "-bookgeom" brings up the flipbook in landscape mode, with a 906 by 700 pixel page size. Useful for viewing illustrated books prepared in this mode. "-slideshow sec" continuously plays the contents of a flipbook file with "sec" delay between frames (currently only available when built with ACE). Also see "-help" for more options, and the comdraw, drawtool, and idraw man pages. .SH SEE ALSO drawtool, idraw .SH WEB PAGE http://www.ivtools.org/ivtools/flipbook.html ivtools-1.2.11a1/src/man/man1/graphdraw.1000066400000000000000000000044301214471147700177650ustar00rootroot00000000000000.TH graphdraw 1 .SH NAME graphdraw \- directed graph editor derived from drawtool .SH SYNOPSIS .B graphdraw .I ['X-params'] [file] .SH DESCRIPTION graphdraw implements a graph (node/edge) editor. graphdraw adds two new graphical objects to idraw/drawtool: an elliptical shaped node and a directed edge represented as an arrow line. Two new tools to create these objects are provided at the bottom of the toolbar. The Node tool (selectable by the 'N' key) takes a single mouse click and creates a new graph node at the click location. The Edge tool (selectable by the 'E' key) lets you drag a line to create a new graph edge. If an edge is drawn from or to an existing node, it will connect itself to the node(s) and maintain that connectivity during any later movement of nodes or edges. The Move tool will move edges or nodes, rubberbanding the rest of the graph, and redrawing any connected edges to maintain graph connectivity and edge alignment. .PP Nodes contain a (initially empty) text string which can be edited by applying the Alter tool to a node. A single click on a node while on the Alter tool will create a text cursor, possibly within an existing text string, and allow editing of the text via the usual Emacs editing commands. A click outside the text terminates editing and causes the new text to be centered within the node. .PP For Node and Edge objects, the Selection highlight mechanism has also been changed from the usual drawing of "handles" around a graphical object to a red foreground color. When Nodes or Edges are selected, they turn red instead of handles being drawn around them. .PP graphdraw documents are saved/restored in a readable text file. Some of the tokens used in the text file are specific to graphdraw (and possibly any program derived from graphdraw). graph drawings can be exported to other idraw/drawtool applications via the "Export Graphic" command (under the File menu). This generates Postscript in a format that idraw can read back in, and programs like drawtool can import via "Import Graphic" (under the file menu). .PP A Tools menu has been added to the set of pull-down menus to allow switching between a graph editing toolbar and a generic graphics editing toolbar. .SH SEE ALSO drawtool, idraw .SH WEB PAGE http://www.ivtools.org/ivtools/graphdraw.html ivtools-1.2.11a1/src/man/man1/iclass.1000066400000000000000000000105741214471147700172720ustar00rootroot00000000000000.TH iclass 1 .SH NAME iclass \- class browser .SH SYNOPSIS .B iclass .RB [ -r ] .RB [ -v ] .RB [ -c ] .I path .RI [ path... ] .SH DESCRIPTION .I Iclass is a simple class browser that lets you navigate through C++ class hierarchies and view the definition of a particular class. You can select classes from three browsers: the first shows a list of all known classes; the second shows the parents of the selected class, if any; and the third shows the children of the selected class, if any. You can choose a name from any of these lists and tell \fIiclass\fP to show the definition of that class, or you can type the name of a class explicitly in the StringEditor labeled ``selected class.'' The view of the class definition shows the source code from the header file that defines the selected class. .SH ARGUMENTS \fIIclass\fP interprets arguments that specify the header files to search for class definitions. Each non-option argument on the command line should specify a pathname to a header file or a directory containing header files. If the pathname is a filename ending in the suffix ``.h'', then \fIiclass\fP will scan that header file. If the pathname is a directory, then it will scan every header file in that directory. \fIIclass\fP will ignore filenames that do not end in the suffix ``.h'', unless the ``\-c'' option is given. In this case \fIiclass\fP will search both ``.h'' and ``.C'' files for class definitions. .PP You may use any of the standard options accepted by InterViews programs in addition to the following options: .TP .B \-r Recursively scan subdirectories for additional header files when scanning a directory. .TP .B \-v Verbosely print the name of every header file scanned. .TP .B \-c Allow \fIiclass\fP to search ``.C'' files as well as ``.h'' for class definitions. This option should be used carefully. Because of the way that iclass searches for definitions, it is possible for it to get confused by code in a ``.C'' file and think it is a definition. Nonetheless, this is a useful option if there are C++ input files that contain definitions. .SH COMMANDS \fIIclass\fP provides pull-down menus for issuing commands. The ``File'' menu includes the following commands: .TP 4 .B "Scan Files/Directories..." Prompt for additional pathnames to scan. .TP .B "Clear Classes" Purge iclass of all classes it has scanned. .TP .B Quit Close the window and exit. .PP Commands in the ``Search'' menu include: .TP .B "Forward Search..." Search forward in the class definition for a match with a given regular expression, wrapping from the end to the beginning of the buffer if necessary. .TP .B "Backward Search..." Search backward for a match with a given regexp. .TP .B "Go to Line..." Move the cursor to the beginning of the given line, scrolling the display if necessary. .SH MOUSE BINDINGS The left mouse button selects text. Left-clicking inside a browser, StringEditor, or class definition also focuses keyboard input to it, which lets it interpret subsequent keyboard commands as scrolling or selection operations. Double left-clicking inside a browser is equivalent to selecting a class and then pressing the ``Show'' button. .PP The middle and right mouse buttons scroll text in different ways. Middle-clicking lets you ``grab-scroll'' the text. During grab-scrolling, the text is scrolled to follow the mouse position, making it appear as though you are dragging the text itself. Right-clicking engages ``rate-scrolling,'' a joy-stick-like scrolling interface in which the scrolling rate increases as you drag the mouse away from the initial click point. For example, dragging the mouse downwards after the initial click scrolls a browser downwards at an increasing rate; dragging upwards thereafter reduces the rate until scrolling stops entirely at the initial click point. Dragging up beyond this point makes the browser scroll in the reverse direction. .SH KEYBOARD BINDINGS For convenience, all menu commands have keyboard equivalents: .TP .B "(^V)" Scan a file or directory. .TP .B "(^Q)" Quit. .TP .B "(^S)" Search forward. .TP .B "(^R)" Search backward. .TP .B "(^N)" Go to a line. .PP \fIIclass\fP also provides keyboard commands for changing focus: .TP .B "ESC or TAB" Set focus to the StringEditor showing the selected class. .TP .B "CR" Show the selected class (equivalent to pressing the Show button) and set focus to the class definition. .SH SEE ALSO Regexp(3I), StringBrowser(3I), StringEditor(3I), TextEditor(3I) ivtools-1.2.11a1/src/man/man1/idraw.1000066400000000000000000000416461214471147700171260ustar00rootroot00000000000000.TH idraw 1 .SH NAME idraw \- drawing editor .SH SYNOPSIS .B idraw .RI [ options ] .RI [ file ] .SH DESCRIPTION Idraw is a drawing editor that lets you create and edit drawings made up of graphics like text, lines, splines, rectangles, polygons, and ellipses. Drawings are stored in files that can be printed on a PostScript printer. You can can open an existing drawing when starting up idraw by typing a file name on the command line. Idraw displays a portrait or landscape view of an 8.5 by 11 inch page in its \fIdrawing area\fP. In a column along the drawing area's left side is a set of \fIdrawing tool\fP icons, and above the drawing area is a set of pull-down menus containing \fIcommands\fP. A panner in the lower left corner lets you pan and zoom the the drawing area. Along the top is a set of indicators that display editing information. .SH "DRAWING TOOLS" You must engage a tool before you can use it. You engage a tool by clicking on its icon or by typing the character below and to the right of its icon. The icon of the drawing tool that's engaged appears in inverted colors. Once engaged, you use the tool by clicking the left mouse button in the drawing area. The .BR Select , .BR Move , .BR Scale , .BR Stretch , .BR Rotate , and .B Alter tools manipulate existing graphics. .B Magnify makes a part of the view expand to fill the entire view. .BR Text , .BR Line , .BR Multiline , .BR "Open Spline" , .BR Ellipse , .BR Rectangle , .BR Polygon , and .B Closed Spline create new graphics. Each tool works as follows: .TP 15 .B Select Select a graphic, unselecting all others. A graphic is selected if its \fIhandles\fP are visible. Handles are small inverse-video squares that either surround the graphic or demarcate its important points (such as the endpoints of a line). If you hold down the shift key, \fBSelect\fP \fIextends\fP the selection: it selects the unselected graphic (or unselects the selected graphic) you clicked on but does not unselect other selections. Clicking anywhere other than on a graphic unselects everything; you may also drag a rubberband rectangle around a group of graphics to select all of them at once. .I Shortcut: the right mouse button invokes .B Select while the mouse is in the drawing area. .TP .B Move Move graphics from one spot to another. .I Shortcut: the middle mouse button invokes .B Move while the mouse is in the drawing area. .TP .B Scale Scale graphics about their centers. .TP .B Stretch Stretch graphics vertically or horizontally while tying down the opposite edge. .TP .B Rotate Rotate graphics about their centers according to the angle between two radii: the one defined by the original clicking point and the one defined by the current dragging point. .TP .B Alter Modify a graphic's structure. This tool's effect is described below for each graphic. .TP .B Magnify Magnify a portion of the drawing specified by sweeping out a rectangular area. Idraw will magnify the area to occupy the entire screen, if possible. .TP .B Text Create some text. Left-click to position the first line of text, and then type as much text as you want. You may use emacs-style keystrokes to edit the text as well as enter it. You can leave text editing mode by typing ESC or by simply clicking somewhere else. The Alter tool lets you edit the text in an existing text graphic. .TP .B Line Create a line. The shift key constrains the line to lie on either the vertical or the horizontal axis. You may left-click with the Alter tool on either endpoint of a line to move the endpoint to a new location. .TP .B "Multiline" Create a set of connected lines. The shift key constrains each segment to lie on either the vertical or the horizontal axis. Each left-click starts a new segment (i.e., adds a vertex); each right-click removes the last vertex added. The middle button finalizes the multiline. The Alter tool lets you move, add, and remove vertices from an existing multiline. .TP .B "Open Spline" Create an open B-spline. The shift key constrains each control point to lie on either the vertical or the horizontal axis with the preceding point. Each left-click adds a control point; each right-click removes the last control point added. The middle button finalizes the spline. The Alter tool lets you move, add, and remove control points from an existing open spline. .TP .B Ellipse Create an ellipse. The shift key constrains the ellipse to the shape of a circle. The Alter tool does not affect ellipses. .TP .B Rectangle Create a rectangle. The shift key constrains the rectangle to the shape of a square. The Alter tool lets you move the rectangle's corners independently to form a four-sided polygon. .TP .B Polygon Create a polygon. The shift key constrains each side to lie on either the vertical or the horizontal axis. Each left-click starts a new segment (i.e., adds a vertex); each right-click removes the last vertex added. The middle button finalizes the polygon. The Alter tool lets you move, add, and remove vertices from an existing polygon. .TP .B "Closed Spline" Create a closed B-spline. The shift key constrains each control point to lie on either the vertical or the horizontal axis with the preceding point. Each left-click adds a control point; each right-click removes the last control point added. The middle button finalizes the spline. The Alter tool lets you move, add, and remove control points from an existing closed spline. .SH "PULL-DOWN MENUS" The pull-down menus .BR File , .BR Edit , .BR Structure , .BR Font , .BR Brush , .BR Pattern , .BR FgColor , .BR BgColor , .BR Align , and .B View above the drawing area contain commands for editing the drawing and for controlling idraw's execution. The .B File menu contains the following commands to operate on files: .TP 15 .B New Destroy the current drawing and replace it with an unnamed blank drawing. .TP .B Revert Reread the current drawing, destroying any unsaved changes. .TP .B Open... Specify an existing drawing to edit through a FileChooser(3I), which lets you browse the file system easily. .TP .B Save As... Save the current drawing in a file with a specific name. .TP .B Save Save the current drawing in the file it came from. .TP .B Print... Send a PostScript version of the drawing to a printer or to a file. The bold rectangular outline (called the .IR "page boundary" ) appearing in the drawing area indicates the portion of the drawing that will appear on the printed page. .TP .B Import Graphic... Create a graphic from the information in a file and insert it into the current drawing. Idraw can import images from files in the following formats: TIFF; PostScript generated by pgmtops, ppmtops, and idraw; X bitmap format; and Unidraw format. .TP .B Quit Quit idraw. .PP The .B Edit menu contains the following commands for editing graphics: .TP 15 .B Undo Undo the last editing operation. Successive .B Undo commands undo earlier and earlier editing operations. .TP .B Redo Redo the last editing operation. Successive \fBRedo\fP commands redo later and later editing operations up to the first operation undone by \fBUndo\fP. Undone operations that have not been redone are lost as soon as a new operation is performed. .TP .B Cut Remove the selected graphics from the drawing and place them in a temporary storage area called the \fIclipboard\fP. .TP .B Copy Copy the selected graphics into the clipboard. .TP .B Paste Paste copies of the graphics in the clipboard into the drawing. Together, .BR Cut , .BR Copy , and .B Paste let you transfer graphics between drawings simply by cutting graphics out of one view and pasting them into another. .TP .B Duplicate Duplicate the selected graphics and add the copies to the drawing. .TP .B Delete Destroy the selected graphics. .TP .B Select All Select every graphic in the drawing. .TP .BR "Flip Horizontal" ", " "Flip Vertical" Flip the selected graphics into their mirror images along the horizontal or vertical axes. .TP .BR "90 Clockwise" ", " "90 CounterCW" Rotate the selected graphics 90 degrees clockwise or counterclockwise. .TP .BR "Precise Move..." ", " "Precise Scale..." ", " "Precise Rotate..." Move, scale, or rotate graphics by exact amounts that you type in a dialog box. You can specify movements in pixels, points, centimeters, or inches. Scalings are specified in terms of magnification factors in the horizontal and vertical dimensions. Rotations are in degrees. .PP The .B Structure menu contains the following commands to modify the structure of the drawing, that is, the order in which graphics are drawn: .TP 15 .B Group Nest the selected graphics in a newly created picture. A picture is just a graphic that contains other graphics. .B Group allows you to build hierarchies of graphics. .TP .B Ungroup Dissolve any selected pictures. .TP .B Bring To Front Bring the selected graphics to the front of the drawing so that they are drawn on top of (after) other graphics. .TP .B Send To Back Send the selected graphics to the back of the drawing so that they are drawn behind (before) other graphics. .PP The .B Font menu contains a set of fonts in which to display text. When you set the current font from the menu, you will also set all the selected graphics' fonts to that font. A font indicator in the upper right corner displays the current font. .PP The .B Brush menu contains a set of brushes with which to draw lines. When you set the current brush from the menu, you will also set all the selected graphics' brushes to that brush. The nonexistent brush draws invisible lines and non-outlined graphics. The arrowhead brushes add arrowheads to either or both ends of lines, multilines, and open splines. A brush indicator in the upper left corner displays the current brush. .PP The .B Pattern menu contains a set of patterns with which to fill graphics but not text. Text always appears solid, but you can use a different color than black to get a halftoned shade. When you set the current pattern from the menu, you will also set all the selected graphics' patterns to that pattern. The nonexistent pattern draws unfilled graphics, while the other patterns draw graphics filled with a bitmap or a halftoned shade. .PP The .B FgColor and .B BgColor menus contains a set of colors with which to draw graphics and text. When you set the current foreground or background color from the FgColor or BgColor menu, you will also set all the selected graphics' foreground or background colors. The ``on'' bits in the bitmaps for dashed lines and fill patterns appear in the foreground color while the ``off'' bits appear in the background color. A black and white printer will print a halftoned shade of gray for any color other than black or white. The brush, pattern, and font indicators all reflect the current colors. .PP The .B Align menu contains commands to align graphics with other graphics. The first graphic selected stays fixed while the other graphics move in the order they were selected according to the type of alignment chosen. The last Align command, \fBAlign to Grid\fB, aligns a key point on each selected graphic to the nearest point on idraw's grid (see below). .PP The .B View menu contains the following commands: .TP 15 .B New View Create a duplicate idraw window containing a second view of the current drawing. The second view may be panned, zoomed, and edited independently of the first. Any number of additional views may be made in this manner. Changes made to a drawing through one view appear synchronously in all other views of the same drawing. You may also view another drawing in any idraw window via the Open command. .TP .B Close View Close the current idraw window. Closing the last idraw window is equivalent to issuing a Quit command. .TP .B Normal Size Set the magnification to unity so the drawing appears at actual size. .TP .B Reduce to Fit Reduce the magnification until the drawing fits entirely within the view. .TP .B Center Page Center the view over the center of the 8.5 by 11 inch page. .TP .B Orientation Toggle the drawing's orientation. If the editor was formerly showing a portrait view of the drawing, it will now show a landscape view of the drawing and vice versa. .TP .B Grid on/off Toggle idraw's grid on or off. When the grid is on, idraw draws a grid of equally spaced points behind the drawing. .TP .B Grid Spacing... Change the grid spacing by specifying one or two values in the units desired (pixels, points, centimeters, or inches). If two values are given (separated by a space), the first specifies the horizontal spacing and second the vertical spacing. One value will specify equal horizontal and vertical spacing. .TP .B Gravity on/off Toggle gravity on or off. Gravity constrains tool operation to the grid, whether or not the grid is visible. .SH "X DEFAULTS" You can customize the number of undoable changes and the font, brush, pattern, or color menus by setting resources in your X defaults database. Each string of the form ``idraw.resource:definition'' sets a resource. For example, to customize any of the paint menus, set a resource given by the concatenation of the menu's name and the entry's number (e.g., ``idraw.pattern8'') for each entry that you want to override. All menus use the number 1 for the first entry. You must set resources only for the entries that you want to override, not all of them. If you want to add entries to the menus, simply set resources for them. However, don't skip any numbers after the end of the menu, because the menu will end at the first undefined resource. To shorten a menu instead of extending it, specify a blank string as the resource for the entry following the last. .PP Idraw understands the following resources: .TP 15 .B history Set the maximum number of undoable changes (20 by default). .TP .B initialfont Specify the font that will be active on startup. Supply a number that identifies the font by its position in the Font menu starting from 1 for the first entry. .TP .BI font i Define a custom font to use for the \fIi\fPth entry in the Font menu. Give three strings separated by whitespace. The first string defines the font's name, the second string the corresponding print font, and the third string the print size. For example, ``idraw.font3:8x13bold Courier-Bold 13'' defines the third font entry. .TP .B initialbrush Specify the brush that will be active on startup. Give a number that identifies the brush by its position in the Brush menu starting from 1 for the first entry. .TP .BI brush i Define a custom brush to use for the .IR i th entry in the Brush menu. The definition requires two numbers: a 16-bit hexadecimal number to define the brush's line style (each 1 bit draws a dash and each 0 bit produces a gap), and a decimal integer to define the brush's width in pixels. For example, ``idraw.brush2:ffff 1'' defines a single pixel wide solid line. If the definition specifies only the string ``none'', then it defines the nonexistent brush. .TP .B initialpattern Specify the pattern that will be active on startup. Give a number that identifies the pattern by its position in the Pattern menu starting from 1 for the first entry. .TP .BI pattern i Define a custom pattern to use for the .IR i th entry in the Pattern menu. You can specify the pattern from a 16x16 bitmap, a 8x8 bitmap, a 4x4 bitmap, a grayscale number, or the string ``none''. You specify the 16x16 bitmap with sixteen 16-bit hexadecimal numbers, the 8x8 bitmap with eight 8-bit hexadecimal numbers, the 4x4 bitmap with a single 16-bit hexadecimal number, and the grayscale number with a single floating point number. The floating point number must contain a period to distinguish itself from the single hexadecimal number, and it must lie between 0.0 and 1.0, where 0.0 corresponds to a solid pattern and 1.0 to a clear pattern. On the printer, the bitmap patterns appear as bitmaps, the grayscale patterns appear as halftoned shades, and the ``none'' patterns never obscure any underlying graphics. For example, ``idraw.pattern8:8421'' defines a diagonally hatched pattern. .TP .B initialfgcolor Specify the foreground color that will be active on startup. Give a number that identifies the color by its position in the FgColor menu starting from 1 for the first entry. .TP .BI fgcolor i Define a custom color to use for the .IR i th entry in the FgColor menu. Give a string defining the name of the color and optionally three decimal numbers between 0 and 65535 following the name to define the red, green, and blue components of the color's intensity. The intensities override the name; that is, idraw will look the name up in a window system database of common colors only if you omit the intensities. You can define shades of gray by using equal proportions of each primary color. For example, ``idraw.fgcolor8:Indigo 48896 0 65280'' defines a color that is a mixture of red and blue. .TP .B initialbgcolor Specify the background color that will be active on startup. Give a number that identifies the color by its position in the BgColor menu starting from 1 for the first entry. .TP .BI bgcolor i Define a custom color to use for the .IR i th entry in the BgColor menu. The same rules apply to background colors as to foreground colors. .SH "SEE ALSO" drawtool(1) ivtools-1.2.11a1/src/man/man3/000077500000000000000000000000001214471147700157255ustar00rootroot00000000000000ivtools-1.2.11a1/src/man/man3/Adjuster.3000066400000000000000000000056321214471147700176000ustar00rootroot00000000000000.TH Adjuster 3I "15 January 1988" "InterViews" "InterViews Reference Manual" .SH NAME Adjuster \- button-like interactors for incremental scrolling and zooming .SH SYNOPSIS .B #include .SH DESCRIPTION \fBAdjuster\fP objects manipulate a perspective using a pushbutton-like interface. Adjusters also provide an auto-repeat capability. Depressing and holding down any mouse button on an adjuster for a specified time causes it to repeatedly perform its operation. The auto-repeat terminates when the button is released. Predefined subclasses of Adjuster include \fBZoomer\fP and \fBMover\fP. Zoomers adjust the perspective's \fIcurwidth\fP and \fIcurheight\fP members to suggest magnification. The user clicks on a zoomer to magnify or reduce the contents of the interactor through its perspective. The \fBEnlarger\fP zoomer subclass halves the perspective values while the \fBReducer\fP class doubles them. Movers provide an incremental movement of the perspective in one of four directions; left, right, down, or up. The user clicks on a mover to move the perspective. .SH PUBLIC OPERATIONS .TP .B "Adjuster(Interactor*, int = NO_AUTOREPEAT)" Adjuster constructors take a pointer to the interactor whose perspective will be adjusted and a delay (in tenths of a second) after which auto-repeat will begin once the adjuster is ``pressed''. .TP .B "virtual void Highlight()" .ns .TP .B "virtual void UnHighlight()" These functions define how the adjuster draws itself when it is pressed. The adjuster is highlighted when it is pressed with any mouse button and unhighlighted when the button is released. The default is to invert the adjuster when highlighted. .SH PROTECTED OPERATIONS .TP .B "virtual void AdjustView(Event&)" This function defines how the adjuster adjusts the interactor's perspective. It is called after the adjuster is pressed and released, or repeatedly during auto-repeat. Derived classes should redefine this function to implement the desired behavior. .SH DERIVED CLASSES .TP .B "Enlarger(Interactor*)" .ns .TP .B "Reducer(Interactor*)" Enlargers and reducers adjust an interactor's perspective to enlarge and reduce the visible area by factors of one half and two, respectively. This suggests to an interactor to enlarge or reduce its contents. Auto-repeat is disabled on these adjusters. .TP .B "LeftMover(Interactor*, int delay = NO_AUTOREPEAT)" .ns .TP .B "RightMover(Interactor*, int delay = NO_AUTOREPEAT)" .ns .TP .B "DownMover(Interactor*, int delay = NO_AUTOREPEAT)" .ns .TP .B "UpMover(Interactor*, int delay = NO_AUTOREPEAT)" These subclasses of \fBMover\fP adjust the current origin of the interactor's perspective by an amount in the corresponding direction. If the shift key is down while the mover is pressed, the amount corresponds to the perspective's \fIlx\fP or \fIly\fP member variables; otherwise, the \fIsx\fP or \fIsy\fP values are used. .SH SEE ALSO Interactor(3I), Perspective(3I) ivtools-1.2.11a1/src/man/man3/Banner.3000066400000000000000000000020541214471147700172170ustar00rootroot00000000000000.TH Banner 3I "15 June 1987" "InterViews" "InterViews Reference Manual" .SH NAME Banner \- one line title bar .SH SYNOPSIS .B #include .SH DESCRIPTION A banner is an interactor that draws a one line title bar with optional left-justified, centered, and right-justified headings. The member variable \fIhighlight\fP can be set to cause drawing to be performed with the foreground and background colors reversed. .PP The natural size of a banner depends on the size of its headings. Banners are infinitely stretchable horizontally, but fixed size vertically. .SH PUBLIC OPERATIONS .TP .B "Banner(char* left, char* middle, char* right)" The \fIleft\fP string will be left-justified, the \fImiddle\fP string centered, and \fIright\fP string right-justified in the banner. A header can be omitted by passing a nil string. .TP .B "void Update()" The strings can be set through the \fIleft\fP, \fImiddle\fP, and \fIright\fP member variables. The Update operation should be called after one or more of the strings is changed. .SH SEE ALSO Interactor(3I) ivtools-1.2.11a1/src/man/man3/BasicDialog.3000066400000000000000000000162071214471147700201600ustar00rootroot00000000000000.TH BasicDialog 3U "23 July 1990" "Unidraw" "InterViews Reference Manual" .SH NAME AcknowledgeDialog, BasicDialog, ConfirmDialog, GridDialog, \ PrintDialog, UChooser - an assortment of useful dialog boxes .SH SYNOPSIS .B #include .SH DESCRIPTION BasicDialog is the base class for subclasses that implement simple but common dialog boxes. AcknowledgeDialog simply displays a one or two line message with a PushButton for dismissing the dialog. ConfirmDialog displays one or two lines of descriptive text with three pushbuttons marked ``Yes,'' ``No,'' and ``Cancel'', all of which dismiss the dialog. ConfirmDialog also provides an interface for retrieving the button pushed. GridDialog lets the user specify the resolution of a cartesian grid. PrintDialog is a FileChooser for specifying the name of a file or a printer. Finally, UChooser extends the StringChooser protocol to provide additional useful features, including support for alphabetizing its StringBrowser's contents and for embellishing the dialog with descriptive text. .SH BASICDIALOG PUBLIC OPERATIONS .TP .B "void SetTitle(const char*)" .ns .TP .B "void SetSubtitle(const char*)" BasicDialogs can display one or two lines of descriptive text. These functions change the text appearing in these lines. The change appears immediately if the dialog is visible. .SH BASICDIALOG PROTECTED OPERATIONS .TP .B "BasicDialog(" .ns .TP .B " ButtonState*, const char* title = ``''," .ns .TP .B " const char* subtitle = ``'', Alignment = Center" .ns .TP .B ")" .ns .TP .B "BasicDialog(" .ns .TP .B " const char*, ButtonState*, const char* title = ``''," .ns .TP .B " const char* subtitle = ``'', Alignment = Center" .ns .TP .B ")" .br Instantiate a BasicDialog, supplying an optional instance name, a button state, title and subtitle strings, and the dialog's alignment, which is used by its Popup operation. These operations will initialize two protected MarginFrame member variables, \fI_title\fP and \fI_subtitle\fP, which will contain either a Message instance with the specified string or a piece of glue if the string is null. These MarginFrames will be composed vertically at the top of the dialog, and no vertical space will be taken up by a null title or subtitle string. .TP .B "virtual void Forward(Event&)" .ns .TP .B "boolean IsAChild(Interactor*)" These functions are useful for rejecting spurious events while the dialog is visible, effectively locking out the rest of the application. If Forward's event argument has \fIx\fP and \fIy\fP coordinates that fall within the dialog's canvas, then Forward calls Handle on the event's target. Otherwise the BasicDialog's Handle is called. IsAChild returns true if the given interactor is a child of the dialog. .SH ACKNOWLEDGEDIALOG PUBLIC OPERATIONS .TP .B "AcknowledgeDialog(const char* title, const char* subtitle)" Construct an AcknowledgeDialog instance with the given title and subtitle. .TP .B "virtual void Acknowledge()" Call this function when the application should wait for the user to acknowledge the dialog. It returns when the user has pressed and released the dialog's push button. This function does \fInot\fP pop up the dialog. .SH CONFIRMDIALOG PUBLIC OPERATIONS .TP .B "ConfirmDialog(const char* title, const char* subtitle)" Construct a ConfirmDialog instance with the given title and subtitle. .TP .B "virtual char Confirm()" Call this function when the application should wait for the user to confirm the dialog. It returns 'y', 'n', or '^G' ('\\007'), depending whether the ``Yes,'' ``No,'' or ``Cancel'' push button was pressed, respectively. This function does \fInot\fP pop up the dialog. .SH GRIDDIALOG PUBLIC OPERATIONS .TP .B "GridDialog()" Construct a GridDialog instance. The GridDialog contains a MatchEditor instance for specifying the size of the grid's graduations in the \fIx\fP and \fIy\fP axes. The user can specify these values in pixels, points, centimeters, or inches by clicking on the appropriate radio button. .TP .B "virtual void GetValues(float& xincr, float& yincr)" Return the user-specified values for the size of the grid's graduations, in pixel units. .TP .B "void SelectMessage()" Highlight the values in the dialog's MatchEditor. .SH PRINTDIALOG PUBLIC OPERATIONS .TP .B "PrintDialog(boolean to_printer = true)" Construct a PrintDialog instance, optionally specifying whether the dialog should prompt for a printer name or a file name. .TP .B "void ToPrinter(boolean)" .ns .TP .B "boolean ToPrinter()" Specify and Return whether or not the string specified in the PrintDialog refers to a printer name. .SH UCHOOSER PUBLIC OPERATIONS .TP .B "UChooser(" .ns .TP .B " const char* title, const char* subtitle," .ns .TP .B " const char* acceptLabel, const char* sample" .ns .TP .B ")" .br Construct a UChooser instance. The \fItitle\fP and \fIsubtitle\fP parameters specify the descriptive text at the top of the dialog box. This constructor initializes two protected MarginFrame member variables \fI_title\fP and \fI_subtitle\fP that are analogous to the corresponding BasicDialog members described above. .TP .B "void Clear()" Removes all strings from the UChooser's string browser. .TP .B "void Include(const char*)" .ns .TP .B "void Exclude(const char*)" Include inserts a string into the string browser at a position defined by the UChooser's Position function, described below. Exclude removes the given string from the string browser. If the string browser contains more than one copy of the string, then Exclude removes the one with the smallest index. .TP .B "void SetTitle(const char*)" .ns .TP .B "void SetSubtitle(const char*)" These functions change the text appearing in UChooser's title or subtitle. The change appears immediately if the dialog is visible. .SH UCHOOSER PROTECTED OPERATIONS .TP .B "UChooser(ButtonState*, int rows, int cols, Alignment)" Direct the UChooser to initialize itself with a string browser of the given size \fIwithout\fP initializing the MarginFrame members. Subclasses that require a different look-and-feel can use this constructor to avoid creating MarginFrames or Messages they don't need. The Init, Interior, and AddScroller functions (described below) factor out different parts of the default look and feel, allowing subclasses to use parts of it. .TP .B "void Init(const char* title, const char* subtitle)" Explicitly initialize the MarginFrame members to display the given title and/or subtitle strings. .TP .B "Interactor* Interior(const char* acceptLabel)" Return an interactor that composes the UChooser's default look and feel. .TP .B "Interactor* AddScroller(Interactor*)" Return a composition containing the given interactor with a vertical scroll bar and adjusters along its right side, initializing them to scroll the interactor. The Interior function uses this operation to provide the string browser's scrolling interface. .TP .B "virtual int Position(const char*)" Return an appropriate string browser index for the given string. By default, this function returns the index that will place the string in alphabetical order among those in the string browser. .SH SEE ALSO Button(3I), Dialog(3I), Event(3I), FileChooser(3I), Frame(3I), MatchEditor(3I), Message(3I), StringBrowser(3I), StringChooser(3I), StringEditor(3I) ivtools-1.2.11a1/src/man/man3/Border.3000066400000000000000000000013201214471147700172220ustar00rootroot00000000000000.TH Border 3I "15 June 1987" "InterViews" "InterViews Reference Manual" .SH NAME Border, HBorder, VBorder \- visual separators .SH SYNOPSIS .B #include .SH DESCRIPTION .B Border is the base class for interactors that simply display a line of a given thickness, usually to separate other interactors in a scene. .B HBorder objects have a fixed height and are infinitely stretchable and shrinkable horizontally. .B VBorder objects have a fixed width and are infinitely stretchable and shrinkable vertically. .SH PUBLIC OPERATIONS .TP .B "HBorder(int thickness = 1)" .ns .TP .B "VBorder(int thickness = 1)" Construct a border with a given thickness (default is one pixel). .SH SEE ALSO Interactor(3I) ivtools-1.2.11a1/src/man/man3/Box2_6.3000066400000000000000000000037261214471147700170600ustar00rootroot00000000000000.TH Box 3I "15 June 1987" "InterViews" "InterViews Reference Manual" .SH NAME Box, HBox, VBox \- tile interactors in a box .SH SYNOPSIS .B #include .SH DESCRIPTION A box is a scene of interactors that are tiled side-by-side in the available space. Interactors are placed left-to-right in a horizontal box, and top-to-bottom in a vertical box. .PP A box will try to stretch or shrink the interactors inside it to fit the available space. The natural size of a box is the sum of its elements along the major axis, and the maximum along its minor axis. A box's stretchability (shrinkability) is the sum of its elements along its major axis and the minimum of its elements along its minor axis. .SH PUBLIC OPERATIONS .TP .B "HBox(...)" .ns .TP .B "VBox(...)" Create a new box. Zero to seven interactors may be passed as arguments; the interactors are inserted into the box. .TP .B "void Align(Alignment)" Set the alignment mode that the box uses to place elements along the minor axis. The default alignment for an hbox is \fIBottom\fP; other choices are \fITop\fP and \fICenter\fP. The default alignment for a vbox is \fILeft\fP; other choices are \fIRight\fP and \fICenter\fP. .TP .B "void Insert(Interactor*)" Append an interactor to the box. Components of an hbox (vbox) will appear left-to-right (top-to-bottom) in the order in which they are inserted. .TP .B "void Change(Interactor*)" Notify the box that the given interactor's shape has changed. If change propagation is true, the box will modify its own shape to reflect the change and notify its parent. Regardless of propagation, the box will recompute the positions of the component interactors and update any that have changed. .TP .B "void Remove(Interactor*)" Take an element of out a box. Remove does not cause any immediate change to the other components in the box; the Change operation must be called after one or more Removes to update the component positions. .SH SEE ALSO Glue(3I), Interactor(3I), Scene(3I), Shape(3I) ivtools-1.2.11a1/src/man/man3/BrushCmd.3000066400000000000000000000014211214471147700175160ustar00rootroot00000000000000.TH BrushCmd 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME BrushCmd \- command for setting components' brush attribute .SH SYNOPSIS .B #include .SH DESCRIPTION BrushCmd is a purely interpretive command for setting the brush attribute of selected components. .SH PUBLIC OPERATIONS .TP .B "BrushCmd(ControlInfo*, PSBrush* = nil)" .ns .TP .B "BrushCmd(Editor* = nil, PSBrush* = nil)" Create a BrushCmd, optionally specifying the PSBrush that components should adopt. .TP .B "virtual void Execute()" BrushCmd extends Execute to set the value of the affected editor's BrushVar instance, if it defines one. .TP .B "PSBrush* GetBrush()" Return the PSBrush supplied in the constructor. .SH SEE ALSO Command(3U), pspaint(3U), statevars(3U) ivtools-1.2.11a1/src/man/man3/Button2_6.3000066400000000000000000000117311214471147700175760ustar00rootroot00000000000000.TH Button 3I "15 June 1987" "InterViews" "InterViews Reference Manual" .SH NAME ButtonState, Button, TextButton, PushButton, RadioButton, CheckBox \- interactive buttons .SH SYNOPSIS .B #include .SH DESCRIPTION .B Button is a class of interactors that can set the value of a piece of state. .B ButtonState is a class of objects that contain a value and a list of buttons that can set its value. A value is either an integer or an arbitrary pointer. .PP .B TextButton is a subclass of .B Button that has an associated text label to be displayed inside or to the right of the button. .B PushButton, .B RadioButton, and .B CheckBox are subclasses of .B TextButton that provide particular displays for buttons. Each kind of button will display itself differently for each of the five possible cases: ``enabled'', when the button is listening to input, ``disabled'', when the button is not listening, ``chosen'', when the button's value is equal to its button state's value, ``hit'', when a button that is not chosen first receives a DownEvent, and ``same-hit'', when a button that is chosen receives a DownEvent. .PP When a button receives a DownEvent, it calls the virtual Refresh() to update its display. It then reads input waiting for an UpEvent. If the UpEvent coordinates are also within the button, then it calls the virtual Press(). The default Press operation sets the associated state's value to the button's value. .PP A button can have a list of attached buttons. When a button is not chosen its attached buttons are ``disabled'', meaning they ignore all input events. .SH BUTTONSTATE OPERATIONS .TP .B "ButtonState()" .ns .TP .B "ButtonState(int)" .ns .TP .B "ButtonState(void*)" Define a button state optionally with an initial value. .TP .B "void Attach(Button*)" Add a button to the list associated with a button state. The button will be notified when the button state's value is modified. .TP .B "void Detach(Button*)" Remove a button from the list associated with a button state. .TP .B "void GetValue(int&)" .ns .TP .B "void GetValue(void*&)" Get the value of a button. .TP .B "void SetValue(int)" .ns .TP .B "void SetValue(void*)" Set the value of a button state and notify all the buttons associated with the state. .TP .B "void operator=(ButtonState&)" Copy the value of one button state to another. The button list associated with the source button state is not copied. .SH BUTTON OPERATIONS .TP .B "void PushButton(const char* text, ButtonState* s, int v)" .ns .TP .B "void PushButton(const char* text, ButtonState* s, void* v)" Construct a button with \fItext\fP in the center and a polygon on the outside. The polygon is like a rectangle, but with rounded corners. When chosen, the entire button is drawn with foreground and background colors reversed. .TP .B "void RadioButton(const char* text, ButtonState* s, int v)" .ns .TP .B "void RadioButton(const char* text, ButtonState* s, void* v)" Construct a button with a circle on the left and \fItext\fP on the right. When hit, a second circle is drawn inside the first. When chosen, a filled circle is drawn inside the outer circle. .TP .B "void CheckBox(const char* text, ButtonState* s, int on, int off)" .ns .TP .B "void CheckBox(const char* text, ButtonState* s, void* on, void* off)" Construct a button with a rectangle on the left and \fItext\fP on the right. When hit, a second rectangle is drawn inside the first. When chosen, two diagonal lines are drawn connecting the opposite corners of the rectangle. When a checkbox is pressed the first time, it sets \fIs\fP to \fIoff\fP if the value is \fIon\fP and sets \fIs\fP to \fIon\fP otherwise. Subsequent presses swap the values of the checkbox and \fIs\fP. .TP .B "void Attach(Button*)" Add to this button's list of associated buttons. These buttons are enabled when the button is chosen and disabled when it is not chosen. .TP .B "void Detach(Button*)" Remove a button from this button's list of associated buttons. .TP .B "void Disable()" Stop listening to input events. Disabled buttons are typically ``grayed out'' by drawing a half-filled rectangle in the background. .TP .B "void Enable()" Start listening to input events. .TP .B "void Choose()" Make the button as chosen, enabling any associated buttons. .TP .B "void Handle(Event&)" If the event type is DownEvent and the button is enabled, call Refresh and read events until an UpEvent occurs. If the button is the target of the UpEvent, then call Press. .TP .B "virtual void Press()" Take the appropriate action for the button being pressed. The default is to set the associated state to the button's value, which will trigger all related buttons to update their display. .TP .B "virtual void Refresh()" Update the button display. .TP .B "void SetDimensions(int width, int height)" Specify the natural size of the button. The default size is a function of the size of the text. This routine is obsolete; use Interactor::Reshape instead. .TP .B "void UnChoose()" Mark the button as not chosen, disabling any associated buttons. .SH SEE ALSO Event(3I), Interactor(3I) ivtools-1.2.11a1/src/man/man3/CGlue.3000066400000000000000000000040641214471147700170140ustar00rootroot00000000000000.TH CGlue 3U "23 November 1990" "Unidraw" "InterViews Reference Manual" .SH NAME CGlue \- connector glue .SH SYNOPSIS .B #include .SH DESCRIPTION CGlue defines a natural size, elasticity (its rate of stretching and shrinking relative to other CGlue), and deformation limits (total amount it can stretch and shrink) in both the horizontal and vertical dimensions. CGlue can be interposed between two connected connectors to augment their connectivity semantics; it acts like two non-linear springs, one horizontal and one vertical, connecting the connectors' centers. .SH PUBLIC OPERATIONS .TP .B "CGlue(" .ns .TP .B " float hnat = 0, float vnat = 0," .ns .TP .B " float hshr = 0, float hstr = 0," .ns .TP .B " float vshr = 0, float vstr = 0," .ns .TP .B " float hshrlim = 0, float hstrlim = 0," .ns .TP .B " float vshrlim = 0, float vstrlim = 0" .ns .TP .B ")" .ns .TP .B "CGlue(const Shape&)" Instantiate CGlue, providing the requisite parameters explicitly or inferring them from a Shape object. If a shape is supplied, then the CGlue adopts the shape's natural size, and it assigns the shape's stretchability and shrinkability values to its corresponding CGlue elasticity members to obtain a proportionately equivalent elasticity. It also assigns the shape's stretchability and shrinkability values to its deformation limit members. The parameters are described below: \fIhnat, vnat\fP: horizontal and vertical natural sizes, screen units \fIhshr, vshr\fP: horizontal and vertical shrinking rate, constant units \fIhstr, vstr\fP: horizontal and vertical stretching rate, constant units \fIhshrlim, vshrlim\fP: horizontal and vertical shrink limit, screen units \fIhstrlim, vstrlim\fP: horizontal and vertical stretch limit, screen units .TP .B "CGlue* Copy()" Create a copy of this CGlue instance. .TP .B "void Rigid()" Set all elasticity and deformation limits equal to zero. .TP .B "void Interpose(const CGlue* glue)" Change this instance's attributes to reflect the series combination of \fIthis\fP and \fIglue\fP. .SH SEE ALSO Connector(3U), Shape(3I) ivtools-1.2.11a1/src/man/man3/CSolver.3000066400000000000000000000067271214471147700174020ustar00rootroot00000000000000.TH CSolver 3U "20 November 1990" "Unidraw" "InterViews Reference Manual" .SH NAME CSolver \- enforces connector semantics .SH SYNOPSIS .B #include .SH DESCRIPTION A CSolver object defines and implements a model for specifying connectivity semantics that connector subclasses can build upon to implement their specialized semantics. Normally, only one CSolver instance is used per application, and only connector subclasses need access it. The Unidraw class constructor initializes the \fIcsolver\fP global to point to a CSolver instance it creates. Thus applications should not instantiate CSolver directly. CSolver models a connection between two connectors (regardless of their particular subclass or semantics) as a pair of generic connectors with a piece of CGlue interposed. The CGlue characterizes the relationship between the connectors' centers in terms of a natural size (which corresponds to the distance between the centers), elasticity, and deformation limits. Connector subclasses specify their connectivity behavior with a CGlue instance and subsequently rely on the CSolver to reorient them to conform to that behavior. For example, when a pin is told to connect itself to another pin, it registers with the global csolver a connection containing the two connectors (the pins themselves) and a piece of CGlue having zero natural size, elasticity, and deformation limits. This specification effectively constrains the connectors' centers to coincide. The connectivity semantics of other connector combinations, including those involving application-specific connectors, must be specified using CGlue. .SH PUBLIC OPERATIONS .TP .B "CSolver()" Create a new instance. Application programs do not normally instantiate CSolver explicitly. .TP .B "virtual void Connect(Connector*, Connector*, CGlue* = nil)" Specify a connection between two connectors, optionally with a piece of CGlue interposed. Omitting the CGlue parameter is equivalent to specifying a connection with CGlue having zero natural size, elasticity, and deformation limits. .TP .B "void Disconnect(Connector*, Connector*)" .ns .TP .B "void Disconnect(Connector*)" Destroy the connection(s) established between two connectors (the two-parameter form), or destroy all connections to a given connector (the one-parameter form). .TP .B "void Solve()" Solve instructs the CSolver to reorient connected connectors to conform to their connectivity semantics as reflected by its connection specifications. Normally this function is called automatically and only in response to Unidraw::Update. .TP .B "CSolverState* GetState(Connector*)" .ns .TP .B "void SetState(CSolverState*)" CSolverState is a class that encapsulates all the information about the connections in which a connector participates. Only CSolver can create or do anything with a CSolverState instance. GetState initializes and returns a CSolverState instance for the given connector, and SetState establishes the connections that a CSolverState instance specifies without disturbing existing connections. These operations are useful when it is necessary to reestablish a connector's connections after they have been lost, for example, by removing the connector from the component hierarchy (as caused by a command to delete the component). .TP .B "void Read(istream&)" .ns .TP .B "void Write(ostream&)" Explicitly read/write the csolver's contents from/to disk. Normally only a catalog calls these operations. .SH SEE ALSO Catalog(3U), GGlue(3U), Connector(3U), globals(3U) ivtools-1.2.11a1/src/man/man3/Catalog.3000066400000000000000000000277551214471147700174030ustar00rootroot00000000000000.TH Catalog 3U "11 June 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Catalog \- stores and retrieves named objects .SH SYNOPSIS .B #include .SH DESCRIPTION A catalog provides independent name-to-object mappings for component subjects, commands, tools, and editor info objects. Once named, an object can be retrieved later, even if the application has been exited and restarted. The catalog thus provides a means for saving objects in non-volatile form for subsequent retrieval. .SH PUBLIC OPERATIONS .TP .B "Catalog(const char* domainName, Creator*, float version)" Construct a catalog, supplying an application-unique domain name, a creator object, and a version number. Unidraw objects may use the domain name for file type checking purposes, and they may rely on the version number to handle evolving storage formats. .TP .B "virtual boolean Save(EditorInfo*, const char*)" .ns .TP .B "virtual boolean Save(Component*, const char*)" .ns .TP .B "virtual boolean Save(Command*, const char*)" .ns .TP .B "virtual boolean Save(Tool*, const char*)" Save an object instance under the specified name. The catalog stores a textual representation for the object in a file with the given name; therefore a name with embedded slashes corresponds to the path name for the file containing the textual representation. These operations return \fIfalse\fP if the file could not be written. .TP .B "virtual boolean Retrieve(const char*, EditorInfo*&)" .ns .TP .B "virtual boolean Retrieve(const char*, Component*&)" .ns .TP .B "virtual boolean Retrieve(const char*, Command*&)" .ns .TP .B "virtual boolean Retrieve(const char*, Tool*&)" Retrieve an object instance having the specified name. The catalog reconstructs an instance of the object from the corresponding file when the instance is first retrieved. Subsequent retrievals with the same name return a reference to the instance already in memory. These operations return \fIfalse\fP if the instance could not be reconstructed from the file. .TP .B "virtual void Forget(EditorInfo*, const char* = nil)" .ns .TP .B "virtual void Forget(Component*, const char* = nil)" .ns .TP .B "virtual void Forget(Command*, const char* = nil)" .ns .TP .B "virtual void Forget(Tool*, const char* = nil)" Forget the name-to-object mapping for the given instance. If the optional string is supplied, the catalog forgets a specific name-to-object mapping, which is useful when an instance has been saved under different names. .TP .B "virtual const char* GetName(EditorInfo*)" .ns .TP .B "virtual const char* GetName(Component*)" .ns .TP .B "virtual const char* GetName(Command*)" .ns .TP .B "virtual const char* GetName(Tool*)" Get a name associated with an instance. These operations do not specify which name is returned for instances that have been saved under more than one name. .TP .B "virtual boolean Valid(const char*, EditorInfo*&)" .ns .TP .B "virtual boolean Valid(const char*, Component*&)" .ns .TP .B "virtual boolean Valid(const char*, Command*&)" .ns .TP .B "virtual boolean Valid(const char*, Tool*&)" Return whether the given name has an instance already associated with it (i.e., it has been saved or retrieved) and if so return that instance in the second parameter. .TP .B "virtual Component* Copy(Component*)" .ns .TP .B "virtual Command* Copy(Command*)" .ns .TP .B "virtual Tool* Copy(Tool*)" Copy an instance by saving it under a temporary name, then retrieving it, and finally forgetting the temporary name. A component, command, or tools subclass can use the corresponding function to implement their Copy function easily, possibly at the expense of run-time performance. .TP .B "virtual boolean Exists(const char*)" Return whether a file with the given name exists. A return value of \fItrue\fP does not necessarily mean that an object has been saved under the specified name. .TP .B "virtual boolean Writable(const char*)" Return whether it is permitted to save an object under the given name. .TP .B "void SetClipboard(Clipboard*)" .ns .TP .B "Clipboard* GetClipboard()" Set or get a globally-accessible clipboard object. .TP .B "void SetEditorInfo(EditorInfo*)" .ns .TP .B "EditorInfo* GetEditorInfo()" Set or get a globally-accessible editor info object. .TP .B "const char* GetName()" .ns .TP .B "Creator* GetCreator()" .ns .TP .B "float GetVersion()" Return the values of constructor-specified parameters. .TP .B "float FileVersion()" Return the Unidraw version number of the file being read currently. .TP .B "const char* GetAttribute(const char*)" Return the value of a user preference with the given name as stored in the global PropertySheet. This operation is equivalent to the World operation of the same name. .TP .B "void WriteVersion(int, ostream&)" .ns .TP .B "void WriteClassId(ClassId, ostream&, int id = 0)" .ns .TP .B "void WriteComponent(Component*, ostream&)" .ns .TP .B "void WriteCommand(Command*, ostream&)" .ns .TP .B "void WriteTool(Tool*, ostream&)" .ns .TP .B "void WriteStateVar(StateVar*, ostream&)" .ns .TP .B "void WriteTransferFunct(TransferFunct*, ostream&)" .ns .TP .B "void WriteBgFilled(boolean, ostream&)" .ns .TP .B "void WriteBrush(PSBrush*, ostream&)" .ns .TP .B "void WriteColor(PSColor*, ostream&)" .ns .TP .B "void WriteFont(PSFont*, ostream&)" .ns .TP .B "void WritePattern(PSPattern*, ostream&)" .ns .TP .B "void WriteTransformer(Transformer*, ostream&)" .ns .TP .B "void WriteString(const char*, ostream&)" .ns .TP .B "void WriteControlInfo(ControlInfo*, ostream&)" .ns .TP .B "void WriteEditorInfo(EditorInfo*, ostream&)" .ns .TP .B "void WriteBitmap(Bitmap*, ostream&)" .ns .TP .B "void WriteBitmapData(Bitmap*, ostream&)" .ns .TP .B "void WriteGraymap(Raster*, ostream&)" .ns .TP .B "void WriteGraymapData(Raster*, ostream&)" .ns .TP .B "void WriteRaster(Raster*, ostream&)" .ns .TP .B "void WriteRasterData(Raster*, ostream&)" .TP .B "int ReadVersion(istream&)" .ns .TP .B "ClassId ReadClassId(istream&, int& id)" .ns .TP .B "Component* ReadComponent(istream&)" .ns .TP .B "Command* ReadCommand(istream&)" .ns .TP .B "Tool* ReadTool(istream&)" .ns .TP .B "StateVar* ReadStateVar(istream&)" .ns .TP .B "TransferFunct* ReadTransferFunct(istream&)" .ns .TP .B "int ReadBgFilled(istream&)" .ns .TP .B "PSBrush* ReadBrush(istream&)" .ns .TP .B "PSColor* ReadColor(istream&)" .ns .TP .B "PSFont* ReadFont(istream&)" .ns .TP .B "PSPattern* ReadPattern(istream&)" .ns .TP .B "Transformer* ReadTransformer(istream&)" .ns .TP .B "char* ReadString(istream&)" .ns .TP .B "ControlInfo* ReadControlInfo(istream&)" .ns .TP .B "EditorInfo* ReadEditorInfo(istream&)" .ns .TP .B "Bitmap* ReadBitmap(istream&)" .ns .TP .B "Bitmap* ReadBitmapData(istream&)" .ns .TP .B "Raster* ReadGraymap(istream&)" .ns .TP .B "Raster* ReadGraymapData(istream&)" .ns .TP .B "Raster* ReadRaster(istream&)" .ns .TP .B "Raster* ReadRasterData(istream&)" Write and read information via streams. Catalog-managed classes use these operations in their Write and Read functions to write and read the objects they contain. The operations for writing and reading bitmaps and rasters have accompanying operations that write and read only the ASCII data (i.e., omitting transformation and other Unidraw format-specific data) that encodes their information content. .TP .B "PSBrush* ReadBrush(const char* definition, int index)" .ns .TP .B "PSColor* ReadColor(const char* definition, int index)" .ns .TP .B "PSFont* ReadFont(const char* definition, int index)" .ns .TP .B "PSPattern* ReadPattern(const char*, int index)" Return a PostScript paint object corresponding to the value of a user preference with the given definition and index number as stored in the global PropertySheet. Each string in the X defaults database of the form ``.resource:definition'' sets a resource. The resource names and their definitions are specified as follows: .sp .BI brush i: Define the \fIi\fPth brush resource. The ReadBrush operation retrieves the brush object for this resource given a definition. The definition usually specifies two numbers: a 16-bit hexadecimal number to define the brush's line style (each 1 bit draws a dash and each 0 bit produces a gap), and a decimal integer to define the brush's width in pixels. For example, ``ffff 1'' defines a single pixel wide solid line. If the definition specifies only the string ``none'', then it defines the nonexistent brush. .sp .BI fgcolor i: Define the \fIi\fPth foreground color resource. The ReadColor operation retrieves the color object for this resource given a definition. The definition contains a string defining the name of the color, optionally followed by three decimal numbers between 0 and 65535 to define the red, green, and blue components of the color's intensity. The intensities override the name; that is, the catalog will look the name up in the database of common colors only if you omit the intensities. For example, ``Indigo 48896 0 65280'' defines a color which is a mixture of red and blue. You can define shades of gray by using equal proportions of each primary color. .sp .BI bgcolor i: The background color resource definition is specified in the same manner as the foreground color. .sp .BI font i: Define the \fIi\fPth font resource. The ReadFont operation retrieves the font object for this resource given a definition. The definition contains three strings separated by whitespace. The first string defines the font's name, the second string the corresponding print font, and the third string the print size. For example, ``8x13bold Courier-Bold 13'' defines the third font entry. .sp .BI pattern i: Define the \fIi\fPth pattern resource. The ReadPattern operation retrieves the pattern object for this resource given a definition. The definition can specify the pattern for a 16x16 bitmap, a 8x8 bitmap, a 4x4 bitmap, a grayscale number, or the string ``none''. You specify the 16x16 bitmap with sixteen 16-bit hexadecimal numbers, the 8x8 bitmap with eight 8-bit hexadecimal numbers, the 4x4 bitmap with a single 16-bit hexadecimal number, and the grayscale number with a single floating point number. The floating point number must contain a period to distinguish itself from the single hexadecimal number, and it must lie between 0.0 and 1.0, where 0.0 corresponds to a solid pattern and 1.0 to a clear pattern. On the printer, the bitmap patterns appear as bitmaps, the grayscale patterns appear as halftoned shades, and the ``none'' patterns never obscure underlying graphics. For example, ``pattern8:8421'' defines a diagonally hatched pattern. .PP .TP .B "PSBrush* FindNoneBrush()" .ns .TP .B "PSBrush* FindBrush(int, int)" .ns .TP .B "PSColor* FindColor(const char*, int = 0, int = 0, int = 0)" .ns .TP .B "PSFont* FindFont(const char*, const char*, const char*)" .ns .TP .B "PSPattern* FindNonePattern()" .ns .TP .B "PSPattern* FindGrayLevel(float)" .ns .TP .B "PSPattern* FindPattern(int[], int)" Return a PostScript paint object with the corresponding attributes. These operations return a new paint object if no object with the given attributes already exists; otherwise the operations return an existing instance with matching attributes. .TP .B "void Skip(istream&)" .ns .TP .B "void Mark(ostream&)" Mark injects a synchronization sequence defined by MARK (see globals(3U)) into the output stream. Skip searches for the same sequence in the given input stream and position the stream immediately after that sequence. .SH PROTECTED OPERATIONS .TP .B "void Register(EditorInfo*, const char*)" .ns .TP .B "void Register(Component*, const char*)" .ns .TP .B "void Register(Command*, const char*)" .ns .TP .B "void Register(Tool*, const char*)" Register an object under a particular name in the catalog's internal maps. Objects are normally registered automatically when they are stored or retrieved. .TP .B "int GetToken(istream&, char* buf, int buf_size)" Search an input stream for a sequence of characters defined in the buffer \fIbuf\fP of size \fIbuf_size\fP. GetToken returns the number of characters matched. .SH SEE ALSO Clipboard(3U), Command(3U), Component(3U), ControlInfo(3U), Creator(3U), EditorInfo(3U), Graphic(3U), PropertySheet(3I), StateVar(3U), Tool(3U), TransferFunct(3U), World(3I), globals(3U), istream(3C++), ostream(3C++) ivtools-1.2.11a1/src/man/man3/Clipboard.3000066400000000000000000000067701214471147700177220ustar00rootroot00000000000000.TH Clipboard 3U "12 June 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Clipboard \- manages a list of graphical component subjects .SH SYNOPSIS .B #include .SH DESCRIPTION A Clipboard maintains a list of GraphicComp objects and provides operations for manipulating the list. Catalog and Command classes use clipboards to store graphical components they affect. .SH PUBLIC OPERATIONS .TP .B "Clipboard(GraphicComp* = nil)" Construct a new clipboard object, optionally with a GraphicComp that should appear initially on the list. .TP .B "virtual ~Clipboard()" Delete the clipboard. Deleting the clipboard does \fInot\fP delete the GraphicComp objects it contains. .TP .B "void Init(Selection*)" .ns .TP .B "void CopyInit(Selection*)" Init initializes the clipboard with the subjects belonging to the graphical views in the given selection object. CopyInit initializes it with \fIcopies\fP of the subjects. .TP .B "void Clear()" Remove all GraphicComp objects from the clipboard. The objects are not deleted. .TP .B "void DeleteComps()" Delete each GraphicComp in the clipboard. This operation does \fInot\fP delete the list itself; thus it will still be possible to iterate through the list afterwards. DeleteComps is generally called just before the clipboard is destroyed. .TP .B "void Append(GraphicComp*)" .ns .TP .B "void Prepend(GraphicComp*)" .ns .TP .B "void InsertAfter(Iterator, GraphicComp*)" .ns .TP .B "void InsertBefore(Iterator, GraphicComp*)" .ns .TP .B "void Remove(GraphicComp*)" .ns .TP .B "void Remove(Iterator&)" Operations for adding and removing GraphicComp objects from the clipboard. InsertAfter and InsertBefore take an iterator that specifies the point before or after which the given GraphicComp should be inserted. Remove(Iterator&) removes the GraphicComp to which the iterator refers and increments the iterator to point to the following GraphicComp. .TP .B "GraphicComp* GetComp(Iterator)" .ns .TP .B "void SetComp(GraphicComp*, Iterator&)" GetComp effectively dereferences an iterator, returning the GraphicComp to which it points. SetComp initializes an iterator to point to the given GraphicComp object, assuming the object is in the clipboard. .TP .B "void First(Iterator&)" .ns .TP .B "void Last(Iterator&)" .ns .TP .B "void Next(Iterator&)" .ns .TP .B "void Prev(Iterator&)" .ns .TP .B "boolean Done(Iterator&)" Operations for iterating through the GraphicComps in the clipboard. First and Last modify the iterator to point to the first and last GraphicComp objects. Next and Prev make the iterator point to the succeeding and preceding GraphicComp objects. Done returns whether the iterator points to the sentinel object on the list, which marks the beginning and the end of list. .TP .B "boolean IsEmpty()" .ns .TP .B "boolean Includes(GraphicComp*)" Return whether or not the clipboard is empty or whether it includes the given GraphicComp object. .TP .B "virtual Clipboard* Copy()" .ns .TP .B "virtual Clipboard* DeepCopy()" Copy creates a new clipboard with a list of the same GraphicComp objects as \fIthis\fP. DeepCopy creates a new clipboard containing copies of the objects in \fIthis\fP. .SH PROTECTED OPERATIONS .TP .B "UList* Elem(Iterator)" .ns .TP .B "GraphicComp* Comp(UList*)" The Clipboard class stores its GraphicComp objects in a UList. These convenience functions convert an iterator into a UList element and dereference a UList element to obtain a GraphicComp object, respectively. .SH SEE ALSO Catalog(3U), Command(3U), GraphicComp(3U), Iterator(3U), Selection(3U), UList(3U) ivtools-1.2.11a1/src/man/man3/ColorCmd.3000066400000000000000000000016551214471147700175220ustar00rootroot00000000000000.TH ColorCmd 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME ColorCmd \- command for setting components' color attributes .SH SYNOPSIS .B #include .SH DESCRIPTION ColorCmd is a purely interpretive command for setting the foreground and background color attributes of selected components. .SH PUBLIC OPERATIONS .TP .B "ColorCmd(ControlInfo*, PSColor* fg = nil, PSColor* bg = nil)" .ns .TP .B "ColorCmd(Editor* = nil, PSColor* fg = nil, PSColor* bg = nil)" Create a ColorCmd, optionally specifying the foreground (\fIfg\fP) and background (\fIbg\fP) PSColors that components should adopt. .TP .B "virtual void Execute()" ColorCmd extends Execute to set the value of the affected editor's ColorVar instance, if it defines one. .TP .B "PSColor* GetFgColor()" .ns .TP .B "PSColor* GetBgColor()" Return the PSColors supplied in the constructor. .SH SEE ALSO Command(3U), pspaint(3U), statevars(3U) ivtools-1.2.11a1/src/man/man3/Command.3000066400000000000000000000217131214471147700173730ustar00rootroot00000000000000.TH Command 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME Command \- base class for command objects .SH SYNOPSIS .B #include .SH DESCRIPTION Command is an abstract base class for objects that define operations on components and other objects. Commands are similar to messages in traditional object-oriented systems in that components can receive and respond to them. Commands can also be executed in isolation to perform arbitrary computation, and they can reverse the effects of such execution to support undo. .sp Some commands (termed \fIpurely interpretive\fP commands) are interpreted by components but never executed in isolation, some are executed but never interpreted (\fInon-interpretive\fP commands), and some are used in both ways. Some commands may be directly accessible to the user through menus, while others are internal to the application. In general, an undoable operation should be carried out by a command object. .SH PUBLIC OPERATIONS .TP .B "virtual void Execute()" .ns .TP .B "virtual void Unexecute()" .ns .TP .B "virtual boolean Reversible()" Execute performs computation to carry out the command's semantics. Unexecute performs computation to reverse the effects of a previous Execute, based on whatever internal state the command maintains. A command is responsible for maintaining enough state to reverse one Execute operation; repeated Unexecute operations will not undo the effects of more than one Execute. .sp By default, Execute examines the current selection maintained in the command's editor (see below). Execute will do nothing if the nothing is selected and the command's clipboard (see below) is empty or non-existent. Otherwise, if something is selected and the command's clipboard is non-existent, then Execute creates a clipboard containing the selected component subjects. Finally, Execute will tell each component on the command's clipboard to interpret \fIthis\fP. Conversely, Unexecute tells each component on the clipboard (if any) to Uninterpret \fIthis\fP this. Thus, commands are purely interpretive by default. .sp It may not be meaningful or appropriate, however, for some commands to reverse their effect. For example, it is probably not feasible to undo a command that generates an external representation. The Reversible operation returns whether or not the command is unexecutable and uninterpretable. If the command is irreversible, then it is ignored during the undo process. By default, Reversible examines the command's clipboard; if the command doesn't have one, then the command is reversible if the user has at least one component view selected. If the command has a non-empty clipboard, then it is deemed reversible. Subclasses may redefine Reversible to base the command's reversibility on their own criteria. .TP .B "virtual void Store(Component*, Data* = nil)" .ns .TP .B "virtual Data* Recall(Component*)" Since a command can affect more than one component, commands must let components that interpret them store undo information somewhere. The commands must also let components recall the information during uninterpretation. Store lets a component store a Data object in the command itself as part of the component's interpretation process. The component can later retrieve the data with the Recall operation. Store and Recall require a Component argument to distinguish requests from potentially many components. .TP .B "virtual void Log()" A convenience function for calling the equivalent function on the global unidraw object. .TP .B "virtual void SetControlInfo(ControlInfo*)" .ns .TP .B "virtual void SetEditor(Editor*)" .ns .TP .B "virtual void SetClipboard(Clipboard*)" .TP .B "virtual ControlInfo* GetControlInfo()" .ns .TP .B "virtual Editor* GetEditor()" .ns .TP .B "virtual Clipboard* GetClipboard()" Operations for setting and getting constructor-specified state stored in the command. Commands use a ControlInfo object to store information from which to build a user interface for executing the command. Commands keep a pointer to the Editor instance they potentially affect. Finally, a command uses a clipboard to store the components it affects or affected. A clipboard containing the components to be affected can be supplied in the constructor, but more often the command itself creates and primes a clipboard based on the editor's selected components. The Set... operations do \fInot\fP delete the object being replaced. .TP .B "virtual void First(Iterator&)" .ns .TP .B "virtual void Last(Iterator&)" .ns .TP .B "virtual void Next(Iterator&)" .ns .TP .B "virtual void Prev(Iterator&)" .ns .TP .B "virtual boolean Done(Iterator)" Operations for iterating over the command's children, if any. These operations do nothing by default. Commands that compose other commands should redefine these operations to permit traversal of their children. First and Last initialize an iterator to point to the beginning and end of the list of children, respectively. Next increments the iterator to point to the following child, while Prev decrements the iterator to point to the preceding child. Done returns whether or not the iterator points beyond the first or last child in the list. .TP .B "virtual Component* Copy()" Return a copy of the command. Subclasses should redefine this operation to return an instance of their type. .TP .B "virtual void Read(istream&)" .ns .TP .B "virtual void Write(ostream&)" Read and write the command's contents to a stream to support catalog operations. Read and write typically call first the corresponding operations defined by their parent class, and then they read or write their class-specific state. Note that you must ensure that the objects are read in the same order they are written. .TP .B "virtual ClassId GetClassId()" .ns .TP .B "virtual boolean IsA(ClassId)" GetClassId returns the unique class identifier for the Command subclass, while IsA returns whether the instance is of a class or subclass corresponding to the given identifier. IsA typically checks the given identifier against the instance's own (as defined by its GetClassId operation) and, failing that, calls its parent classes' IsA operation. All subclasses must redefine GetClassId and IsA to ensure that their identifiers are unique and that instances are written and read properly. .TP .B "virtual ClassId GetSubstId(const char*& delim)" A Command subclasses can redefine GetSubstId to specify a command that can substitute for it. This lets applications that do not define a particular command subclass still read in a substitute that is compatible with the subclass. The substitute class should be one of the predefined commands in the Unidraw library. This guarantees that all applications can instantiate the substitute. GetSubstId returns the class identifier for the substitute. When an another Unidraw application's catalog reads this object, it can create an instance of the substitute (which it is guaranteed to define) instead of the original (which it may not define). The original should read and write a superset of the substitute's data. The catalog will read to the end of the substitute's data and then advance the stream to the point following the sequence of characters specified by \fIdelim\fP, saving the extra characters between the two points in the stream. When the substitute object is saved subsequently, the original class identifier will be written along with the substitute's data plus the extra characters saved previously. Thus information needn't be lost as a result of being read and written by an unsophisticated application. .SH PROTECTED OPERATIONS .TP .B "Command(ControlInfo*, Clipboard* = nil)" .ns .TP .B "Command(Editor* = nil, Clipboard* = nil)" The constructors are protected to prevent instatiation of the abstract base class. You can supply a ControlInfo or Editor and an optional clipboard. Only commands that will be accessible to the user need a ControlInfo object. All commands should be given an editor object before they are used. .TP .B "void InitCopy(Command*)" .ns .TP .B "ControlInfo* CopyControlInfo()" .ns .TP .B "Clipboard* CopyClipboard()" .ns .TP .B "Clipboard* DeepCopyClipboard()" Convenience functions for use by subclasses in their Copy operation. InitCopy gives \fIthis\fP a copy of the given command's editor, clipboard, and interpretation data stored by the components that interpreted it, if any. CopyControlInfo and CopyClipboard return copies of the command's ControlInfo and Clipboard objects, respectively, if they are non-nil. Both CopyControlInfo and CopyClipboard simply check for a nil argument before calling the corresponding Copy operations on the objects. DeepCopyClipboard checks for a nil clipboard before calling DeepCopy on the command's clipboard and returning the result. .TP .B "GraphicComp* GetGraphicComp()" A convenience function that returns the GraphicComp in the editor that the command affects. .SH SEE ALSO Catalog(3U), Clipboard(3U), ControlInfo(3U), Data(3U), Editor(3U), GraphicComp(3U), Iterator(3U), Unidraw(3U), classes(3U), globals(3U), istream(3C++), ostream(3C++) ivtools-1.2.11a1/src/man/man3/CompletionEditor.3000066400000000000000000000032521214471147700212730ustar00rootroot00000000000000.TH MatchEditor 3I "13 Dec 1989" "InterViews" "InterViews Reference Manual" .SH NAME MatchEditor \- StringEditor with string completion .SH SYNOPSIS .B #include .SH DESCRIPTION CompletionEditor is a StringEditor subclass with the added ability to complete the current contents of the edit buffer against a specified set of strings. A CompletionEditor is often useful when a user must specify a selection from a large set of well-known strings--the user need only type the first few characters of the string; he types the completion character to fill out the remainder. .PP When the user types the completion character, CompletionEditor checks the current string against the list of possible completions. If the current string is a prefix of one or more completion strings, characters are appended so that the edit string contains the longest common prefix; if the current string does not match any completion string, trailing characters are removed until the string matches at least one completion. In any case, if there is more than one possible completion of a string, CompletionEditor rings the workstation bell. .SH PUBLIC OPERATIONS .TP .B "CompletionEditor(ButtonState*, const char* sample, const char* done)" Create a new CompletionEditor object. The ButtonState, sample string, and termination string are passed to the StringEditor constructor. .TP .B "void Completions(const char* completions[], int count, char complete)" Specify the list of completion strings and the completion character. The initial completion list is empty, and the completion character defaults to a space. CompletionEditor does not copy the strings in the list. .SH SEE ALSO StringEditor(3I) ivtools-1.2.11a1/src/man/man3/Component.3000066400000000000000000000161321214471147700177560ustar00rootroot00000000000000.TH Component 3U "20 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Component \- base class for objects that model domain-specific elements .SH SYNOPSIS .B #include .SH DESCRIPTION Component is an abstract base class for objects that are created, edited, and composed to form domain-specific drawings. Components represent the objects of interest in an editing domain, encapsulating their appearance and semantics. Components are partitioned into a subject and zero or more views: the subject encapsulates the context-independent state and operations of a component, and each view supports a context-dependent presentation of the subject. A subject notifies its views whenever its state is modified to allow them to change their state or appearance to reflect the modification. The Component class defines the protocol for component subjects, while ComponentView is the abstract base class defining the protocol for component views. See ComponentView(3U) for more information on the component view class. .SH PUBLIC OPERATIONS .TP .B "virtual void Interpret(Command*)" .ns .TP .B "virtual void Uninterpret(Command*)" Interpret performs a component-specific operation based on the type of command passed. Uninterpret reverses the effects of a preceding Interpret. The component is responsible for storing enough state (either in itself or in the command) to carry out the Uninterpret operation. .TP .B "virtual void Attach(ComponentView*)" .ns .TP .B "virtual void Detach(ComponentView*)" Attach adds a component view to the component's list of views. Note that by default these operations do not check to ensure that the view is compatible with the subject. Detach removes the argument from the component's list of views. .TP .B "virtual void Notify()" Notify the component's views that its state has changed. This operation calls Update on each view in the component's list of attached views. .TP .B "virtual void Update()" Other classes may use this operation to notify the component subject of a possible change in state that the component depends upon. This operation does nothing by default. .TP .B "virtual Component* GetParent()" .ns .TP .B "virtual TransferFunct* GetTransferFunct()" Return the component's parent and transfer function, if any. These operations return nil by default. .TP .B "virtual Component* GetRoot()" Return the root component in this hierarchy. GetRoot calls GetParent recursively and returns the last non-nil parent, if any. .TP .B "virtual StateVar* GetState(const char*)" The component may maintain a string-to-state variable mapping to provide external access to any state variables it defines. The GetState operation returns a state variable given an identifying string. Defining such a mapping lets other objects (typically commands) query the component for state variables that it may define without extending the component protocol, potentially allowing interchange of components from different applications. This operation returns nil by default. .TP .B "virtual void First(Iterator&)" .ns .TP .B "virtual void Last(Iterator&)" .ns .TP .B "virtual void Next(Iterator&)" .ns .TP .B "virtual void Prev(Iterator&)" .ns .TP .B "virtual boolean Done(Iterator)" Operations for iterating over the component subject's children, if any. First and Last initialize an iterator to point to the beginning and end of the list of children, respectively. Next increments the iterator to point to the following child, while Prev decrements the iterator to point to the preceding child. Done returns whether or not the iterator points beyond the first or last child in the list. .TP .B "virtual Component* Copy()" Return a copy of the component. Subclasses should redefine this operation to return an instance of their type. .TP .B "virtual void Read(istream&)" .ns .TP .B "virtual void Write(ostream&)" Read and write the component's contents to a stream to support catalog operations. Read and write typically call first the corresponding operations defined by their parent class, and then they read or write their class-specific state. Note that you must ensure that the objects are read in the same order they are written. .TP .B "virtual ClassId GetClassId()" .ns .TP .B "virtual boolean IsA(ClassId)" GetClassId returns the unique class identifier for the Component subclass, while IsA returns whether the instance is of a class or subclass corresponding to the given identifier. IsA typically checks the given identifier against the instance's own (as defined by its GetClassId operation) and, failing that, calls its parent classes' IsA operation. All subclasses must redefine GetClassId and IsA to ensure that their identifiers are unique and that instances are written and read properly. .TP .B "virtual ClassId GetSubstId(const char*& delim)" A Component subclasses can redefine GetSubstId to specify a component that can substitute for it. This lets applications that do not define a particular component subclass still read in a substitute that is compatible with the subclass. The substitute class should be one of the predefined components in the Unidraw library. This guarantees that all applications can instantiate the substitute. GetSubstId returns the class identifier for the substitute. When an another Unidraw application's catalog reads this object, it can create an instance of the substitute (which it is guaranteed to define) instead of the original (which it may not define). The original should read and write a superset of the substitute's data. The catalog will read to the end of the substitute's data and then advance the stream to the point following the sequence of characters specified by \fIdelim\fP, saving the extra characters between the two points in the stream. When the substitute object is saved subsequently, the original class identifier will be written along with the substitute's data plus the extra characters saved previously. Thus information needn't be lost as a result of being read and written by an unsophisticated application. .TP .B "ComponentView* Create(ClassId)" Create a view instance that is appropriate for the component subject given a view category. The relationship between subjects, views, and view categories is encoded in their class identifiers. See classes(3U) for more information on class identifiers and view categories. .SH PROTECTED OPERATIONS .TP .B "void Component()" The Component class is abstract; therefore the constructor is protected. .TP .B "ComponentView* View(UList*)" Each component maintains a list of its views, implemented with a UList. This operation returns the component view associated with a given entry in the UList. .TP .B "virtual void SetParent(Component* child, Component* parent)" Notify a child component that it has a new or different parent. This operation does nothing by default. Composite components should call this function in their structure-modifying operations, and components that keep information about their parents should redefine it to update this information. .SH SEE ALSO Catalog(3U), Command(3U), ComponentView(3U), Creator(3U), Iterator(3U), StatVar(3U), TransferFunct(3U), UList(3U), classes(3U), istream(3C++), ostream(3C++) ivtools-1.2.11a1/src/man/man3/ComponentView.3000066400000000000000000000065571214471147700206230ustar00rootroot00000000000000.TH ComponentView 3U "20 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME ComponentView \- base class for views of objects that model domain-specific elements .SH SYNOPSIS .B #include .SH DESCRIPTION ComponentView is an abstract base class for views of component subjects. Component views provide a specialized presentation of the information in the component subject to which they are attached. Usually there is at least one view subclass defined for each subclass of component subject. .SH PUBLIC OPERATIONS .TP .B "virtual void Interpret(Command*)" .ns .TP .B "virtual void Uninterpret(Command*)" These operations call the corresponding subject operations by default. They are included in the component view protocol for convenience, since other objects often deal with component views rather than their subjects. .TP .B "virtual void Update()" Notify the view of a change in some state that it depends on, normally state in the subject. This operation does nothing by default. .TP .B "virtual Component* GetParent()" Return the view's parent, if any. Like component subjects, component views may be structured hierarchically, and their structure may or may not reflect that of their subject. .TP .B "Component* GetSubject()" Return the component view's subject. .TP .B "virtual void First(Iterator&)" .ns .TP .B "virtual void Last(Iterator&)" .ns .TP .B "virtual void Next(Iterator&)" .ns .TP .B "virtual void Prev(Iterator&)" .ns .TP .B "virtual boolean Done(Iterator)" Operations for iterating over the component view's children, if any. First and Last initialize an iterator to point to the beginning and end of the list of children, respectively. Next increments the iterator to point to the following child, while Prev decrements the iterator to point to the preceding child. Done returns whether or not the iterator points beyond the first or last child in the list. .TP .B "virtual ClassId GetClassId()" .ns .TP .B "virtual boolean IsA(ClassId)" GetClassId returns the unique class identifier for the ComponentView subclass, while IsA returns whether the instance is of a class or subclass corresponding to the given identifier. IsA typically checks the given identifier against the instance's own (as defined by its GetClassId operation) and, failing that, calls its parent classes' IsA operation. All subclasses must redefine GetClassId and IsA to ensure that their identifiers are unique and that view category information is defined properly. See classes(3U) for more information on class identifiers and view categories. .SH PROTECTED OPERATIONS .TP .B "ComponentView(Component* subject = nil)" The constructor initializes the component view's subject pointer to the given value. The view will also attach itself to the subject if the argument is non-nil. .TP .B "virtual void SetSubject(Component*)" Set the component's subject pointer to the given value. By default, this operation does not call Attach or Detach on the subject(s). .TP .B "virtual void SetParent(Component* child, Component* parent)" Notify a child component that it has a new or different parent. This operation does nothing by default. Composite components should call this function in their structure-modifying operations, and components that keep information about their parents should redefine it to update this information. .SH SEE ALSO Command(3U), Component(3U), Iterator(3U), classes(3U) ivtools-1.2.11a1/src/man/man3/ConnectTool.3000066400000000000000000000016241214471147700202430ustar00rootroot00000000000000.TH ConnectTool 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME ConnectTool \- tool for connecting connectors .SH SYNOPSIS .B #include .SH DESCRIPTION ConnectTool lets the user establish a connection between two connectors by direct manipulation. .SH PUBLIC OPERATIONS .TP .B "ConnectTool(ControlInfo* = nil)" Create a new ConnectTool. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" CreateManipulator detects whether the user clicked on a connector. If so, it delegates manipulator creation to that connector, and InterpretManipulator in turn delegates interpretation to the same connector. CreateManipulator clears the editor's selection and returns a nil value if the user did not click on a connector. .SH SEE ALSO Connector(3U), Tool(3U) ivtools-1.2.11a1/src/man/man3/Connector.3000066400000000000000000000113301214471147700177410ustar00rootroot00000000000000.TH Connector 3U "20 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Connector, ConnectorView \- base classes for connector subjects and views .SH SYNOPSIS .B #include .SH DESCRIPTION Connector is an abstract base class for graphical component subjects that enforce different connectivity semantics depending on the particular connector subclass. ConnectorView is the abstract base class for views of connector subjects. A connector can be connected to one or more other connectors. Once connected, two connectors can affect each other's position in specific ways as defined by the semantics of the connection. Connectors also participate in the propagation of state variable values during dataflow. Two connected connectors with bound state variables will assign the value of one state variable to other, and the direction of transfer depends on the connectors' transmission method. For example, if the transmission method of connector C1 with bound state variable S1 is In, and if the transmission method of connector C2 with bound state variable S2 is Out, and if C1 and C2 are connected, then S1 will be assigned the value of S2 during dataflow. .SH CONNECTOR PUBLIC OPERATIONS .TP .B "virtual void Interpret(Command*)" .ns .TP .B "virtual void Uninterpret(Command*)" In addition to (un)interpreting the commands GraphicComp (un)interprets, connectors also (un)interpret DeleteCmd and CutCmd to sever and restore any connections to them. .TP .B "virtual void Connect(Connector*, CGlue* = nil); Connect this connector to the given one, optionally with a piece of CGlue interposed. This operation allows redundant connections by default. .TP .B "virtual void Disconnect(Connector*)" .ns .TP .B "void DisconnectAll()" Disconnect the given connector from this one, if they are connected. DisconnectAll calls Disconnect on all connected connectors until no connections remain. .TP .B "virtual boolean ConnectedTo(Connector*)" Return whether this connector is connected to the given one. .TP .B "virtual void GetCenter(float&, float&)" Return the coordinates of the connector's center, which defines its position. .TP .B "virtual void SetBinding(StateVar*)" .ns .TP .B "virtual StateVar* GetBinding()" Assign and return the state variable bound to the connector, if any. Only one state variable can be bound to a connector at a time. .TP .B "virtual void SetTransMethod(TransMethod)" .ns .TP .B "virtual TransMethod GetTransMethod()" Assign and return the connector's transmission method. .TP .B "virtual void Transmit(Path* = nil)" Initiate dataflow originating from this connector, optionally based on information supplied in the given path object. Other Unidraw or application objects call this operation whenever data modifications should be propagated. .SH CONNECTOR PROTECTED OPERATIONS .TP .B "Connector(Graphic* = nil)" Initialize the connector instance, optionally with a graphic whose center defines the connector's position. .TP .B "virtual void ConnectMe(Connector*)" .ns .TP .B "virtual void DisconnectMe(Connector*)" Connectors maintain a list of the connectors to which they are connected. The Connect and Disconnect operations update this connector's list, while the ConnectMe and DisconnectMe operations inform their argument to update their lists. .TP .B "void Retransmit(Path*)" .ns .TP .B "void Retransmit(Connector* peer, Path*)" .ns .TP .B "boolean Transferable(Connector* peer)" The Transmit operation uses these operations to propagate state variable values. The first Retransmit function calls the second one on each of the connector's peers (i.e., the connectors to which it is connected) if the path records that this connector has not already been visited (otherwise propagation ceases). The first Retransmit copies the path if necessary to avoid accumulating visit information from multiple branches. The second Retransmit calls Transferable, which returns whether the value of this connector's state variable can be transferred to the given peer's state variable based on the two connectors' transmission methods. If the values are transferable, then the Transferable operation carries out the assignment to the peer's state variable as a side-effect. The second Retransmit also enables further propagation by evaluating the transfer function of the peer's parent and by calling the first Retransmit operation on the peer. .SH CONNECTORVIEW PUBLIC OPERATIONS .TP .B "Connector* GetConnector()" Return the view's subject, if any. .SH CONNECTORVIEW PROTECTED OPERATIONS .TP .B "ConnectorView(Connector* = nil)" The constructor takes a subject as an optional argument. The view will attach itself to the subject if one is specified. .SH SEE ALSO CGlue(3U), GraphicComp(3U), GraphicView(3U), Path(3U), StateVar(3U), edit(3U0, globals(3U) ivtools-1.2.11a1/src/man/man3/Control.3000066400000000000000000000077321214471147700174420ustar00rootroot00000000000000.TH Control 3I "15 September 1989" "InterViews" "InterViews Reference Manual" .SH NAME Control, ControlState \- select and execute an action .SH SYNOPSIS .B #include .SH DESCRIPTION A control is a monoscene that allows an action to be selected and executed. The component of a control determines the appearance associated with the control. A control state is a subject that coordinates a group of related controls. The control state contains a pointer to the currently selected control (if any). .PP Controls are useful for grabbing input and moving over potentially selectable items. Examples of controls include popup menus, pull-down menus, and menu items. It is generally not necessary to call functions directly on a control. .SH PUBLIC OPERATIONS .TP .B "Control(Interactor*)" Construct a new control with the given interactor as the component. .TP .B "~Control" Destruct a control. Because a control is a monoscene, deleting it implies deleting its component interactor. .TP .B "ControlState* State()" .ns .TP .B "void SetState(ControlState*)" Get or set the control state associated with a control. .TP .B "virtual void Handle(Event&)" Controls are initially inactive. A DownEvent causes a control to become active. If an active control receives an EnterEvent, it will set the current selection to itself. If an active control receives a LeaveEvent, it will set the current selection to \fInil\fP. .TP .B "virtual void Enable(boolean)" .ns .TP .B "boolean Enabled()" Depending on the argument, Enable enables (\fItrue\fP) or disables (\fIfalse\fP) the control. Control subclasses can check whether the control is enabled with the Enabled operation and then take whatever action is appropriate. .TP .B "virtual void Select()" Highlight the control and call the protected virtual functions Open and Grab (see below). .TP .B "virtual void Unselect()" Call the protected virtual function Close and then unhighlight the control. .TP .B "virtual void Do()" Implement a selected action. When a control sees an UpEvent, it calls Do on the current selection. .TP .B "Control* ParentControl()" .ns .TP .B "Control* RootControl()" The control hierarchy does not necessarily correspond to the interactor hierarchy. These operations return the control's parent control or the root of the control hierarchy, if any, as defined by control subclasses. .SH PROTECTED OPERATIONS .TP .B "virtual void Down()" .ns .TP .B "virtual void Up()" Down and Up are called when the control receives a DownEvent and an UpEvent, respectively. By default, Down activates the control if it is enabled, and Up deactivates the control and calls Do on the current selection. .TP .B "virtual void Enter()" .ns .TP .B "virtual void Leave()" Enter makes the control the current selection if it is enabled and active, while Leave nullifies the current selection if the control is enabled and active. .TP .B "virtual void Open()" .ns .TP .B "virtual void Close()" The base class Open and Close do nothing, but subclasses may insert and remove an interactor, such as a pull-down menu. .TP .B "virtual void Grab()" Grab reads input and only passes through an event if its target is an active control. .TP .B "virtual void Skip()" Skip reads and discards input events until it reads an event targetted for a control that is currently grabbing input, as indicated by IsGrabbing (see below). .TP .B "virtual void Busy()" .ns .TP .B "virtual void Done()" The Up operation calls Busy just before it calls Do on the target, and it calls Done immediately afterwards. These operations do nothing by default; subclasses may reimplement them to start and stop some indication that the control is doing its job. .TP .B "virtual boolean IsGrabbing(Interactor*)" IsGrabbing returns true if the given interactor is grabbing control. .TP .B "void Reparent(Control* target, Control* parent)" Set \fItarget\fP's parent to \fIparent\fP. Controls that compose child controls should call this operation on their children. .SH SEE ALSO Event(3I), Interactor(3I), Menu(3I), Scene(3I) ivtools-1.2.11a1/src/man/man3/ControlInfo.3000066400000000000000000000044501214471147700202500ustar00rootroot00000000000000.TH ControlInfo 3U "20 November 1990" "Unidraw" "InterViews Reference Manual" .SH NAME ControlInfo \- object for storing control-related information .SH SYNOPSIS .B #include .SH DESCRIPTION A ControlInfo object stores information from which to build a Control for executing a command or engaging the current tool. The ControlInfo object is stored with the command or tool, thus providing all the information necessary to recreate the interface when the command or tool is retrieved from disk through a catalog. The ControlInfo object also defines the mapping between a keycode and a UControl instance to support keyboard equivalents via the KeyMap class. .SH PUBLIC OPERATIONS .TP .B "ControlInfo(" .ns .TP .B " GraphicComp* label, const char* keylabel = ``''," .ns .TP .B " const char* keycode = ``'', void* owner = nil" .ns .TP .B ")" .ns .TP .B "ControlInfo(" .ns .TP .B " const char* label , const char* = ``''," .ns .TP .B " const char* = ``'', void* = nil .ns .TP .B ")" .br Create a new ControlInfo instance, supplying either a GraphicComp or a character string to define its label's appearance. The \fIlabel\fP parameter is an iconic or textual cue that a control displays to identify the command or tool it activates. The \fIkeylabel\fP parameter specifies a string to be displayed in the control that identifies the control's keyboard equivalent, while the \fIkeycode\fP parameter defines the mapping between a keyboard event and the ControlInfo. Finally, the \fIowner\fP parameter specifies the command or tool instance to which the ControlInfo object corresponds. .TP .B "void SetLabel(GraphicComp*)" .ns .TP .B "void SetLabel(const char*)" .ns .TP .B "void SetKeyLabel(const char*)" .ns .TP .B "void SetKeyCode(const char*)" .ns .TP .B "void SetOwner(void*)" .TP .B "GraphicComp* GetLabel()" .ns .TP .B "const char* GetKeyLabel()" .ns .TP .B "const char* GetKeyCode()" .ns .TP .B "void* GetOwner()" Explicitly set or get a constructor-specified parameter. The Set operations delete the value they replace if it is different from the given one. The string setting operations copy their arguments. .TP .B "virtual ControlInfo* Copy()" Return a copy of this ControlInfo object, copying its constituent members. .SH SEE ALSO Catalog(3U), Command(3U), KeyMap(3U), Tool(3U), UControl(3U), uctrls(3U) ivtools-1.2.11a1/src/man/man3/Creator.3000066400000000000000000000047411214471147700174160ustar00rootroot00000000000000.TH Creator 3U "12 June 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Creator \- recreates catalog-managed objects from disk and instantiates component views from their class identifiers .SH SYNOPSIS .B #include .SH DESCRIPTION A creator object can reconstruct a catalog-managed object from disk and can instantiate a component view given a class identifier. Generally only the Catalog class uses the creator to reconstruct objects from disk, but it may be useful for other classes (e.g., the Component base class) to use the creator to create views of component subjects. Applications that derive new catalog-managed classes or component views must also derive a subclass of Creator that extends the base class operations to support the new classes. .SH PUBLIC OPERATIONS .TP .B "Creator()" Instantiate an new creator object. The Catalog constructor requires an instance of a creator object, either an instance of the Creator base class or an instance of an application-specific Creator subclass. .TP .B "virtual void* Create(" .ns .TP .B " ClassId, istream& in, ObjectMap* objmap, int objid" .ns .TP .B ")" .br Create an instance of the class corresponding to the given class identifier. Normally this operation will be used by the Catalog class exclusively. This operation contains a switch statement that calls a CREATE macro for each possible class identifier. The CREATE macro takes the istream, ObjectMap, and int arguments as parameters; it is not important to understand how the macro uses these arguments. For example, the entry for the LineComp line component subject class is case LINE_COMP: CREATE(LineComp, in, objmap, objid); Derived Creator classes must redefine this operation to include a switch statement for application-specific classes, with the default case calling the parent class's Create operation. .TP .B "virtual void* Create(ClassId id)" Create an instance of the view class corresponding to the given view class identifier. This operation is implemented with a set of consecutive if statements of the form if (id == \fI\fP) return new \fI\fP; For example, the entry for the PostScript external view class identifier for line components is if (id == PS_LINE) return new PSLine; Derived Creator classes must redefine this operation to include if statements for application-specific view classes, with the final statement being a call to the parent classes's Create operation. .SH SEE ALSO Catalog(3U), classes(3U), globals(3U) ivtools-1.2.11a1/src/man/man3/Damage.3000066400000000000000000000075361214471147700172020ustar00rootroot00000000000000.TH Damage 3U "30 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME Damage \- repairs damaged graphics .SH SYNOPSIS .B #include .SH DESCRIPTION Damage objects store damaged areas of a graphic for subsequent incremental repair. Areas of a graphic are "damaged" if they need to be redrawn for any reason, e.g., if their state has been modified or if under/overlapping graphics change their appearance. Damage objects try to minimize the amount of redrawing needed to repair a graphic. They are most useful when the graphic is complicated enough that it would be undesirable to redraw the entire canvas when the graphic is modified. Damage objects do \fInot\fP eliminate the need for an interactor's \fIRedraw\fP member function, though they could be used to implement it. .SH PUBLIC OPERATIONS .TP .B "Damage(Canvas* = nil, Painter* = nil, Graphic* = nil)" Create a new Damage object for a graphic on the given canvas. The painter is used to erase damaged areas using its ClearRect function prior to redrawing them. .TP .B "virtual void Incur(Graphic*)" .ns .TP .B "virtual void Incur(BoxObj&)" .ns .TP .B "virtual void Incur(" .ns .TP .B " Coord left, Coord bottom, Coord right, Coord top" .ns .TP .B ")" .br Notify the damage object that a rectangular area has been damaged, either by passing the graphic that contributed the area or the area itself. .TP .B "virtual void Added(Graphic*)" Notify the damage object that the given graphic was appended (\fInot\fP inserted) to the graphic but never drawn. The damage object can thus be responsible for drawing newly added graphics as well. .TP .B "virtual void Repair()" Repair all damage incurred since the last Repair (or since the damage object was created if this is the first Repair). .TP .B "virtual void Reset()" Reset the damage object. Any damage incurred is lost. .TP .B "virtual boolean Incurred()" Returns true if any damage has been incurred. .TP .B "void SetCanvas(Canvas*)" .ns .TP .B "void SetPainter(Painter*)" .ns .TP .B "void SetGraphic(Graphic*)" .TP .B "Canvas* GetCanvas()" .ns .TP .B "Painter* GetPainter()" .ns .TP .B "Graphic* GetGraphic()" Set and get attributes of the damage object. .SH PROTECTED OPERATIONS .TP .B "int Area(BoxObj&)" A helper function that returns the area in square pixels occupied by the given BoxObj. .TP .B "virtual void DrawAreas()" .ns .TP .B "virtual void DrawAdditions()" Explicitly draw the areas of incurred and added damage, respectively. .TP .B "virtual void Merge(BoxObj&)" Merge the given BoxObj into the list of incur-damaged areas, coalescing it into an existing area if the number of non-overlapping areas exceeds 2. .TP .B "void FirstArea(Iterator&)" .ns .TP .B "void FirstAddition(Iterator&)" .ns .TP .B "void Next(Iterator&)" .ns .TP .B "boolean Done(Iterator)" .ns .TP .B "BoxObj* GetArea(Iterator)" .ns .TP .B "Graphic* GetAddition(Iterator)" Operations for iterating over the lists of damaged areas (represented with BoxObj objects) and added Graphics. FirstArea and FirstAddition initialize the iterator to point to the first item on the corresponding list, Next advances the iterator, and Done returns true if the iterator points beyond the end of the list. GetArea and GetAddition return the BoxObj or Graphic to which the iterator points. .TP .B "UList* Elem(Iterator)" A helper function for returning the UList to which an iterator points. The \fI_areas\fP protected member is a UList that stores the list of damaged areas, and the \fI_additions\fP protected stores the list of added graphics. .TP .B "void DeleteArea(BoxObj*)" .ns .TP .B "void DeleteAreas()" DeleteArea is a helper function for deleting the storage associated with a damaged area, including the area itself and the UList element. DeleteAreas is a helper function that deletes the list of damaged areas. .SH SEE ALSO Canvas(3I), Graphic(3U), Iterator(3U), Painter(3I), UList(3U), geomobjs(3U) ivtools-1.2.11a1/src/man/man3/Data.3000066400000000000000000000010601214471147700166570ustar00rootroot00000000000000.TH Data 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME Data \- object containing undo information for storage in a command .SH SYNOPSIS .B #include .SH DESCRIPTION Data is an abstract base class for objects that components store in commands they (un)interpret. Components use Data subclasses to store whatever information they need to uninterpret the command. .SH PROTECTED OPERATIONS .TP .B "Data()" The constructor is protected to prevent instantiation. .SH SEE ALSO Command(3U), Component(3U), Resource(3I) ivtools-1.2.11a1/src/man/man3/Deck2_6.3000066400000000000000000000042631214471147700171730ustar00rootroot00000000000000.TH Deck 3I "13 December 1987" "InterViews" "InterViews Reference Manual" .SH NAME Deck \- a stack of interactors on top of each other .SH SYNOPSIS .B #include .SH DESCRIPTION A deck is a scene containing interactors that are conceptually stacked on top of each other. Only one interactor is visible at a time. A deck is useful to implement ``paging'' through a document, or where only one of several similar components should be visible at a time, as in applications using alternate tool pallets or menus with alternate entries. .PP A deck will try to stretch or shrink the visible interactor to fill the total space. The natural size of a deck is the maximum of its components. .PP A deck uses its \fIperspective\fP to specify which component is visible. The components are numbered in the order in which they are inserted into the deck, starting with one. A scroller or other interactor which operates on the perspective can be used to allow a user to specify the component to view. Either horizontal or vertical scrolling can be used. .SH PUBLIC OPERATIONS .TP .B "Deck()" Construct a new deck. .TP .B "void Insert(Interactor*)" Add an interactor to the deck. .TP .B "void Change(Interactor*)" Notify the deck that an interactor's shape has changed. If propagation is on, the deck recomputes its own shape and notifies its parent. .TP .B "void Remove(Interactor*)" Take an interactor out of a deck. .TP .B "void Flip(int count = 1)" .ns .TP .B "void FlipTo(int position)" .ns .TP .B "void Top()" .ns .TP .B "void Bottom()" Perform operations on the perspective to specify the component to view. Flip specifies the component relative to the current component. A positive value of \fIcount\fP specifies a component nearer to the ``bottom'' of the deck (the components inserted last), and a negative value specifies a component nearer to the ``top''. FlipTo specifies a component by its absolute position in the deck. A positive value of \fIposition\fP specifies a position from the top, starting at 1. A negative value specifies a position from the bottom, starting at -1. Top and Bottom are equivalent to FlipTo(1) and FlipTo(-1) respectively. .SH SEE ALSO Interactor(3I), Scene(3I), Shape(3I) ivtools-1.2.11a1/src/man/man3/Dialog.3000066400000000000000000000025031214471147700172100ustar00rootroot00000000000000.TH Dialog 3I "11 August 1988" "InterViews" "InterViews Reference Manual" .SH NAME Dialog \- popup dialog interactor .SH SYNOPSIS .B #include .SH DESCRIPTION A dialog is an interactor that handles input for a dialog box. The dialog layout is specified by a separate interactor passed to the dialog constructor. The dialog completes when the value of an associated button state becomes non-zero. This button state is typically set by one or more buttons in the component interactor. .SH PUBLIC OPERATIONS .TP .B "Dialog(ButtonState*, Interactor*, Alignment = Center)" Construct a new dialog with the given button state and interactor. The alignment is used by the Popup operation. .TP .B "virtual boolean Accept()" Set the dialog button state to zero and loop reading events until the button state's value becomes non-zero. Each event is passed to is target's Handle operation. Return true if the value is one, false otherwise. .TP .B "virtual boolean Popup(Event&, boolean placed = true)" Insert the dialog into the world associated with the given event. If \fIplaced\fP is true, align the dialog around the event's (\fIx\fP,\ \fIy\fP) coordinate. Otherwise, the dialog is inserted without specifying a position. Popup then calls the Accept operation and returns its value. .SH SEE ALSO Button(3I), Interactor(3I), World(3I) ivtools-1.2.11a1/src/man/man3/Dispatcher.3000066400000000000000000000055051214471147700201040ustar00rootroot00000000000000.TH Dispatcher 3I "21 December 1990" "InterViews" "InterViews Reference Manual" .SH NAME Dispatcher \- wait on multiple file descriptors until a condition occurs .SH SYNOPSIS .B #include .SH DESCRIPTION Conceptually, the dispatcher plays the role of detecting new data on multiple input file descriptors and dispatching the data to the appropriate iohandlers. The dispatcher also notifies iohandlers of expired timers. Notification of either an I/O condition or an expired timer occurs by calling one of the iohandler's virtual functions (see IOHandler(3I)). Since a program needs only one instance of Dispatcher, a static member function is provided to create that instance if necessary and return it. .SH PUBLIC OPERATIONS .TP .B "enum DispatcherMask { ReadMask, WriteMask, ExceptMask }" .ns .TP .B "virtual IOHandler* handler(int fd, DispatcherMask)" .ns .TP .B "virtual void link(int fd, DispatcherMask, IOHandler*)" .ns .TP .B "virtual void unlink(int fd)" Return a file descriptor's iohandler, link a file descriptor to an iohandler, or unlink a file descriptor from its iohandlers. The DispatcherMask describes the I/O condition that the iohandler is interested in, such as whether the file descriptor has new data available for reading. If the I/O condition occurs, the iohandler will be expected to read data from the file descriptor, write data to the file descriptor, or handle the exception depending on the I/O condition. .TP .B "virtual void startTimer(long sec, long usec, IOHandler*)" .ns .TP .B "virtual void stopTimer(IOHandler*)" Attach an iohandler to a timer or remove a timer before it expires. A timer expires after the given number of seconds and microseconds have elapsed. If a timer expires, the dispatcher will notify the attached iohandler. Timers will not expire until the program calls either variant of Dispatcher::dispatch. .TP .B "virtual void dispatch()" .ns .TP .B "virtual boolean dispatch(long& sec, long& usec)" With no arguments, block indefinitely until an I/O condition occurs or a timer expires and then notify the attached iohandler. With two arguments, block no longer than the given number of seconds and microseconds. If both numbers are zero, the function will return immediately after checking all file descriptors and timers. The return value will be true if an I/O condition caused the function to return and false if the function returned because a timer expired or it exceeded the given poll time. The function will decrease the given poll time by the amount of time it spent blocking. .TP .B "static Dispatcher& instance()" .ns .TP .B "static void instance(Dispatcher*)" With no arguments, create an instance of Dispatcher if it doesn't already exist and return it. With an argument, set the instance of Dispatcher that will be used throughout the program. .SH SEE ALSO select(2), IOHandler(3I) ivtools-1.2.11a1/src/man/man3/Editor.3000066400000000000000000000126031214471147700172410ustar00rootroot00000000000000.TH Editor 3U "30 July 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Editor \- base class for top-level windows in an application .SH SYNOPSIS .B #include .SH DESCRIPTION An editor provides a complete user interface for editing a component subject. It unites one or more viewers with commands and tools that act upon the component and its subcomponents. Editor is an abstract class derived from MonoScene; the Editor class adds the protocol for associating tools, commands, and viewers with the component(s) they affect. A programmer normally derives one or more application-specific editors from the Editor base class and defines their appearance with a composition of interactors. Each window of a Unidraw application is usually an instance of an editor subclass designed for the editing domain, and it is these windows that the user recognizes as the application program. .SH PUBLIC OPERATIONS .TP .B "virtual ~Editor()" Editors should not be deleted explicitly if the Unidraw object is used to open and close them. Moreover, Editor subclasses should not explicitly delete the component they edit. The Unidraw object will delete the editor's component after the editor is closed, provided no other editor references the component (or its relatives) and the component is not known to the catalog. .TP .B "virtual void Open()" .ns .TP .B "virtual void Close()" Open informs the editor that it has just become visible and accessible to the user, in case it needs to know, and Close signals the editor that it is no longer needed and should perform any final housekeeping operations. For example, the editor may display a copyright message when it is first opened, or it make take the opportunity when closed to warn the user to save a modified component. These operations simply notify the editor of a condition and are not usually called by the application; instead, the application makes editors appear and disappear with the Unidraw object, which calls these operations as appropriate. .TP .B "virtual void Handle(Event&)" Editor redefines Handle to interpret key events as keyboard equivalents via the HandleKey operation (described below). This is appropriate in the common case where the interactor composition that defines the editor's appearance does not interpret keyboard events. .TP .B "virtual void Update()" By default, the editor's Update operation calls Update on its viewer(s). .TP .B "virtual void SetComponent(Component*)" .ns .TP .B "virtual void SetViewer(Viewer*, int = 0)" .ns .TP .B "virtual void SetSelection(Selection*)" .ns .TP .B "virtual void SetKeyMap(Viewer*, int = 0)" .ns .TP .B "virtual void SetCurTool(Tool*)" .TP .B "virtual Component* GetComponent()" .ns .TP .B "virtual Viewer* GetViewer(int = 0)" .ns .TP .B "virtual KeyMap* GetKeyMap()" .ns .TP .B "virtual Selection* GetSelection()" .ns .TP .B "virtual Tool* GetCurTool()" Assign and return various objects managed by the editor. These operations are undefined by default. The component is the object that the user edits through the editor. The editor can have any number of viewers, identified serially. An editor can maintain a key map for defining keyboard equivalents and a selection object for keeping track of selected components (typically subcomponents of the component being edited). The editor also has a notion of the tool that is currently engaged, that is, the tool that would be used if the user clicked in a viewer. The SetCurTool and GetCurTool operations assign and return this tool, respectively. .TP .B "virtual StateVar* GetState(const char*)" The editor may maintain a string-to-state variable mapping to provide external access to any state variables it defines. The GetState operation returns a state variable given an identifying string. Defining such a mapping lets components query the editor for state variables that may affect them without extending the editor protocol, potentially allowing interchange of components from different applications. This operation returns nil by default. .TP .B "virtual void InsertDialog(Interactor*)" .ns .TP .B "virtual void RemoveDialog(Interactor*)" Insert or remove an interactor that provides a modal interface, such as a dialog box. By default, these operations insert the dialog into the world as a transient window centered atop the editor's canvas. Subclasses can redefine them to insert and remove an interactor (suitably embellished with a border, drop shadow, etc.) as needed. Subclasses should not assume that two InsertDialog operations will always be separated by a RemoveDialog operation; that is, multiple dialogs might be visible at once. .SH PROTECTED OPERATIONS .TP .B "Editor()" You cannot create instances of the Editor class; rather, you define subclasses that suit your application. The constructor is thus protected to disallow instantiation. .TP .B "virtual void HandleKey(Event&)" Executes a command given a valid keyboard event as defined by the key-to-command mapping in the KeyMap object. .TP .B "virtual boolean DependsOn(Component*)" Return whether the editor depends on the given component in any way. Unidraw may destroy the component if no editor depends on it. .TP .B "void SetWindow(ManagedWindow*)" .ns .TP .B "ManagedWindow* GetWindow()" Get and set the window associated with the editor. .SH SEE ALSO Catalog(3U), Command(3U), Component(3U), Interactor(3I), KeyMap(3U), MonoScene(3I), Selection(3U), StateVar(3U), Tool(3U), Unidraw(3U), Viewer(3U), Window(3I), World(3I) ivtools-1.2.11a1/src/man/man3/EditorInfo.3000066400000000000000000000040721214471147700200560ustar00rootroot00000000000000.TH EditorInfo 3U "30 July 1990" "Unidraw" "InterViews Reference Manual" .SH NAME EditorInfo \- stores information about an editor's contents .SH SYNOPSIS .B #include .SH DESCRIPTION An EditorInfo object is a UMap that stores a list of strings and/or string tuples. Application-specific editors can use these objects to store information about what components, commands, and tools they incorporate in their interface. The programmer can write out this information with a catalog object and read it back in later. The application can then let the user change the editor's configuration by editing the catalog-generated file. For example, an EditorInfo object could have a list of names for tools in the editor's interface that have been saved with the catalog. When the application is restarted, the EditorInfo object can be read first, and then the catalog can reconstruct the tools given their names. .SH PUBLIC OPERATIONS .TP .B "EditorInfo()" Construct an EditorInfo instance. .TP .B "void Register(const char* name, const char* info = ``'')" .ns .TP .B "void UnregisterName(const char*)" .ns .TP .B "void UnregisterInfo(const char*)" .ns .TP .B "boolean Registered(const char* name)" Register enters a name or name-info tuple into the EditorInfo object. UnregisterName removes an entry whose name string matches the given one, while UnregisterInfo removes an entry whose info string matches the given one. The Registered operation returns whether or not an entry with a matching name exists. .TP .B "const char* GetName(const char* info)" .ns .TP .B "const char* GetInfo(const char* name)" Name-info tuple lookup operations. The GetName operation returns the name corresponding to a given info string, while the GetInfo operation returns the info string for a given name. .TP .B "const char* GetName(int index)" .ns .TP .B "const char* GetInfo(int index)" Name or info strings can be accessed by an index that reflects the order in which they were registered. These operations return the name or info string for a given index. .SH SEE ALSO Catalog(3U), Editor(3U), UMap(3U) ivtools-1.2.11a1/src/man/man3/EllipseComp.3000066400000000000000000000035131214471147700202270ustar00rootroot00000000000000.TH EllipseComp 3U "22 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME EllipseComp, EllipseView, PSEllipse \- ellipse component subject, view, and PostScript external representation .SH SYNOPSIS .B #include .SH DESCRIPTION EllipseComp is a GraphicComp that defines an ellipse. It uses an Ellipse graphic to store its graphical attributes. EllipseView is a GraphicView for displaying the ellipse. PSEllipse is a PostScriptView that externalizes the subject's information in PostScript form. .SH ELLIPSECOMP PUBLIC OPERATIONS .TP .B "EllipseComp(SF_Ellipse* = nil)" The constructor takes an optional stroked-filled ellipse that defines the attributes of the ellipse. .TP .B "SF_Ellipse* GetEllipse()" Return the SF_Ellipse graphic that defines the ellipse's attributes. GetEllipse is simply a more specific form of the GetGraphic operation. .SH ELLIPSEVIEW PUBLIC OPERATIONS .TP .B "EllipseView(EllipseComp* = nil)" Create an EllipseView, optionally supplying the subject. .TP .B "virtual void Interpret(Command*)" EllipseView interprets AlignToGridCmd to align its center to the grid. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" EllipseView redefines its response to manipulation with a GraphicCompTool. The user clicks to specify the center of the ellipse and then drags to vary its axes. The center and the axes will be constrained by gravity, if any. .TP .B "EllipseComp* GetEllipseComp()" Return the subject. .SH PSELLIPSE PUBLIC OPERATIONS .TP .B "PSEllipse(EllipseComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH SEE ALSO GraphicComp(3U), GraphicCompTool(3U), GraphicView(3U), Grid(3U), PostScriptView(3U), align(3U), ellipses(3U) ivtools-1.2.11a1/src/man/man3/ExternView.3000066400000000000000000000051311214471147700201110ustar00rootroot00000000000000.TH ExternView 3U "19 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME ExternView, PreorderView, InorderView, PostorderView \- base class for external representation objects and subclasses for common traversals .SH SYNOPSIS .B #include .SH DESCRIPTION ExternView is the abstract base class for external representation objects. Generally speaking, external representation objects convey domain-specific information outside the editor. They are simply component views that extract information from their subject and externalize it as a stream of bytes; thus the ExternView base class is derived from ComponentView. .sp There are three predefined ExternView subclasses: PreorderView, InorderView, and PostorderView. These subclasses manage subviews and support three common traversals of the external view hierarchy. .SH EXTERNVIEW PUBLIC OPERATIONS .TP .B "virtual boolean Emit(ostream&)" .ns .TP .B "virtual boolean Definition(ostream&)" Emit and Definition make up the basic ExternView protocol. Emit initiates external representation generation and calls Definition on each of its children. Emit normally calls the external view's own Definition operation first. Then if the external view contains subviews, Emit invokes the children's Definition operations in the proper order to ensure a syntactically correct external representation. Both of these operation do nothing by default, and both return a boolean that indicates whether the stream of bytes was generated successfully. .TP .B "ExternView* GetView(Iterator)" .ns .TP .B "void SetView(ExternView*, Iterator&)" These operations do nothing by default. Subclasses that contain children should redefine them as follows: GetView should return the ExternView to which an iterator points. SetView should initialize the iterator to point to a particular ExternView in the list of children; it should initialize the iterator to point to a nil instance if the given ExternView is not a child. .SH EXTERNVIEW PROTECTED OPERATIONS .TP .B "ExternView(Component* = nil)" The abstract base class constructor is protected to guard against instantiation. It takes the subject as an optional argument. .SH DERIVED CLASSES PreorderView, InorderView, and PostorderView redefine their Definition operations to perform preorder, inorder, and postorder traversals of their children, respectively. Each child's Definition operation is called during the traversal. Note that every child must be an instance of the same ExternView subclass to ensure a consistent traversal order. .SH SEE ALSO Component(3U), ComponentView(3U), Iterator(3U), ostream(3C++) ivtools-1.2.11a1/src/man/man3/FileBrowser.3000066400000000000000000000076411214471147700202440ustar00rootroot00000000000000.TH FileBrowser 3I "30 November 1989" "InterViews" "InterViews Reference Manual" .SH NAME FileBrowser \- browse and/or select file names .SH SYNOPSIS .B #include .SH DESCRIPTION FileBrowser is a StringBrowser that displays file names. In addition to the standard StringBrowser constructor parameters, the FileBrowser constructor takes a directory name as an argument. The FileBrowser scans the corresponding directory, appending the file names to its list of strings. FileBrowser lets the user choose a file name, and the application queries the FileBrowser for the chosen file. .SH PUBLIC OPERATIONS .TP .B "FileBrowser(ButtonState*, const char* dir, int rows, int cols, boolean uniqueSel, \ int highlight, const char* done)" .ns .TP .B "FileBrowser(const char* name, ButtonState*, const char*, int, int, \ boolean, int, const char*)" Create a new FileBrowser object. The ButtonState, \fIrows, cols, uniqueSel, highlight, done\fP, and \fIname\fP parameters have semantics identical to those of the corresponding StringBrowser parameters. The \fIdir\fP parameter specifies the directory to search for file names. Internally, FileBrowser prepends \fIdir\fP to relative path specifications in operations that require them, thus avoiding a chdir(2). .TP .B "boolean IsADirectory(const char*)" Return whether or not the given relative path corresponds to a valid directory. .TP .B "boolean SetDirectory(const char* newdir)" Change the search directory to \fInewdir\fP if that directory is accessible. The function returns true if successful. .TP .B "const char* GetDirectory()" Return the name of the search directory. .TP .B "const char* ValidDirectories(const char* path)" Given a path string, return the largest substring (starting from the beginning of \fIpath\fP) that represents a valid path. The substring is returned in a static buffer and should be copied before use. .TP .B "const char* Normalize(const char* path)" Return a normalized version of \fIpath\fP with all spurious slashes, dots, and tildes interpreted. The normalized path is returned in a static buffer and should be copied before use. .TP .B "const char* Path(int i)" Return the \fIi\fPth string as it appears in the FileBrowser. This function prepends the search directory to the string, normalizes the concatenation, and returns the result. .TP .B "void RereadDirectory()" Rescan the current directory without updating the FileBrowser's appearance. .TP .B "virtual void Update()" Rescan the current directory and update the FileBrowser's appearance to reflect any changes in the set of files it should display. .TP .B "void SetTextFilter(const char*)" .ns .TP .B "void SetDirectoryTextFilter(const char*)" .ns .TP .B "void SetModeFilter(int)" .ns .TP .B "void SetDirectoryModeFilter(int)" By default, FileBrowser displays all the files and directories it finds in the search directory. These functions provide some control over the entries that FileBrowser displays. SetTextFilter specifies a regular expression (see Regexp(3I)) to match against file names. SetDirectoryTextFilter serves a similar role for directory names. SetModeFilter and SetDirectoryModeFilter specify the mode (see chmod(1)) that displayed files and directories should have. Only files and directories that match both the regular expression and the mode will appear in the FileBrowser. Passing \fInil\fP for the regular expression or 0 for the mode restores the default behavior. .SH PROTECTED OPERATIONS .TP .B "void UpdateStrings()" Explicitly update the FileBrowser's appearance to reflect any changes in the set of files it should display without rescanning the directory. .TP .B "virtual boolean Acceptable(const char*)" Return whether the given file name is an acceptable name. By default, files that conform to the text or mode filter specifications are acceptable. Only acceptable files will be displayed by UpdateStrings. .SH SEE ALSO Interactor(2I), Button(3I), StringBrowser(3I), Regexp(3I), chmod(1) ivtools-1.2.11a1/src/man/man3/FileChooser.3000066400000000000000000000046471214471147700202260ustar00rootroot00000000000000.TH FileChooser 3I "30 November 1989" "InterViews" "InterViews Reference Manual" .SH NAME FileChooser \- dialog box for choosing a file name .SH SYNOPSIS .B #include .SH DESCRIPTION FileChooser is a StringChooser that provides a complete dialog box interface to selecting a file name. The interface consists of two lines of descriptive text, a StringEditor for entering the file name explicitly, a FileBrowser, and two PushButtons, one for accepting and one for canceling the dialog. .SH PUBLIC OPERATIONS .TP .B "FileChooser(const char* title, const char* subtitle, const char* dir, \ int rows, int cols, const char* acceptLabel, Alignment)" .ns .TP .B "FileChooser(const char* name, const char*, const char*, const char*, \ int, int, const char* accept, Alignment)" Construct a new FileChooser with the given \fItitle\fP and \fIsubtitle\fP, search directory \fIdir\fP, FileBrowser size specification \fIrows\fP and \fIcols\fP, label for the accept PushButton \fIacceptLabel\fP, and pop-up alignment. These constructors create all the elements of the dialog box and compose them into a default layout. .TP .B "void SetTitle(const char*)" .ns .TP .B "void SetSubtitle(const char*)" Change the text in title or the subtitle. The new text will appear immediately in the dialog when either function is called. .TP .B "void SelectFile()" Highlight the text in the StringEditor. .TP .B "void Update()" FileChooser's Update simply calls Update on the FileBrowser instance to rescan the current directory and update its appearance. .SH PROTECTED OPERATIONS .TP .B "FileChooser(ButtonState*, Alignment = Center)" Construct a new FileChooser with the given button state and pop-up alignment \fIwithout\fP creating FileBrowser, StringEditor, title, subtitle, or PushButton instances. This constructor should be called in subclasses requiring a specialized StringEditor or FileBrowser. .TP .B "FileChooser(ButtonState*, const char* dir, int rows, int cols, \ Alignment)" Construct a new FileChooser (along with its StringEditor and its FileBrowser) with the given button state, search directory, FileBrowser size specification, and pop-up alignment \fIwithout\fP composing them into the default layout and without creating the title, subtitle, or PushButtons. This constructor should be used by FileChooser subclasses that define a specialized look and feel. .SH SEE ALSO Button(3I), Dialog(3I), FileBrowser(3I), StringChooser(3I), StringEditor(3I) ivtools-1.2.11a1/src/man/man3/FontCmd.3000066400000000000000000000013751214471147700173510ustar00rootroot00000000000000.TH FontCmd 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME FontCmd \- command for setting components' font attribute .SH SYNOPSIS .B #include .SH DESCRIPTION FontCmd is a purely interpretive command for setting the font attribute of selected components. .SH PUBLIC OPERATIONS .TP .B "FontCmd(ControlInfo*, PSFont* = nil)" .ns .TP .B "FontCmd(Editor* = nil, PSFont* = nil)" Create a FontCmd, optionally specifying the PSFont that components should adopt. .TP .B "virtual void Execute()" FontCmd extends Execute to set the value of the affected editor's FontVar instance, if it defines one. .TP .B "PSFont* GetFont()" Return the PSFont supplied in the constructor. .SH SEE ALSO Command(3U), pspaint(3U), statevars(3U) ivtools-1.2.11a1/src/man/man3/Frame.3000066400000000000000000000060601214471147700170450ustar00rootroot00000000000000.TH Frame 3I "15 June 1987" "InterViews" "InterViews Reference Manual" .SH NAME Frame, ShadowFrame, MarginFrame, ShowFrame, TitleFrame, BorderFrame \- surrounding interactor .SH SYNOPSIS .B #include .SH DESCRIPTION A frame is a monoscene subclass that outlines another interactor. A shadow frame draws an outline with a drop shadow. A margin frame surrounds its component with horizontal and vertical glue. .PP A show frame is an abstract class that changes its appearance in response to an EnterEvent or LeaveEvent. A title frame provides a banner that it displays in reverse video when it receives an EnterEvent. A border frame draws an outline using a solid pattern when it receives an EnterEvent and draws the outline using a gray pattern when it receives a LeaveEvent. .SH PUBLIC OPERATIONS .TP .B "Frame(Interactor*, int width = 1)" Construct a frame. If the given interactor is not nil, it is inserted as the frame's component. The frame extends \fIwidth\fP pixels outside of the interactor. .TP .B "ShadowFrame(Interactor*, int h = 1, int v = 1)" Construct a shadow frame. The \fIh\fP and \fIv\fP ShadowFrame parameters specify the width of the horizontal and vertical shadows, respectively. Positive values for these parameters specify shadows falling to the right and below the interactor, respectively; negative values specify shadows falling to the left and above. .TP .B "MarginFrame(Interactor* = nil, int margin = 0)" .ns .TP .B "MarginFrame(Interactor*, int margin, int shrink, int stretch)" .ns .TP .B "MarginFrame(Interactor*, int hmargin, int vmargin)" .ns .TP .B "MarginFrame(Interactor*, int hm, int hshr, int hstr, int vm, int vshr, int vstr)" Construct a margin frame. The first constructor puts rigid, fixed-sized glue around the component, while the second surrounds it with fixed-sized glue of the given shrinkability and stretchability. Independent horizontal and vertical margins are set with the third constructor. The last constructor allows full specification of the margin frame's horizontal and vertical margins, shrinkabilities, and stretchabilities. .TP .B "virtual void ShowFrame::HandleInput(Event&)" ShowFrame objects listen for EnterEvent and LeaveEvent. When an EnterEvent is received, ShowFrame::Handle calls InsideFrame(true); when an LeaveEvent is received, it calls InsideFrame(false). For any other event, it calls HandleInput. ShowFrame::InsideFrame does nothing. ShowFrame::HandleInput calls Handle on the frame's component. .TP .B "TitleFrame(Banner*, Interactor*, int width = 1)" Construct a title frame with the given banner. TitleFrame::InsideFrame highlights and unhighlights the banner. .TP .B "BorderFrame(Interactor*, int width = 1)" Construct a border frame. BorderFrame::InsideFrame highlights and unhighlights the border. .SH PROTECTED OPERATIONS .TP .B "Frame(Interactor*, int, int, int, int)" This constructor is used by subclasses to explicitly set the widths of each line in the outline. The integers specify the width of the left, bottom, right, and top lines, respectively. .SH SEE ALSO Banner(3I), Event(3I), Glue(3I), Scene(3I) ivtools-1.2.11a1/src/man/man3/GVUpdater.3000066400000000000000000000040451214471147700176550ustar00rootroot00000000000000.TH GVUpdater 3U "19 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME GVUpdater \- updates GraphicViews structure to match its subject .SH SYNOPSIS .B #include .SH DESCRIPTION GVUpdater is an implementation class that GraphicViews uses to keep its state and structure consistent with its GraphicComps subject. GVUpdater ensures that subject's immediate children are identical to the view's in number and graphics state attributes. It also ensures that the root GraphicViews and GraphicComps themselves have the same graphics state. GVUpdater does \fInot\fP ensure that it will detect and update changes made to deeper child nodes. .SH PUBLIC OPERATIONS .TP .B "GVUpdater(GraphicView*)" The constructor takes the GraphicView that it will be updating as a parameter and stores it in the protected member \fI_gv\fP. Normally, GraphicViews are the only objects that will instantiate GVUpdater. .TP .B "virtual void Update()" Update the GraphicView to make it consistent with its subject. .SH PROTECTED OPERATIONS .TP .B "void UpdateStructure()" .ns .TP .B "void UpdateState()" The Update procedure takes place in two stages. The subject's and view's structures are reconciled first by UpdateStructure, and then the view's graphic state is changed to match the subjects with UpdateState. .TP .B "void AddDamage(Graphic*)" .ns .TP .B "void IncurDamage(Graphic*)" .ns .TP .B "void Unselect(GraphicView*)" .ns .TP .B "virtual void Add(GraphicView*)" .ns .TP .B "virtual void Append(GraphicView*)" .ns .TP .B "virtual void InsertBefore(Iterator, GraphicView*)" .ns .TP .B " virtual void Remove(Iterator&)" .ns .TP .B "virtual void DeleteView(Iterator&)" GVUpdater is a friend of GraphicViews. These convenience operations provide an interface to the corresponding protected GraphicViews operations. .TP .B "virtual ClassId ViewCategory()" Returns the view category (see classes(3U)) GVUpdater will use to instantiate views of subjects. ViewCategory returns COMPONENT_VIEW by default. .SH SEE ALSO GraphicComp(3U), GraphicView(3U), classes(3U) ivtools-1.2.11a1/src/man/man3/Glue2_6.3000066400000000000000000000022611214471147700172150ustar00rootroot00000000000000.TH Glue 3I "15 June 1987" "InterViews" "InterViews Reference Manual" .SH NAME Glue, HGlue, VGlue \- open space between interactors .SH SYNOPSIS .B #include .SH DESCRIPTION A glue object is an interactor that is used to define variable-size space between interactors in boxes. The \fBHGlue\fP subclass is for space in a horizontal box; \fBVGlue\fP for space in a vertical box. Along its minor axis (vertical for \fBHGlue\fP, horizontal for \fBVGlue\fP), glue has a natural size of zero and infinite stretchability. .SH PUBLIC OPERATIONS .TP .B "HGlue(int natural = 0, int stretch = hfil)" .ns .TP .B "VGlue(int natural = 0, int stretch = vfil)" Construct glue with a given natural size and stretchability. The glue's shrinkability is defined to be the same as the natural size, meaning it can shrink to zero. .TP .B "HGlue(int natural, int shrink, int stretch)" .ns .TP .B "VGlue(int natural, int shrink, int stretch)" Construct glue with a given natural size, shrinkability, and stretchability. If \fIshrink\fP is larger than \fInatural\fP the glue potentially can have ``negative size'', meaning interactors will overlap in a box. .SH SEE ALSO Box(3I), Interactor(3I), Shape(3I) ivtools-1.2.11a1/src/man/man3/Graphic.3000066400000000000000000000453621214471147700174000ustar00rootroot00000000000000.TH Graphic 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME Graphic, FullGraphic \- structured graphic abstract base class and subclass that stores a complete set of graphics state attributes .SH SYNOPSIS .B #include .SH DESCRIPTION \fBGraphic\fP is an abstract base class for structured graphics objects. Graphic objects maintain graphics state and geometric information, which lets them draw themselves on demand and support hit detection. .sp Graphic subclasses can implement graphical objects such as lines, rectangles, ellipses, and polygons. Subclasses can also support hierarchical composition of Graphic instances, thus providing an object-oriented rendition of traditional structured graphics functionality. .SH GRAPHIC PUBLIC OPERATIONS .TP .B "virtual void Draw(Canvas*)" .ns .TP .B "virtual void Draw(Canvas*, Coord, Coord, Coord, Coord)" .ns .TP .B "virtual void DrawClipped(Canvas*, Coord, Coord, Coord, Coord)" .TP .B "virtual void Erase(Canvas*)" .ns .TP .B "virtual void Erase(Canvas*, Coord, Coord, Coord, Coord)" .ns .TP .B "virtual void EraseClipped(Canvas*, Coord, Coord, Coord, Coord)" Draw or erase the graphic on the given canvas. The one-parameter Draw and Erase operations draw and erase the graphic in its entirety. The five-parameter forms take four coordinates defining a rectangular area with which to cull drawing. Composite graphics in particular can use this information to avoid drawing children falling entirely outside the given area. DrawClipped and EraseClipped draw the graphic strictly within a rectangular area. All Coord parameters are in canvas coordinates. .TP .B "virtual void FillBg(boolean)" .ns .TP .B "virtual void SetBrush(PSBrush*)" .ns .TP .B "virtual void SetColors(PSColor* fg, PSColor* bg)" .ns .TP .B "virtual void SetFont(PSFont*)" .ns .TP .B "virtual void SetPattern(PSPattern*)" .TP .B "virtual int BgFilled()" .ns .TP .B "virtual PSBrush* GetBrush()" .ns .TP .B "virtual PSColor* GetFgColor()" .ns .TP .B "virtual PSColor* GetBgColor()" .ns .TP .B "virtual PSFont* GetFont()" .ns .TP .B "virtual PSPattern* GetPattern()" Set and get the graphic's graphic state attributes analogous to those defined for Painters. The base class implements the operations for setting and getting the fill mode and colors; the other operations should be redefined in subclasses that need them. .TP .B "void Translate(float dx, float dy)" .ns .TP .B "void Scale(float x, float y, float cx = 0.0, float cy = 0.0)" .ns .TP .B "void Rotate(float angle, float cx = 0.0, float cy = 0.0)" .ns .TP .B "void SetTransformer(Transformer*)" .ns .TP .B "Transformer* GetTransformer()" .ns .TP .B "void TotalTransformation(Transformer& t)" Coordinates passed to drawing operations are transformed according to the current translation, rotation, and scale factor. Optionally, scaling and rotation can be performed relative to a point (\fIcx\fP, \fIcy\fP). The base class stores a transformer \fI_t\fP that can be directly set and accessed with SetTransformer and GetTransformer. The default transformer is nil, meaning no transformations are performed. TotalTransformation uses concatTransformer (described below) to concatenate \fIt\fP (usually the identity transformation) and the transformers of the graphic's parents to obtain the graphic's total transformation, which it then stores in \fIt\fP. .sp Unless otherwise noted, input and output coordinates are affected by the concatentation of \fIthis\fP's transformer, its parent's transformer, its parent's parent's, and so on up to the root of the graphic instance hierarchy. Prior to transformation, coordinates reflect the \fIgraphic's coordinate system\fP. Following transformation, the coordinates reflect the canvas coordinate system (i.e., they are canvas coordinates). The coordinates that Graphic subclass constructors require are normally in graphic coordinates, while operations for returning a graphic's bounding box (see below) are in canvas coordinates. .TP .B "void Align(Alignment, Graphic*, Alignment)" Position the given graphic relative to \fIthis\fP, which stays fixed, while the graphic supplied as the argument is translated appropriately. The first Alignment parameter specifies the alignment with respect to \fIthis\fP, while the second specifies the alignment with respect to the given graphic. .TP .B "virtual void GetBounds(" .ns .TP .B " float& left, float& bottom, float& right, float& top" .ns .TP .B ")" .br Return the exact coordinates of the smallest box circumscribing the graphic. The return values are in canvas coordinates. .TP .B "void GetBox(Coord& left, Coord& bottom, Coord& right, Coord& top)" .ns .TP .B "void GetBox(BoxObj&)" Return the smallest bounding box circumscribing the graphic. The return values are in canvas coordinates. The \fBBoxObj\fP represents a rectangle defined by lower left and upper right coordinates (see geomobjs(3U) for details). .TP .B "virtual void GetCenter(float& x, float& y)" Return the center point of the graphic in canvas coordinates. .TP .B "virtual boolean Contains(PointObj&)" .ns .TP .B "virtual boolean Intersects(BoxObj&)" Return whether or not the graphic contains the given point or intersects the given rectangular area specified in canvas coordinates. \fBPointObj\fP describes a point (see geomobjs(3U)). These operations are used most often for fine-grained hit detection. .TP .B "void SetTag(void*)" .ns .TP .B "void* GetTag()" Set or return a tag associated with the graphic. .TP .B "Graphic* Parent()" Return the graphic's parent, if any. .TP .B "virtual void First(Iterator&)" .ns .TP .B "virtual void Last(Iterator&)" .ns .TP .B "virtual void Next(Iterator&)" .ns .TP .B "virtual void Prev(Iterator&)" .ns .TP .B "virtual boolean Done(Iterator)" Operations for iterating over the graphic's children, if any. These operations do nothing by default. Graphics that compose other graphics should redefine these operations to permit traversal of their children. First and Last initialize an iterator to point to the beginning and end of the list of children, respectively. Next increments the iterator to point to the following child, while Prev decrements the iterator to point to the preceding child. Done returns whether or not the iterator points beyond the first or last child in the list. .TP .B "Graphic* GetGraphic(Iterator)" .ns .TP .B "void SetGraphic(Graphic*, Iterator&)" These operations do nothing by default. Subclasses that contain children should redefine them as follows: GetGraphic should return the graphic to which an iterator points. SetGraphic should initialize the iterator to point to a particular graphic in the list of children; it should initialize the iterator to point to a nil instance if the given graphic is not a child. .TP .B "virtual void Bequeath()" Bequeath does nothing by default. Composite graphic subclasses should redefine it so that it propagates to the children all the graphics state in \fIthis\fP that can affect them. This will prevent a change in a child's appearance should it be removed from \fIthis\fP. Following the call to Bequeath, \fIthis\fP should no longer define any graphics state attributes. .TP .B "virtual Graphic* FirstGraphicContaining(PointObj&)" .ns .TP .B "virtual Graphic* LastGraphicContaining(PointObj&)" .ns .TP .B "virtual Graphic* FirstGraphicIntersecting(BoxObj&)" .ns .TP .B "virtual Graphic* LastGraphicIntersecting(BoxObj&)" .ns .TP .B "virtual Graphic* FirstGraphicWithin(BoxObj&)" .ns .TP .B "virtual Graphic* LastGraphicWithin(BoxObj&)" These operation do nothing by default. Composite graphic subclasses should redefine them so that they return the first or last child that contains a point, intersects a rectangular area, or does not extend beyond the given rectangular area, respectively. .TP .B "virtual Graphic& operator = (Graphic&)" Assign the given graphic's graphics state attributes to \fIthis\fP. .TP .B "virtual Graphic* Copy()" Return a copy of the graphic. Subclasses should redefine this operation to return an instance of their type. .SH GRAPHIC PROTECTED MEMBERS .TP .B "Graphic(Graphic* gr = nil)" Initialize the graphics, optionally supplying a graphic from which to obtain an initial set of graphics state attributes. Graphic is an abstract base class. Therefore its constructor is protected to prevent instantiation. .TP .B "virtual void draw(Canvas*, Graphic* gs) .ns .TP .B "virtual void drawClipped(" .ns .TP .B " Canvas*, Coord, Coord, Coord, Coord, Graphic*" .ns .TP .B ")" .ns .TP .B "virtual void erase(Canvas*, Graphic*) .ns .TP .B "virtual void eraseClipped(" .ns .TP .B " Canvas*, Coord, Coord, Coord, Coord, Graphic*" .ns .TP .B ")" .br Graphic subclasses redefine these \fIstateless drawing operations\fP to render themselves. These operations are called by the corresponding capitalized operations, which supply them with the extra trailing Graphic parameter \fIgs\fP. This parameter defines the graphics state with which to draw the graphic. The graphic state is normally computed using the \fIconcat\fP functions described below. Subclasses normally use the graphics state passed to them without ignoring or modifying it, though they may safely do so if they must override one or more attributes. .TP .B "void update(Graphic* gs)" Graphics ultimately use a Painter to draw themselves. The Graphic class maintains a protected static painter \fI_p\fP that subclasses can use to draw themselves. The update operation sets \fI_p\fP's graphics state attributes to match those of the given graphic to ensure that the painter will generate graphics with the proper color, font, etc. Subclasses should call update in their stateless drawing operations (normally supplying the graphic they were passed) before they call any drawing operations on \fI_p\fP. The graphics that \fI_p\fP generates, therefore, will reflect the graphics state that was passed to the stateless drawing operation. .TP .B "virtual void getExtent(" .ns .TP .B " float& left, float& bottom, float& cx, float& cy," .ns .TP .B " float& tol, Graphic* gs" .ns .TP .B ")" .ns .TP .B "void GetExtent(Extent&)" A graphic's \fIextent\fP defines its physical boundaries. Subclasses redefine getExtent to return this boundary information based on the graphics state supplied in \fIgs\fP. The \fIleft\fP, \fIbottom\fP, \fIcx\fP, and \fIcy\fP parameters define the graphic's lower left corner and center, respectively, in canvas coordinates. The \fItol\fP parameter specifies a fixed amount of space around the boundary to account for parts of the graphic's appearance that do not scale linearly (e.g., brush width). The relationship between getExtent and GetExtent is the same as that between draw and Draw: getExtent is the stateless version of GetExtent, which concatenates the parent's graphics state and calls getExtent with the result. .TP .B "void getBounds(" .ns .TP .B " float& left, float& bottom, float& right, float& top," .ns .TP .B " Graphic* gs" .ns .TP .B ")" .ns .TP .B "void getBox(" .ns .TP .B " Coord& left, Coord& bottom, Coord& right, Coord& top," .ns .TP .B " Graphic*" .ns .TP .B ")" .ns .TP .B "void getBox(BoxObj&, Graphic*)" Stateless versions of the corresponding capitalized bounding box operations, which call the stateless versions with the cumulative graphics state of \fIthis\fP's ancestors. These operations are defined in terms of getExtent and therefore should not be reimplemented by subclasses. .TP .B "virtual boolean contains(PointObj&, Graphic* gs)" .ns .TP .B "virtual boolean intersects(BoxObj&, Graphic*)" Stateless versions of the corresponding capitalized operations for fine-grained hit detection. By default, these operations return true if the argument is contained in or intersects \fIthis\fP's bounding box. Subclasses can redefine these operations to make a more discerning decision. .TP .B "Graphic* getRoot()" .ns .TP .B "void totalGS(Graphic& g)" .ns .TP .B "void parentXform(Transformer& t)" Helper functions for parent-related operations. getRoot returns the root graphic in \fIthis\fP's hierarchy. totalGS uses concat (described below) to concatenate the graphics state of \fIthis\fP and all its ancestors, returning the result in \fIg\fP. Any graphics state that \fIg\fP stored initially will be lost. The parentXform operation uses concatTransform (described below) to concatenate the transformations of all ancestors of \fIthis\fP, returning the result in \fIt\fP. Any transformations that \fIt\fP stored initially will be lost. .TP .B "void setParent(Graphic* g, Graphic* parent)" .ns .TP .B "void unsetParent(Graphic* g)" Operations for setting and getting the value of another graphic's (\fIg\fP's) parent as stored in the \fI_parent\fP protected member variable. Normally only composite graphics change this attribute of another graphic, usually a newly-acquired child. .TP .B "void cachingOn()" .ns .TP .B "void cachingOff()" .ns .TP .B "virtual boolean extentCached()" .ns .TP .B "virtual void uncacheExtent()" .ns .TP .B "virtual void uncacheParents()" .ns .TP .B "virtual void uncacheChildren()" .ns .TP .B "virtual void invalidateCaches()" Operations that support extent caching. Some Graphic subclasses may cache extent information when it is computed for the first time, thereby improving performance. For example, it may be expensive to compute the extent for composite graphics that have many children; thus caching the extent will improve performance if the extent does not change often. .sp cachingOn and cachingOff change the value of \fI_caching\fP, a protected static boolean member of Graphic that indicates whether caching is active on a global basis. Extent-caching subclasses should check this member to avoid caching when it is \fIfalse\fP. Caching subclasses should redefine extentCached to return whether or not they have cached their extent (in whatever form they store it). They should redefine uncacheExtent to discard any extent information they've cached. By default, uncacheParents simply calls uncacheExtent on each ancestor of \fIthis\fP, while uncacheChildren does nothing by default. Subclasses should redefine uncacheChildren to make any children uncache their extents. .TP .B "virtual void concatGS(Graphic* a, Graphic* b, Graphic* dest)" .ns .TP .B "virtual void concatTransformer(" .ns .TP .B " Transformer* a, Transformer* b, Transformer* dest" .ns .TP .B ")" .ns .TP .B "virtual void concat(Graphic* a, Graphic* b, Graphic* dest)" Operations for concatenting graphics state. concatGS concatenates \fIa\fP's graphics state (brush, font, pattern, etc., but \fInot\fP transformation matrix) with \fIb\fP's and assigns the result to \fIdest\fP. According to the default concatenation semantics, \fIdest\fP will receive graphics state attributes defined by \fIb\fP; \fIdest\fP will receive only those attributes from \fIa\fP that \fIb\fP does not define (i.e., those for which \fIb\fP returns \fInil\fP). By default, concatTransformer does a matrix multiply of \fIa\fP and \fIb\fP and assigns the result to \fIdest\fP. The concat operation concatenates both the graphics state and transformation of its arguments, assigning the results to \fIdest\fP. .TP .B "void transform(Coord&, Coord&, Graphic*)" .ns .TP .B "void transform(Coord, Coord, Coord&, Coord&, Graphic*)" .ns .TP .B "void transform(float, float, float&, float&, Graphic*)" .ns .TP .B "void transformList(" .ns .TP .B " Coord[], Coord[], int, Coord[], Coord[], Graphic*" .ns .TP .B ")" .ns .TP .B "void transformRect(" .ns .TP .B " float, float, float, float," .ns .TP .B " float&, float&, float&, float&, Graphic*" .ns .TP .B ")" .TP .B "void invTransform(Coord&, Coord&, Graphic*)" .ns .TP .B "void invTransform(Coord, Coord, Coord&, Coord&, Graphic*)" .ns .TP .B "void invTransform(float, float, float&, float&, Graphic*)" .ns .TP .B "void invTransformList(" .ns .TP .B " Coord[], Coord[], int, Coord[], Coord[], Graphic*" .ns .TP .B ")" .ns .TP .B "void invTransformRect(" .ns .TP .B " float, float, float, float," .ns .TP .B " float&, float&, float&, float&, Graphic*" .ns .TP .B ")" .br Convenience functions analogous to the Transformer operations of the same name. These operations simply check if \fI_t\fP is nil before calling the corresponding Transformer operation on it. .TP .B "virtual void drawGraphic(Graphic* g, Canvas*, Graphic* gs) .ns .TP .B "virtual void drawClippedGraphic(" .ns .TP .B " Graphic* g, Canvas*, Coord, Coord, Coord, Coord, Graphic*" .ns .TP .B ")" .ns .TP .B "virtual void eraseGraphic(Graphic* g, Canvas*, Graphic*) .ns .TP .B "virtual void eraseClippedGraphic(" .ns .TP .B " Graphic* g, Canvas*, Coord, Coord, Coord, Coord, Graphic*" .ns .TP .B ")" .TP .B "virtual void getExtentGraphic(" .ns .TP .B " Graphic* g, float& left, float& bottom, float& cx, float& cy," .ns .TP .B " float& tol, Graphic* gs" .ns .TP .B ")" .ns .TP .B "virtual boolean containsGraphic(" .ns .TP .B " Graphic* g, PointObj&, Graphic* gs" .ns .TP .B ")" .ns .TP .B "virtual boolean intersectsGraphic(Graphic* g, BoxObj&, Graphic*)" .TP .B "virtual boolean extentCachedGraphic(Graphic* g)" .ns .TP .B "virtual void uncacheExtentGraphic(Graphic* g)" .ns .TP .B "virtual void uncacheParentsGraphic(Graphic* g)" .ns .TP .B "virtual void uncacheChildrenGraphic(Graphic* g)" .ns .TP .B "virtual void invalidateCachesGraphic(Graphic* g)" .TP .B "virtual void concatGSGraphic(" .ns .TP .B " Graphic* g, Graphic* a, Graphic* b, Graphic* dest" .ns .TP .B ")" .ns .TP .B "virtual void concatTransformerGraphic(" .ns .TP .B " Graphic* g, Transformer* a, Transformer* b," .ns .TP .B " Transformer* dest" .ns .TP .B ")" .ns .TP .B "virtual void concatGraphic(" .ns .TP .B " Graphic* g, Graphic* a, Graphic* b, Graphic* dest" .ns .TP .B ")" .br Helper functions that let graphic subclasses call the protected member functions on instances of other subclasses that redefine them. All these helper functions take the affected instance as their first parameter. All are semantically identical to the corresponding functions described above (which omit the "Graphic" suffix and the leading \fIg\fP parameter). Composite graphics are the most likely users of such helper functions, calling them on their children. .SH FULLGRAPHIC PUBLIC OPERATIONS .TP .B "FullGraphic(Graphic* = nil)" Construct a full graphic, optionally supplying another graphic from which to copy an initial set of graphics state attributes. FullGraphic objects store a full complement of graphics state attributes; consequently, FullGraphic redefines all the operations for setting and getting these attributes. The FullGraphic class can be used as a base class from which to derive graphics that require a complete set of graphics state and store such state. It is also useful to instantiate FullGraphics and use them as graphics state repositories. .SH SEE ALSO Canvas(3I), Iterator(3U), Painter(3I) Transformer(3I), geomobjs(3U), pspaint(3U) .LP "Applying Object-Oriented Design to Structured Graphics," John M. Vlissides and Mark A. Linton, in \fIProceedings of the 1988 USENIX C++ Conference\fP, Denver, CO, October 1988, pp. 81\-94. ivtools-1.2.11a1/src/man/man3/GraphicBlock.3000066400000000000000000000122731214471147700203460ustar00rootroot00000000000000.TH GraphicBlock 3U "30 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME GraphicBlock \- interactor that displays a graphic .SH SYNOPSIS .B #include .SH DESCRIPTION A GraphicBlock is an interactor that displays a graphic. GraphicBlocks are useful for interactors whose appearance is most conveniently defined with structured graphics. The GraphicBlock will draw its graphic in response to Draw and Redraw calls. The graphic can be aligned with respect to the GraphicBlock's canvas. The GraphicBlock positions its graphic so that its bounding box is aligned with the canvas when the canvas is allocated. On subsequent resizes, the portion of the graphic within the canvas is aligned. With the default alignment, for example, a graphic will be centered in the canvas initially. If the canvas is resized, then the part of the graphic in the center of the canvas prior to resizing will appear in the center of the canvas after resizing. The graphic can be scrolled and zoomed as well. Changing either the \fIcurwidth/curheight\fP or the \fIwidth/height\fP members of the GraphicBlock's perspective effectively zooms the graphic. For example, calling the Adjust member function with a perspective whose \fIcurwidth\fP and \fIcurheight\fP are half that of the GraphicBlock's canvas will enlarge the graphic by a factor of two. Zooming can be limited to magnifications that are powers of two by specifying Binary for the Zooming parameter. A GraphicBlock's natural size depends on the size of the graphic it displays and on any padding (white space surrounding the graphic) specified. GraphicBlocks are infinitely stretchable horizontally and vertically by default. .SH PUBLIC OPERATIONS .TP .B "GraphicBlock(" .ns .TP .B " Graphic*, Coord pad = 0," .ns .TP .B " Alignment = Center, Zooming = Continuous" .ns .TP .B ")" .ns .TP .B "GraphicBlock(" .ns .TP .B " const char*, Graphic*, Coord pad = 0," .ns .TP .B " Alignment = Center, Zooming = Continuous" .ns .TP .B ")" .br Create a new GraphicBlock with the specified graphic, padding, alignment, and zooming behavior. You can also specify the GraphicBlock's instance name with the second form. .TP .B "void Update()" Update updates the GraphicBlock's perspective to reflect any change in the values returned by GetGraphicBox (described below), which defines the extremities of the scrolling area. Update should be called after the graphic is changed. .TP .B "virtual void Highlight(boolean)" When highlighted, GraphicBlock draws itself with the foreground and background colors of its graphic and its painter reversed. GraphicBlock uses its output painter to fill its canvas with background color, thus providing a background for the graphic. .TP .B "Graphic* GetGraphic()" Return the graphic in the GraphicBlock, stored in the \fI_graphic\fP protected member variable. .TP .B "float GetMagnification()" .ns .TP .B "void SetMagnification(float)" Get and set the magnification applied to the graphic, relative to its magnification when the GraphicBlock was created (1x). .SH PROTECTED OPERATIONS .TP .B "void Init()" Initialize the GraphicBlock, positioning its graphic according to the alignment specified in the constructor. The constructor calls this operation. Subclasses should call Init if they should replace the displayed graphic with another. .TP .B "void UpdatePerspective()" Change the GraphicBlock's perspective to reflect the bounding box of the graphic. UpdatePerspective encapsulates this functionality to facilitate redefinition of the Update function in derived classes. .TP .B "void GrabScroll(Event&)" .ns .TP .B "void RateScroll(Event&)" Initiate grab scrolling or rate scrolling. Once called, GrabScroll (RateScroll) polls the current mouse position as long as the middle (right) button is pressed. As GrabScroll polls, it scrolls the GraphicBlock to follow the mouse position, making it appear as though the user is dragging the GraphicBlock's graphic itself. Each time RateScroll polls the mouse, it scrolls the GraphicBlock by an amount corresponding to the differential between the current and initial mouse positions. This creates the illusion of a joystick interface: the further away the mouse is from its initial position, the greater the scrolling increment and the faster the graphic appears to scroll; scrolling slows down, stops, and reverses direction as the user drags the mouse back towards and past the initial position. .TP .B "virtual void GetGraphicBox(Coord&, Coord&, Coord&, Coord&)" Return the lower-left and upper-right coordinates of the total area in which to scroll. By default, this area is corresponds to the graphic's bounding box. .TP .B "virtual void Zoom(Perspective&)" .ns .TP .B "virtual void Scroll(Perspective&)" These functions define how zooming and scrolling are inferred from the perspective supplied to Adjust. The default behaviors implement standard scrolling semantics and zooming as described above. .TP .B "virtual float LimitMagnification(float)" Limit the amount of magnification that can be applied to the graphic. This function is used as a filter to convert desired magnifications into legal ones. By default, the argument is returned; no limits are imposed. .SH SEE ALSO Graphic(3U), Interactor(3I), Perspective(3I) ivtools-1.2.11a1/src/man/man3/GraphicComp.3000066400000000000000000000257671214471147700202260ustar00rootroot00000000000000.TH GraphicComp 3U "24 November 1990" "Unidraw" "InterViews Reference Manual" .SH NAME GraphicComp, GraphicComps \- base classes for graphical component subjects .SH SYNOPSIS .B #include .SH DESCRIPTION GraphicComp is an abstract base class for components that store graphical information in a Graphic object. GraphicComp is derived from Component and adds operations for manipulating its graphical attributes. GraphicComps is a non-abstract subclass of GraphicComp for composite graphical component subjects. .SH GRAPHICCOMP PUBLIC OPERATIONS .TP .B "virtual ~GraphicComp()" The destructor deletes the GraphicComp's graphic, if any. .TP .B "virtual void Interpret(Command*)" .ns .TP .B "virtual void Uninterpret(Command*)" GraphicComp objects can (un)interpret the following commands: .sp .B "AlignCmd" aligns the GraphicComp's graphic with respect to the graphic in the GraphicComp returned by AlignCmd::GetReference. The alignment's sense is defined by the alignments that the AlignCmd specifies: The first Alignment parameter returned by AlignCmd::GetAlignment specifies the alignment with respect to the reference graphic, while the second Alignment parameter specifies the alignment with respect to \fIthis\fP's graphic. .sp .B "BrushCmd" sets the graphic's brush to the BrushCmd's value. .sp .B "ColorCmd" sets the graphic's foreground and background colors. .sp .B "FontCmd" sets the graphic's font. .sp .B "MobilityCmd" sets the GraphicComp's mobility to the MobilityCmd's value. .sp .B "MoveCmd" translates the GraphicComp's graphic by the amounts in the MoveCmd. .sp .B "PatternCmd" sets the graphic's pattern. .sp .B "RotateCmd" rotates the GraphicComp's graphic by the amount in the RotateCmd. .sp .B "ScaleCmd" scales the GraphicComp's graphic by the amounts in the ScaleCmd. .TP .B "virtual Graphic* GetGraphic()" Return the GraphicComp's graphic. GraphicComp subclass normally redefine this operation to return the graphic that defines their appearance. .TP .B "virtual Component* GetParent()" GraphicComp redefines GetParent to return its parent. However, GraphicComp does not store a pointer to the parent explicitly; instead, it obtains its graphic's parent and obtains the GraphicComp associated with the parent graphic. The graphic stores the GraphicComp that contains it in its tag (see SetGraphic below). .TP .B "GraphicComp* GetComp(Iterator)" .ns .TP .B "void SetComp(GraphicComp*, Iterator&)" These operations do nothing by default. Subclasses that contain children should redefine them as follows: GetComp should return the GraphicComp to which an iterator points. SetComp should initialize the iterator to point to a particular GraphicComp in the list of children; it should initialize the iterator to point to a nil instance if the given GraphicComp is not a child. .TP .B "void Append(GraphicComp*)" .ns .TP .B "void Prepend(GraphicComp*)" .ns .TP .B "void InsertAfter(Iterator, GraphicComp*)" .ns .TP .B "void InsertBefore(Iterator, GraphicComp*)" .ns .TP .B "void Remove(GraphicComp*)" .ns .TP .B "void Remove(Iterator&)" Unimplemented operations that composite subclasses should redefine for modifying the their (conceptual) list of children. Note that subclasses needn't necessarily store their children in a list data structure, but a list maps closely to the semantics of these operations. .sp Append and Prepend add a GraphicComp to the end and the beginning of the list, respectively. InsertAfter and InsertBefore insert a GraphicComp after and before the GraphicComp pointed to by the iterator, respectively. The Remove operations remove a view from the list without deleting it. You can remove a view instance by referring to it explicitly or by specifying an iterator. If an iterator is supplied, the Remove operation should advance it to point to the following view as a side effect. .TP .B "virtual void Bequeath()" Modify the GraphicComp's graphic state by calling Bequeath on its Graphic. Graphic::Bequeath propagates \fIthis\fP's graphic state to its immediate children, nullifying its own graphics state; see Graphic(3U) for a more complete description. .TP .B "virtual Mobility GetMobility()" .ns .TP .B "virtual void SetMobility(Mobility)" Get and set the GraphicComp's mobility. GetMobility returns Undef by default, and SetMobility does nothing. .SH GRAPHICCOMP PROTECTED OPERATIONS .TP .B "GraphicComp(Graphic* = nil)" The Graphic instance that defines the GraphicComp's graphical attributes can be specified in the constructor, which is protected to guard against instantiation. .TP .B "virtual void SetGraphic(Graphic*)" .ns .TP .B "virtual GraphicComp* GetGraphicComp(Graphic*)" SetGraphic sets the GraphicComp's graphic to the given one, and store \fIthis\fP in the graphic using Graphic::SetTag. This makes it possible to obtain the GraphicComp that owns the graphic from the graphic itself. GetGraphicComp returns the GraphicComp associated with the given graphic. .TP .B "void Skip(istream&)" .ns .TP .B "void Mark(ostream&)" Convenience functions that simply call their Catalog counterparts. .TP .B "int ReadBgFilled(istream&)" .ns .TP .B "PSBrush* ReadBrush(istream&)" .ns .TP .B "PSColor* ReadColor(istream&)" .ns .TP .B "PSFont* ReadFont(istream&)" .ns .TP .B "PSPattern* ReadPattern(istream&)" .ns .TP .B "PSTransformer* ReadTransformer(istream&)" .ns .TP .B "char* ReadString(istream&)" .ns .TP .B "Bitmap* ReadBitmap(istream&)" .ns .TP .B "Raster* ReadGraymap(istream&)" .ns .TP .B "Raster* ReadRaster(istream&)" .ns .TP .B "void ReadVertices(istream&, Coord*&, Coord*&, int&)" .TP .B "void WriteBgFilled(boolean, ostream&)" .ns .TP .B "void WriteBrush(PSBrush*, ostream&)" .ns .TP .B "void WriteColor(PSColor*, ostream&)" .ns .TP .B "void WriteFont(PSFont*, ostream&)" .ns .TP .B "void WritePattern(PSPattern*, ostream&)" .ns .TP .B "void WriteTransformer(PSTransformer*, ostream&)" .ns .TP .B "void WriteString(const char*, ostream&)" .ns .TP .B "void WriteBitmap(Bitmap*, ostream&)" .ns .TP .B "void WriteGraymap(Raster*, ostream&)" .ns .TP .B "void WriteRaster(Raster*, ostream&)" .ns .TP .B "void WriteVertices(const Coord*, const Coord*, int, ostream&)" Convenience functions for reading and writing common GraphicComp information. These operations are most often used in the Read and Write calls of GraphicComp subclasses. The Write... operations send a stream of bytes characterizing their first parameter to the ostream. The Read... operations reconstruct the object(s) from the bytes that the istream supplies. .SH GRAPHICCOMPS PUBLIC OPERATIONS .TP .B "GraphicComps()" .ns .TP .B "GraphicComps(Graphic*)" .ns .TP .B "virtual ~GraphicComps()" The parameterless constructor sets the GraphicComps' graphic to a new Picture instance, while the other lets you specify the graphic explicitly. The destructor deletes its children. .TP .B "virtual void Interpret(Command*)" .ns .TP .B "virtual void Uninterpret(Command*)" GraphicComps can (un)interpret the following commands in addition to those that GraphicComp objects (un)interpret: .sp .B "BackCmd" and .B "FrontCmd" change the position of the GraphicComps' children that are in the command's clipboard object. If the command has no clipboard, it will create one and fill it with the subjects of GraphicViews that are selected currently in the command's editor. Interpreting a BackCmd will move the children on the clipboard so that they appear behind the others, preserving their relative order; the opposite occurs when interpreting a FrontCmd. .sp .B "CutCmd" removes the components in the CutCmd's clipboard from the GraphicComps and places them in the catalog's global clipboard. Interpret will create a clipboard containing the subjects of selected GraphicViews if the CutCmd has no clipboard initially. .sp .B "DeleteCmd" removes the components in the DeleteCmd's clipboard from the GraphicComps and destroys them when the DeleteCmd is destroyed if it has not been uninterpreted. Interpret will create a clipboard containing the subjects of selected GraphicViews if the DeleteCmd has no clipboard initially. .sp .B "DupCmd" duplicates the components in the DupCmd's clipboard, appending them to the list of children. Interpret will create a clipboard containing the subject of selected GraphicViews if the DupCmd has no clipboard initially. .sp .B "GroupCmd" removes the components in the GroupCmd's clipboard from the GraphicComps and inserts them into the destination GraphicComp returned by GroupCmd::GetGroup. The destination is inserted at the position formerly occupied by the last component in the clipboard. If the GroupCmd has no clipboard initially, interpret will create a clipboard containing the subjects of selected GraphicViews. If GroupCmd does not define a destination, Interpret will create a GraphicComps instance and set the GroupCmd's destination explicitly. Interpret does nothing if the clipboard contains less than two components. .sp .B "UngroupCmd" extracts the children from components in the UngroupCmd's clipboard and inserts them in order immediately after their parents. The parents are then removed from the GraphicComps. The parents are destroyed along with the UngroupCmd if it has not been Uninterpreted. .sp .B "PasteCmd" appends copies of the components in the PasteCmd's clipboard to the GraphicComps. If the PasteCmd has no clipboard initially, it will use the global clipboard from the catalog. .SH GRAPHICCOMPS PROTECTED OPERATIONS .TP .B "GraphicComp* Comp(UList*)" .ns .TP .B "UList* Elem(Iterator)" Convenience functions for extracting a GraphicComp from a UList element and a UList from an iterator. .TP .B "void SelectViewsOf(GraphicComp*, Editor*)" A convenience function for selecting all the views of the given GraphicComp that appear in the given editor. SelectViewsOf clears the original contents of the selection. .TP .B "void SelectClipboard(Clipboard*, Editor)" A convenience function for selecting all the views of all the components in the given Clipboard that appear in the given editor. SelectViewsOf clears the original contents of the selection. .TP .B "void StorePosition(GraphicComp*, Command*)" Store the given child's position into the given Command with Command::Store. .TP .B "void RestorePosition(GraphicComp*, Command*)" Insert the given GraphicComp into \fIthis\fP based on position information stored in the given command. The position information must have been stored with StorePosition. .TP .B "void Group(Clipboard*, GraphicComp* destination, Command*)" .ns .TP .B "void Ungroup(GraphicComp* parent, Clipboard*, Command*)" Helper functions used in the interpretation of GroupCmd and UngroupCmd, respectively. Group inserts the components in the clipboard into \fIdestination\fP and inserts \fIdestination\fP into \fIthis\fP, storing undo information in the command. Ungroup removes all children from \fIparent\fP, puts them on the clipboard, and then removes \fIparent\fP from \fIthis\fP. Ungroup also stores undo information in the command. .SH SEE ALSO BrushCmd(3U), Catalog(3U), Clipboard(3U), ColorCmd(3U), Component(3U), Editor(3U), FontCmd(3U), Iterator(3U), PatternCmd(3U), Picture(3U), Selection(3U), UList(3U), align(3U), edit(3U), globals(3U), struct(3U), transforms(3U) ivtools-1.2.11a1/src/man/man3/GraphicCompTool.3000066400000000000000000000022611214471147700210440ustar00rootroot00000000000000.TH GraphicCompTool 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME GraphicCompTool \- tool for instantiating graphical components .SH SYNOPSIS .B #include .SH DESCRIPTION A GraphicCompTool lets the user instantiate graphical components by direct manipulation. The GraphicCompTool keeps a prototypical component that defines the type of component it can instantiate. .SH PUBLIC OPERATIONS .TP .B "GraphicCompTool(ControlInfo*, GraphicComp* prototype)" .ns .TP .B "GraphicCompTool()" Create a new GraphicCompTool, supplying the prototypical GraphicComp. (You should not normally call the parameterless constructor, which Creator requires.) The first constructor creates a graphical view of the prototype for internal use. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" CreateManipulator clears the editor's selection and delegates manipulator creation and interpretation to the graphical view of the prototype. .TP .B "GraphicComp* GetPrototype()" Return the prototypical GraphicComp. .SH SEE ALSO GraphicComp(3U), Tool(3U) ivtools-1.2.11a1/src/man/man3/GraphicView.3000066400000000000000000000265211214471147700202270ustar00rootroot00000000000000.TH GraphicView 3U "18 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME GraphicView, GraphicViews \- base classes for graphical component views .SH SYNOPSIS .B #include .SH DESCRIPTION GraphicView is an abstract base class for graphical views of GraphicComp objects. GraphicView is derived from ComponentView and adds operations for manipulating its graphical attributes. GraphicViews is a non-abstract subclass of GraphicView for composite graphical component views. .SH GRAPHICVIEW PUBLIC OPERATIONS .TP .B "virtual void Interpret(Command*)" .ns .TP .B "virtual void Uninterpret(Command*)" GraphicView objects can (un)interpret the following command: .sp .B "AlignToGridCmd" aligns the graphical component to the grid that affects the view. Interpret uses AlignToGridCmd::Align to carry out the alignment, while Uninterpret uses AlignToGridCmd::Unalign to reverse Interpret's effects. .TP .B "virtual void DrawHandles()" .ns .TP .B "virtual void RedrawHandles()" .ns .TP .B "virtual void InitHandles()" .ns .TP .B "virtual void EraseHandles()" Operations for displaying and hiding the view's selection handles. All use CreateHandles (described below) to create component-specific rubberbands that draw the handles if they do not already exist. The rubberband is stored in the \fI_handles\fP protected member. DrawHandles makes the handles visible if they are not already visible. RedrawHandles forces the handles to draw themselves even if they are already drawn, which may make them disappear if the rubberband draws them in XOR mode. InitHandles deletes and recreates the rubberband defining the handles if it existed when InitHandles was called. EraseHandles erases the handles and deletes the rubberband. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" Operations that define how the GraphicView reacts when it is manipulated by a tool and how the tool affects that component following manipulation. They effectively override the tool's default behavior if the tool defers manipulator creation and interpretation to the view. This allows the same tool to behave differently depending on the component it manipulates. .sp CreateManipulator creates a manipulator that is appropriate for the given tool. It receives the viewer in which the manipulation will take place, an event with which to initialize the manipulator if necessary, and the coordinate transformation that maps canvas coordinates into the subject's coordinate space. InterpretManipulator is called following manipulation and defines how to construct a command that carries out the manipulation's desired effect. GraphicView objects create and interpret manipulators for the following tools: .sp .B "GraphicCompTool" will let the user position a fixed-sized outline reflecting the view's bounding box on the screen. Interpretation will produce a command that inserts a copy of the subject into the editor's component at the specified position. Placement will be constrained by gravity, if active. .sp .B "MoveTool" will let the user move a fixed-sized outline reflecting the view's bounding box on the screen. Interpretation will produce a command that moves the subject to the specified position. Holding down the Shift key will constrain the movement to purely horizontal or vertical, and movement will be constrained by gravity. .sp .B "ScaleTool" will let the user drag a scaling rectangular outline corresponding to the view's scale following manipulation with the tool. Scaling will be constrained by gravity. .sp .B "StretchTool" will let the user drag a variable-sized rectangular outline corresponding to a two-dimensional stretch that the component will undergo following manipulation. Holding the Shift key down will constrain the stretch to one dimension. Stretching will be constrained by gravity. .sp .B "RotateTool" will let the user rotate a fixed-sized rectangular outline reflecting the view's bounding box. The rotation of the outline corresponds to the rotation that the component will undergo following manipulation. Rotation will be constrained by gravity. .TP .B "virtual Graphic* GetGraphic()" Return the graphic that defines the GraphicView's appearance. Often this graphic is a copy of that in the subject, but it needn't be. .TP .B "virtual Viewer* GetViewer()" Return the viewer (if any) that displays the view. .TP .B "GraphicComp* GetGraphicComp()" Return the view's subject. .TP .B "boolean Includes(GraphicView*)" A convenience function that returns whether or not the GraphicView includes the given view, that is, whether the view is a child of \fIthis\fP. .TP .B "GraphicView* GetGraphicView(Component*)" A convenience function that returns the view of the given component (if any) that appears in the same viewer as \fIthis\fP. .TP .B "GraphicView* GetView(Iterator)" .ns .TP .B "void SetView(GraphicView*, Iterator&)" These operations do nothing by default. Subclasses that contain children should redefine them as follows: GetView should return the GraphicView to which an iterator points. SetView should initialize the iterator to point to a particular GraphicView in the list of children; it should initialize the iterator to point to a nil instance if the given GraphicView is not a child. .TP .B "virtual Selection* SelectAll()" .ns .TP .B "virtual Selection* ViewContaining(Coord, Coord)" .ns .TP .B "virtual Selection* ViewsContaining(Coord, Coord)" .ns .TP .B "virtual Selection* ViewIntersecting(Coord, Coord, Coord, Coord)" .ns .TP .B "virtual Selection* ViewsIntersecting(Coord, Coord, Coord, Coord)" .ns .TP .B "virtual Selection* ViewsWithin(Coord, Coord, Coord, Coord)" .ns .TP .B "virtual ConnectorView* ConnectorIntersecting(" .ns .TP .B " Coord, Coord, Coord, Coord" .ns .TP .B ")" .br These convenience operations do nothing by default. Subclasses containing children should redefine them to do the following: SelectAll should return a selection object containing (pointers to) all its children; ViewContaining should return the last (visibly topmost) child view containing the given point, while ViewsContaining should return \fIall\fP children containing the point; ViewIntersecting should return the last (visibly topmost) child view intersecting a rectangular area, while ViewsIntersecting should return all such children; ViewsWithin should return all the child views falling strictly within a rectangular area; and ConnectorIntersecting should return the child ConnectorView (if any) that intersects a rectangular area. .SH GRAPHICVIEW PROTECTED OPERATIONS .TP .B "GraphicView(GraphicComp* = nil)" The constructor is protected to guard against instantiation. It takes the view's subject as an optional argument, passing it to the ComponentView constructor. .TP .B "virtual void SetGraphic(Graphic*)" Set the GraphicView's graphic to the given one, and store \fIthis\fP in the graphic using Graphic::SetTag. This makes it possible to obtain the GraphicView that owns the graphic from the graphic itself, e.g., after hit detection. .TP .B "virtual void CreateHandles()" Initialize the \fI_handles\fP member with a rubberband that will draw the appropriate handles. By default, CreateHandles creates a RubberHandles object with eight handles around the periphery of the view's bounding box. .TP .B "virtual int ClosestPoint(" .ns .TP .B " Coord x[], Coord y[], int n, Coord px, Coord py" .ns .TP .B ")" .br A convenience function that returns the index of the point closest to (\fIpx, py\fP) in an array of \fIn\fP points. .TP .B "GraphicView* View(UList*)" .ns .TP .B "GraphicView* GetGraphicView(Graphic*)" Convenience functions that return the GraphicView in a UList element and the GraphicView associated with a graphic, respectively. .TP .B "Manipulator* CreateGraphicCompManip(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "Manipulator* CreateStretchManip(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "Command* InterpretGraphicCompManip(Manipulator*)" .ns .TP .B "Command* InterpretStretchManip(Manipulator*)" Helper functions used by CreateManipulator and InterpretManipulator to create and interpret the manipulators associated with GraphicCompTool and StretchTool. .TP .B "void AddDamage(Graphic*)" .ns .TP .B "void IncurDamage(Graphic*)" GraphicViews should incur damage in response to a change in their appearance, which generally happens in their Update function. AddDamage and IncurDamage produce damage by calling the related operations on the enclosing viewer's damage object. Subclasses can use these functions for convenience to avoid accessing the enclosing viewer's damage object directly. .TP .B "void Unselect(GraphicView*)" A convenience function that unselects the given view, which entails erasing its handles and removing it from the enclosing editor's selection object. .TP .B "virtual void Add(GraphicView*)" .ns .TP .B "virtual void Append(GraphicView*)" .ns .TP .B "virtual void InsertBefore(Iterator, GraphicView*)" .ns .TP .B "virtual void Remove(Iterator&)" .ns .TP .B "virtual void DeleteView(Iterator&)" Unimplemented operations that composite subclasses should redefine for modifying the their (conceptual) list of children. Note that subclasses needn't necessarily store their children in a list data structure, but a list maps closely to the semantics of these operations. These operations are not public because only the view itself knows how to keep its structure consistent with that of the subject and/or its semantics. .sp Add adds a GraphicView to the end of the list of children. InsertBefore inserts a GraphicView before the GraphicView pointed to by the iterator. Remove removes a view to which the given iterator refers from the list without deleting it, while DeleteView removes it and deletes it. Remove and DeleteView should advance the iterator to point to the following view as a side effect. .SH GRAPHICVIEWS PUBLIC OPERATIONS .TP .B "GraphicViews(GraphicComps* = nil)" .ns .TP .B "virtual ~GraphicViews()" The constructor creates a GraphicViews, optionally supplying the subject. The destructor deletes the GraphicViews' children. .TP .B "virtual void Interpret(Command*)" GraphicViews objects interpret the following command: .sp .B "AlignToGridCmd" aligns the graphical component to the grid that affects the view. The overall alignment is based on how the first leaf subcomponent aligns itself: Interpret aligns the first leaf subcomponent to the grid and then moves all other subcomponents by the amount that the leaf moved. .TP .B "virtual void Update()" Automatically update the GraphicViews' state and structure to match the subject's. Update will \fInot\fP necessarily detect restructurings or state modifications made to the subject's children more than one level deep. Update uses GVUpdater to do its work. .TP .B "virtual Graphic* GetGraphic()" Return the GraphicViews' graphic, which (like its subject's graphic) is a Picture. .TP .B "GraphicComps* GetGraphicComps()" Return the subject. .SH GRAPHICVIEWS PROTECTED OPERATIONS .TP .B "UList* Elem(Iterator)" A convenience function for extracting a UList from an iterator. .SH SEE ALSO Command(3U), ComponentView(3U), Connector(3U), Damage(3U), GVUpdater(3U), GraphicComp(3U), GraphicCompTool(3U), Grid(3U), Event(3I), Manipulator(3U), MoveTool(3U), Picture(3U), RotateTool(3U), Rubband(3I), ScaleTool(3U), Selection(3U), StretchTool(3U), Transformer(3I), Viewer(3U), align(3U) ivtools-1.2.11a1/src/man/man3/Grid.3000066400000000000000000000031551214471147700167020ustar00rootroot00000000000000.TH Grid 3U "30 July 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Grid \- displays a grid in a viewer and constrains points to lie on it .SH SYNOPSIS .B #include .SH DESCRIPTION The Grid object performs two functions: it displays a grid in a viewer, and it can constrain points to lie on the grid. The base class draws the grid as a simple array of dots; subclasses can draw arbitrarily complex grids. .SH PUBLIC OPERATIONS .TP .B "Grid(float w, float h, float xincr, float yincr)" The constructor parameters correspond to a width, a height, and independent units of graduation for the horizontal and vertical axes, all in pixels. The Grid base class employs a special-purpose graphic to render itself, one that draws an array of dots based on the information supplied in this constructor. .TP .B "virtual Graphic* GetGraphic()" Return the graphic used to render the grid. .TP .B "virtual void Constrain(Coord&, Coord&)" Constrain the given coordinate pair to fall on the grid. The pair is changed to fall on the nearest grid point by default. .TP .B "virtual void Visiblity(boolean)" Make the grid visible (specify \fItrue\fP) or invisible (specify \fIfalse\fP). .TP .B "virtual boolean IsVisible()" Return whether the grid is visible or not. .TP .B "virtual void SetSpacing(float xincr, float yincr)" Reset the grid's units of graduation. .SH PROTECTED OPERATIONS .TP .B "Grid(Graphic*)" The protected constructor allows subclasses to specify an arbitrary graphic for rendering the grid. Subclasses that use this constructor \fImust\fP also redefine the Constrain operation. .SH SEE ALSO Graphic(3U), Viewer(3U) ivtools-1.2.11a1/src/man/man3/IOCallback.3000066400000000000000000000031071214471147700177360ustar00rootroot00000000000000.TH IOCallback 3I "21 December 1990" "InterViews" "InterViews Reference Manual" .SH NAME IOCallback \- generic callback class for readers, writers, or I/O exception handlers .SH SYNOPSIS .B #include .SH DESCRIPTION For convenience, the macros defined in iocallback.h allow the user to define an iohandler which does nothing more than call an arbitrary object's member function. The actual code to read data from a file descriptor, write data to a file descriptor, handle an I/O exception on a file descriptor, or handle a timer's expiration can reside in any arbitrary class rather than in the iohandler. .SH MACROS .TP .B "declareIOCallback(T)" Declare an iocallback type for the given class type T. .TP .B "implementIOCallback(T)" Emit code at this point to implement the iocallback's member functions. .TP .B "IOCallback(T)* instance = new IOCallback(T)(...)" Define an instance of the iocallback type for the given class type T. .SH CONSTRUCTORS .TP .B "typedef int T::IOReady(T)(int fd)" .ns .TP .B "typedef void T::IOTimer(T)(long sec, long usec)" .TP .B "IOCallback(T)(T*, IOReady(T)* in, IOReady(T)* out = nil, IOReady(T)* ex = nil)" .ns .TP .B "IOCallback(T)(T*, IOTimer(T)*, IOReady(T)* in = nil, IOReady(T)* out = nil, IOReady(T)* ex = nil)" Construct an instance of the iocallback type that will call the given member functions of the given class type T's instance. Note that you do not have to use the IOReady(T) or IOTimer(T) macros; rather, you only have to pass the address of a T member function, such as &T::inputReady. .SH SEE ALSO Dispatcher(3I), IOHandler(3I) ivtools-1.2.11a1/src/man/man3/IOHandler.3000066400000000000000000000045111214471147700176170ustar00rootroot00000000000000.TH IOHandler 3I "9 January 1991" "InterViews" "InterViews Reference Manual" .SH NAME IOHandler \- read input, write output, or handle an I/O exception or timeout .SH SYNOPSIS .B #include .SH DESCRIPTION An iohandler reads data from a file descriptor, writes data to a file descriptor, handles an I/O exception on a file descriptor, or handles a timer's expiration. Once the user has requested the dispatcher to attach an iohandler to a file descriptor or a timer, the dispatcher will automatically notify the iohandler when the file descriptor's I/O condition changes or the timer expires. .PP For convenience, the user can use a derived generic class (see IOCallback(3I)) to make the iohandler do nothing more than call an arbitrary object's member function. .SH PUBLIC OPERATIONS .TP .B "virtual int inputReady(int fd)" .ns .TP .B "virtual int outputReady(int fd)" .ns .TP .B "virtual int exceptionRaised(int fd)" The dispatcher will call one of these functions to notify an iohandler that it can read data from a file descriptor, write data to a file descriptor, or handle an I/O exception on a file descriptor. The iohandler should perform the appropriate action and tell the dispatcher what to do next. A negative return value means that the iohandler encountered an error or it doesn't want to read or write anything more. The dispatcher will unlink the iohandler from its file descriptor automatically. A positive return value means that the iohandler didn't read or write everything that it could have. The dispatcher will call the iohandler again in round robin fashion WITHOUT checking select, which means that the iohandler will be called again as soon as the rest of the iohandlers have performed their actions. A zero return value means that the iohandler finished reading or writing everything it was able to. The dispatcher must check the descriptor's status with the select call before it can call the iohandler again. .TP .B "virtual void timerExpired(long sec, long usec)" The dispatcher will call this function to notify an iohandler that a timer has expired. For informational purposes, the parameters give the current time in seconds and microseconds since midnight January 1, 1970. If the iohandler wants to reset the timer, it must tell the dispatcher to start another timer. .SH SEE ALSO Dispatcher(3I), IOCallback(3I) ivtools-1.2.11a1/src/man/man3/ImportCmd.3000066400000000000000000000035631214471147700177160ustar00rootroot00000000000000.TH ImportCmd 3U "10 August 1991" "Unidraw" "InterViews Reference Manual" .SH NAME ImportCmd \- import a graphical component .SH SYNOPSIS .B #include .SH DESCRIPTION ImportCmd imports a graphical image from a file into the drawing being edited. ImportCmd supports the following file formats: TIFF; PostScript generated by pgmtops and ppmtops; X bitmap format; and Unidraw format. .SH PUBLIC OPERATIONS .TP .B "ImportCmd(ControlInfo*, FileChooser* = nil)" .ns .TP .B "ImportCmd(Editor* = nil, FileChooser* = nil)" Create a new ImportCmd instance, optionally supplying the FileChooser that will prompt the user to specify the file to import. After the user specifies the file, ImportCmd reads it, creates an appropriate graphical component, and pastes it into the component being edited in the enclosing editor. .TP .B "static GraphicComp* Import(const char*)" .ns .TP .B "static GraphicComp* TIFF_Image(const char*)" .ns .TP .B "static GraphicComp* PGM_Image(const char*)" .ns .TP .B "static GraphicComp* PPM_Image(const char*)" .ns .TP .B "static GraphicComp* XBitmap_Image(const char*)" Operations for reading data from various file formats and creating an appropriate graphical component. TIFF_Image, PGM_Image, PPM_Image, and XBitmap_Image assume that the specified file is in the corresponding format. Import is more general: it determines the format from the file and then calls one of the other functions. .SH PROTECTED OPERATIONS .TP .B "void Init(FileChooser*)" Specify the FileChooser instance (stored in the \fI_dialog\fP protected member) explicitly. This operation does \fInot\fP delete the existing instance, if any. .TP .B "GraphicComp* PostDialog()" Post the FileChooser and return the graphical component created from the user-specified file, if any. .SH SEE ALSO Catalog(3U), Command(3U), FileChooser(3I), GraphicComp(3U), bitmap(1), pgmtops(1), ppmtops(1) ivtools-1.2.11a1/src/man/man3/Interactor.3000066400000000000000000000324121214471147700201250ustar00rootroot00000000000000.TH Interactor 3I "" "InterViews Reference Manual" .SH NAME Interactor \- base class for interactive objects .SH SYNOPSIS .B #include .SH DESCRIPTION In 2.6, .B Interactor was the base class for all interactive objects. It is currently provided for backward compatibility. .PP Every interactor has a \fIshape\fP member variable that defines the desired characteristics of screen space in terms of size, shrinkability, and stretchability. This information is used to allocate display space for the interactor and the interactor's \fIcanvas\fP member variable is set to the actual space obtained. The lower left corner of the canvas is addressed by (0,\ 0); the upper right by the member variables (\fIxmax\fP,\ \fIymax\fP). .PP The \fIinput\fP member variable is the normal sensor for reading events. The \fIoutput\fP member variable is the standard painter for performing graphics operations. Interactors generally should not set \fIoutput\fP; it will either be inherited (and shared) from the interactor's parent or set by user customization attributes. .PP An interactor may optionally define the \fIperspective\fP member variable to represent the portion of total area that the interactor is displaying. Perspectives allow interactors to coordinate with other interactors, such as scrollers, that want to control the display area. .PP An interactor also may specify certain characteristics of the interactor's canvas, such as whether it is read-only or read/write, whether its contents should be saved when not visible. Interactors also may specify the visual format and interpretation of the input pointing device (e.g., mouse cursor) when it is inside the interactor's canvas. .PP To be mapped to some portion of the display, an interactor must have been inserted into a scene, called its \fIparent\fP. The interactor will be mapped when its parent is mapped. The root scene for the display can be accessed through a World(3I) object. .SH CONSTRUCTORS .TP .B "Interactor()" Construct an interactor. The \fIinput\fP sensor and \fIoutput\fP painters are initialized to \fInil\fP. .TP .B "Interactor(const char* name)" Construct an interactor associated with the string \fIname\fP. The string is used to customize the behavior of the interactor according to user preferences. Behavior can also be customized on a per-class basis using the subclass name. Although not explicitly documented, an instance of any object inheriting from interactor may be constructed with an additional argument (appearing first) containing the string name. For example, both ``HGlue(natural, stretch)'' and ``HGlue("somename", natural, stretch)'' are valid. .TP .B "~Interactor()" The base destructor automatically deletes the base fields, including \fIshape\fP, \fIcanvas\fP, \fIinput\fP, and \fIoutput\fP. .SH CONFIGURATION .TP .B "void Align(Alignment, int w, int h, Coord& l, Coord& b)" Return the coordinates at which an object with the given width and height will have the given alignment within the interactor's canvas. .TP .B "void SetClassName(const char*)" .ns .TP .B "const char* GetClassName()" .ns .TP .B "void SetInstance(const char*)" .ns .TP .B "const char* GetInstance()" Set/get the class or instance name for an interactor. The names are used to determine user style preferences. SetClassName and SetInstance can only be performed by subclasses. .TP .B "void Config(Scene* s)" Configure this interactor and its descendants according to user preferences. The scene \fIs\fP is assumed to be the interactor's parent and is used to inherit attribute values. This operation need not be called explicitly; it is called automatically when the ancestors of an interactor become known (e.g., when the interactor or an ancestor is inserted into a world). .PP Configuration involves a traversal of the interactor hierarchy. For each interactor in the hierarchy, the \fIoutput\fP painter is either inherited from its parent or copied from its parent if there are user preferences specific to the interactor for painter attributes such as colors, font, and brush. For example, suppose the user preference is ``A*B*font:9x15'' and the interactor hierarchy is ``A.B.C.D'' (each ``.'' representing a nesting level in the hierarchy). Interactors A and B will share the same output painter, C will copy B's output and change the font to ``9x15'', and D will share C's output. .PP After assigning the output painter, configuration is performed recursively on any children interactors. The final step at each node in the traversal is to call the virtual Reconfig operation. .TP .B "virtual void Reconfig()" Perform any configuration specific to a particular interactor. This operation should minimally compute the interactor's shape based on the shape of its children and/or the characteristics of its output painter (e.g., font). It can also retrieve user preferences specific to this interactor's class or instance name using GetAttribute. .TP .B "const char* GetAttribute(const char*)" Retrieve the value of a user preference with the given name. GetAttribute searches for the most specific match to the current context. .TP .B "virtual void Reshape(Shape&)" .ns .TP .B "Shape* GetShape()" Set/get the shape of an interactor. Reshape is a a suggestion that an interactor's shape should change to the given one. The default operation sets the interactor's shape to the new shape and calls Scene::Change on the interactor's parent. Suggested shape information may be lost when an interactor is configured; thus, it is best to avoid use of Reshape. The same affect can usually be achieved by putting the interactor in a box along with a particular shape of glue. .TP .B "void SetCursor(Cursor*)" .ns .TP .B "Cursor* GetCursor()" Set/get the cursor that will be displayed when the pointing device is inside the interactor's canvas. If the interactor does not explicitly set its cursor, it will use its parent's cursor. GetCursor returns nil in this case. .SH INTERACTOR HIERARCHY .TP .B "Scene* Parent()" Return the interactor's parent or \fInil\fP if the interactor has not been inserted into a scene. .TP .B "World* GetWorld()" Return a pointer to the world the interactor has been inserted into or \fInil\fP if the interactor's root ancestor is not mapped. .TP .B "void GetRelative(Coord& x, Coord& y, Interactor* = nil)" Map coordinates that are relative to this interactor's canvas to be relative to another interactor's canvas. If the other interactor is \fInil\fP, then the coordinates are made relative to the world. .TP .B "virtual void GetComponents(Interactor**, int, Interactor**&, int&)" Construct an array of pointers to the interactors contained within this interactor. The first and second parameters specify an array of interactors that is already allocated. This array is used if it is large enough, otherwise a new array is allocated from free store. The third and fourth parameters return the which array was used and the actual number of components. This operation is only defined by scenes; the default operation sets the number of elements to zero. .SH OUTPUT .TP .B "Canvas* GetCanvas() const" Return the interactor's canvas, which may be \fInil\fP if the interactor is not mapped to a display. .TP .B "ManagedWindow* GetTopLevelWindow() const" Return the top-level window associated with the interactor, if it is mapped and top-level. .TP .B "virtual void Draw()" Draw is used to display the contents of an interactor, including the contents of any interior interactors. The default Draw operation calls Redraw(0,\ 0,\ \fIxmax\fP,\ \fIymax\fP). Interactors usually don't need to redefine Draw unless they contain interior interactors (i.e., scene subclasses); most simple interactors redefine only Redraw. .TP .B "virtual void Highlight(boolean)" Turn highlighting on or off, depending on whether the parameter is true or false. The default operation is a nop. .TP .B "void SetCanvasType(CanvasType)" .ns .TP .B "CanvasType GetCanvasType()" Set/get the type of canvas desired for an interactor. This operation must be performed before an interactor is mapped. The possible canvas types are CanvasShapeOnly, meaning the interactor performs no input or output (e.g., glue), CanvasInputOnly, meaning the interactor performs no output, CanvasInputOutput, which is the default, CanvasSaveUnder, which suggests that the interactor will be mapped for a short time (e.g., a popup menu) and that the information under the canvas should be saved, CanvasSaveContents, which suggests that Redraw calls are expensive and should be avoided by caching the display, and CanvasSaveBoth, which requests both CanvasSaveUnder and CanvasSaveContents. .TP .B "void Sync()" .ns .TP .B "void Flush()" Sync waits until any pending operations have completed. Flush makes sure the local buffer of pending operations (if any) is sent to the display. An input operation will do a Sync automatically if it would block; thus, applications generally need not call Sync or Flush explicitly. .SH INPUT .TP .B "void Listen(Sensor*)" When an interactor is mapped onto a display, its input interest is determined by its \fIinput\fP sensor. A different sensor can be specified with the Listen operation. To switch back to \fIinput\fP, call Listen(\fIinput\fP). .TP .B "void Read(Event&)" .ns .TP .B "boolean Read(long sec, long usec, Event&)" Each application has a single input queue of events. Any interactor can use Read to take the next event from the queue. Redraw and Resize operations may be called as a side effect of a Read (or any input operation). The \fItarget\fP field of the event specifies the interactor for which the event is intended, which is not necessarily the same as the interactor that performed the Read. The target is normally the interactor whose canvas is under the pointing device. The second form of Read behaves differently if there are no events to read in that it times out after the given number of seconds and microseconds have elapsed and returns false to the calling program. .TP .B "void UnRead(Event&)" UnRead puts an event back on the input queue as if it had never been read. .TP .B "virtual void Handle(Event&)" When an interactor wishes to pass an event to another interactor, it calls the other interactor's Handle operation. Thus, input flow control can be either procedural with Read or event-driven with Handle. .TP .B "void Run()" Run implements a simple event dispatching loop. It calls Read to get the next event and passes the event to the target interactor via Handle. The loop terminates if the Handle operation sets the event's target to nil. .TP .B "void QuitRunning(Event&)" QuitRunning sets the event's target to nil. A Handle operation can call it to make Run exit its event dispatching loop. .TP .B "boolean Check()" Check determines whether an event of interest has occurred. .TP .B "void Poll(Event&)" Poll sets an event to reflect the current input state. Input polling can be wasteful of cycles and should be avoided if possible. .TP .B "int CheckQueue()" CheckQueue returns the number of input packets that have been queued within the application. The event queue manager always reads as much information as possible from input; thus, a single Read might store many events in a local buffer. Subsequent reads can simply access the buffer. This buffer can include out-of-band packets, such as those requiring a Redraw. The number returned by CheckQueue does not correspond, therefore, to the actual number of input events. .SH VIEWS .TP .B "virtual void Adjust(Perspective&)" Adjust suggests to an interactor that its perspective should change to the given perspective; the interactor may choose to accept any part of the new perspective and must ensure that the parameter matches its (new) perspective before returning. Adjust can be used by another interactor to scroll, pan, or zoom an interactor. .TP .B "Perspective* GetPerspective()" GetPerspective returns the perspective associated with an interactor or nil if the interactor has not assigned one. .TP .B "virtual void Update()" Change the display to reflect some change in state that the interactor depends on. This operation is used in a number of contexts. One example is in managing perspectives. If an interactor changes its perspective (e.g., the total of size of what it is displaying changes), it must notify its perspective, which in turn calls Update on the interactors that access the perspective (such as a scroller). .SH PROTECTED OPERATIONS .TP .B "virtual void Redraw(Coord l, Coord b, Coord r, Coord t)" The Redraw operation is called when some portion of the Interactor needs to be redrawn, presumably because it was previously obscured. The Redraw operation should NOT redraw interior interactors; the Interviews library or the Draw operation will call their Redraw operations automatically. The default Redraw operation does nothing. .TP .B "virtual void RedrawList(int n, Coord l[], Coord b[], Coord r[], Coord t[])" RedrawList notifies an interactor that several areas of its canvas need to be redrawn, presumably because it was raised to the top of other canvases. The default RedrawList operation redraws each area separately with Redraw. .TP .B "virtual void Resize()" Resize notifies an interactor that its canvas has been created or modified. Only scenes are typically concerned with Resize, as they must place their component interactors within the new or resized canvas. The default Resize operation does nothing. .SH SEE ALSO \fIInterViews Reference Manual\fR, Perspective(3I), Scene(3I), Sensor(3I), Shape(3I), World(3I) ivtools-1.2.11a1/src/man/man3/Iterator.3000066400000000000000000000015771214471147700176140ustar00rootroot00000000000000.TH Iterator 3U "11 June 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Iterator \- marks a position in a data structure .SH SYNOPSIS .B #include .SH DESCRIPTION An iterator marks a position in a data structure, generally during a traversal of some sort. For example, an iterator keeps track of the current position when iterating through a list of elements. Unidraw's Iterator class serves this purpose in conjunction with ULists or objects that use them. .SH PUBLIC OPERATIONS .TP .B "Iterator()" .ns .TP .B "Iterator(Iterator&)" Construct a new iterator. The second constructor initializes the iterator's value to that of the given iterator. .TP .B "virtual void SetValue(void*)" .ns .TP .B "virtual void* GetValue()" Classes that use an iterator must store position information in it. These operations set and get the this information. .SH SEE ALSO UList(3U) ivtools-1.2.11a1/src/man/man3/KeyMap.3000066400000000000000000000027011214471147700171770ustar00rootroot00000000000000.TH KeyMap 3U "1 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME KeyMap \- activates controls given their keyboard equivalents .SH SYNOPSIS .B #include .SH DESCRIPTION KeyMap supports keyboard equivalents, which allow the user of a Unidraw application to execute menu commands or select from a palette of controls by typing rather than pointing and clicking with the mouse. The KeyMap can activate a control given its key code as defined by its ControlInfo object. Only those controls registered with the KeyMap can be activated through the KeyMap. By default, the Editor base class handles key events by having its KeyMap execute the key code. .SH PUBLIC OPERATIONS .TP .B "KeyMap()" Construct a new keymap, initially with no registrants. .TP .B "void Register(UControl*)" .ns .TP .B "void Register(KeyMap*)" .ns .TP .B "void Unregister(UControl*)" .ns .TP .B "void Unregister(KeyMap*)" Register and unregister a control or another KeyMap. Registering a KeyMap is equivalent to registering all its registered controls individually. .TP .B "void Execute(const char* keyCode)" Execute the given key code by activating the corresponding control. Each UControl contains a ControlInfo object that specifies its key code; thus the mapping between key codes and controls is defined by the ControlInfo objects collectively. Key codes among registered controls should be unique. .SH SEE ALSO ControlInfo(3U), KeyMap(3U), UControl(3U), kybd(3U) ivtools-1.2.11a1/src/man/man3/LineComp.3000066400000000000000000000106231214471147700175210ustar00rootroot00000000000000.TH LineComp 3U "22 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME LineComp, LineView, PSLine, MultiLineComp, MultiLineView, PSMultiLine \- line and multiline component subject, view, and PostScript external representation .SH SYNOPSIS .B #include .SH DESCRIPTION LineComp is a GraphicComp that defines a line. It uses an Line graphic to store its graphical attributes. LineView is a GraphicView for displaying the line. PSLine is a PostScriptView that externalizes the subject's information in PostScript form. The MultiLine counterparts of these classes define the component and external representation for a contiguous set of line segments, i.e., an open polygon. MultiLineComp is derived from VerticesComp, MultiLineView is a VerticesView, and PSMultiLine is a PSVertices. .SH LINECOMP PUBLIC OPERATIONS .TP .B "LineComp(Line* = nil)" The constructor takes an optional line graphic that defines the attributes of the line. .TP .B "virtual void Interpret(Command*)" LineComp redefines Interpret to ignore PatternCmds. .TP .B "Line* GetLine()" Return the Line graphic that defines the line's attributes. GetLine is simply a more specific form of the GetGraphic operation. .SH LINEVIEW PUBLIC OPERATIONS .TP .B "LineView(LineComp* = nil)" Create an LineView, optionally supplying the subject. .TP .B "virtual void Interpret(Command*)" LineView interprets AlignToGridCmd to align its first endpoint to the grid. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" LineView redefines its response to manipulation with a GraphicCompTool. The user clicks to specify the first endpoint of the line and then drags to position remaining endpoint. The endpoints will be constrained by gravity, if any. LineView also defines a response to the ReshapeTool, allowing the user to click on one of its endpoints to reposition it. The subject is actually replaced (via ReplaceCmd) with a new LineComp subject reflecting the repositioned endpoint. Repositioning will be influenced by gravity. .TP .B "virtual void GetEndpoints(Coord&, Coord&, Coord&, Coord&)" Return the line's endpoints, in canvas coordinates. .TP .B "LineComp* GetLineComp()" Return the subject. .SH LINEVIEW PROTECTED OPERATIONS .TP .B "virtual void CreateHandles()" LineView redefines CreateHandles to use a RubberHandles object with two handles, one at each endpoint of the line. .SH PSLINE PUBLIC OPERATIONS .TP .B "PSLine(LineComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH MULTILINECOMP PUBLIC OPERATIONS .TP .B "MultiLineComp(SF_MultiLine* = nil)" The constructor takes an optional stroked-filled multiline graphic that defines the attributes of the multiline. .TP .B "SF_MultiLine* GetMultiLine()" Return the MultiLine graphic that defines the multiline's attributes. GetMultiLine is simply a more specific form of the GetGraphic operation. .SH MULTILINEVIEW PUBLIC OPERATIONS .TP .B "MultiLineView(MultiLineComp* = nil)" Create an MultiLineView, optionally supplying the subject. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" MultiLineView redefines its response to manipulation with a GraphicCompTool. The user clicks the left mouse button to specify each vertex and clicks with the middle mouse button to specify the final vertex. Vertex positioning will be constrained by gravity, if any. MultiLineView also defines a response to the ReshapeTool, allowing the user to click on one of its vertices to reposition it. The subject is actually replaced (via ReplaceCmd) with a new MultiLineComp subject reflecting the repositioned vertex. Repositioning will be influenced by gravity. .TP .B "MultiLineComp* GetMultiLineComp()" Return the subject. .SH PSMULTILINE PUBLIC OPERATIONS .TP .B "PSMultiLine(MultiLineComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH PSMULTILINE PROTECTED OPERATIONS .TP .B "virtual const char* Name()" PSMultiLine identifies itself as "MLine" in the PostScript output. .SH SEE ALSO Event(3I), GraphicComp(3U), GraphicCompTool(3U), GraphicView(3U), Grid(3U), PatternCmd(3U), PostScriptView(3U), ReshapeTool(3U), Rubband(3I), Transformer(3I), VerticesComp(3U), Viewer(3U), align(3U), edit(3U), lines(3U) ivtools-1.2.11a1/src/man/man3/LinkComp.3000066400000000000000000000120541214471147700175270ustar00rootroot00000000000000.TH LinkComp 3U "22 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME LinkComp, LinkView, PSLink \- component subject, view, and PostScript external representation for lines with connectable endpoints .SH SYNOPSIS .B #include .SH DESCRIPTION LinkComp is a GraphicComp defining a line with two pins on each end. The line's endpoints will always coincide with the pins, even if they are moved, thereby maintaining a graphical link between the objects to which it is connected. LinkComp uses an Line graphic to define its initial geometry and graphical attributes. LinkView is a GraphicView for displaying the link. PSLink is a PostScriptView that externalizes the subject's information in PostScript form. .SH LINKCOMP PUBLIC OPERATIONS .TP .B "LinkComp(Line* = nil)" The constructor takes an optional line graphic to define its initial appearance. .TP .B "virtual void Interpret(Command*)" .ns .TP .B "virtual void Uninterpret(Command*)" In addition to (un)interpreting the commands GraphicComp (un)interprets, LinkComp also (un)interprets DeleteCmd and CutCmd by passing these commands to its pins for (un)interpretation. .TP .B "virtual void Update()" When the LinkComp's pins move to maintain connectivity, LinkComp will reorient the line so that its endpoints and the pins coincide. .TP .B "virtual void First(Iterator&)" .ns .TP .B "virtual void Last(Iterator&)" .ns .TP .B "virtual void Next(Iterator&)" .ns .TP .B "virtual void Prev(Iterator&)" .ns .TP .B "virtual boolean Done(Iterator)" .ns .TP .B "GraphicComp* GetComp(Iterator)" .ns .TP .B "void SetComp(GraphicComp*, Iterator&)" LinkComp redefines GraphicComp's traversal operations to make its pins accessible to the Unidraw library. Thus Unidraw can determine the connectors that belong to the component and call its Update operation only once for efficiency. The traversal does \fInot\fP include the line. .TP .B "Line* GetLine()" Return the Line graphic that defines the link's attributes. GetLine is simply a more specific form of the GetGraphic operation. .TP .B "void GetConnectors(Connector*&, Connector*&)" Return the LinkView's pins, which are stored in the \fI_conn1\fP and \fI_conn2\fP protected members. .SH LINKVIEW PUBLIC OPERATIONS .TP .B "LinkView(LinkComp* = nil)" Create an LinkView, optionally supplying the subject. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" LinkView redefines its response to manipulation with a GraphicCompTool. The user clicks to specify the first endpoint of the link and then drags to position the remaining endpoint. (Up)clicking on an existing connector will establish a connection between it and the LinkComp's first (second) pin. LinkView uses a ConnectManip to produce a gravitational attraction between existing connectors and the second pin as the user drags to position it. The endpoints will \fInot\fP be constrained by gravity. LinkView will use ConnectCmds to connect the pin(s) to their target(s). Pin(s) connected in this way will receive floating mobility; unconnected pin(s) will be fixed. .TP .B "virtual void First(Iterator&)" .ns .TP .B "virtual void Last(Iterator&)" .ns .TP .B "virtual void Next(Iterator&)" .ns .TP .B "virtual void Prev(Iterator&)" .ns .TP .B "virtual boolean Done(Iterator)" .ns .TP .B "GraphicView* GetView(Iterator)" .ns .TP .B "void SetView(GraphicView*, Iterator&)" LinkView redefines GraphicView's traversal operations to make its pins accessible to the Unidraw library. Thus Unidraw can determine the connectors that belong to the component, for example, to support ConnectManip's gravitational attraction effect. .TP .B "virtual void GetEndpoints(Coord&, Coord&, Coord&, Coord&)" Return the link's endpoints, in canvas coordinates. .TP .B "LinkComp* GetLinkComp()" Return the subject. .SH LINKVIEW PROTECTED OPERATIONS .TP .B "virtual void CreateHandles()" LinkView redefines CreateHandles to use a RubberHandles object with two handles, one at each endpoint of the link. .TP .B "Line* GetLine()" Return the line that LinkView draws between its pins. .TP .B "virtual LinkComp* NewSubject(Line*)" A helper function that creates a LinkComp subject with the given line graphic. This function produces the proper subject when the GraphicCompTool's manipulator is interpreted. Subclasses can redefine this operation to return a LinkComp subclass, thus eliminating the need to reimplement InterpretManipulator. .TP .B "Manipulator* CreateLinkCompManip(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .TP .B "Command* InterpretLinkCompManip(Manipulator*)" Helper functions that CreateManipulator and InterpretManipulator use to create and interpret the manipulator for GraphicCompTool. .SH PSLINK PUBLIC OPERATIONS .TP .B "PSLink(LinkComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH SEE ALSO Event(3I), Graphic(3U), GraphicComp(3U), GraphicCompTool(3U), GraphicView(3U), Grid(3U), PinComp(3U), PostScriptView(3U), Transformer(3I), align(3U), edit(3U), manips(3U) ivtools-1.2.11a1/src/man/man3/MacroCmd.3000066400000000000000000000050211214471147700174740ustar00rootroot00000000000000.TH MacroCmd 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME MacroCmd \- a command that composes other commands .SH SYNOPSIS .B #include .SH DESCRIPTION MacroCmd composes other commands in a linear fashion. Executing a MacroCmd is equivalent to executing its children in preorder. .SH PUBLIC OPERATIONS .TP .B "MacroCmd(ControlInfo*)" .ns .TP .B "MacroCmd(" .ns .TP .B " Editor* = nil," .ns .TP .B " Command* first = nil, Command* second = nil," .ns .TP .B " Command* third = nil, Command* fourth = nil" .ns .TP .B ")" .br Construct a MacroCmd instance, optionally supplying up to four of its child commands. .TP .B "virtual void Execute()" .ns .TP .B "virtual void Unexecute()" .ns .TP .B "virtual boolean Reversible()" Execute simply executes each child, from first to last. Unexecute calls Unexecute on each child, from last to first. The MacroCmd is reversible if any of its children are. .TP .B "virtual void SetEditor(Editor*)" SetEditor calls SetEditor on each child with the given argument. .TP .B "Command* GetCommand(Iterator)" .ns .TP .B "void SetCommand(Command*, Iterator&)" GetCommand returns the child Command to which an iterator points. SetCommand initializes the iterator to point to a particular child Command; it initializes the iterator to point to a nil instance if the given Command is not a child. .TP .B "void Append(" .ns .TP .B " Command*, Command* = nil, Command* = nil, Command* = nil" .ns .TP .B ")" .ns .TP .B "void Prepend(" .ns .TP .B " Command*, Command* = nil, Command* = nil, Command* = nil" .ns .TP .B ")" .ns .TP .B "void InsertAfter(Iterator, Command*)" .ns .TP .B "void InsertBefore(Iterator, Command*)" .ns .TP .B "void Remove(Command*)" .ns .TP .B "void Remove(Iterator&)" Operations that modify the MacroCmd's list of children. Append and Prepend add up to four Commands to the end and the beginning of the list, respectively. InsertAfter and InsertBefore insert a Command after and before the Command pointed to by the iterator, respectively. The Remove operations remove a child from the list without deleting it. You can remove a child by referring to it explicitly or by specifying an iterator. If an iterator is supplied, the Remove operation should advance it to point to the following child as a side effect. .SH PROTECTED OPERATIONS .TP .B "Command* Cmd(UList*)" .ns .TP .B "UList* Elem(Iterator)" Convenience functions for extracting a Command from a UList element a UList from an iterator, respectively. .SH SEE ALSO Command(3U), Iterator(3U), UList(3U) ivtools-1.2.11a1/src/man/man3/MagnifyTool.3000066400000000000000000000020651214471147700202440ustar00rootroot00000000000000.TH MagnifyTool 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME MagnifyTool \- tool for magnifying a portion of the GraphicView displayed in a viewer .SH SYNOPSIS .B #include .SH DESCRIPTION MagnifyTool lets the user magnify a portion a viewer's contents. The user sweeps out a rectangular area with the MagnifyTool, and the viewer will magnify the area to occupy the entire screen, if possible. .SH PUBLIC OPERATIONS .TP .B "MagnifyTool(ControlInfo* = nil)" Instantiate a MagnifyTool. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" CreateManipulator generates a DragManip with a RubberRect to provide visual feedback for specifying the rectangular area to be magnified. InterpretManipulator does not create a command; rather, it examines the DragManipulator's RubberRect and calls Magnify on the viewer with the RubberRect's final coordinates. .SH SEE ALSO Rubband(3I), Tool(3U), Viewer(3U), manips(3U) ivtools-1.2.11a1/src/man/man3/Manipulator.3000066400000000000000000000044111214471147700203040ustar00rootroot00000000000000.TH Manipulator 3U "1 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Manipulator \- base class for defining direct-manipulation semantics .SH SYNOPSIS .B #include .SH DESCRIPTION Tools use manipulator objects to encapsulate the mechanics of direct manipulation. Manipulators turn user input events into an animation sequence that characterize the manipulation. Manipulators abstract the manipulation into three phases: the \fIgrasping\fP phase, which occurs at the start of the manipulation and lets the manipulator initialize state it will need in later phases; the \fImanipulating\fP phase, during which the manipulator accepts input events and generates graphical output that characterizes successive frames of the animation; and finally the \fIeffect\fP phase, which occurs at the end of the manipulation and lets the manipulator finalize its state. Manipulator is an abstract base class. Subclasses support different manipulation semantics. .SH MANIPULATOR PUBLIC OPERATIONS .TP .B "virtual void Grasp(Event&)" Grasp is called once at the beginning of direct manipulation to allow the manipulator to initialize its internal state based on the initiating event. .TP .B "virtual boolean Manipulating(Event&)" Manipulating is called repeatedly during the manipulation whenever a new event arrives, until it returns false. Each call to Manipulating should produce a new frame of the animation that characterizes the manipulation. .TP .B "virtual void Effect(Event&)" Effect is called once at the end of direct manipulation to allow the manipulator to finalize its internal state based on the last event supplied to the Manipulating operation. .TP .B "virtual void SetViewer(Viewer*)" .ns .TP .B "virtual Viewer* GetViewer()" .ns .TP .B "virtual void SetTool(Tool*)" .ns .TP .B "virtual Tool* GetTool()" Get and set the viewer, in which the manipulator generates graphical output, and the tool that created the manipulator. These operations do nothing by default; subclasses that require this information must redefine these operations to assign and retrieve the state they require. .SH MANIPULATOR PROTECTED OPERATIONS .TP .B "Manipulator()" The constructor is protected to disallow instantiation of abstract base class objects. .SH SEE ALSO Event(3I), Tool(3U), Viewer(3U) ivtools-1.2.11a1/src/man/man3/MatchEditor.3000066400000000000000000000031711214471147700202160ustar00rootroot00000000000000.TH MatchEditor 3I "7 Dec 1989" "InterViews" "InterViews Reference Manual" .SH NAME MatchEditor \- StringEditor with pattern matching .SH SYNOPSIS .B #include .SH DESCRIPTION MatchEditor is a StringEditor subclass that checks the validity of its contents against a specified pattern. It is suitable for entering strings that must conform to a particular format such as a number or a file name. The matching pattern is specified according to the rules of scanf(3). For example, a pattern of "%3d" will match a 3-digit integer, a pattern of "%[ab]" will match a string containing only a's and b's, and a pattern of "(%f, %f)" will match the string "(12.0, 5E23)". .SH PUBLIC OPERATIONS .TP .B "MatchEditor(ButtonState*, const char* sample, const char* done)" Create a new MatchEditor object. The ButtonState, sample string, and termination string are passed to the StringEditor constructor. .TP .B "void Match(const char* pattern, boolean keystroke = true)" Specify the pattern to match against. When MatchEditor performs matching, it will highlight any trailing part of the edit string that does not conform to \fIpattern\fP. The user can then correct the string. If \fIkeystroke\fP is true, matching will occur on every keystroke; otherwise matching will only occur on the completion of the edit. The initial pattern matches any string, and the initial value of keystroke is true. .SH RESTRICTIONS MatchEditor uses sscanf internally to check the pattern match. Different versions of sscanf have different scanning capabilities; check with your local version to see what patterns you can use. .SH SEE ALSO StringEditor(3I) ivtools-1.2.11a1/src/man/man3/Menu2_6.3000066400000000000000000000075301214471147700172310ustar00rootroot00000000000000.TH Menu 3I "6 December 1989" "InterViews" "InterViews Reference Manual" .SH NAME Menu, MenuItem, MenuBar, PopupMenu, PulldownMenu, PullrightMenu \- menus .SH SYNOPSIS .B #include .SH DESCRIPTION N.B.: This Menu class is completely different from the Menu class in version 2.5. No attempt has been made to be compatible, as this class and its subclasses are more powerful and easier to use than the original class. .PP Menu is a subclass of Control that contains a scene of other controls, called its body. When a menu is opened, it inserts the body into the world with a drop shadow. The appearance of the menu itself is defined by its interactor component. For example, a menu in a menu bar might appear as ``File'' and insert a pulldown menu with commands such as ``Save'' when opened. .PP MenuItem is a subclass of Control for defining the leaves of a menu hierarchy. Normally, an application will derive a command class from MenuItem and implement the virtual function Do as appropriate. One technique is to pass the Command an application object and pointer to member function; the Do function calls the member function on the application object. .PP PopupMenu, PulldownMenu, and PullrightMenu are subclasses of Menu that implement a common styles of menus. MenuBar is a subclass of HBox that manages the control state associated with a set of menus. PopupMenu has no appearance; it is opened explicitly in response to an input event. PulldownMenu and PullrightMenu open the menu body below and to the right of the menu, respectively. These classes make it possible to use menus in an application without creating or passing control states explicitly. .PP .SH PUBLIC OPERATIONS .TP .B "Menu::Menu(Interactor*)" Construct a new menu. .TP .B "Menu::~Menu()" The destructor deletes the menu body in addition to its appearance component. .TP .B "virtual void Menu::Include(Control*)" Add an item to the menu. If no scene is specified, Menu will create a vbox and insert items into it. .TP .B "virtual void Menu::Popup(Event&)" Insert the body into the world centered around the coordinates associated with the event and activate the controls in the body. The menu is removed from the world when the controls are deactivated (normally when a button is released). .TP .B "void Menu::SetBody(Interactor*)" .ns .TP .B "Interactor* Menu::GetBody()" .ns .TP .B "void Menu::SetAlign(Alignment)" .ns .TP .B "Alignment Menu::GetAlign()" .ns .TP .B "void Menu::SetDepth(int)" .ns .TP .B "int GetDepth()" .ns .TP .B "void Menu::SetBodyState(ControlState*)" .ns .TP .B "ControlState* Menu::GetBodyState()" .ns .TP .B "void Menu::SetScene(Scene*)" .ns .TP .B "Scene* Menu::GetScene()" Set or get attributes of the menu. The depth of a menu is the number of pixels separating the body and the drop shadow. .TP .B "Coord Menu::InsertX()" .ns .TP .B "Coord Menu::InsertY()" Return the coordinates where the menu's body was last inserted into the world. .TP .B "MenuItem::MenuItem(Interactor*)" .ns .TP .B "MenuItem::MenuItem(const char* str, Alignment = Left)" Construct a new menu item. The second constructor defines the appearance of the item to be a message containing the text in \fIstr\fP. .TP .B "PulldownMenu::PulldownMenu(Interactor*)" .ns .TP .B "PulldownMenu::PulldownMenu(const char* str)" .ns .TP .B "PullrightMenu::PullrightMenu(Interactor*)" .ns .TP .B "PullrightMenu::PullrightMenu(const char* str)" Construct a new pulldown or pullright menu. The second constructor defines the appearance of the menu to be a message containing the text in \fIstr\fP. .TP .B "PopupMenu::PopupMenu()" Construct a new popup menu. .TP .B "MenuBar::MenuBar()" Construct a new menu bar. .TP .B "virtual void MenuBar::Include(Control*)" Add a control to a menu bar. In addition to inserting the control into the bar's hbox, this operation attaches the control to the bar's control state. .SH SEE ALSO Control(3I), Event(3I) ivtools-1.2.11a1/src/man/man3/Message.3000066400000000000000000000013531214471147700173770ustar00rootroot00000000000000.TH Message 3I "28 March 1988" "InterViews" "InterViews Reference Manual" .SH NAME Message \- interactor containing text .SH SYNOPSIS .B #include .SH DESCRIPTION A message is an interactor that contains a line of text. The alignment of the text with respect to the interactor's canvas can be specified in the constructor. .SH PUBLIC OPERATIONS .TP .B "Message(const char*, Alignment = Center, int pad = 0, int hstretch = 0, int vstretch = 0)" Construct a new message interactor with the given text string and alignment. The text will be surrounded on all sides by whitespace of width \fIpad\fP, and the horizontal and vertical stretchability of the message will be set to the indicated values. .SH SEE ALSO Interactor(3I) ivtools-1.2.11a1/src/man/man3/MoveTool.3000066400000000000000000000025141214471147700175570ustar00rootroot00000000000000.TH MoveTool 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME MoveTool \- tool for translating components .SH SYNOPSIS .B #include .SH DESCRIPTION MoveTool lets the user translate components to new positions by direct manipulation. .SH PUBLIC OPERATIONS .TP .B "MoveTool(ControlInfo* = nil)" Create a new MoveTool. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" CreateManipulator detects whether the user clicked on a component. If not, it clears the editor's selection and returns a nil manipulator. If a component was hit, and if the component was not previously selected, then CreateManipulator clears the editor's selection, selects the component the user hit, and delegates manipulator creation and interpretation to it. If the component was the only selected component, it again delegates manipulator creation and interpretation to the component, but the selection is unaltered. If the user clicks on one of many selected components, then CreateManipulator will delegate manipulator creation and interpretation without altering the selection by calling GraphicView::CreateManipulator and GraphicView::InterpretManipulator on the component. .SH SEE ALSO GraphicView(3U), Tool(3U) ivtools-1.2.11a1/src/man/man3/NOPCmd.3000066400000000000000000000007441214471147700170760ustar00rootroot00000000000000.TH NOPCmd 3U "9 August 1991" "Unidraw" "InterViews Reference Manual" .SH NAME NOPCmd \- do-nothing command .SH SYNOPSIS .B #include .SH DESCRIPTION NOPCmd is a command that does no work. It acts as a convenient and harmless placeholder. It is not reversible. .SH PUBLIC OPERATIONS .TP .B "NOPCmd(ControlInfo*)" .ns .TP .B "NOPCmd(Editor* = nil)" Create a NOPCmd. .TP .B "virtual void Execute()" NOPCmd's Execute function is empty. .SH SEE ALSO Command(3U) ivtools-1.2.11a1/src/man/man3/PadComp.3000066400000000000000000000102201214471147700173270ustar00rootroot00000000000000.TH PadComp 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME PadComp, PadView, PadGraphic, PSPad \- pad connector subject, view, structured graphic, and PostScript external representation .SH SYNOPSIS .B #include .SH DESCRIPTION PadComp is a Connector subclass that supports connectivity with two degrees of freedom. It uses a PadGraphic to store its graphical attributes. PadView is a GraphicView for displaying the pad. PSPad is a PostScriptView that externalizes the subject's information in PostScript form. .SH PADCOMP PUBLIC OPERATIONS .TP .B "PadComp(PadGraphic* = nil)" The constructor takes an optional PadGraphic that defines the pad's graphical attributes. .TP .B "virtual void Interpret(Command*)" .ns .TP .B "virtual void Uninterpret(Command*)" PadComp (un)interprets a subset of commands that connectors can generally interpret, namely MoveCmd, BrushCmd, AlignCmd, MobilityCmd, DeleteCmd, and CutCmd. .TP .B "virtual Mobility GetMobility()" .ns .TP .B "virtual void SetMobility(Mobility)" PadComp redefines these functions to return and assign its \fI_mobility\fP protected member. The pad has fixed mobility initially. .TP .B "Pad* GetPad()" Return the Pad graphic that defines the line's attributes. GetPad is simply a more specific form of the GetGraphic operation. .SH PADVIEW PUBLIC OPERATIONS .TP .B "PadView(PadComp* = nil)" Create an PadView, optionally supplying the subject. .TP .B "virtual void Interpret(Command*)" PadView interprets AlignToGridCmd to align its lower left to the grid. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" PadViews respond only to manipulation by GraphicCompTools, MoveTools, and ConnectTools. PadView inherits its MoveTool response from ConnectorView. GraphicCompTool will let the user sweep out a rectangle that reflects the pad's size. Creation will be influenced by gravity, if any. PadView creates a ConnectManip in response to the ConnectTool, which will exhibit a gravational attraction to potential target connectors. PadView will produce a ConnectCmd to connect the pad to its target. A pad connected in this way will receive floating mobility. .TP .B "PadComp* GetPadComp()" Return the subject. .SH PADVIEW PROTECTED OPERATIONS .TP .B "PadGraphic* GetPad()" Return the PadGraphic that defines the pad's attributes. GetPad is simply a more specific form of the GetGraphic operation. .TP .B "virtual PadComp* NewSubject(PadGraphic*)" A helper function that creates a PadComp subject with the given pad graphic. This function produces the proper subject when the GraphicCompTool's manipulator is interpreted. Subclasses can redefine this operation to return a PadComp subclass, thus eliminating the need to reimplement InterpretManipulator. .TP .B "Manipulator* CreateGraphicCompManip(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "Manipulator* CreateConnectManip(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "Command* InterpretGraphicCompManip(Manipulator*)" .ns .TP .B "Command* InterpretConnectManip(Manipulator*)" Helper functions used by CreateManipulator and InterpretManipulator to create and interpret the manipulators associated with GraphicCompTool and ConnectTool. .SH PADGRAPHIC PUBLIC OPERATIONS .TP .B "PadGraphic(" .ns .TP .B " Coord = 0, Coord = 0, Coord = 0, Coord = 0," .ns .TP .B " Graphic* = nil .ns .TP .B ")" .br Create a PadGraphic, optionally specifying lower-left and upper-right corners and a graphic from which to obtain its default graphics attributes. .TP .B "void GetOriginal(Coord&, Coord&, Coord&, Coord&)" Return the PadGraphic's original coordinates as specified in the constructor. .SH PSPAD PUBLIC OPERATIONS .TP .B "PSPad(PadComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH SEE ALSO BrushCmd(3U), ConnectTool(3U), Connector(3U), ConnectorView3U), Event(3I), Graphic(3U), GraphicCompTool(3U), Grid(3U), MoveTool(3U), PatternCmd(3U), PostScriptView(3U), Transformer(3I), Viewer(3U), align(3U), edit(3U), manips(3U), transforms(3U) ivtools-1.2.11a1/src/man/man3/Page.3000066400000000000000000000021411214471147700166630ustar00rootroot00000000000000.TH Page 3U "6 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Page \- defines and displays a visual boundary for a viewer .SH SYNOPSIS .B #include .SH DESCRIPTION A Page object delineates an area of interest in a viewer. The page's appearance guides the user to stay within a particular area, and the page's bounding box defines the total scrollable area in the viewer. Page displays a rectangle by default, but the boundary can be an arbitrary graphic. The page occludes any graphical components in the viewer. A typical use for a page is to define the page boundary in a drawing editor; graphics beyond this area will not appear on the printed page. .SH PUBLIC OPERATIONS .TP .B "Page(float width, float height)" Instantiate a rectangular page with dimensions \fIwidth\fP and \fIheight\fP, in pixels. .TP .B "Page(Graphic*)" Instantiate a page of arbitrary appearance, as defined by a graphic. The graphic's bounding box defines the total scrollable area. .TP .B "virtual Graphic* GetGraphic()" Returns the graphic defining the page's appearance. .SH SEE ALSO Graphic(3U), Viewer(3U) ivtools-1.2.11a1/src/man/man3/Painter.3000066400000000000000000000213541214471147700174200ustar00rootroot00000000000000.TH Painter 3I "15 June 1987" "InterViews" "InterViews Reference Manual" .SH NAME Painter \- graphics output .SH SYNOPSIS .B #include .SH DESCRIPTION .B Painter is a class that provides ``immediate-mode'' graphics operations for drawing on a canvas. The state of a painter defines the graphics context for the drawing operations and includes a brush, foreground and background colors, a fill pattern and mode, a text font, a text style, an output origin and current position, and a transformation matrix. .SH STATE OPERATIONS .TP .B "Painter(Painter* = stdpaint)" Create a new painter and copy its state from the given painter. .TP .B "void SetBrush(Brush*)" .ns .TP .B "Brush* GetBrush()" Set or return the painter's brush. Default is the predefined brush ``single''. .TP .B "void SetColors(Color* fg, Color* bg)" .ns .TP .B "Color* GetFgColor()" .ns .TP .B "Color* GetBgColor()" Set or return the painter's colors. If either argument to SetColors is nil, then the corresponding color is not changed. Defaults are ``black'' for foreground and ``white'' for background. .TP .B "void SetFont(Font*)" .ns .TP .B "Font* GetFont()" Set or return the painter's text font. Default is the predefined font ``stdfont''. .TP .B "void SetStyle(int style)" .ns .TP .B "int GetStyle()" Set or get the painter's text style. A text style is a bit vector that can be assembled from the predefined constants \fIPlain\fP, \fIBoldface\fP, \fIUnderlined\fP, and \fIReversed\fP. Default is Plain. .TP .B "void SetPattern(Pattern*)" .ns .TP .B "Pattern* GetPattern()" .ns .TP .B "void FillBg(boolean mode)" .ns .TP .B "boolean BgFilled()" Set or return the painter's fill pattern and mode. If the mode is \fItrue\fP, fill operations will set pixels corresponding to ones in the current fill pattern to the foreground color and pixels corresponding to zeros to the background color. If \fIfalse\fP, then only foreground pixels will be set. Default pattern is ``solid''; default mode is \fItrue\fP. .TP .B "void SetOrigin(int x0, int y0)" .ns .TP .B "void GetOrigin(int& x0, int& y0)" Set or return the origin by which all coordinates are offset. Default is (0,\ 0). .TP .B "void Translate(float dx, float dy)" .ns .TP .B "void Rotate(float angle)" .ns .TP .B "void Scale(float x, float y)" .ns .TP .B "void SetTransformer(Transformer*)" .ns .TP .B "Transformer* GetTransformer()" Coordinates passed to drawing operations are transformed according to the current origin, translation (cumulative), rotation, and scale factor. Internally, a transformation matrix is stored that can be directly set and accessed using SetTransformer and GetTransformer. The default transformer is nil, meaning no transformations are performed. .TP .B "void SetPlaneMask(int mask)" Set which bit planes are affected by drawing operations. If the Kth bit of \fImask\fP is set, then display operations will draw on plane K. .TP .B "void SetOverwrite(boolean)" Set whether a painter is allowed to write in subcanvases. If true, drawing operations will be able to write over the canvases of component interactors. If false, drawing operations will be clipped by any subcanvases. The default is false. .TP .B "void Clip(Canvas*, Coord x1, Coord y1, Coord x2, Coord y2)" .ns .TP .B "void NoClip()" Clip restricts output operations to the specified region of the canvas. NoClip removes the restriction so that operations affect the entire canvas. Only one clipping region may be in effect at a time. .TP .B "void MoveTo(Coord x, Coord y)" Set the current output position. The output position is used and updated by Text and CurveTo. .SH DRAWING OPERATIONS .TP .B "void Curve(Canvas*, Coord x0, y0, x1, y1, x2, y2, x3, y3)" .ns .TP .B "void CurveTo(Canvas*, Coord x1, y1, x2, y2, x3, y3)" Paint a Bezier curve on the canvas from the first point to the last point (but not going through the intermediate control points). The curve will lie within the polygon formed by the four points. CurveTo uses the current position for the first point. .TP .B "void BSpline(Canvas*, Coord x[], y[], int n)" .ns .TP .B "void ClosedBSpline(Canvas*, Coord x[], y[], int n)" .ns .TP .B "void FillBSpline(Canvas*, Coord x[], y[], int n)" Draw the B-spline defined by the \fIn\fP control vertices. If closed or filled, the last point is connected to the first point. .TP .B "void Circle(Canvas*, Coord x, y, int r)" .ns .TP .B "void FillCircle(Canvas*, Coord x, y, int radius)" Draw a circle with center (\fIx\fP,\ \fIy\fP) and radius \fIr\fP. .TP .B "void Ellipse(Canvas*, Coord x, y, int xr, int yr)" .ns .TP .B "void FillEllipse(Canvas*, Coord x, y, int xr, int yr)" Draw an ellipse with center (\fIx\fP,\ \fIy\fP), horizontal radius \fIxr\fP, and vertical radius \fIyr\fP. .TP .B "void Line(Canvas*, Coord x1, y1, x2, y2)" .ns .TP .B "void MultiLine(Canvas*, Coord x[], y[], int n)" .ns .TP .B "void Polygon(Canvas*, Coord x[], y[], int n)" .ns .TP .B "void FillPolygon(Canvas*, Coord x[], y[], int n)" Draw a path using the current brush and colors. The Line operation draws a vector between two points (inclusive); MultiLine draws a number of connected vectors; Polygon draws a closed set of vectors; FillPolygon fills the area inside a polygon using the current fill pattern and colors. .TP .B "void Point(Canvas*, Coord x, y)" .ns .TP .B "void MultiPoint(Canvas*, Coord x[], y[], int n)" Set a point or set of points to the current foreground color. .TP .B "void Rect(Canvas*, Coord x1, y1, x2, y2)" .ns .TP .B "void FillRect(Canvas*, Coord x1, y1, x2, y2)" .ns .TP .B "void ClearRect(Canvas*, Coord x1, y1, x2, y2)" Draw a rectangle with opposite corners specfied by (\fIx1\fP,\ \fIy1\fP) and (\fIx2\fP,\ \fIy2\fP). FillRect fills the rectangle using the current pattern and colors; ClearRect fills the rectangle with the background color. .TP .B "void Text(Canvas*, const char* str, Coord x, Coord y)" .ns .TP .B "void Text(Canvas*, const char* str, int n, Coord x, Coord y)" .ns .TP .B "void Text(Canvas*, const char* str)" .ns .TP .B "void Text(Canvas*, const char* str, int n)" Draw a string or substring of text using the current Font and text style. The (\fIx\fP,\ \fI\y\fP) coordinates specify the lower-left corner of the bounding box of the text. The width of the bounding box is the width of the string as reported by the Font::Width operation, and the height of the bounding box is the Font height. Most fonts will result in output which only affects pixels within the bounding box. The current transformation matrix is applied to both the positions and the shapes of characters drawn. If the matrix specifies a transformation involving rotation or scaling, the resulting operation may proceed much more slowly than normal. If background fill mode is on, then the characters are drawn in the foreground color, and other pixels within the bounding box are set to the background color. If background fill mode is off, only the foreground pixels are set. If no coordinates are specified, then the current position (defined by MoveTo) is used and updated to reflect the lower-right corner of the bounding box. .TP .B "void Stencil(Canvas*, Coord x, Coord y, Bitmap* image, Bitmap* mask = nil)" Paint foreground and background colors through a stencil formed by positioning the image and mask Bitmaps with their origins at the point (\fIx\fP,\ \fIy\fP). Foreground color is painted where the \fIimage\fP Bitmap has a true value and background color where image is false. However, only pixels corresponding to a true value in the mask Bitmap are affected. A nil \fImask\fP is equivalent to a mask of the same size and shape as image and containing all true values. The current transformation matrix is applied to both the image and mask Bitmaps. If the matrix specifies a transformation involving rotation or scaling, the resulting operation may proceed much more slowly than normal. .TP .B "void RasterRect(Canvas*, Coord x, Coord y, Raster*)" Render the Raster with its lower-left corner at the position (\fIx\fP,\ \fIy\fP). The current transformation matrix is applied to the Raster. If the matrix specifies a transformation involving rotation or scaling, the resulting operation may proceed much more slowly than normal. .TP .B "void Read(Canvas*, void*, Coord x1, y1, x2, y2)" .ns .TP .B "void Write(Canvas*, const void*, Coord x1, y1, x2, y2)" .ns .TP .B "void Copy(Canvas* src, Coord x1, y1, x2, y2, Canvas* dst, Coord x0, y0)" Read copies a region of a canvas into memory. Write copies data from memory to a region of a canvas. Copy reads a region of one canvas and writes the data into a region of another canvas (or within a canvas if \fIsrc\fP and \fIdst\fP are the same). The point (\fIx0\fP,\ \fIy0\fP) is the lower-left corner of the destination region. Note that \fIRead\fP and \fIWrite\fP are superceded by operations that use Rasters. .SH SEE ALSO Bitmap(3I), Brush(3I), Canvas(3I), Color(3I), Font(3I), Pattern(3I), Raster(3I), Transformer(3I) ivtools-1.2.11a1/src/man/man3/Panner.3000066400000000000000000000051511214471147700172360ustar00rootroot00000000000000.TH Panner 3I "15 January 1988" "InterViews" "InterViews Reference Manual" .SH NAME Panner \- two-dimensional scrolling and zooming .SH SYNOPSIS .B #include .SH DESCRIPTION A panner is an interactor that manipulates the perspective of another interactor to provide two-dimensional scrolling and zooming. A panner is composed of a \fIslider\fP and several adjusters, including two zoomers and four movers. The slider's position and size reflect the current origin, size, and aspect ratio in the interactor's perspective. Dragging the slider around with the mouse changes the perspective's \fIcurx\fP and \fIcury\fP members. .SH PUBLIC OPERATIONS .TP .B "Panner(Interactor*, int size = 0)" Create a panner for the given interactor, optionally with the given width. If the size is 0, a reasonable default size is used. The panner's aspect ratio reflects that of the perspective. .TP .B "Slider(Interactor*)" .ns .TP .B "Slider::Handle(Event&)" .ns .TP .B "Slider::Reshape(Shape&)" .ns .TP .B "Slider::Update()" A slider reflects and lets the user specify the visible portion of the view. A rectangle represents the visible area, while the area surrounding it represents the total area. Clicking and holding down any mouse button on the rectangle allows you to drag it to a different position within the total area. The perspective's current origin is shifted to reflect the new position when the button is released. Holding down the shift key while dragging the rectangle constrains its motion horizontally or vertically. Clicking outside the rectangle moves it in the corresponding one of eight directions; for example, clicking to the right of the rectangle moves it to the right. If the left mouse button is used, the movement increment equals the perspective's \fIsx\fP or \fIsy\fP member variables. The middle mouse button increments by \fIlx\fP or \fIly\fP, and the right mouse button centers the rectangle around the cursor. The Reshape call sets the width of the slider to that of the passed Shape and calls Change on the parent interactor. Update redisplays the slider to reflect a change in the interactor's perspective. .SH X DEFAULTS The ``syncScroll'' resource specifies whether the slider should work in real-time or not. When synchronized scrolling is employed the interactor scrolls synchronously as the slider is dragged; otherwise the slider's outline follows the mouse during dragging, and the interactor is scrolled only after the user stops dragging the slider. Sliders will scroll synchronously if their syncScroll resource is set to ``on'' or ``true.'' .SH SEE ALSO Adjuster(3I), Interactor(3I), Perspective(3I) ivtools-1.2.11a1/src/man/man3/Path.3000066400000000000000000000015641214471147700167130ustar00rootroot00000000000000.TH Path 3U "6 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Path \- record of connectors visited during dataflow .SH SYNOPSIS .B #include .SH DESCRIPTION A Path object stores a record of connectors that have been visited during dataflow. Transfer functions, state variables, connectors, and other components can use the information in the path to determine whether data should be transmitted, for example, to avoid circular flow. .SH PUBLIC OPERATIONS .TP .B "Path(Path* = nil)" Instantiate a new path, optionally with a duplicate of the information contained in the given path. .TP .B "virtual void Visit(Connector*)" Register a connector as having been visited. .TP .B "virtual boolean Visited(Connector*)" Return whether or not a connector has been registered previously with the path. .SH SEE ALSO Connector(3U), StateVar(3U), TransferFunct(3U) ivtools-1.2.11a1/src/man/man3/Pattern.3000066400000000000000000000022721214471147700174310ustar00rootroot00000000000000.TH Pattern 3I "" "InterViews Reference Manual" .SH NAME Pattern \- fill patterns .SH SYNOPSIS .B #include .SH DESCRIPTION A pattern defines how to fill areas during graphics operations. A pattern is essentially a mask for drawing that is replicated to fill the size of the destination. .PP N.B.: Patterns are relatively low-level objects, typically used to implement an alpha value for a color. Since the color object now supports an alpha value, there is no need to use patterns. .SH PUBLIC OPERATIONS .TP .B "Pattern()" Create a solid pattern. .TP .B "Pattern(char*, unsigned int width, unsigned int height)" Create a pattern with the given width and height, using the bits described by the first parameter. .TP .B "Pattern(int)" Create a 4x4 pattern determined from the least significant 16 bits of the parameter. .TP .B "Pattern(int*)" Construct a 16x16 pattern from the given data. This function is provided solely for backward compatibility and will be removed in the future. .TP .B "Pattern(Bitmap*)" Construct a pattern from the bitmap. If necessary, the bitmap will be tiled or truncated to satisfy window system requirements for fill pattern sizes. .SH SEE ALSO Painter(3I) ivtools-1.2.11a1/src/man/man3/PatternCmd.3000066400000000000000000000014571214471147700200610ustar00rootroot00000000000000.TH PatternCmd 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME PatternCmd \- command for setting components' pattern attribute .SH SYNOPSIS .B #include .SH DESCRIPTION PatternCmd is a purely interpretive command for setting the pattern attribute of selected components. .SH PUBLIC OPERATIONS .TP .B "PatternCmd(ControlInfo*, PSPattern* = nil)" .ns .TP .B "PatternCmd(Editor* = nil, PSPattern* = nil)" Create a PatternCmd, optionally specifying the PSPattern that components should adopt. .TP .B "virtual void Execute()" PatternCmd extends Execute to set the value of the affected editor's PatternVar instance, if it defines one. .TP .B "PSPattern* GetPattern()" Return the PSPattern supplied in the constructor. .SH SEE ALSO Command(3U), pspaint(3U), statevars(3U) ivtools-1.2.11a1/src/man/man3/Perspective.3000066400000000000000000000034611214471147700203060ustar00rootroot00000000000000.TH Perspective 3I "15 June 1987" "InterViews" "InterViews Reference Manual" .SH NAME Perspective \- visible portion of an interactor .SH SYNOPSIS .B #include .SH DESCRIPTION A perspective object describes which part of an interactor's total display area is visible in the interactor's canvas. The main use of perspectives is for scrolling, panning, and zooming interactors. The member variables (\fIx0\fP,\ \fIy0\fP) define the origin of the interactor's display area; \fIwidth\fP and \fIheight\fP define the total height of the area. The member variables (\fIcurx\fP,\ \fIcury\fP) define the lower-left corner of the interactor's canvas relative to the total area; \fIcurwidth\fP and \fIcurheight\fP define how much of the total area is displayed in the canvas. .PP The member variables \fIsx\fP, \fIsy\fP, \fIlx\fP, and \fIly\fP specify small and large increments in each dimension. These increments are used by a scroller to implement line and page scrolling. .SH PUBLIC OPERATIONS .TP .B "Perspective()" Define a new perspective with all member variables initialized to zero. .TP .B "void Attach(Interactor*)" Add to the list of interactors that are interested in updates to the perspective. These interactors reflect the perspective visually; examples include scrollers and sliders. .TP .B "void Detach(Interactor*)" Remove an interactor from the list of those interested in updates. This operation should be called from the interactor's destructor. .TP .B "void Init(Coord x0, Coord y0, Coord width, Coord height)" Initialize the perspective display area. .TP .B "void Update()" Notify all the interactors interested in the perspective that it has changed. The perspective's interactor should call Update after modifying its perspective. .SH SEE ALSO Adjuster(3I), Interactor(3I), Panner(3I), Scroller(3I) ivtools-1.2.11a1/src/man/man3/Picture.3000066400000000000000000000031541214471147700174270ustar00rootroot00000000000000.TH Picture 3U "1 February 1991" "Unidraw" "InterViews Reference Manual" .SH NAME Picture \- composite structured graphic .SH SYNOPSIS .B #include .SH DESCRIPTION A Picture defines a composition of graphic objects. A picture has its own graphics state, which it concatenates with its children's state when it is drawn or erased. Picture adopts the default concatenation semantics supported by the Graphic base class: The picture's graphics state effectively overrides its children's so that they are drawn with the picture's state information substituted for their own. A child's attribute is used only when the picture does not already define it. Moreover, each child's transformer is postmultiplied by the picture's transformer when the picture is drawn; thus children are drawn relative to the picture's coordinate system. .SH PUBLIC OPERATIONS .TP .B "Picture(Graphic* = nil)" Construct a new picture, optionally supply a graphic from which to copy an initial set of graphics state. Picture is derived from FullGraphic and therefore defines a full set of graphics state. .TP .B "virtual ~Picture()" The picture deletes its children when it is deleted. .TP .B "boolean IsEmpty()" Picture defines IsEmpty in addition to the standard Graphic child traversal operations to provide a convenient way to check if the picture has any children. .SH PROTECTED OPERATIONS .TP .B "Graphic* graphic(UList*)" .ns .TP .B "UList* Elem(Iterator)" Convenience functions for extracting a graphic from a UList element and a UList from an iterator. .SH SEE ALSO Graphic(3U), Iterator(3U), Transformer(3I), UList(3U), pspaint(3U) ivtools-1.2.11a1/src/man/man3/PinComp.3000066400000000000000000000107031214471147700173570ustar00rootroot00000000000000.TH PinComp 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME PinComp, PinView, PinGraphic, PSPin \- pin connector subject, view, structured graphic, and PostScript external representation SlidingPin, FixedPin \- rubberbands used in pin manipulation .SH SYNOPSIS .B #include .SH DESCRIPTION PinComp is a Connector subclass that supports connectivity with zero degrees of freedom. It uses a PinGraphic to store its graphical attributes. PinView is a GraphicView for displaying the pin. PSPin is a PostScriptView that externalizes the subject's information in PostScript form. SlidingPin and FixedPin are special rubberbands used to implement the animation effects that pins produce during direct manipulation. A SlidingPin is a circle with crosshairs (duplicating the appearance of a PinGraphic) that follows the mouse position, while a FixedPin draws a static circle with crosshairs. .SH PINCOMP PUBLIC OPERATIONS .TP .B "PinComp(PinGraphic* = nil)" The constructor takes an optional PinGraphic that defines the pin's graphical attributes. The pad has fixed mobility initially .TP .B "virtual void Interpret(Command*)" .ns .TP .B "virtual void Uninterpret(Command*)" PinComp (un)interprets a subset of commands that connectors can generally interpret, namely MoveCmd, BrushCmd, AlignCmd, MobilityCmd, DeleteCmd, and CutCmd. .TP .B "virtual Mobility GetMobility()" .ns .TP .B "virtual void SetMobility(Mobility)" PinComp redefines these functions to return and assign its \fI_mobility\fP protected member. The pin has fixed mobility initially. .TP .B "Pin* GetPin()" Return the Pin graphic that defines the line's attributes. GetPin is simply a more specific form of the GetGraphic operation. .SH PINVIEW PUBLIC OPERATIONS .TP .B "PinView(PinComp* = nil)" Create an PinView, optionally supplying the subject. .TP .B "virtual void Interpret(Command*)" PinView interprets AlignToGridCmd to align its lower left to the grid. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" PinViews respond only to manipulation by GraphicCompTools, MoveTools, and ConnectTools. PinView inherits its MoveTool response from ConnectorView. GraphicCompTool will let the user place the pin at a particular position. Placement will be influenced by gravity, if any. PinView creates a ConnectManip in response to the ConnectTool, which will exhibit a gravational attraction to potential target connectors. PinView will produce a ConnectCmd to connect the pin to its target. A pin connected in this way will receive floating mobility. .TP .B "PinComp* GetPinComp()" Return the subject. .SH PINVIEW PROTECTED OPERATIONS .TP .B "PinGraphic* GetPin()" Return the PinGraphic that defines the pin's attributes. GetPin is simply a more specific form of the GetGraphic operation. .TP .B "virtual PinComp* NewSubject(PinGraphic*)" A helper function that creates a PinComp subject with the given pin graphic. This function produces the proper subject when the GraphicCompTool's manipulator is interpreted. Subclasses can redefine this operation to return a PinComp subclass, thus eliminating the need to reimplement InterpretManipulator. .TP .B "Manipulator* CreateGraphicCompManip(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "Manipulator* CreateConnectManip(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "Command* InterpretGraphicCompManip(Manipulator*)" .ns .TP .B "Command* InterpretConnectManip(Manipulator*)" Helper functions used by CreateManipulator and InterpretManipulator to create and interpret the manipulators associated with GraphicCompTool and ConnectTool. .SH PINGRAPHIC PUBLIC OPERATIONS .TP .B "PinGraphic(Coord = 0, Coord = 0, Graphic* = nil)" Create a PinGraphic, optionally specifying its center and a graphic from which to obtain its default graphics attributes. .TP .B "void GetOriginal(Coord&, Coord&)" Return the PinGraphic's original center coordinates as specified in the constructor. .SH PSPIN PUBLIC OPERATIONS .TP .B "PSPin(PinComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH SEE ALSO BrushCmd(3U), ConnectTool(3U), Connector(3U), ConnectorView3U), Event(3I), Graphic(3U), GraphicCompTool(3U), Grid(3U), MoveTool(3U), PatternCmd(3U), PostScriptView(3U), Rubband(3I), Transformer(3I), Viewer(3U), align(3U), edit(3U), manips(3U), transforms(3U) ivtools-1.2.11a1/src/man/man3/PolygonComp.3000066400000000000000000000044401214471147700202610ustar00rootroot00000000000000.TH PolygonComp 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME PolygonComp, PolygonView, PSPolygon \- polygon component subject, view, and PostScript external representation .SH SYNOPSIS .B #include .SH DESCRIPTION PolygonComp is a VerticesComp that defines a polygon. It uses an SF_Polygon graphic to store its graphical attributes. PolygonView is a VerticesView for displaying the polygon. PSPolygon is a PSVertices that externalizes the subject's information in PostScript form. .SH POLYGONCOMP PUBLIC OPERATIONS .TP .B "PolygonComp(SF_Polygon* = nil)" The constructor takes an optional stroked-filled polygon graphic that defines the attributes of the polygon. .TP .B "SF_Polygon* GetPolygon()" Return the Polygon graphic that defines the polygon's attributes. GetPolygon is simply a more specific form of the GetGraphic operation. .SH POLYGONVIEW PUBLIC OPERATIONS .TP .B "PolygonView(PolygonComp* = nil)" Create an PolygonView, optionally supplying the subject. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" PolygonView redefines its response to manipulation with a GraphicCompTool. The user clicks the left mouse button to specify each vertex and clicks with the middle mouse button to specify the final vertex. Vertex positioning will be constrained by gravity, if any. PolygonView also defines a response to the ReshapeTool, allowing the user to click on one of its vertices to reposition it. The subject is actually replaced (via ReplaceCmd) with a new PolygonComp subject reflecting the repositioned vertex. Repositioning will be influenced by gravity. .TP .B "PolygonComp* GetPolygonComp()" Return the subject. .SH PSPOLYGON PUBLIC OPERATIONS .TP .B "PSPolygon(PolygonComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH PSPOLYGON PROTECTED OPERATIONS .TP .B "virtual const char* Name()" PSPolygon identifies itself as "Poly" in the PostScript output. .SH SEE ALSO Event(3I), GraphicComp(3U), GraphicCompTool(3U), GraphicView(3U), Grid(3U), PatternCmd(3U), PostScriptView(3U), ReshapeTool(3U), Rubband(3I), Transformer(3I), VerticesComp(3U), Viewer(3U), align(3U), edit(3U), polygons(3U) ivtools-1.2.11a1/src/man/man3/PostScriptView.3000066400000000000000000000161531214471147700207640ustar00rootroot00000000000000.TH PostScriptView 3U "19 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME PostScriptView, PostScriptViews \- base classes for external representation objects that generate PostScript code .SH SYNOPSIS .B #include .SH DESCRIPTION PostScriptView is a PreorderView that serves as the abstract base class for external representation objects for emitting PostScript code. A PostScriptView's subject is normally a GraphicComp subclass. PostScriptViews is a subclass of PostScriptView for composite PostScript external views. .SH POSTSCRIPTVIEW PUBLIC OPERATIONS .TP .B "virtual boolean Emit(ostream&)" PostScriptView redefines Emit to generate header information. Thus you can call Emit on any PostScriptView subclass to generate encapsulated PostScript. Subclasses redefine Definition to generate the PostScript fragment that defines their basic attributes. .TP .B "GraphicComp* GetGraphicComp()" Return the subject. .SH POSTSCRIPTVIEW PROTECTED OPERATIONS .TP .B "PostScriptView(GraphicComp* = nil)" Initialize a PostScriptView, optionally of the given GraphicComp. The constructor is protected to disallow instantiation. .SH PostScriptView defines numerous protected helper functions to make it easier for subclasses to generate the PostScript that describes their appearance. The output conforms to the original idraw PostScript format. .TP .B "virtual void Comments(ostream&)" .ns .TP .B "virtual void PSVersion(ostream&)" .ns .TP .B "virtual void Creator(ostream&)" .ns .TP .B "virtual void FontNames(ostream&)" .ns .TP .B "virtual void Pages(ostream&)" .ns .TP .B "virtual void BoundingBox(ostream&)" The Comments operation generates a standard PostScript comments block. Comments calls the other operations to generate a complete set of comments. .TP .B "virtual void Prologue(ostream&)" .ns .TP .B "virtual void Version(ostream&)" .ns .TP .B "virtual void GridSpacing(ostream&)" .ns .TP .B "virtual void Trailer(ostream&)" Operations that generate global data, procedures, and idraw-format-specific information. .TP .B "virtual void MinGS(ostream&)" .ns .TP .B "virtual void FullGS(ostream&)" .ns .TP .B "virtual void TextGS(ostream&)" .ns .TP .B "virtual void Brush(ostream&)" .ns .TP .B "virtual void FgColor(ostream&)" .ns .TP .B "virtual void BgColor(ostream&)" .ns .TP .B "virtual void Font(ostream&)" .ns .TP .B "virtual void Pattern(ostream&)" .ns .TP .B "virtual void Transformation(ostream&)" Operations that generate graphics state information. All output the graphics state attribute that their name suggests, with three exceptions: MinGS outputs a minimal set of graphics state defined by practical graphic objects, namely a brush, foreground and background colors, a pattern, and a transformation matrix. TextGS outputs the graphics state required by textual graphics, including a foreground color, a font, and a transformation matrix. FullGS generates a full set of graphics state. .TP .B "virtual void SetPSFonts(UList*)" .ns .TP .B "virtual UList* GetPSFonts()" Get and set the list of all PostScript font names required by the PostScriptView. This set of names appears in a comment near the beginning of the generated output as required by standard PostScript conventions. .TP .B "virtual void GetBox(Coord&, Coord&, Coord&, Coord&)" Return the bounding box of the graphic for which PostScript is being generated. These values also appear in a standard PostScript comment. .TP .B "virtual void GridSpacing(float&, float&)" Return the grid spacing, if applicable. Idraw requires this information, and it is buried in a comment. .TP .B "virtual void BeginProc(ostream&)" .ns .TP .B "virtual void EndProc(ostream&)" Begin and end a scope for defining a graphical object. .TP .B "virtual void ConstProcs(ostream&)" Generate PostScript procedures containing constant information, such as the character encoding dictionary, string length limit, etc. .TP .B "virtual void SetGSProcs(ostream&)" .ns .TP .B "virtual void SetBrushProc(ostream&)" .ns .TP .B "virtual void SetFgColorProc(ostream&)" .ns .TP .B "virtual void SetBgColorProc(ostream&)" .ns .TP .B "virtual void SetFontProc(ostream&)" .ns .TP .B "virtual void SetPatternProc(ostream&)" Generate PostScript procedures for setting graphics state attributes. .TP .B "virtual void ObjectProcs(ostream&)" .ns .TP .B "virtual void BSplineProc(ostream&)" .ns .TP .B "virtual void CircleProc(ostream&)" .ns .TP .B "virtual void ClosedBSplineProc(ostream&)" .ns .TP .B "virtual void EllipseProc(ostream&)" .ns .TP .B "virtual void LineProc(ostream&)" .ns .TP .B "virtual void MultiLineProc(ostream&)" .ns .TP .B "virtual void PolygonProc(ostream&)" .ns .TP .B "virtual void RectangleProc(ostream&)" .ns .TP .B "virtual void TextProc(ostream&)" Generate PostScript procedures for instantiating basic graphical objects. .TP .B "virtual void MiscProcs(ostream&)" .ns .TP .B "virtual void DefinitionProc(ostream&)" .ns .TP .B "virtual void FillProc(ostream&)" .ns .TP .B "virtual void StrokeProc(ostream&)" .ns .TP .B "virtual void ShowProc(ostream&)" .ns .TP .B "virtual void PatternProc(ostream&)" .ns .TP .B "virtual void MinMaxProcs(ostream&)" .ns .TP .B "virtual void MidpointProc(ostream&)" .ns .TP .B "virtual void ThirdpointProc(ostream&)" .ns .TP .B "virtual void SubsplineProc(ostream&)" .ns .TP .B "virtual void StoreVerticesProc(ostream&)" MiscProcs encapsulates calls to the subsequent PostScript procedure-generating operations shown above. DefinitionProc generates PostScript code that declares a procedure. FillProc and StrokeProc fill and stroke the path that a graphical object defines. ShowProc fine-tunes a text object's position. PatternProc creates a PostScript rendition of a pattern. MinMaxProcs define min and max functions. MidpointProc and ThirdpointProc calculate the point midway and one-third the way between two points, respectively. SubsplineProc breaks the vertices defining a spline into smaller pieces to allow approximating the spline with Bezier curves. Finally, StoreVerticesProc stores a set of vertices in arrays. .TP .B "PSFont* GetFont(UList*)" .ns .TP .B "PostScriptView* View(UList*)" Convenience functions that return the PSFont and PostScriptView in UList elements, respectively. .TP .B "PostScriptView* CreatePSView(GraphicComp*)" Create the appropriate PostScriptView subclass for the given GraphicComp. The relationship between subjects, views, and view categories is encoded in their class identifiers. See classes(3U) for more information on class identifiers and view categories. .SH POSTSCRIPTVIEWS PUBLIC OPERATIONS .TP .B "PostScriptViews(GraphicComps* = nil)~ The constructor takes the subject as an optional argument. .TP .B "virtual boolean Update()" For simplicity, PostScriptViews reconciles its state with its subject's by destroying its children and reconstructing them from scratch. .SH POSTSCRIPTVIEWS PROTECTED OPERATIONS .TP .B "UList* Elem(Iterator)" A convenience function for extracting a UList from an iterator. .TP .B "void DeleteView(Iterator&)" .ns .TP .B "void DeleteViews()" DeleteView removes a child and deletes it, while DeleteViews removes and deletes all children. .SH SEE ALSO ExternView(3U), GraphicComp(3U), GraphicView(3U), UList(3U), classes(3U), idraw(1I), pspaint(3U) ivtools-1.2.11a1/src/man/man3/RasterComp.3000066400000000000000000000030301214471147700200640ustar00rootroot00000000000000.TH RasterComp 3U "10 August 1991" "Unidraw" "InterViews Reference Manual" .SH NAME RasterComp, RasterView, PSRaster \- raster component subject, view, and PostScript external representation .SH SYNOPSIS .B #include .SH DESCRIPTION RasterComp is a GraphicComp that represents a raster image. It uses a RasterRect graphic to store its graphical attributes. RasterView is a GraphicView for displaying the raster image. PSRaster is a PostScriptView that externalizes the subject's information in PostScript form. .SH RASTERCOMP PUBLIC OPERATIONS .TP .B "RasterComp(RasterRect* = nil, const char* filename = nil)" The constructor takes an optional RasterRect structured graphic that defines the attributes of the raster image. You can also supply an optional file name to associate the component with a file containing the (copious) image data. .TP .B "RasterRect* GetRasterRect()" Return the RasterRect graphic that defines the raster's attributes. GetRaster is simply a more specific form of the GetGraphic operation. .TP .B "const char* GetFileName()" Return the file name specified in the constructor, if any. .SH RASTERVIEW PUBLIC OPERATIONS .TP .B "RasterView(RasterComp* = nil)" Create an RasterView, optionally supplying the subject. .TP .B "RasterComp* GetRasterComp()" Return the subject. .SH PSRASTER PUBLIC OPERATIONS .TP .B "PSRaster(RasterComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH SEE ALSO GraphicComp(3U), GraphicView(3U), PostScriptView(3U), RasterRect(3U) ivtools-1.2.11a1/src/man/man3/RasterRect.3000066400000000000000000000013751214471147700200750ustar00rootroot00000000000000.TH RasterRect 3U "2 February 1991" "Unidraw" "InterViews Reference Manual" .SH NAME RasterRect \- structured graphic displaying a raster image .SH SYNOPSIS .B #include .SH DESCRIPTION A RasterRect is a Graphic that displays a raster image defined by a Raster object. With no transformation, the raster will be drawn with its lower-left corner at the origin. .SH PUBLIC OPERATIONS .TP .B "RasterRect(Raster*, Graphic* = nil)" Construct a RasterRect, supplying a Raster object and an optional graphic from which to obtain an initial transformation. The RasterRect references the given graphic. .TP .B "Raster* GetOriginal()" Return the raster that defines the image that the RasterRect displays. .SH SEE ALSO Graphic(3U), Raster(3I) ivtools-1.2.11a1/src/man/man3/RectComp.3000066400000000000000000000046611214471147700175340ustar00rootroot00000000000000.TH RectComp 3U "22 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME RectComp, RectView, PSRect \- rectangle component subject, view, and PostScript external representation .SH SYNOPSIS .B #include .SH DESCRIPTION RectComp is a GraphicComp that defines a rectangle. It uses an SF_Rect graphic to store its graphical attributes. RectView is a GraphicView for displaying the rectangle. PSRect is a PostScriptView that externalizes the subject's information in PostScript form. .SH RECTCOMP PUBLIC OPERATIONS .TP .B "RectComp(SF_Rect* = nil)" The constructor takes an optional stroked-filled rectangle that defines the attributes of the rectangle. .TP .B "SF_Rect* GetRect()" Return the SF_Rect graphic that defines the rectangle's attributes. GetRect is simply a more specific form of the GetGraphic operation. .SH RECTVIEW PUBLIC OPERATIONS .TP .B "RectView(RectComp* = nil)" Create an RectView, optionally supplying the subject. .TP .B "virtual void Interpret(Command*)" RectView interprets AlignToGridCmd to align its lower-left to the grid. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" RectView redefines its response to manipulation with a GraphicCompTool. GraphicCompTool will let the user sweep out a rectangle that reflects the RectComp's size. Creation will be influenced by gravity, if any. RectView also defines a response to the ReshapeTool, allowing the user to click on one of its corners to reposition it. The subject is actually replaced (via ReplaceCmd) with a PolygonComp subject reflecting the repositioned corner. Repositioning will be influenced by gravity. .TP .B "virtual void GetCorners(Coord*, Coord*)" GetCorners takes two arrays of four Coord values and stores into them the coordinates of its corners, in canvas coordinates. .TP .B "RectComp* GetRectComp()" Return the subject. .SH RECTVIEW PROTECTED OPERATIONS .TP .B "virtual void CreateHandles()" RectView redefines CreateHandles to use a RubberHandles object with four handles, one at each corner of the rectangle. .SH PSRECT PUBLIC OPERATIONS .TP .B "PSRect(RectComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH SEE ALSO GraphicComp(3U), GraphicCompTool(3U), GraphicView(3U), Grid(3U), PolygonComp(3U), PostScriptView(3U), ReshapeTool(3U), align(3U), edit(3U), polygons(3U) ivtools-1.2.11a1/src/man/man3/Regexp.3000066400000000000000000000035521214471147700172500ustar00rootroot00000000000000.TH Regexp 3I "23 May 1989" "InterViews" "InterViews Reference Manual" .SH NAME Regexp \- regular expression searching .SH SYNOPSIS .B #include .SH DESCRIPTION A Regexp encapsulates a regular expression pattern and defines operations for searching and matching the pattern against a string. The syntax of the regular expression pattern is the same as that for ed(1). Information can be obtained about the most recent match of the regular expression (and its sub-expressions). .SH PUBLIC OPERATIONS .TP .B "Regexp(const char* pattern)" .ns .TP .B "Regexp(const char* pattern, int length)" Construct a new Regexp for \fIpattern\fP. .TP .B "int Match(const char* text, int length, int index)" Attempt a match against \fItext\fP (of length \fIlength\fP) at position \fIindex\fP. The return value is the length of the matching string, or a negative number if the match failed. .TP .B "int Search(const char* text, int length, int index, int range)" Search for a match in the string \fItext\fP (of length \fIlength\fP). Matches are attempted starting at positions between \fIindex\fP and \fIindex\fP plus \fIrange\fP. If \fIrange\fP is positive the first match after \fIindex\fP is reported. If \fIrange\fP is negative the first match before \fIindex\fP is reported. The return value is the index of the starting position of the match, or a negative number if there is no match in the specified range. .TP .B "int BeginningOfMatch(int subexp)" .ns .TP .B "int EndOfMatch(int subexp)" Return information about the most recent match. If \fIsubexp\fP is zero (the default), information is reported for the complete regular expression. Other values of \fIsubexp\fP refer to sub-expressions in the pattern. For example, if \fIsubexp\fP is 2, information is returned for the sub-expression specified by the second pair of \\( and \\) delimiters in the pattern. .SH SEE ALSO ed(1) ivtools-1.2.11a1/src/man/man3/ReqErr.3000066400000000000000000000021541214471147700172130ustar00rootroot00000000000000.TH ReqErr 3I "15 June 1987" "InterViews" "InterViews Reference Manual" .SH NAME ReqErr \- handle request errors .SH SYNOPSIS .B #include .SH DESCRIPTION Some requests to the window server may generate an error. For example, if a window is destroyed while it is being repositioned interactively, the request to place the window in the new position will fail. Normally, errors cause a process to terminate. The ReqErr class is used to handle errors within an application. The base class defines the attributes associated with each error, including a \fImessage\fP string describing the error, an integer \fIrequest\fP code that specifies the kind of call that generated the error, and a \fIid\fP object that was the target of the request. When an error occurs, the attributes of the current request handler are assigned and the handler's Error operation is called. .SH PUBLIC OPERATIONS .TP .B "ReqErr* Install()" Use this error handler for subsequent errors and return the previous error handler. .TP .B "virtual void Error()" Handle a detected error. The default handler is a nop. .SH SEE ALSO Interactor(3I) ivtools-1.2.11a1/src/man/man3/ReshapeTool.3000066400000000000000000000015671214471147700202470ustar00rootroot00000000000000.TH ReshapeTool 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME ReshapeTool \- tool for reshaping or otherwise altering components' structures .SH SYNOPSIS .B #include .SH DESCRIPTION ReshapeTool lets the user perform component-specific structural changes by direct manipulation. .SH PUBLIC OPERATIONS .TP .B "ReshapeTool(ControlInfo* = nil)" Create a new ConnectTool. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" CreateManipulator detects whether the user clicked on a component. If not, it returns a nil manipulator. If a component was hit, CreateManipulator clears the editor's selection, selects that component, and delegates manipulator creation and interpretation to that component. .SH SEE ALSO Tool(3U) ivtools-1.2.11a1/src/man/man3/Resource.3000066400000000000000000000034711214471147700176050ustar00rootroot00000000000000.TH Resource 3I "" "InterViews Reference Manual" .SH NAME Resource \- shared object .SH SYNOPSIS .B #include .SH DESCRIPTION .B Resource is a class that provides a simple form of reference counting for shared objects. Every resource has a reference count that is initially set to zero and must be explicitly incremented through a call to Reference. A resource should not be deleted like other objects; instead, the static member function unref should be used to unreference the object. .PP When a resource is unreferenced, the reference count is decremented unless it is already zero. If the count is zero, the object is destroyed. .SH PUBLIC OPERATIONS .TP .B "Resource()" Create a new resource object with its reference count set to zero. .TP .B "void ref()" Increment the resource's reference count. .TP .B "void unref()" Decrement the resource's reference count, if it is positive, and delete this if the count is zero. .TP .B "static void ref(Resource*)" If the resource is not nil, call ref on it. Otherwise do nothing. .TP .B "static void unref(Resource*)" If the resource is not nil, call unref on it. Otherwise do nothing. .TP .B "void Reference()" This function is equivalent to ref and is provided solely for backward compatibility. It will be removed in a future version. .TP .B "void Unreference()" This function is equivalent to unref and is provided solely for backward compatibility. It will be removed in a future version. .SH FRIEND OPERATIONS .TP .B "void Unref(Resource*)" This function is equivalent to static unref and is provided solely for backward compatibility. It will be removed in a future version. .SH BUGS This scheme relies on manual referencing, which is more efficient, but also more dangerous. .PP When garbage collection is supported by the runtime system, resources will be unnecessary. ivtools-1.2.11a1/src/man/man3/RotateTool.3000066400000000000000000000023441214471147700201100ustar00rootroot00000000000000.TH RotateTool 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME RotateTool \- tool for rotating components .SH SYNOPSIS .B #include .SH DESCRIPTION RotateTool lets the user rotate components by direct manipulation. .SH PUBLIC OPERATIONS .TP .B "RotateTool(ControlInfo* = nil)" Create a new RotateTool. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" CreateManipulator detects whether the user clicked on a component. If not, it clears the editor's selection and returns a nil manipulator. If a component was hit, and if the component was not previously selected, then CreateManipulator clears the editor's selection, selects the component the user hit, and delegates manipulator creation and interpretation to it. If the component was the only selected component, it again delegates manipulator creation and interpretation to the component, but the selection is unaltered. If the user clicks on one of many selected components, then CreateManipulator will delegate manipulator creation and interpretation to the hit component without altering the selection. .SH SEE ALSO Tool(3U) ivtools-1.2.11a1/src/man/man3/RpcHdr.3000066400000000000000000000034001214471147700171700ustar00rootroot00000000000000.TH RpcHdr 3I "27 March 1991" "InterViews" "InterViews Reference Manual" .SH NAME RpcHdr \- header for remote procedure calls .SH SYNOPSIS .B #include .SH DESCRIPTION An RpcHdr enables an RPC request to be sent or received. To send an RPC request, you would insert an RpcHdr into an rpcstream followed by any arguments and then flush the rpcstream if you wanted the request to be sent immediately. The rpcstream automatically fills in each RPC request's length field. To receive an RPC request, you would extract an RpcHdr from an rpcstream and examine the ``request()'' member to determine which additional arguments need to be extracted as well. You can examine the ``ndata()'' member too if you need to estimate how much space to allocate. .SH CONSTRUCTORS .TP .B "RpcHdr(void* writer, int request)" .ns .TP .B "RpcHdr(int request)" .ns .TP .B "RpcHdr()" Construct an initialized header for an outgoing RPC request (first two constructors) or construct an uninitialized header for an incoming RPC request (third constructor). To initialize the header, you'll have to store the request's protocol number. You can also store the address of the writer sending the RPC request if you want to route the RPC request to a specific reader on the peer's side. .SH PUBLIC OPERATIONS .TP .B "unsigned long reader()" .ns .TP .B "int request()" .ns .TP .B "unsigned int ndata()" Get information about the RPC request. ``reader()'' identifies the reader which should handle the RPC request. ``request()'' identifies the action that should be performed. ``ndata()'' gives the number of data bytes following the header, which may be useful for estimating the amount of space that must be allocated to store an argument. .SH SEE ALSO RpcReader(3I), RpcWriter(3I), rpcstream(3I) ivtools-1.2.11a1/src/man/man3/RpcPeer.3000066400000000000000000000035061214471147700173550ustar00rootroot00000000000000.TH RpcPeer 3I "27 March 1991" "InterViews" "InterViews Reference Manual" .SH NAME RpcPeer \- support bi-directional RPC between two services .SH SYNOPSIS .B #include .SH DESCRIPTION An RpcPeer (actually, an instance of a derived class) tries to open a connection to another RpcPeer. If the other RpcPeer is not yet running, the RpcPeer will create its own port and wait for the other RpcPeer to open a connection. When either RpcPeer opens a connection, each RpcPeer will create both a reader and a writer so each RpcPeer can send RPC requests to its opposite over the same connection. .SH CONSTRUCTOR .TP .B "RpcPeer(const char* lPath, int lPort = 0)" Store the arguments for later use since a base constructor can't call a derived class's virtual function. The derived class's constructor should call ``init'', described below. .TP .B "void init(const char* rPath)" Find the host name and port number registered by the other RpcPeer and try to open a connection to it. If it's not running, create our own port and wait for the other RpcPeer to open a connection. .SH PUBLIC OPERATIONS .TP .B "void run()" .ns .TP .B "void quitRunning()" Read RPC requests continuously until ``quitRunning()'' terminates the loop. If you're using InterViews, you don't have to call ``run()'' since the InterViews event-reading code will also read RPC requests. .SH PROTECTED OPERATIONS .TP .B "virtual boolean createReaderAndWriter(const char* rHost, int rPort) = 0" .ns .TP .B "virtual void createReaderAndWriter(int fd) = 0" You must define both functions in a derived class in order to start reading and writing RPC requests over the connection. Typically both functions would create a writer using the given parameters and then attach a reader to the writer's rpcstream. .SH SEE ALSO Dispatcher(3I), RpcReader(3I), RpcRegistry(3I), RpcWriter(3I) ivtools-1.2.11a1/src/man/man3/RpcReader.3000066400000000000000000000051171214471147700176640ustar00rootroot00000000000000.TH RpcReader 3I "27 March 1991" "InterViews" "InterViews Reference Manual" .SH NAME RpcReader \- read RPC requests from a client .SH SYNOPSIS .B #include .SH DESCRIPTION An RpcReader reads RPC requests from an rpcstream which represents a connection to a client. When it reads an RPC request, it uses the request number to look up the address of a function in an array and calls that function to unmarshall the request's arguments and execute the request. .PP An RpcReader is not instantiable; you have to implement a derived class which initializes the function array with addresses of static member functions to unmarshall RPC requests and which defines the action to be performed when the client closes the connection. The function array looks like this: .PP typedef void (*PF)(RpcReader*, RpcHdr&, rpcstream&); .br PF* _function; .PP Each function stored in the array should extract any arguments needed by the RPC request from the rpcstream, execute the RPC request, and insert any return values into the rpcstream so they can be sent back to the client. .SH CONSTRUCTORS .TP .B "RpcReader(rpcstream* client, int nfcns)" .ns .TP .B "RpcReader(int fd, int nfcns, boolean binary = true)" If given a non-nil rpcstream, prepare to read RPC requests from the client using it. If given a nil rpcstream, just allocate the function array. If given a file descriptor, create a new rpcstream and prepare to read RPC requests from the client using it. ``nfcns'' sets the size of the function array that each constructor allocates. .SH PROTECTED OPERATIONS .TP .B "virtual int inputReady(int)" Read an RPC request (only one request per call so the program can service RPC requests from multiple connections in round robin fashion). Look up the appropriate function in the reader's or another reader's function array and call it to handle the RPC request. Return the appropriate status to tell the Dispatcher whether to detach the RpcReader, call inputReady again, or wait for new data before calling inputReady again. A derived class should not need to redefine this function. .TP .B "virtual RpcReader* map(unsigned long reader)" You can redefine this function to change which reader executes an RPC request after it's read. Ordinarily the same reader that reads an RPC request also executes it, but you can hand the request off to another reader as well. .TP .B "virtual void connectionClosed(int fd) = 0" You have to define this function since it may be your only chance to perform cleanup (such as deleting this) when the client closes the connection. .SH SEE ALSO RpcHdr(3I), RpcService(3I), rpcstream(3I) ivtools-1.2.11a1/src/man/man3/RpcRegistry.3000066400000000000000000000037111214471147700202700ustar00rootroot00000000000000.TH RpcRegistry 3I "27 March 1991" "InterViews" "InterViews Reference Manual" .SH NAME RpcRegistry \- name space for finding RPC services .SH SYNOPSIS .B #include .SH DESCRIPTION RpcRegistry provides a name space for finding RPC services based on the use of NFS filesystems among a group of hosts. When an RPC service wishes to record its host name and port number, it will give the path of a file in which to store the information. When a client wants to find the RPC service's host name and port number, it will give the path of a file from which to read the information. Usually the path will be the name of a file in the current working directory since different hosts may have different absolute pathnames for the same file in a NFS filesystem. The RPC service's name space is the name space of the host's filesystem and the file's contents provides the information needed to open a connection to the RPC service. .SH PUBLIC OPERATIONS Each function is a static member function, which means a program can call it without having to instantiate an RpcRegistry object. Each function returns true if it succeeded or false if some error occurred. .TP .B "boolean record(const char* path, int port)" Record the RPC service's host name and port number in the given file. If the file already exists, its previous contents will be lost. .TP .B "boolean erase(const char* path)" Remove the file which stores the RPC service's host name and port number so that no more clients will be able to contact the RPC service. .TP .B "boolean find(const char* path, char*& hostname, int& port)" Open the file which stores the RPC service's host name and port number. If the file does not exist, return failure silently. If the file does exist, read the RPC service's host name and port address from it. If ``hostname'' is nil upon entry, it will contain the address of a dynamically allocated string upon exit (which must be freed by the caller). .SH SEE ALSO RpcService(3I) ivtools-1.2.11a1/src/man/man3/RpcService.3000066400000000000000000000027121214471147700200600ustar00rootroot00000000000000.TH RpcService 3I "27 March 1991" "InterViews" "InterViews Reference Manual" .SH NAME RpcService \- support RPC between a service and its clients .SH SYNOPSIS .B #include .SH DESCRIPTION An RpcService (actually, an instance of a derived class) creates a port and listens to it for connections from clients. When a client opens a connection, the RpcService will create a reader to handle RPC requests from the connection. .SH CONSTRUCTORS .TP .B "RpcService(int port)" .ns .TP .B "RpcService(const char* path, int port = 0)" Start up an RPC service. If a filename is given, record the RPC service's hostname and port number in it so clients can contact the service. If ``port'' is zero, the next free port number will be used. .SH PUBLIC OPERATIONS .TP .B "void run()" .ns .TP .B "void quitRunning()" Read RPC requests continuously until ``quitRunning()'' terminates the loop. If you're using InterViews, you don't have to call ``run()'' since the InterViews event-reading code will also read RPC requests. .SH PROTECTED OPERATIONS .TP .B "virtual void createReader(int fd) = 0" You must define this function in a derived class in order to start servicing RPC requests from a new client. Typically all you have to do is to construct a reader using the passed file descriptor and make the reader responsible for deleting itself when it notices that the connection has been closed by the client. .SH SEE ALSO Dispatcher(3I), RpcReader(3I), RpcRegistry(3I) ivtools-1.2.11a1/src/man/man3/RpcWriter.3000066400000000000000000000021711214471147700177330ustar00rootroot00000000000000.TH RpcWriter 3I "27 March 1991" "InterViews" "InterViews Reference Manual" .SH NAME RpcWriter \- write RPC requests to a server .SH SYNOPSIS .B #include .SH DESCRIPTION An RpcWriter (actually, an instance of a class derived from RpcWriter) writes RPC requests to a server. Derived classes should add member functions that send RPC requests corresponding to the RPC service's protocol. .SH CONSTRUCTORS .TP .B "RpcWriter(const char* path, boolean fatal, boolean binary)" .ns .TP .B "RpcWriter(const char* host, int port, boolean fatal, boolean binary)" .ns .TP .B "RpcWriter(int fd, boolean fatal, boolean binary)" .ns .TP .B "RpcWriter(rpcstream* server)" Open a connection to an RPC service at its registered host name and port number, or give the host name and port number needed to open a connection to the RPC service, or give the number of an already open file descriptor, or give the address of an already open rpcstream (connection). Negotiate the I/O format (binary or formatted) if opening a connection. Terminate the program if errors should be fatal. .SH SEE ALSO RpcHdr(3I), RpcRegistry(3I), rpcstream(3I) ivtools-1.2.11a1/src/man/man3/Rubband.3000066400000000000000000000250731214471147700173750ustar00rootroot00000000000000.TH Rubband 3I "15 June 1987" "InterViews" "InterViews Reference Manual" .SH NAME Rubband \- rubberbanding graphical objects .SH SYNOPSIS .B #include .br .B #include .br .B #include .br .B #include .br .B #include .br .B #include .br .SH DESCRIPTION .B Rubband is the base class for a set of classes that provide graphical feedback to a user during an interactive operation such as sizing a rectangle. A rubberband varies in appearance as its \fItracking point\fP changes. A rubberband is \fInot\fP an interactor itself; interactors use rubberbands to provide animated effects. Because rubberbands are not interactors, rubberband constructors must be passed the painter and canvas to use for drawing. .SH PUBLIC OPERATIONS .TP .B "RubberLine(" .ns .TP .B " Painter*, Canvas*, Coord fx, fy, mx, my, offx = 0, offy = 0" .ns .TP .B ")" .br A rubber line stretches to follow the tracking point while its other endpoint stays tied down. .TP .B "RubberAxis(" .ns .TP .B " Painter*, Canvas*, Coord fx, fy, mx, my, offx = 0, offy = 0" .ns .TP .B ")" .br A rubber axis stretches either horizontally or vertically to follow the tracking point while its other endpoint stays tied down. One endpoint stays fixed while the other moves along either the horizontal or vertical axis, whichever is closer to the tracking point. .TP .B "SlidingLine(" .ns .TP .B " Painter*, Canvas*, Coord x0, y0, x1, y1, rfx, rfy," .ns .TP .B " Coord offx = 0, offy = 0" .ns .TP .B ")" .br A sliding line slides around without changing its length or angle as the tracking point moves around a reference point. .TP .B "RotatingLine(" .ns .TP .B " Painter*, Canvas*, Coord x0, y0, x1, y1, rfx, rfy," .ns .TP .B " Coord offx = 0, offy = 0" .ns .TP .B ") .br A rotating line rotates around (\fIcx\fP,\ \fIcy\fP) based on the angle between the radius from (\fIcx\fP,\ \fIcy\fP) to (\fIrfx\fP,\ \fIrfy\fP) and the radius from (\fIcx\fP,\ \fIcy\fP) to the tracking point. .TP .B "RubberRect(" .ns .TP .B " Painter*, Canvas*, Coord fx, fy, mx, my, offx = 0, offy = 0" .ns .TP .B ")" .br A rubber rectangle stretches to follow the tacking point while its opposite corner stays tied down. .TP .B "SlidingRect(" .ns .TP .B " Painter*, Canvas*, Coord x1, y1, x2, y2, rfx, rfy," .ns .TP .B " Coord offx = 0, offy = 0" .ns .TP .B ")" .br A sliding rectangle slides around the screen without changing its side or orientation as the tracking point moves around a reference point. .TP .B "ScalingRect(" .ns .TP .B " Painter*, Canvas*, Coord x1, y1, x2, y2, cx, cy," .ns .TP .B " Coord offx = 0, offy = 0" .ns .TP .B ")" .br A scaling rectangle scales equally in both dimensions about (\fIcx\fP,\ \fIcy\fP) to keep one edge intersecting the tracking point. .TP .B "RotatingRect(" .ns .TP .B " Painter*, Canvas*, Coord x1, y1, x2, y2, cx, cy, rfx, rfy," .ns .TP .B " Coord offx = 0, offy = 0" .ns .TP .B ")" .br A rotating rectangle rotates about (\fIcx\fP,\ \fIcy\fP) based on the radius from (\fIcx\fP,\ \fIcy\fP) to (\fIrfx\fP,\ \fIrfy\fP) and the radius from (\fIcx\fP,\ \fIcy\fP) to the tracking point. .TP .B "StretchingRect(" .ns .TP .B " Painter*, Canvas*, Coord x1, y1, x2, y2, Side ts," .ns .TP .B " Coord offx = 0, offy = 0" .ns .TP .B ")" .br A stretching rectangle's tracking side follows the tracking point while the opposite side stays fixed. The \fIside\fP can be one of \fILeftSide\fP, \fIRightSide\fP, \fIBottomSide\fP, or \fITopSide\fP. .TP .B "RubberCircle(" .ns .TP .B " Painter*, Canvas*, Coord cx, cy, rx, ry, offx = 0, offy = 0" .ns .TP .B ")" .br A rubber circle's radius varies with the magnitude of the tracking point's distance from (\fIcx\fP,\ \fIcy\fP). .TP .B "RubberEllipse(" .ns .TP .B " Painter*, Canvas*, Coord cx, cy, rx, ry, offx = 0, offy = 0" .ns .TP .B ")" .br A rubber ellipse's horizontal and vertical radii vary with the magnitude of the tracking point's distance from (\fIcx\fP,\ \fIcy\fP). .TP .B "RubberSpline(" .ns .TP .B " Painter*, Canvas*, Coord x[], y[], int n, pt," .ns .TP .B " Coord offx = 0, offy = 0" .ns .TP .B ")" .br .ns .TP .B "RubberClosedSpline(" .ns .TP .B " Painter*, Canvas*, Coord x[], y[], int n, pt," .ns .TP .B " Coord offx = 0, offy = 0" .ns .TP .B ")" .br A rubber spline is the section of a B-spline defined by \fIn\fP control points that changes shape as the control point indexed by \fIpt\fP is set to the tracking point. .TP .B "RubberHandles(" .ns .TP .B " Painter*, Canvas*, Coord x[], y[], int n, pt, size," .ns .TP .B " Coord offx = 0, offy = 0" .ns .TP .B ")" .br A rubber handles object is a set of filled squares centered about each point in the list. The point index by \fIpt\fP follows the tracking point. .TP .B "SlidingPointList(" .ns .TP .B " Painter*, Canvas*, Coord x[], y[], int n, pt, Coord rfx, rfy," .ns .TP .B " Coord offx = 0, offy = 0" .ns .TP .B ")" .br A sliding point list slides around the screen without changing its appearance as the tracking point moves around a reference point. .TP .B "SlidingLineList(" .ns .TP .B " Painter*, Canvas*, Coord x[], y[], int n, pt, Coord rfx, rfy," .ns .TP .B " Coord offx = 0, offy = 0" .ns .TP .B ")" .br A sliding line list slides around the screen without changing the appearance of its connected lines as the tracking point moves around (\fIrfx\fP,\ \fIrfy\fP). .TP .B "ScalingLineList(" .ns .TP .B " Painer*, Canvas*, Coord x[], Coord y[], int n," .ns .TP .B " Coord cx, cy, rfx, rfy, offx = 0, offy = 0" .ns .TP .B ")" .br A scaling line list scales a list of lines about (\fIcx, cy\fP) to keep the line list's bounding box intersecting the tracking point. .TP .B "RotatingLineList(" .ns .TP .B " Painer*, Canvas*, Coord x[], Coord y[], int n," .ns .TP .B " Coord cx, cy, rfx, rfy, offx = 0, offy = 0" .ns .TP .B ")" .br A rotating line list rotates a list of lines about (\fIcx, cy\fP) based on the angle between the radius from (\fIcx\fP,\ \fIcy\fP) to (\fIrfx\fP,\ \fIrfy\fP) and the radius from (\fIcx\fP,\ \fIcy\fP) to the tracking point. .TP .B "GrowingVertices(" .ns .TP .B " Painter*, Canvas*, Coord x[], y[], int n," .ns .TP .B " int pt = -1, int handleSize = -1" .ns .TP .B ")" .br .ns .TP .B "GrowingMultiLine(" .ns .TP .B " Painter*, Canvas*, Coord x[], y[], int n," .ns .TP .B " int pt = -1, int handleSize = -1" .ns .TP .B ")" .br .ns .TP .B "GrowingPolygon(" .ns .TP .B " Painter*, Canvas*, Coord x[], y[], int n," .ns .TP .B " int pt = -1, int handleSize = -1" .ns .TP .B ")" .br .ns .TP .B "GrowingBSpline(" .ns .TP .B " Painter*, Canvas*, Coord x[], y[], int n," .ns .TP .B " int pt = -1, int handleSize = -1" .ns .TP .B ")" .br .ns .TP .B "GrowingClosedBSpline(" .ns .TP .B " Painter*, Canvas*, Coord x[], y[], int n," .ns .TP .B " int pt = -1, int handleSize = -1" .ns .TP .B ")" .br .ns .TP .B "virtual void AddVertex(Coord, Coord)" .ns .TP .B "virtual void RemoveVertex()" GrowingVertices is an abstract rubberband containing a list of vertices that grows or shrinks dynamically. The \fIpt\fP parameter specifies the index of the vertex that will follow the tracking point; a value of -1 specifies a vertex after the last one in the list. The \fIhandleSize\fP parameter specifies the size of the handle drawn at each vertex (as in RubberHandles above); a value of -1 specifies that no handles be drawn. The AddVertex operation adds a new vertex at the tracking point to the list and makes the next (or last) vertex in the list follow the tracking point. RemoveVertex removes the vertex at the tracking point and makes the previous (or first) vertex the new tracking point. GrowingMultiLine, GrowingPolygon, GrowingBSpline, and GrowingClosedBSpline are GrowingVertices subclasses that draw a multiline, polygon, B-spline, and closed B-spline, respectively. .TP .B "RubberGroup(Painter*, Canvas*)" .ns .TP .B "void Append(" .ns .TP .B " Rubberband*, Rubberband* = nil, Rubberband* = nil," .ns .TP .B " Rubberband* = nil" .ns .TP .B ")" .br .ns .TP .B "void Remove(Rubberband*)" .ns .TP .B "void RemoveCur()" .ns .TP .B "void SetCurrent(Rubberband*)" .ns .TP .B "Rubberband* GetCurrent()" .ns .TP .B "Rubberband* First()" .ns .TP .B "Rubberband* Last()" .ns .TP .B "Rubberband* Next()" .ns .TP .B "Rubberband* Prev()" .ns .TP .B "boolean IsEmpty()" .ns .TP .B "boolean AtEnd()" A RubberGroup composes other rubberbands, providing operations for including, excluding, and traversing its children. RubberGroups are useful for combining the behavior of several rubberbands into one, eliminating the need to call Track on multiple rubberbands. The RubberGroup's SetCanvas and SetPainter operations set the children's canvas and painter as well as the RubberGroup's, but the children do not otherwise inherit the group's canvas and painter. The Track operation calls Track on each child with the same parameters. .TP .B "virtual void Draw()" .ns .TP .B "void Redraw()" .ns .TP .B "virtual void Erase()" Explicitly draw, redraw, and erase the rubberband. Multiple calls to Draw without an intervening Erase will only draw the rubberband once. Redraw forces the rubberband to be drawn. Since rubberbands are drawn in XOR mode, Redraw will erase the rubberband every other time it is called. These functions are used only on occasion, for example, when part of the screen is erased while a rubberband is visible. The Track function is normally used to draw the rubberband in response to mouse input. .TP .B "virtual void Track(Coord x, Coord y)" Erase the rubberband and redraw it using the new tracking point. .TP .B "void GetOriginal(Coord& x1, Coord& y2, Coord& x2, Coord& y2)" .ns .TP .B "void GetCurrent(Coord& x1, Coord& y2, Coord& x2, Coord& y2)" GetOriginal obtains the original points specified for the rubberband. GetCurrent obtains the current points based on the most recent call to Track. The meaning of the points depends on the kind of rubberband. For lines, the points are the endpoints; for rectangles, the points are opposite corners; for curves, (\fIx1\fP,\ \fIy1\fP) is the center and \fIx2\fP and \fIy2\fP are the radii. .TP .B "virtual void SetPainter(Painter*)" .ns .TP .B "Painter* GetPainter()" Explicitly set and get the painter used by the rubberband. By default, rubberbands use a copy of the painter passed to their constructor. The user can specify a particular painter to use by passing a nil painter to the constructor and later calling SetPainter. \fIN.B.:\fP the rubberband may alter the painter specified via SetPainter. .TP .B "virtual void SetCanvas(Canvas*)" .ns .TP .B "Canvas* GetCanvas()" Explicitly set and get the canvas used by the rubberband. .SH SEE ALSO Canvas(3I), Painter(3I) ivtools-1.2.11a1/src/man/man3/ScaleTool.3000066400000000000000000000023361214471147700177020ustar00rootroot00000000000000.TH ScaleTool 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME ScaleTool \- tool for rotating components .SH SYNOPSIS .B #include .SH DESCRIPTION ScaleTool lets the user rotate components by direct manipulation. .SH PUBLIC OPERATIONS .TP .B "ScaleTool(ControlInfo* = nil)" Create a new ScaleTool. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" CreateManipulator detects whether the user clicked on a component. If not, it clears the editor's selection and returns a nil manipulator. If a component was hit, and if the component was not previously selected, then CreateManipulator clears the editor's selection, selects the component the user hit, and delegates manipulator creation and interpretation to it. If the component was the only selected component, it again delegates manipulator creation and interpretation to the component, but the selection is unaltered. If the user clicks on one of many selected components, then CreateManipulator will delegate manipulator creation and interpretation to the hit component without altering the selection. .SH SEE ALSO Tool(3U) ivtools-1.2.11a1/src/man/man3/Scene.3000066400000000000000000000107671214471147700170610ustar00rootroot00000000000000.TH Scene 3I "7 Mar 1989" "InterViews" "InterViews Reference Manual" .SH NAME Scene, MonoScene \- composite interactors .SH SYNOPSIS .B #include .SH DESCRIPTION .B Scene is the base class for all interactors that are defined in terms of one or more instances of other interactors. .B MonoScene is a subclass for scenes that contain a single instance. A monoscene's shape is copied from its component and the component's canvas is given the same size and location as the monoscene's canvas. .PP When a scene is deleted, it should delete all its component interactors. A monoscene deletes its existing component if a new component is inserted. .SH PUBLIC OPERATIONS .TP .B "void Insert(Interactor*)" .ns .TP .B "void Insert(Interactor*, Coord x, Coord y, Alignment = BottomLeft)" .ns .TP .B "virtual Interactor* Wrap(Interactor*)" .ns .TP .B "virtual void DoInsert(Interactor*, boolean, Coord& x, Coord& y, Shape*)" Add an interactor to the scene, optionally aligned with respect to a specific position relative to the lower-left corner of the scene. Valid alignment types are TopLeft, TopCenter, TopRight, CenterLeft, Center, CenterRight, BottomLeft, BottomCenter, BottomRight, Left, Right, Top, Bottom, HorizCenter, and VertCenter. The scene uses the interactor's desired shape, if it has non-zero width, to size the interactor. The base scene class always calls Wrap and DoInsert from Insert; thus subclasses only implement DoInsert (and Wrap if they want to wrap additional interactors around the inserted interactor) and users only call Insert. In the case of a monoscene, the current interior interactor, if not nil, is deleted and replaced by the given interactor. If an interactor is inserted into a scene that is already mapped, the interactor and its descendants will be configured before DoInsert is called. .TP .B "void Propagate(boolean)" .ns .TP .B "void Change(Interactor*)" .ns .TP .B "virtual void DoChange(Interactor*, Shape*)" Change notifies a scene that a given interactor has changed its desired shape. If the propagate flag associated with the scene is true, Change will call DoChange and then Change(this) on the scene's parent. If the propagate flag is false, Resize will be called instead. The propagate flag is true by default and can be set with the Propagate operation. .TP .B "void Move(Interactor*, Coord x, Coord y, Alignment = BottomLeft)" .ns .TP .B "virtual void DoMove(Interactor*, Coord& x, Coord& y)" Request that an interactor be moved to the given coordinates using the given alignment. As with Insert and Change, users call Move and subclasses implement DoMove. .TP .B "void Remove(Interactor*)" .ns .TP .B "virtual void DoRemove(Interactor*)" Remove an interactor from a scene. Users call Remove and subclasses implement DoRemove. .TP .B "void Lower(Interactor*)" .ns .TP .B "virtual void DoLower(Interactor*)" Put the interactor's canvas below all others in the scene, potentially obscuring it. Users call Lower and subclasses implement DoLower. .TP .B "void Raise(Interactor*)" .ns .TP .B "virtual void DoRaise(Interactor*)" Put the interactor's canvas above all others in the scene, making it fully visible. Users call Raise and subclasses implement DoRaise. .SH PROTECTED OPERATIONS .TP .B "Scene()" .ns .TP .B "MonoScene()" Construct a new scene or monoscene. Scenes and monoscenes are abstract classes; thus, the constructors should only be called implicitly by subclass constructors. .TP .B "void Place(Interactor*, Coord x1, Coord y1, Coord x2, Coord y2, boolean = true)" Assign an interactor's canvas to be a given region of the scene's canvas. Unless the optional sixth parameter is false, the interactor will be mapped. If the interactor is already assigned the given position and size, then this operation will have no effect. This optimization means that a scene can place all of its elements in response to a Change and be assured that only those elements that have really changed will be redrawn. .TP .B "void Map(Interactor*, boolean = true)" Make the interactor visible on the display if and when the scene is visible. Unless the optional second parameter is false, the interactor will be raised to the top of the scene. .TP .B "void Unmap(Interactor*)" Make the interactor not be visible on the display if and when the scene is visible. .TP .B "void UserPlace(Interactor*, int w, int h)" Let the user interact with the window manager to specify the size and location of the interactor's canvas, whose default width and height must also be supplied by the program. .SH SEE ALSO Canvas(3I), Interactor(3I), Shape(3I) ivtools-1.2.11a1/src/man/man3/Scroller.3000066400000000000000000000030611214471147700175760ustar00rootroot00000000000000.TH Scroller 3I "15 June 1987" "InterViews" "InterViews Reference Manual" .SH NAME Scroller, HScroller, VScroller \- scrolling an interactor .SH SYNOPSIS .B #include .SH DESCRIPTION A scroller is an interactor that manipulates the perspective of another interactor. It contains a bar whose position and size reflect the current origin and size in the interactor's perspective. Clicking and dragging in the scroller modifies the attached interactor's perspective. .B VScroller is a class for defining vertical scrollers, .B HScroller for horizontal scrollers. .SH PUBLIC OPERATIONS .TP .B "HScroller(Interactor*, int size = 0)" .ns .TP .B "VScroller(Interactor*, int size = 0)" Create a scroller of a given size (height for a horizontal scroller, width for a vertical scroller). A zero size means to use the default size. .TP .B "virtual void Update()" Redisplay the scroller to reflect a change in the interactor's perspective. .SH X DEFAULTS The ``syncScroll'' resource specifies whether the scroller should work in real-time or not. When synchronized scrolling is employed the interactor scrolls synchronously as the scroller's bar is dragged; otherwise the bar's outline follows the mouse during dragging, and the interactor is scrolled only after the user stops dragging the bar. Scrollers will scroll synchronously if their syncScroll resource is set to ``on'' or ``true.'' The state of the syncScroll attribute can be toggled temporarily by holding down the ``control'' key while the scroller is manipulated. .SH SEE ALSO Interactor(3I), Perspective(3I) ivtools-1.2.11a1/src/man/man3/SelectTool.3000066400000000000000000000040211214471147700200630ustar00rootroot00000000000000.TH SelectTool 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME SelectTool \- tool for modifying an editor's current selection .SH SYNOPSIS .B #include .SH DESCRIPTION SelectTool lets a user change the current selection by direct manipulation, thus affecting the enclosing editor's selection object. A single click directly on a component view selects that view and unselects all others. Clicking while holding the Shift key down adds the target component to the selection if it was not already selected and removes it if it was selected. The user can select all components within a rectangular area in the viewer by clicking somewhere outside the nearest component and dragging to specify the rectangular area. All components completely within the area will be selected. .SH PUBLIC OPERATIONS .TP .B "SelectTool(ControlInfo* = nil)" Create a new SelectTool. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" If the user did not click on a component, then CreateManipulator creates a DragManip with a RubberRect for dragging out a rectangular area. Otherwise, CreateManipulator clears the editor's selection and selects the hit component. If the user holds the Shift key down in either case, the components that would have otherwise been selected will be unselected, and vice versa. InterpretManipulator will only be called if CreateManipulator returned a non-nil manipulator; in this case InterpretManipulator will examine the DragManipulator's RubberRect and select the component views falling completely within it. .SH PROTECTED OPERATIONS .TP .B "virtual void Localize(Selection*, Viewer*)" Localize ensures that the given selection object contains only those views displayed in the given viewer. CreateManipulator calls this function to avoid possibly shift-selecting views from different components. .SH SEE ALSO Editor(3U), Rubband(3I), Selection(3U), Tool(3U), Viewer(3U), manips(3U) ivtools-1.2.11a1/src/man/man3/Selection.3000066400000000000000000000123111214471147700177340ustar00rootroot00000000000000.TH Selection 3U "6 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Selection \- maintains a list of selected graphical component views .SH SYNOPSIS .B #include .SH DESCRIPTION A Selection manages a set of distinguished graphical component views, usually those in which the user has expressed interest by selecting them with a tool or command. Each selection object maintains a list of graphical component views and provides operations for iterating through and manipulating the list. Components, commands, tools, and editors often rely on one or more selection objects to supply the components on which they operate. .SH PUBLIC OPERATIONS .TP .B "Selection(Selection* = nil)" Create a new selection object, optionally containing references to the same views as the given selection object. .TP .B "virtual ~Selection()" Destroy a selection instance. Deleting the selection does \fInot\fP in turn delete the view instances it maintains. .TP .B "void Show(Viewer* = nil)" .ns .TP .B "void Update(Viewer* = nil)" .ns .TP .B "void Hide(Viewer* = nil)" .ns .TP .B "void Init(Viewer* = nil)" These operations affect how the selection is represented visually in the viewer. Show instructs the views to initialize and draw their handles to highlight themselves, thus indicating that they are selected. To do so, it calls RedrawHandles on each view. Update makes handles of newly-selected, unhighlighted views appear by calling DrawHandles on all its views. Hide unhighlights the views by calling their EraseHandles operation. Finally, Init initializes each view's handles without drawing them (in case the handles' appearance may have changed) by calling InitHandles on each. .TP .B "void Clear(Viewer* = nil)" Remove all views from the Selection object, hiding their handles in the process. .TP .B "void Append(GraphicView*)" .ns .TP .B "void Prepend(GraphicView*)" .ns .TP .B "void InsertAfter(Iterator, GraphicView*)" .ns .TP .B "void InsertBefore(Iterator, GraphicView*)" .ns .TP .B "void Remove(GraphicView*)" .ns .TP .B "void Remove(Iterator&)" Operations for modifying the selection's list of views. Append and Prepend add a GraphicView to the end and the beginning of the list, respectively. InsertAfter and InsertBefore insert a GraphicView after and before the GraphicView pointed to by the iterator, respectively. The Remove operations remove a view from the list (without deleting it). You can remove a view instance by referring to it explicitly or by specifying an iterator. If an iterator is supplied, the Remove operation will advance it to point to the following view as a side effect. .TP .B "GraphicView* GetView(Iterator)" .ns .TP .B "void SetView(GraphicView*, Iterator&)" GetView returns the view to which an iterator points. SetView initializes an iterator to point to a particular view in the list; it initializes the iterator to point to a nil instance if the given GraphicView is not in the selection list. .TP .B "void First(Iterator&)" .ns .TP .B "void Last(Iterator&)" .ns .TP .B "void Next(Iterator&)" .ns .TP .B "void Prev(Iterator&)" .ns .TP .B "boolean Done(Iterator)" Operations for iterating over the selection list. First and Last initialize an iterator to point to the beginning and end of the list, respectively. Next increments the iterator to point to the following view, while Prev decrements the iterator to point to the preceding view. Done returns whether or not the iterator points beyond the first or last view in the list. .TP .B "boolean IsEmpty()" .ns .TP .B "boolean Includes(GraphicView*)" .ns .TP .B "int Number()" Operations that return information about the selection object's contents. IsEmpty returns whether the selection list is empty, Includes returns whether the list contains the given view, and Number returns the number of views in the list. .TP .B "void Sort(GraphicView*)" Sort the views in the selection list to conform to their order in the given GraphicView's list of children. The selection list's order usually reflects the order in which the user selected the objects, not their order in their parent. Sort is useful in operations that modify or depend on the parent view's structure. .TP .B "void Merge(Selection*)" .ns .TP .B "void Exclusive(Selection*)" Operations that change the selection object's contents based on another selection's. Merge adds the views in the given selection to those already in the selection object (the union of the two sets), while Exclusive adds those views not already in this object and removes those common to both (the union minus the intersection of the two sets). Neither of these operations change the contents of their argument. .TP .B "void GetBox(Coord&, Coord&, Coord&, Coord&)" Return the bounding box circumscribing the views in the selection list. .SH PROTECTED OPERATIONS .TP .B "UList* Elem(Iterator)" .ns .TP .B "GraphicView* View(UList*)" Selection stores its views on a UList, which is accessible via the \fI_ulist\fP protected member. The Selection's iteration operations store the UList containing the current view in their iterator. Elem is a convenience function for returning the UList to which an iterator points, and View extracts the GraphicView that a UList element contains. .SH SEE ALSO GraphicView(3U), Iterator(3U), UList(3U), Viewer(3U) ivtools-1.2.11a1/src/man/man3/Sensor.3000066400000000000000000000041621214471147700172650ustar00rootroot00000000000000.TH Sensor 3I "" "InterViews Reference Manual" .SH NAME Sensor \- describe input interest .SH SYNOPSIS .B #include .SH DESCRIPTION A sensor specifies a set of input events to catch. .SH PUBLIC OPERATIONS .TP .B "Sensor()" Create a new sensor that initially will not catch any events. .TP .B "virtual void motion(boolean)" Specify the sensor should (parameter is true) or should not (parameter is false) catch pointer motion events. .TP .B "virtual boolean motion()" Return whether the sensor is catching pointer motion events. .TP .B "virtual void key(boolean)" Specify the sensor should (parameter is true) or should not (parameter is false) catch keyboard events. .TP .B "virtual boolean key()" Return whether the sensor is catching keyboard events. .TP .B "virtual void button(boolean, PointerButton = Event::any)" Specify the sensor should (parameter is true) or should not (parameter is false) catch button events. The pointer button may specify a particular button or Event::any (meaning all button events). .TP .B "virtual boolean button(PointerButton = Event::any)" Return whether the sensor is catching button events. The pointer button may specify a particular button or Event::any (meaning any of the buttons). .TP .B "virtual boolean caught(Event&)" Return whether the sensor is catching the given event. .TP .B "void Catch(EventType)" Express interest in a particular type of event. This function is provided solely for backward compatibility and will be removed in a future version. .TP .B "void CatchButton(EventType, int)" Express interest in a particular type of button event for a specific button. This function is provided solely for backward compatibility and will be removed in a future version. .TP .B "void Ignore(EventType)" Remove interest in a particular type of event. This function is provided solely for backward compatibility and will be removed in a future version. .TP .B "void IgnoreButton(EventType, int)" Remove interest in a particular type of button event for a specific button. This function is provided solely for backward compatibility and will be removed in a future version. .SH SEE ALSO Event(3I) ivtools-1.2.11a1/src/man/man3/Shape.3000066400000000000000000000041121214471147700170470ustar00rootroot00000000000000.TH Shape 3I "15 June 1987" "InterViews" "InterViews Reference Manual" .SH NAME Shape \- what shape a canvas should have .SH SYNOPSIS .B #include .SH DESCRIPTION A shape specifies the desired characteristics of a canvas. An interactor should set the fields of its shape when it is reconfigured and should call Change on its parent if any of these fields change. .PP The dimensions of a shape are defined by a ``natural'' size, a stretch amount, and a shrink amount. The \fIwidth\fP and \fIheight\fP fields indicate the desired sizes. The \fIhstretch\fP, \fIvstretch\fP, \fIhshrink\fP, \fIvshrink\fP fields define how flexible these desired sizes are. For example, an interactor may have a natural size of 100, but can adequately handle any size between 50 and 200. The stretchability for this case would be 100 and the shrinkability 50. .PP The constants \fIhfil\fP and \fIvfil\fP are provided to indicate ``infinite'' stretching or shrinking. They are represented as very large numbers and manipulated exactly the same as other stretch and shrink parameters. .PP The \fIaspect\fP field specifies the desired aspect ratio. A value of zero means any aspect is acceptable. .PP The \fIhunits\fP and \fIvunits\fP fields indicate that the canvas dimensions should be multiples of some values. .SH PUBLIC OPERATIONS .TP .B "Shape()" .br Construct a new shape with undefined natural size and infinite stretchability and shrinkability in both directions. .TP .B "boolean Defined()" .ns .TP .B "boolean Undefined()" Test if the shape's natural size is defined or not. .TP .B "void Rect(int width, int height)" .ns .TP .B "void Square(int side)" Short-hand for setting the dimensions of the shape. Square sets both dimensions to \fIside\fP and sets the aspect ratio to one. .TP .B "void Rigid(int hshrink, int hstretch, int vshrink, int vstretch)" .ns .TP .B "void Rigid()" Set the stretchability and shrinkability fields of the shape. If no arguments are specified, the fields are set to zero. .TP .B "void SetUndefined()" Reset the shape's natural size to be undefined. .SH SEE ALSO Interactor(3I), Scene(3I) ivtools-1.2.11a1/src/man/man3/SlotComp.3000066400000000000000000000117461214471147700175620ustar00rootroot00000000000000.TH SlotComp 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME SlotComp, SlotView, HSlotComp, HSlotView, VSlotComp, VSlotView, SlotGraphic, PSSlot \- abstract base class and subclasses for slot connector subject and view; and structured graphic and PostScript external representation classes for slots .SH SYNOPSIS .B #include .SH DESCRIPTION SlotComp is a Connector subclass that supports connectivity with one degree of freedom. It serves as an abstract base class from which to derive HSlotComp and VSlotComp, which support horizontal and vertical orientations. The slot component classes use SlotGraphics to store their graphical attributes. SlotView is an abstract subclass of ConnectorView for displaying slots. HSlotView and VSlotView are SlotViews that display slots with the corresponding orientations. Finally, PSSlot is a PostScriptView that externalizes the slot subject's information in PostScript form. .SH SLOTCOMP PUBLIC OPERATIONS .TP .B "virtual void Interpret(Command*)" .ns .TP .B "virtual void Uninterpret(Command*)" SlotComp (un)interprets a subset of commands that connectors can generally interpret, namely MoveCmd, BrushCmd, AlignCmd, MobilityCmd, DeleteCmd, and CutCmd. .TP .B "virtual Mobility GetMobility()" .ns .TP .B "virtual void SetMobility(Mobility)" SlotComp redefines these functions to return and assign its \fI_mobility\fP protected member. Slots have fixed mobility initially. .TP .B "Slot* GetSlot()" Return the Slot graphic that defines the line's attributes. GetSlot is simply a more specific form of the GetGraphic operation. .SH SLOTCOMP PROTECTED OPERATIONS .TP .B "SlotComp(SlotGraphic* = nil)" The constructor takes an optional SlotGraphic that defines the slot's graphical attributes. It is protected to prevent instantiation, since SlotComp is an abstract class. .TP .B "void SetOrientation(SlotGraphic*, Orientation)" Define the orientation of the SlotComp's SlotGraphic. Only SlotComp can specify this SlotGraphic attribute; HSlotComp and VSlotComp subclasses set it to reflect their respective orientations. .SH SLOTVIEW PUBLIC OPERATIONS .TP .B "virtual void Interpret(Command*)" SlotView interprets AlignToGridCmd to align its starting point to the grid. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" SlotViews respond only to manipulation by GraphicCompTools, MoveTools, and ConnectTools. SlotView inherits its MoveTool response from ConnectorView. GraphicCompTool will let the user sweep out a crosshaired rectangle that reflects the slot's size and orientation. Creation will be influenced by gravity, if any. SlotView creates a ConnectManip in response to the ConnectTool, which will exhibit a gravational attraction to potential target connectors. SlotView will produce a ConnectCmd to connect the slot to its target. A slot connected in this way will receive floating mobility. .TP .B "SlotComp* GetSlotComp()" Return the subject. .SH SLOTVIEW PROTECTED OPERATIONS .TP .B "SlotView(SlotComp* = nil)" Create an SlotView, optionally supplying the subject. The constructor is protected to prevent instantiation. .TP .B "SlotGraphic* GetSlot()" Return the SlotGraphic that defines the slot's attributes. GetSlot is simply a more specific form of the GetGraphic operation. .TP .B "virtual SlotComp* NewSubject(SlotGraphic*)" A helper function that creates a SlotComp subject with the given slot graphic. This function produces the proper subject when the GraphicCompTool's manipulator is interpreted. HSlotView and VSlotView redefine this operation to return the corresponding SlotComp subclasses, thus eliminating the need to reimplement InterpretManipulator. .TP .B "Manipulator* CreateGraphicCompManip(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "Manipulator* CreateConnectManip(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "Command* InterpretGraphicCompManip(Manipulator*)" .ns .TP .B "Command* InterpretConnectManip(Manipulator*)" Helper functions used by CreateManipulator and InterpretManipulator to create and interpret the manipulators associated with GraphicCompTool and ConnectTool. .SH SLOTGRAPHIC PUBLIC OPERATIONS .TP .B "SlotGraphic(Coord, Coord, Coord, Graphic* = nil)" Create a SlotGraphic, specifying the starting point, length, and optionally a graphic from which to obtain its default graphics attributes. .TP .B "void GetOriginal(Coord&, Coord&, Coord&)" Return the SlotGraphic's original geometry parameters as specified in the constructor. .SH PSSLOT PUBLIC OPERATIONS .TP .B "PSSlot(SlotComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH SEE ALSO BrushCmd(3U), ConnectTool(3U), Connector(3U), ConnectorView3U), Event(3I), Graphic(3U), GraphicCompTool(3U), Grid(3U), MoveTool(3U), PatternCmd(3U), PostScriptView(3U), Transformer(3I), Viewer(3U), align(3U), edit(3U), globals(3U), manips(3U), transforms(3U) ivtools-1.2.11a1/src/man/man3/SplineComp.3000066400000000000000000000103661214471147700200700ustar00rootroot00000000000000.TH SplineComp 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME SplineComp, SplineView, PSSpline, ClosedSplineComp, ClosedSplineView, PSClosedSpline \- open and closed spline component subjects, views, and PostScript external representations .SH SYNOPSIS .B #include .SH DESCRIPTION SplineComp and ClosedSplineComp are VerticesComps that define open and closed splines, respectively. SplineComp uses an SFH_OpenBSpline graphic to store its graphical attributes, while ClosedSplineComp uses an SFH_ClosedBSpline. SplineView and ClosedSplineView are VerticesViews for displaying open and closed splines. PSSpline and PSClosedSpline are PSVertices that externalize their subject's information in PostScript form. .SH SPLINECOMP PUBLIC OPERATIONS .TP .B "SplineComp(SFH_OpenBSpline* = nil)" The constructor takes an optional control point hit-detecting stroked-filled open B-spline graphic that defines the attributes of the spline. .TP .B "SFH_OpenBSpline* GetSpline()" Return the SFH_OpenBSpline graphic that defines the spline's attributes. GetSpline is simply a more specific form of the GetGraphic operation. .SH SPLINEVIEW PUBLIC OPERATIONS .TP .B "SplineView(SplineComp* = nil)" Create a SplineView, optionally supplying the subject. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" SplineView redefines its response to manipulation with a GraphicCompTool. The user clicks the left mouse button to specify each vertex and clicks with the middle mouse button to specify the final vertex. Vertex positioning will be constrained by gravity, if any. SplineView also defines a response to the ReshapeTool, allowing the user to click on one of its control points to reposition it. The subject is actually replaced (via ReplaceCmd) with a new SplineComp subject reflecting the repositioned control point. Repositioning will be influenced by gravity. .TP .B "SplineComp* GetSplineComp()" Return the subject. .SH PSSPLINE PUBLIC OPERATIONS .TP .B "PSSpline(SplineComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH PSSPLINE PROTECTED OPERATIONS .TP .B "virtual const char* Name()" PSSpline identifies itself as "BSpl" in the PostScript output. .SH CLOSEDSPLINECOMP PUBLIC OPERATIONS .TP .B "ClosedSplineComp(SFH_ClosedBSpline* = nil)" The constructor takes an optional control point hit-detecting stroked-filled closed B-spline graphic that defines the attributes of the closed spline. .TP .B "SFH_ClosedBSpline* GetClosedSpline()" Return the SFH_ClosedBSpline graphic that defines the closed spline's attributes. GetClosedSpline is simply a more specific form of the GetGraphic operation. .SH CLOSEDSPLINEVIEW PUBLIC OPERATIONS .TP .B "ClosedSplineView(ClosedSplineComp* = nil)" Create a ClosedSplineView, optionally supplying the subject. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" ClosedSplineView redefines its response to manipulation with a GraphicCompTool. The user clicks the left mouse button to specify each vertex and clicks with the middle mouse button to specify the final vertex. Vertex positioning will be constrained by gravity, if any. ClosedSplineView also defines a response to the ReshapeTool, allowing the user to click on one of its control points to reposition it. The subject is actually replaced (via ReplaceCmd) with a new ClosedSplineComp subject reflecting the repositioned control point. Repositioning will be influenced by gravity. .TP .B "ClosedSplineComp* GetClosedSplineComp()" Return the subject. .SH PSCLOSEDSPLINE PUBLIC OPERATIONS .TP .B "PSClosedSpline(ClosedSplineComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH PSCLOSEDSPLINE PROTECTED OPERATIONS .TP .B "virtual const char* Name()" PSClosedSpline identifies itself as "CBSpl" in the PostScript output. .SH SEE ALSO Event(3I), GraphicComp(3U), GraphicCompTool(3U), GraphicView(3U), Grid(3U), PatternCmd(3U), PostScriptView(3U), ReshapeTool(3U), Rubband(3I), Transformer(3I), VerticesComp(3U), Viewer(3U), align(3U), edit(3U), splines(3U) ivtools-1.2.11a1/src/man/man3/StateVar.3000066400000000000000000000065211214471147700175460ustar00rootroot00000000000000.TH StateVar 3U "6 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME .SH NAME StateVar \- state variable subject base class .SH SYNOPSIS .B #include .SH DESCRIPTION StateVar is the base class for state variable subjects. State variables provide a standard way to represent and access state that can be modified by the user or through dataflow. State variable subjects store the state, while state variable views provide a graphical interface for examining and potentially modifying the state in their subject. The StateVar class defines the protocol for state variable subjects. It is an abstract class and thus cannot be instantiated. .SH PUBLIC OPERATIONS .TP .B "Connector* GetBinding()" Return the connector to which the state variable is bound to support dataflow. Data flows through connected connectors with bound state variables: the library automatically assigns one bound state variable's state to another's. The direction of this assignment depends on the participating connectors. See Connector(3U) for details on how to bind state variables to connectors and how to specify the direction of flow. .TP .B "virtual void Attach(StateVarView*)" .ns .TP .B "virtual void Detach(StateVarView*)" Attach associates the subject with a view, represented by an instance of a StateVarView subclass. Detach dissociates a previously attached view. These operations do not ensure that the argument is an appropriate view of the subject. .TP .B "virtual void Notify()" Notify iterates through the views, calling each one's Update operation to notify the view that the subject has potentially changed. Notify is usually called by the subject's state-modifying operations. .TP .B "virtual StateVar& operator = (StateVar&)" The assignment operation should be redefined to carry out subclass-specific assignment semantics. Typically this operator calls the parent classes' assignment operator and then performs additional assignments of its own. This operator is used during dataflow to transfer state variable values. .TP .B "virtual StateVar* Copy()" Return a copy of the state variable. Subclasses should redefine this operation to return an instance of their type. .TP .B "virtual void Read(istream&)" .ns .TP .B "virtual void Write(ostream&)" Read and write the state variable's contents to a stream to support catalog operations. Read and write typically call first the corresponding operations defined by their parent class, and then they read or write their class-specific state. Note that you must ensure that the objects are read in the same order they are written. .TP .B "virtual ClassId GetClassId()" .ns .TP .B "virtual boolean IsA(ClassId)" GetClassId returns the unique class identifier for the StateVar subclass, while IsA returns whether the instance is of a class or subclass corresponding to the given identifier. IsA typically checks the given identifier against the instance's own (as defined by its GetClassId operation) and, failing that, calls its parent classes' IsA operation. All subclasses must redefine GetClassId and IsA to ensure that their identifiers are unique and that instances are written and read properly. .SH PROTECTED OPERATIONS .TP .B "StateVar()" The constructor is protected to prevent instantiation. .SH SEE ALSO Catalog(3U), Connector(3U), Creator(3U), StateVarView(3U), classes(3U), istream(3C++), ostream(3C++) ivtools-1.2.11a1/src/man/man3/StateVarView.3000066400000000000000000000031541214471147700204000ustar00rootroot00000000000000.TH StateVarView 3U "6 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME StateVarView \- state variable view base class .SH SYNOPSIS .B #include .SH DESCRIPTION StateVarView is the base class for state variable views. State variable views provide a graphical interface to examining and potentially modifying a state variable subject. The StateVarView base class is an abstract class derived from MonoScene. Like MonoScene, the StateVarView class is not instantiated; instead, subclasses add state and behavior appropriate for displaying and editing their subject. Like other MonoScene subclasses, StateVarView subclasses use an interactor composition to define their appearance. .SH PUBLIC OPERATIONS .TP .B "virtual void Update()" Update the state variable view in response to a change in state it depends on (typically the subject's). This operation does not normally need redefinition if Init and Stale (described below) are redefined. .SH PROTECTED OPERATIONS .TP .B "StateVarView(StateVar*)" Subclass constructors normally take an instance of the corresponding subject as an argument. The base class constructor automatically attaches the view to the subject. .TP .B "virtual void Init()" Initialize the view based on information in the subject. Subclasses redefine this operation according to their semantics; it does nothing by default. .TP .B "virtual boolean Stale()" Return whether the view is in any way inconsistent with its subject. This operation always returns \fItrue\fP by default; subclasses can redefine it to make a more discerning decision. .SH SEE ALSO MonoScene(3I), StateVar(3U) ivtools-1.2.11a1/src/man/man3/StencilComp.3000066400000000000000000000030411214471147700202270ustar00rootroot00000000000000.TH StencilComp 3U "10 August 1991" "Unidraw" "InterViews Reference Manual" .SH NAME StencilComp, StencilView, PSStencil \- bitmap component subject, view, and PostScript external representation .SH SYNOPSIS .B #include .SH DESCRIPTION StencilComp is a GraphicComp that represents a bitmapped image. It uses a Stencil graphic to store its graphical attributes. StencilView is a GraphicView for displaying the bitmapped image. PSStencil is a PostScriptView that externalizes the subject's information in PostScript form. .SH STENCILCOMP PUBLIC OPERATIONS .TP .B "StencilComp(Stencil* = nil, const char* filename = nil)" The constructor takes an optional Stencil structured graphic that defines the attributes of the bitmapped image. You can also supply an optional file name to associate the component with a file containing the (copious) image data. .TP .B "Stencil* GetStencil()" Return the Stencil graphic that defines the stencil's attributes. GetStencil is simply a more specific form of the GetGraphic operation. .TP .B "const char* GetFileName()" Return the file name specified in the constructor, if any. .SH STENCILVIEW PUBLIC OPERATIONS .TP .B "StencilView(StencilComp* = nil)" Create an StencilView, optionally supplying the subject. .TP .B "StencilComp* GetStencilComp()" Return the subject. .SH PSSTENCIL PUBLIC OPERATIONS .TP .B "PSStencil(StencilComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH SEE ALSO GraphicComp(3U), GraphicView(3U), PostScriptView(3U), Stencil(3U) ivtools-1.2.11a1/src/man/man3/StrBrowser.3000066400000000000000000000140211214471147700201230ustar00rootroot00000000000000.TH StringBrowser 3I "30 November 1989" "InterViews" "InterViews Reference Manual" .SH NAME StringBrowser \- browse and/or select items in a list .SH SYNOPSIS .B #include .SH DESCRIPTION StringBrowser is an interactor that provides a browsing and selection interface to a list of strings. StringBrowsers are often used in dialog boxes to let the user browse and select from an unbounded set of textual entries. A StringBrowser displays the list of strings and provides several ways to scroll the list. The user selects strings with either the mouse or the keyboard; the StringBrowser can restrict selection to a single string or allow multiple selections. The application queries the StringBrowser for the selected string(s). .PP A StringBrowser contains no entries initially; strings are appended consecutively or in random order, and they can be removed in any order. The strings are accessed with a \fB string index\fP from 0 to \fIn\fP-1, where \fIn\fP is the total number of strings. The StringBrowser maintains a separate list of strings that have been selected; these strings are accessed with a \fBselection index\fP from 0 to \fIm\fP-1, where m is the total number of selected strings. .PP Left-clicking inside the StringBrowser (or calling the Browse function) makes it interpret subsequent keyboard events as scrolling or selection operations on the entries. StringBrowser relinquishes control when it detects a click outside its canvas or when it receives a predetermined escape character. .PP Middle-clicking inside the StringBrowser lets the user ``grab-scroll'' the entries. During grab-scrolling, the StringBrowser scrolls the entries to follow the mouse position, making it appear as though the user is dragging the entries themselves. Right-clicking engages ``rate-scrolling,'' a joy-stick-like scrolling interface in which the scrolling rate increases as the user drags the mouse away from the initial click point. For example, dragging the mouse downwards after the initial click scrolls the browser downwards at an increasing rate; dragging upwards thereafter reduces the rate until scrolling stops entirely at the initial click point. Dragging up beyond this point makes the browser scroll in the reverse direction. .SH KEY BINDINGS Below are the key bindings for browsing and selection commands: .IP g Go to the first string. .PP .IP G Go to the last string. .PP .IP a Select all. .PP .IP "DEL or BS" Unselect all. .PP .IP p Select previous string. .PP .IP n Select next string. .PP .IP < Select topmost-visible string. .PP .IP > Select bottommost-visible string. .PP .IP j Scroll down one string. .PP .IP k Scroll up one string. .PP .IP SPACE Scroll down one screenful. .PP .IP b Scroll up one screenful. .PP .IP d Scroll down one-half screenful. .PP .IP u Scroll up one-half screenful. .SH PUBLIC OPERATIONS .TP .B "StringBrowser(ButtonState*, int rows, int cols, boolean uniqueSel, \ int highlight, const char* done)" .ns .TP .B "StringBrowser(const char* name, ButtonState*, int, int, \ boolean, int, const char*)" Create a new StringBrowser object. The StringBrowser will use the ButtonState to communicate the result of browsing operations. The StringBrowser bases its shape on the \fIrows\fP and \fIcols\fP parameters: the height equals \fIrows\fP multiplied by the font height, and the width equals \fIcols\fP multiplied by the width of an average character. The \fIuniqueSel\fP parameter specifies whether or not selection is limited to one string (the default), and the \fIhighlight\fP parameter specifies the appearance of selected strings (Reversed by default). Typing any character in the string \fIdone\fP will make the StringBrowser stop interpreting keyboard events; the ButtonState is set to this terminating character as a side-effect. A double left-click inside the StringBrowser is equivalent to a single left-click selection followed by a key press that generates the first character in \fIdone\fP. To be interpreted as a double-click, two clicks must occur not more than \fIclickDelay\fP milliseconds apart. The default click delay is 250 ms; a different value can be specified via the "clickDelay" user-preference attribute. .TP .B "void Browse()" Initiate browsing. Subsequent keypresses will be interpreted as browsing and selection commands according to the key bindings listed above. .TP .B "void Insert(const char* string, int index)" Insert \fIstring\fP at position \fIindex\fP. StringBrowser makes a copy of the string for internal use. .TP .B "void Replace(const char* string, int index)" Replace the string at position \fIindex\fP with \fIstring\fP. StringBrowser makes a copy of the string for internal use. This operation does nothing if the index supplied is not valid. .TP .B "void Append(const char* string)" Insert a copy of \fIstring\fP after the last string. .TP .B "void Remove(int index)" Remove the string at position \fIindex\fP, moving subsequent strings up to fill the gap. .TP .B "int Index(const char* string)" Return the index of the first string that matches \fIstring\fP. .TP .B "char* String(int index)" Return the string at the given index. .TP .B "int Count()" Return the total number of strings in the StringBrowser. .TP .B "void Clear()" Remove all strings from the StringBrowser. .TP .B "void Select(int index)" .ns .TP .B "void Unselect(int index)" Select (unselect) the string at the given index. The string will be redrawn in the appropriate style. If multiple selections are not allowed and an another string has been selected already, then selecting a new string will unselect the original string. .TP .B "void SelectAll()" .ns .TP .B "void UnselectAll()" Select (unselect) all strings. SelectAll does nothing if multiple selections have been disallowed. .TP .B "int Selection(int n)" Return the string index of the \fIn\fPth selected string. .TP .B "int SelectionIndex(int n)" Return the selection index of the \fIn\fPth string. .TP .B "int Selections()" Return the total number of selected strings. .TP .B "boolean Selected(int n)" Return whether the \fIn\fPth string has been selected. .SH SEE ALSO Interactor(2I), Button(3I) ivtools-1.2.11a1/src/man/man3/StrChooser.3000066400000000000000000000073741214471147700201170ustar00rootroot00000000000000.TH StringChooser 3I "30 November 1989" "InterViews" "InterViews Reference Manual" .SH NAME StringChooser \- dialog box for choosing items in a list .SH SYNOPSIS .B #include .SH DESCRIPTION StringChooser is a dialog that manages keyboard focus between a StringBrowser and a StringEditor to provide a convenient interface to selecting strings. The user can select strings either by selecting them in the StringBrowser or by typing them in the StringEditor. Like Dialog, StringChooser is an abstract class; programmers must derive from StringChooser to add push buttons, etc. and to compose them into custom arrangements. .PP The user can focus keyboard input towards either the StringEditor or the StringBrowser. To set focus to the StringEditor, for example, the user left-clicks in its canvas to make it interpret subsequent keyboard events. When either the StringEditor or the StringBrowser relinquishes keyboard focus, the other acquires it: for example, the user can toggle focus between the two by pressing the tab key repeatedly. If an entry in the StringBrowser is selected when it loses focus, the (first) selected string will be transferred into the StringEditor. .SH PUBLIC OPERATIONS .TP .B "StringChooser(ButtonState*, int rows, int cols, const char* sample, \ Alignment)" .ns .TP .B "StringChooser(const char* name, ButtonState*, int rows, int cols, \ const char* sample, Alignment)" .ns Construct a new StringChooser with the given button state and pop-up alignment. These constructors create a StringBrowser of the specified size and a StringEditor with the given sample string. The StringChooser, StringBrowser, and StringEditor all share the same button state. .TP .B "void Select(int point)" .ns .TP .B "void Select(int left, int right)" .ns .TP .B "void SelectMessage()" Select an insertion point, a subrange, or the entire edit buffer in the StringEditor. .TP .B "void Message(const char* text)" Set the contents of the StringEditor's edit buffer to \fItext\fP. .TP .B "virtual const char* Choice()" Return the chosen string. The string is returned in a static buffer and should be copied before use. .SH PROTECTED OPERATIONS .TP .B "StringChooser(ButtonState*, Alignment = Center)" Construct a new StringChooser with the given button state and pop-up alignment \fIwithout\fP creating StringBrowser and StringEditor instances. This constructor should be called in subclasses that require a specialized StringEditor or StringBrowser or both. .TP .B "void Init(StringEditor*, StringBrowser*)" Initialize the StringEditor and StringBrowser that StringChooser will use. This function is useful in the constructors of StringChooser subclasses that require a specialized StringEditor or StringBrowser or both. .TP .B "virtual void SwitchFocus()" Prepare to shift keyboard focus to the StringBrowser if the StringEditor is focused currently, and vice versa. Focus actually changes when HandleFocus is called (see below). .TP .B "virtual boolean CanFocus(Interactor*)" Return whether or not the given interactor can be focused. This function is used to determine whether the StringChooser should switch focus in response to a downclick. .TP .B "virtual void HandleFocus()" Transfer event reading to the StringBrowser or StringEditor, whichever is the current focus. .TP .B "virtual void UpdateEditor()" .ns .TP .B "virtual void UpdateBrowser()" Update StringEditor and StringBrowser state when the dialog is accepted or in response to a change in focus. This function guarantees that the Choice operation will return the last choice. By default, UpdateEditor changes the StringEditor's contents to match the StringBrowser selection (if any), and UpdateBrowser clears out any selected strings in the StringBrowser. .SH SEE ALSO Button(3I), Dialog(3I), StringBrowser(3I), StringEditor(3I) ivtools-1.2.11a1/src/man/man3/StretchTool.3000066400000000000000000000023521214471147700202650ustar00rootroot00000000000000.TH StretchTool 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME StretchTool \- tool for rotating components .SH SYNOPSIS .B #include .SH DESCRIPTION StretchTool lets the user rotate components by direct manipulation. .SH PUBLIC OPERATIONS .TP .B "StretchTool(ControlInfo* = nil)" Create a new StretchTool. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" CreateManipulator detects whether the user clicked on a component. If not, it clears the editor's selection and returns a nil manipulator. If a component was hit, and if the component was not previously selected, then CreateManipulator clears the editor's selection, selects the component the user hit, and delegates manipulator creation and interpretation to it. If the component was the only selected component, it again delegates manipulator creation and interpretation to the component, but the selection is unaltered. If the user clicks on one of many selected components, then CreateManipulator will delegate manipulator creation and interpretation to the hit component without altering the selection. .SH SEE ALSO Tool(3U) ivtools-1.2.11a1/src/man/man3/StringEditor.3000066400000000000000000000114231214471147700204270ustar00rootroot00000000000000.TH StringEditor 3I "23 May 1989" "InterViews" "InterViews Reference Manual" .SH NAME StringEditor \- single line interactive string editor .SH SYNOPSIS .B #include .SH DESCRIPTION StringEditor is an interactor that provides a convenient mouse-based interactive editor for text strings. It is suitable for incorporation into other components such as dialog boxes. Clicking inside the StringEditor (or calling the Edit function) initiates an edit. Subsequent keyboard events, which need not be inside the StringEditor, are interpreted as editing operations on the text. Clicking outside the StringEdit terminates the edit. StringEditor works with either fixed width or proportionally spaced fonts. .SH EDITING MODEL Text is selected with the mouse or with the keyboard. A single click of the left mouse button selects a new insertion point between characters. Dragging across the text selects a range of characters. A set of control characters is mapped into common editing operations. A character not specifically associated with commands is inserted in place of the the current selection, the replaced text is lost, and the selection becomes an insertion point following the inserted character. Commands currently defined include the following. .TP .B "CharacterLeft (^B)" .ns .TP .B "CharacterRight (^F)" .ns .TP .B "BeginningOfText (^A)" .ns .TP .B "EndOfText (^E)" Move the selection one character position to the left or right, or to the beginning or end of the text. .TP .B "Erase (^H, DEL)" .ns .TP .B "Delete (^D)" Delete the text of the current selection. If the selection is an insertion point, delete the previous character (Erase) or the next character (Delete) instead. .TP .B "SelectAll (^U)" .ns .TP .B "SelectWord (^W)" Select the entire text, or extend the selection to the left by one whole word. These commands enable common editing operations to be performed without using the mouse. For example, to replace the previous word in the text, do a SelectWord and type the new text. .SH SCROLLING Strings that are too long to fit into the StringEditor can be scrolled horizontally. Middle-clicking inside the StringBrowser initiates ``grab-scrolling''. While the button is held down, the StringEditor scrolls the text to follow the mouse position, making it appear as though the user is dragging the test. Right-clicking engages ``rate-scrolling,'' a joy-stick-like scrolling interface in which the scrolling rate increases as the user drags the mouse away from the initial click point. For example, dragging the mouse rightwards after the initial click scrolls the browser rightwards at an increasing rate; dragging leftwards thereafter reduces the rate until scrolling stops entirely at the initial click point. Dragging left beyond this point makes the browser scroll in the reverse direction. .SH PUBLIC OPERATIONS .TP .B "StringEditor(ButtonState*, const char* sample, const char* done)" Create a new StringEditor object. The ButtonState will be used to communicate the result of editing operations. An edit of the string will be terminated if any character in the string \fIdone\fP is typed, and the ButtonState will be set to the terminating character. The shape of the new object is calculated from the length of the sample string. .TP .B "void Message(const char* text)" Set the contents of the edit buffer to \fItext\fP. .TP .B "void Select(int point)" .ns .TP .B "void Select(int left, int right)" Select an insertion point or a subrange of the edit buffer. .TP .B "void Edit()" .ns .TP .B "void Edit(const char* text, int left, int right)" Initiate an edit. Specifying a string and selection range is short hand for first calling Message and Select with the corresponding parameters. .TP .B "const char* Text()" Return the current value of the edit buffer. Note that this buffer is owned by the StringEditor, and that its contents are subject to change. It is the caller's responsibility to copy the string if the value will be needed in the long term. .TP .B "Handle(Event&)" Handle the event, and read and process subsequent events until an Accept or Cancel command is executed or a down click occurs outside the StringEditor's bounds. .SH PROTECTED OPERATIONS .TP .B "virtual boolean HandleChar(char)" .ns .TP .B "void InsertText(const char* text, int length)" Subclasses of StringEditor can perform additional processing on the edit buffer. For instance, an editor for file names might do file name completion, or an editor for numeric input might check the validity of the string as it is entered. Derived classes should redefine the virtual function HandleChar as required. HandleChar should return true to indicate that the edit is completed, or false otherwise. InsertText can be used to insert text into the edit buffer, replacing any currently selected text. .SH SEE ALSO Interactor(3I), Button(3I) ivtools-1.2.11a1/src/man/man3/Subject.3000066400000000000000000000056011214471147700174120ustar00rootroot00000000000000.TH Subject 3I "29 June 1989" "InterViews" "InterViews Reference Manual" .SH NAME Subject \- object with views .SH SYNOPSIS .B #include .SH DESCRIPTION A subject is an object that has one or more views that it wishes to notify when it changes. The SubjectIteractor class can be used if it is necessary to iterate through the views of a subject explicitly. .PP Because subjects are shared, Subject is a subclass of Resource. To allow for the possibility of multiple inheritance, in which case only a single copy of resource information should be maintained, Resource is a virtual base class. .SH PUBLIC OPERATIONS .TP .B "enum UpdateHint {" .ns .TP .B " attaching, detaching, setting, changing" .ns .TP .B "}" .br This type enumerates possible hints when a subject is notifying a view that it has changed. The attaching hint indicates that a view has attached to the subject. The detaching hint means that the subject is being deleted and the view should consider itself detached. The setting hint means that the subject's value has been set, though possibly to the same value as it already has. The changing hint means that the value is set to something different than it was previously. .TP .B "virtual void attach(View*)" Add a view to the subject's list. .TP .B "virtual void detach(View*)" Remove a view from the subject's list. .TP .B "virtual void notify(UpdateHint = changing)" Notify all the views of a subject that it has been updated. .TP .B "virtual boolean viewed_by(View*)" Return whether a given view is on the subject's list of views. .TP .B "virtual void Attach(Interactor*)" This function is equivalent to attach and is provided solely for backward compatibility. It will be removed in a future version. .TP .B "virtual void Detach(Interactor*)" This function is equivalent to detach and is provided solely for backward compatibility. It will be removed in a future version. .TP .B "virtual void Notify()" This function is equivalent to notify(changing) and is provided solely for backward compatibility. It will be removed in a future version. .TP .B "boolean IsView(Interactor*)" This function is equivalent to viewed_by and is provided solely for backward compatibility. It will be removed in a future version. .SH SUBJECTITERATOR OPERATIONS A subject iterator can be used to iterate through the views in a subject. .TP .B "SubjectIterator(Subject*) Create a subject iterator for the given subject. The iterator is only valid as long as the subject exists. .TP .B "virtual void init()" Reset the iteration to start at the beginning of the list. This operation is called by the constructor. .TP .B "virtual boolean more()" Return whether there are more views in the list. .TP .B "virtual View* cur()" Return the current view. .TP .B "virtual void remove()" Remove the current view from the list. .TP .B "virtual void next()" Move the iteration to the next view in the list. .SH SEE ALSO View(3I) ivtools-1.2.11a1/src/man/man3/TextBuffer.3000066400000000000000000000174621214471147700201010ustar00rootroot00000000000000.TH TextBuffer 3I "23 May 1989" "InterViews" "InterViews Reference Manual" .SH NAME TextBuffer \- operations on unstructured text .SH SYNOPSIS .B #include .SH DESCRIPTION TextBuffer defines common editing, searching, and text movement operations on a buffer of unstructured text. Text positions are specified by an index into the buffer and logically refer to positions between characters. For example, the position referred to by the index \fI0\fP is before the first character in the text. Indices can be compared for equality or ordering, but they should not be used to directly access the buffer because TextBuffer might rearrange the text to improve the efficiency of some operations. .SH PUBLIC OPERATIONS .TP .B "TextBuffer(char* buffer, int length, int size)" .ns .TP .B "~TextBuffer()" Create or destroy an instance of TextBuffer. All operations on the text contained in \fIbuffer\fP should be performed through TextBuffer functions. The text is assumed to be of length \fIlength\fP, and the total available buffer size is \fIsize\fP. .TP .B "int Search(Regexp* regexp, int index, int range, int stop)" .ns .TP .B "int ForwardSearch(Regexp* regexp, int index)" .ns .TP .B "int BackwardSearch(Regexp* regexp, int index)" Search for a match with the regular expression \fIregexp\fP, beginning at position \fIindex\fP. Search searches the part of the buffer specified by \fIrange\fP and \fIstop\fP and returns the index of the beginning of the matched text. Positive values of \fIrange\fP specify forward searches, and negative values specify backward searches. In either case, the matched text will not extend beyond the position given by \fIstop\fP. ForwardSearch searches for matches from \fIindex\fP to the end of the text and returns the index of the end of the match. BackwardSearch searches from \fIindex\fP to the start of the text and returns the index of the beginning of the match. All three functions return a negative number if there was no match. .TP .B "int Match(Regexp* regexp, int index, int stop)" .ns .TP .B "boolean ForwardMatch(Regexp* regexp, int index)" .ns .TP .B "boolean BackwardMatch(Regexp* regexp, int index)" Attempt to match the regular expression \fIregexp\fP at the position \fIindex\fP. Match returns the length of the matching string, or a negative number if there was no match. Matching will not succeed beyond the position given by \fIstop\fP. ForwardMatch looks for a match that begins at \fIindex\fP. BackwardMatch looks for a match that ends at \fIindex\fP. .TP .B "int Insert(int index, const char* string, int count)" .ns .TP .B "int Delete(int index, int count)" .ns .TP .B "int Copy(int index, char* buffer, int count)" Edit the text in the buffer. Insert inserts count characters from \fIstring\fP at the position \fIindex\fP. It returns the actual number of characters inserted, which might be less than count if there is insufficient space in the buffer. Delete deletes \fIcount\fP characters from the buffer. A positive \fIcount\fP deletes characters after \fIindex\fP, and a negative value deletes character before \fIindex\fP. Delete returns the actual number of characters deleted, which might be less than \fIcount\fP if index is near the beginning or the end of the text. Copy copies \fIcount\fP characters into \fIbuffer\fP. A positive \fIcount\fP copies characters after \fIindex\fP and a negative \fIcount\fP copies characters before \fIindex\fP. Count returns the actual number of characters copied. It is the caller's responsibility to ensure that \fIbuffer\fP contains sufficient space for the copied text. .TP .B "int Height()" .ns .TP .B "int Width()" .ns .TP .B "int Length()" Return information about the text. Height returns the number of lines in the text, Width returns the number of characters in the longest line, and Length returns the total number of characters. .TP .B "const char* Text()" .ns .TP .B "const char* Text(int index)" .ns .TP .B "const char* Text(int index1, int index2)" .ns .TP .B "char Char (int index)" Access the contents of the text. Char returns the character immediately following \fIindex\fP. The three Text calls return pointers to character strings representing the text. They make various guarantees about the format of the returned string. With no parameters, Text returns a pointer to a string that contains the entire text of the buffer. With a single parameter the string contains at least the text from \fIindex\fP to the end of the line. With two parameters, the returned string contains at least the text between \fIindex1\fP and \fIindex2\fP. In any case, the returned string should be considered temporary and its contents subject to change. To maximize efficiency, you should prefer the more restricted forms of Text. .TP .B "int LineIndex(int line)" .ns .TP .B "int LinesBetween(int index1, int index2)" .ns .TP .B "int LineNumber(int index)" .ns .TP .B "int LineOffset (int index)" Map between text indices and line and offset positions. LineIndex returns the index of the beginning of line \fIline\fP. LineNumber returns the number of the line that contains \fIindex\fP. LineOffset returns the offset of \fIindex\fP from the beginning of its containing line. LinesBetween returns the difference between the numbers of the lines containings \fIindex1\fP and \fIindex2\fP; a return value of zero indicates that \fIindex1\fP and \fIindex2\fP are on the same line, and a positive value indicates that the line containing \fIindex2\fP is after the line containing \fIindex1\fP. Lines are numbered starting from zero. .TP .B "int PreviousCharacter(int index)" .ns .TP .B "int NextCharacter(int index)" Return the index immediately following or preceding \fIindex\fP. The returned value is never before the beginning or after the end of the text. .TP .B "boolean IsBeginningOfText(int index)" .ns .TP .B "int BeginningOfText()" .ns .TP .B "boolean IsEndOfText(int index)" .ns .TP .B "int EndOfText()" Return the index of the beginning or end of the text, or query whether \fIindex\fP is at the beginning or end of the text. .TP .B "boolean IsBeginningOfLine(int index)" .ns .TP .B "int BeginningOfLine(int index)" .ns .TP .B "int BeginningOfNextLine(int index)" .ns .TP .B "boolean IsEndOfLine(int index)" .ns .TP .B "int EndOfLine(int index)" .ns .TP .B "int EndOfPreviousLine(int index)" Return information about the line structure of the text around \fIindex\fP. BeginningOfLine returns the index of the beginning of the line containing \fIindex\fP. BeginningOfNextLine returns the index of the beginning of the next line that begins after \fIindex\fP. EndOfLine returns the index of the end of the line containing \fIindex\fP. EndOfPreviousLine returns the index of the end of the last line that ends before \fIindex\fP. The beginning of a line is logically immediately after a newline character, and the end of a line is logically immediately before a newline character. The beginning and end of the text are considered to be the beginning and end of the first and last lines, respectively. .TP .B "boolean IsBeginningOfWord(int index)" .ns .TP .B "int BeginningOfWord(int index)" .ns .TP .B "int BeginningOfNextWord(int index)" .ns .TP .B "boolean IsEndOfWord(int index)" .ns .TP .B "int EndOfWord(int index)" .ns .TP .B "int EndOfPreviousWord(int index)" Return information about the word structure of the text around \fIindex\fP. BeginningOfWord returns the index of the beginning of the word containing \fIindex\fP. BeginningOfNextWord return the index of the beginning of the nest word that begins after \fIindex\fP. EndOfWord returns the index of the end of the word that contains \fIindex\fP. EndOfPreviousWord returns the index of the end of the last word that ends before \fIindex\fP. A word is defined as a sequence of alpha-numeric characters. The beginning and end of the text are considered to be the beginning and end of the first and last words, respectively. .SH SEE ALSO Regexp(3I) ivtools-1.2.11a1/src/man/man3/TextComp.3000066400000000000000000000067021214471147700175610ustar00rootroot00000000000000.TH TextComp 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME TextComp, TextView, TextGraphic, PSText \- multiline text component subject, view, structured graphic, and PostScript external representation .SH SYNOPSIS .B #include .SH DESCRIPTION TextComp is a GraphicComp that defines a piece of multiline text. It uses a TextGraphic (a subclass of Label) to store its graphical attributes. TextView is a GraphicView for displaying the text. PSText is a PostScriptView that externalizes the subject's information in PostScript form. .SH TEXTCOMP PUBLIC OPERATIONS .TP .B "TextComp(TextGraphic* = nil)" The constructor takes an optional TextGraphic that defines the attributes of the text. .TP .B "virtual void Interpret(Command*)" .ns .TP .B "virtual void Uninterpret(Command*)" TextComp redefines (Un)interpret to ignore BrushCmd and PatternCmd and to (un)interpret FontCmd. .TP .B "TextGraphic* GetText()" Return the TextGraphic that defines the text component's attributes. GetText is simply a more specific form of the GetGraphic operation. .SH TEXTVIEW PUBLIC OPERATIONS .TP .B "TextView(TextComp* = nil)" Create an TextView, optionally supplying the subject. .TP .B "virtual void Interpret(Command*)" TextView interprets AlignToGridCmd to align its lower-left to the grid. .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*, Tool*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" TextView redefines its response to manipulation with a GraphicCompTool. GraphicCompTool will let the user position and type out the component's text using TextManip. Positioning of the text will be influenced by gravity, if any. TextView also defines a response to the ReshapeTool to let the user edit the text. The subject is actually replaced (via ReplaceCmd) with a new TextComp subject positioned at the original TextComp's location but reflecting the edited text. .TP .B "TextComp* GetTextComp()" Return the subject. .SH TEXTVIEW PROTECTED OPERATIONS .TP .B "virtual boolean TextChanged()" Return whether the text in the subject is any different from that in the view. .SH TEXTGRAPHIC PUBLIC OPERATIONS .TP .B "TextGraphic(const char*, int h, Graphic* = nil)" .ns .TP .B "TextGraphic(const char*, Graphic*)" Create a TextGraphic, specifying its text, optional inter-line spacing, and optional graphic from which to obtain default graphics attributes. TextGraphic stores a copy of the given string (behavior it inherits from Label). If inter-line spacing is not specified, then lines will be separated to reflect the font height reported by PSFont. .TP .B "void SetLineHeight(int)" .ns .TP .B "int GetLineHeight()" Explicitly set and get the inter-line spacing. .TP .B "virtual boolean operator == (TextGraphic&)" .ns .TP .B "virtual boolean operator != (TextGraphic&)" Report whether the given graphic contains or does not contain an identical copy of the text in \fIthis\fP .SH PSTEXT PUBLIC OPERATIONS .TP .B "PSText(TextComp* = nil)" Construct a PostScript external representation of the given subject, if any. .SH PSTEXT PROTECTED OPERATIONS .TP .B "const char* Filter(const char* string, int length)" Filter excapes embedded control or other special characters that would cause syntax errors in the PostScript output. .SH SEE ALSO FontCmd(3U), GraphicComp(3U), GraphicCompTool(3U), GraphicView(3U), Grid(3U), Label(3U), PostScriptView(3U), ReshapeTool(3U), align(3U), edit(3U), manips(3U), pspaint(3U) ivtools-1.2.11a1/src/man/man3/TextDisplay.3000066400000000000000000000134001214471147700202610ustar00rootroot00000000000000.TH TextDisplay 3I "23 May 1989" "InterViews" "InterViews Reference Manual" .SH NAME TextDisplay \- unstructured text display .SH SYNOPSIS .B #include .SH DESCRIPTION A TextDisplay manages and displays an array of lines of text. Operations are provided to insert and delete lines, to insert and delete text within a line, and to scroll the display. TextDisplays are typically used to implement interactors that require non-trivial display of unstructured text. .PP The array is addressed by a line number and an index into the line. Text can be inserted or deleted at arbitrary positions. By default, the first character in line number zero is positioned with its top left corner at the top left corner of the TextDisplay. The display is automatically updated following modifications to the text or when scrolling. Each character in the array has an associated text style. Operations are provided to apply, add, or remove font styles to a range of the text. TextDisplay can be used with both constant-width and proportionally-spaced fonts and with arbitrary geometric transformations. .SH PUBLIC OPERATIONS .TP .B "TextDisplay()" .ns .TP .B "~TextDisplay(boolean autosized = false)" Create or destroy a TextDisplay. If \fIautosized\fP is \fItrue\fP, the TextDisplay will automatically grow its size as text is added. The default is to keep the size constant. .TP .B "void LineHeight(Coord lineheight)" .ns .TP .B "void TabWidth(Coord tabwidth)" Lines of text will be positioned with baselines separated by \fIlineheight\fP. Tab characters in the text will cause the following character to be positioned an integral multiple of \fItabwidth\fP from the beginning of the line. .TP .B "void Resize(Coord xmin, Coord ymin, Coord xmax, Coord ymax)" .ns .TP .B "void Bounds(Coord& xmin, Coord& ymin, Coord& xmax, Coord& ymax)" Specify or query the size of the display. Only lines of text that fall completely inside the specified region will be displayed. TextDisplay will not draw on any part of the canvas outside the specified bounds. Conversely, TextDisplay is free to draw on any part of the canvas within the specified bounds. .TP .B "void Draw(Painter*, Canvas*)" Specify the painter and canvas to use for drawing operations; the painter specifies the font, colors, and geometric transformation. Draw should be called before performing any operation on the TextDisplay which produces output or requires graphical information, or when there is a possibility that the painter or canvas has changed since the function was last called. .TP .B "void Redraw(Coord left, Coord bottom, Coord right, Coord top)" Redraw a specified region of the display. .TP .B "void Scroll(int line, Coord x, Coord y)" Scroll the display so that line \fIline\fP is positioned with its upper-left corner at (\fIx\fP, \fIy\fP). There are no restrictions on the arguments: it is possible to scroll the display so that no lines are visible. .TP .B "void InsertLinesAfter(int line, int count)" .ns .TP .B "void InsertLinesBefore(int line, int count)" .ns .TP .B "void DeleteLinesAfter(int line, int count)" .ns .TP .B "void DeleteLinesBefore(int line, int count)" Insert or delete whole lines of text. Line \fIline\fP is not affected by the operation. Other lines will move up or down to accommodate the changes. Newly inserted lines are blank. The specified line need not refer to an existing line. .TP .B "void InsertText(int line, int index, const char*, int count)" .ns .TP .B "void DeleteText(int line, int index, int count)" .ns .TP .B "void ReplaceText(int line, const char*, int count)" Modify the text within line \fIline\fP. InsertText and DeleteText will cause the following characters on the line to move to accommodate the changes. ReplaceText replaces the entire text of the line. If the specified line is non-existent, a new line will be created. .TP .B "void Style(int line1, int index1, int line2, int index2, int style)" .ns .TP .B "void AddStyle(int line1, int index1, int line2, int index2, int style)" .ns .TP .B "void RemoveStyle(int line1, int index1, int line2, int index2, int style)" Modify the styling of a range of text. Style replaces any existing style; AddStyle adds style \fIstyle\fP in addition to any existing styles; RemoveStyle removes style \fIstyle\fP without affecting other existing styles. Styles are specified as any combination of the constants Plain, Boldface, Underlined, and Reversed. .TP .B "void CaretStyle(int style)" .ns .TP .B "void Caret(int line, int index)" Control the shape and position of a caret. Valid caret styles are currently NoCaret, BarCaret, UnderscoreCaret and OutlineCaret. TextDisplay does not automatically adjust the position of the caret following insertions and deletions. .TP .B "int LineNumber(Coord y)" .ns .TP .B "int LineIndex(int line, Coord x)" Map x and y display coordinates into line and index text coordinates. LineNumber returns the number of the line that contains the specified vertical position \fIy\fP. LineIndex returns the index into line \fIline\fP that best corresponds to the specified horizontal position \fIx\fP. .TP .B "Coord Width()" .ns .TP .B "Coord Height()" Return the width or the height of the text currently displayed by the TextDisplay. Width returns the width of the longest line in the display. Height returns the distance from the top of the topmost line to the bottom of the bottommost line. Note that these dimensions do not necessarily correspond to the TextDisplay's bounds as returned by Bounds. .TP .B "Coord Base(int line)" .ns .TP .B "Coord Top(int line)" .ns .TP .B "Coord Left(int line, int index)" .ns .TP .B "Coord Right(int line, int index)" Map line and index text coordinates into x and y display coordinates. The return values define a bounding box for the character specified by \fIline\fP and \fIindex\fP. .SH SEE ALSO Painter(2I), Canvas(2I) ivtools-1.2.11a1/src/man/man3/TextEditor.3000066400000000000000000000142001214471147700201010ustar00rootroot00000000000000.TH TextEditor 3I "24 May 1989" "InterViews" "InterViews Reference Manual" .SH NAME TextEditor \- basic unstructured text editing .SH SYNOPSIS .B #include .SH DESCRIPTION A TextEditor is an interactor that provides an interactive interface for simple text editing of a TextBuffer. TextEditor uses an editing model based on a single current selection. Editing operations operate on the text in the selection, alter the position or size of the selection, or scroll the display to view other parts of the text. TextEditor interprets a perspective for interactive scrolling using a scroller. .PP TextEditor does not provide a default set of keyboard bindings. You can implement the key bindings you desire by subclassing and redefining the Handle operation or by handling keyboard events in an entirely separate class. .SH PUBLIC OPERATIONS .TP .B "TextEditor(int rows, int cols, int tabsize, int highlight)" .ns .TP .B "~TextEditor()" Create or destroy an instance of TextEditor. The natural size of a TextEditor is specified by \fIrows\fP and \fIcolumns\fP. The TextEditor will be tall enough to display \fIrows\fP lines of text in the current font, and it will be wide enough to display \fIcolumns\fP characters. For proportionally-spaced fonts, the width of the character 'n' is taken to be representative. Tab characters in the text are expanded to multiples of \fItabsize\fP character widths. The current selection highlighted with the text style \fIhighlight\fP. .TP .B "void Edit(TextBuffer*, int index = 0)" Specify the text buffer to edit. A text buffer must be specified before the TextEditor is displayed. The optional \fIindex\fP parameter specifies the initial selection point. If necessary, the TextEditor is scrolled so that the selection point is visible. .TP .B "int Dot()" .ns .TP .B "int Mark()" The current selection is bounded by two indices into the text buffer. By convention these indices are called dot and mark. Dot is the position at which text will be inserted and deleted. Mark locates the end of the selection that moves as the selection is modified. When the selection is empty (an insertion point), dot and mark are equal. .TP .B "void InsertText(const char* string, int count)" .ns .TP .B "void DeleteText(int count)" .ns .TP .B "void DeleteSelection()" Edit the text buffer at the current selection. InsertText inserts count characters from string after dot. The selection becomes an insertion point following the newly inserted text. DeleteText deletes count characters at dot. If count is positive, the characters following dot are deleted; if count is negative the characters before dot are deleted. The selection becomes an insertion point in the place of the deleted text. DeleteSelection deletes the text between dot and mark, changing the selection to an insertion point. .TP .B "void BackwardCharacter(int count)" .ns .TP .B "void ForwardCharacter(int count)" .ns .TP .B "void BackwardLine(int count)" .ns .TP .B "void ForwardLine(int count)" .ns .TP .B "void BackwardWord(int count)" .ns .TP .B "void ForwardWord(int count)" .ns .TP .B "void BackwardPage(int count)" .ns .TP .B "void ForwardPage(int count)" Move the current selection forward or backward by the specified number of the specified units. The default movement is one unit. The selection is not moved before the beginning of after the end of the text. .TP .B "void BeginningOfLine()" .ns .TP .B "void EndOfLine()" .ns .TP .B "void BeginningOfWord()" .ns .TP .B "void EndOfWord()" .ns .TP .B "void BeginningOfSelection()" .ns .TP .B "void EndOfSelection()" .ns .TP .B "void BeginningOfText()" .ns .TP .B "void EndOfText()" Move the current selection forwards or backwards to the specified feature of the text. .TP .B "void ScrollToSelection(boolean always = false)" .ns .TP .B "void SetScrollAlignment(Alignment)" .ns .TP .B "Alignment GetScrollAlignment()" ScrollToSelction scrolls the display so that dot will be visible. If dot is currently visible and \fIalways\fP is false, no scrolling takes place; if dot is not visible or \fIalways\fP is true, the display is scrolled so that dot will be positioned as close as possible to the position specified by SetScrollAlignment. GetScrollAlignment returns the current scroll alignment. The default alignment is Center. .TP .B "void ScrollToView(Coord x, Coord y)" .ns .TP .B "void ScrollBy(Coord dx, Coord dy)" ScrollToView scrolls the display so that the text currently at the position (\fIx\fP, \fIy\fP) will be visible. If the specified point is currently visible, no scrolling takes place. ScrollBy specifies an amount by which to scroll the display. Positive values scroll the display upwards and to the right. In each case, the final position of the display is limited so that some text will be visible. .TP .B "void GrabScroll(Event&)" .ns .TP .B "void RateScroll(Event&)" Initiate grab scrolling or rate scrolling. Once called, GrabScroll (RateScroll) polls the current mouse position as long as the middle (right) button is pressed. As GrabScroll polls, it scrolls the text to follow the mouse position, making it appear as though the user is dragging the text itself. Each time RateScroll polls the mouse, it scrolls the text by an amount corresponding to the differential between the current and initial mouse positions. This creates the illusion of a joystick interface: the further away the mouse is from its initial position, the greater the scrolling increment and the faster the text appears to scroll; scrolling slows down, stops, and reverses direction as the user drags the mouse back towards and past the initial position. .TP .B "void Select(int dot)" .ns .TP .B "void Select(int dot, int mark)" .ns .TP .B "void SelectMore(int mark)" .ns .TP .B "void SelectAll()" Modify the current selection in terms of text indices. With a single parameter, Select moves both dot and mark to the specified index. With two parameters, dot and mark can be controlled independently. SelectMore leaves dot unchanged and moves mark. SelectAll sets dot to the end of the text and mark to the beginning. .TP .B "int Locate(Coord x, Coord y)" Return the text index most closely matching the point (\fIx\fP, \fIy\fP). .SH SEE ALSO Interactor(2I), TextBuffer(3I) ivtools-1.2.11a1/src/man/man3/Tool.3000066400000000000000000000113141214471147700167260ustar00rootroot00000000000000.TH Tool 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME Tool \- base class for tool objects .SH SYNOPSIS .B #include .SH DESCRIPTION Tool is an abstract base class for objects that support direct manipulation of components. Tools employ animation and other visual effects for immediate feedback to reinforce the user's perception that he is dealing with real objects. The user \fIgrasps\fP and \fIwields\fP a tool to achieve a desired \fIeffect\fP. The effect may involve a change to one or more components' internal state, or it may change the way components are viewed, or there may be no effect at all (if for example the tool is used in an inapropriate context). .sp Conceptually, tools do their work within viewers, in which graphical component views are displayed and manipulated. Whenever a viewer receives an input event (such as a mouse click or key press), it in turn asks the current tool (defined by the enclosing editor object) to produce a manipulator object. A tool implements its CreateManipulator operation to create and initialize an appropriate manipulator, which encapsulates the tool's manipulation semantics by defining the three phases (grasp, wield, effect) of the manipulation. Moreover, a tool can delegate manipulator creation to one or more of the GraphicView objects in the viewer to allow component-specific interaction. A tool's InterpretManipulator operation accesses and analyzes information in the manipulator that characterizes the manipulation and then creates a command that carries out the desired effect. If a tool delegated manipulator creation to a graphical view, then it must delegate its interpretation to the same view. .SH PUBLIC OPERATIONS .TP .B "virtual Manipulator* CreateManipulator(" .ns .TP .B " Viewer*, Event&, Transformer*" .ns .TP .B ")" .ns .TP .B "virtual void InterpretManipulator(Manipulator*)" Operations that define how the tool reacts when it is used and its ultimate effect. The tool can defer manipulator creation and interpretation to a GraphicView. This allows the same tool to behave differently depending on the component it manipulates. .sp .sp CreateManipulator creates a manipulator that is appropriate for the tool. It receives the viewer in which the manipulation will take place, an event with which to initialize the manipulator if necessary, and the coordinate transformation that maps canvas coordinates into the subject's coordinate space. InterpretManipulator is called following manipulation and defines how to construct a command that carries out the manipulation's desired effect. .TP .B "virtual void SetControlInfo(ControlInfo*)" .ns .TP .B "virtual ControlInfo* GetControlInfo()" Tools use a ControlInfo object to store information from which to build a user interface for engaging the tool. These operations set and get the ControlInfo object. SetControlInfo does \fInot\fP delete the ControlInfo being replaced. .TP .B "virtual Component* Copy()" Return a copy of the tool. Subclasses should redefine this operation to return an instance of their type. .TP .B "virtual void Read(istream&)" .ns .TP .B "virtual void Write(ostream&)" Read and write the tool's contents to a stream to support catalog operations. Read and write typically call first the corresponding operations defined by their parent class, and then they read or write their class-specific state. Note that you must ensure that the objects are read in the same order they are written. .TP .B "virtual ClassId GetClassId()" .ns .TP .B "virtual boolean IsA(ClassId)" GetClassId returns the unique class identifier for the Tool subclass, while IsA returns whether the instance is of a class or subclass corresponding to the given identifier. IsA typically checks the given identifier against the instance's own (as defined by its GetClassId operation) and, failing that, calls its parent classes' IsA operation. All subclasses must redefine GetClassId and IsA to ensure that their identifiers are unique and that instances are written and read properly. .SH PROTECTED OPERATIONS .TP .B "Tool(ControlInfo* = nil)" The constructor is protected to prevent instatiation of the abstract base class. The ControlInfo object is optional, but only tools that have no visible manifestion in the interface should omit it. .TP .B "ControlInfo* CopyControlInfo()" CopyControlInfo is a convenience function that subclasses may use in their Copy operation. It returns a copy of the tool's ControlInfo object if it non-nil, simply checking for a nil argument before calling the corresponding Copy on the ControlInfo object. .SH SEE ALSO Catalog(3U), Command(3U), ControlInfo(3U), Editor(3U), Event(3I), GraphicView(3U), Manipulator(3U), Transformer(3I), Viewer(3U), classes(3U), istream(3C++), ostream(3C++) ivtools-1.2.11a1/src/man/man3/TransferFunct.3000066400000000000000000000044121214471147700205760ustar00rootroot00000000000000.TH TransferFunct 3U "6 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME TransferFunct \- transfer function base class .SH SYNOPSIS .B #include .SH DESCRIPTION A transfer function defines relationships between state variables. A component uses a transfer function to enforce dependencies between its state variables during dataflow. State variables whose values change as a result of data flowing into the component can thus affect the component's dependent state variables as defined by its transfer function. A transfer function can define dependencies between any number of state variables, but a component can define only one transfer function. .SH PUBLIC OPERATIONS .TP .B "virtual void Evaluate(Path* = nil)" Enforce the transfer function's dependencies between its state variables, optionally depending on the information in a path. This operation does nothing by default. .TP .B "virtual TransferFunct* Copy()" Return a copy of the transfer function. Subclasses redefine this operation to return an instance of their type. .TP .B "virtual void Read(istream&)" .ns .TP .B "virtual void Write(ostream&)" Read and write the transfer function's contents to a stream to support catalog operations. Read and write typically call first the corresponding operations defined by their parent class, and then they read or write their class-specific state. .TP .B "virtual ClassId GetClassId()" .ns .TP .B "virtual boolean IsA(ClassId)" GetClassId returns the unique class identifier for the TransferFunct subclass, while IsA returns whether the instance is of a class or subclass corresponding to the given identifier. IsA typically checks the given identifier against the instance's own (as defined by its GetClassId operation) and, failing that, calls its parent classes' IsA operation. All subclasses must redefine GetClassId and IsA to ensure that their identifiers are unique and that instances are written and read properly. .SH PROTECTED OPERATIONS .TP .B "TransferFunct()" The constructor is protected to prevent instantiation. .TP .B "virtual Connector* GetBinding(StateVar*)" Return the connector to which a state variable is bound. .SH SEE ALSO Catalog(3U), Component(3U), Connector(3U), Creator(3U), Path(3U), StateVar(3U) classes(3U), istream(3C++), ostream(3C++) ivtools-1.2.11a1/src/man/man3/Tray.3000066400000000000000000000105541214471147700167350ustar00rootroot00000000000000.TH Tray 3I "8 September 1988" "InterViews" "InterViews Reference Manual" .SH NAME Tray \- compose interactors into arbitrary or constrained layouts .SH SYNOPSIS .B #include .SH DESCRIPTION A tray is a scene of interactors that overlap, tile, or have other constraints on their alignment relative to each other. One of the interactors in a tray can serve as a background for the other interactors. .PP Constraints on the layout of interactors are made by \fIaligning\fP interactors to each other. Two interactors are aligned by specifying which edges coincide. For example, the lower left corner of one interactor may be aligned to the upper right of another. \fBTGlue\fP objects can be used to introduce transparent space between aligned interactors. TGlue has a natural size, shrinkability, and stretchability (though TGlue objects are \fInot\fP interactors). Trays stretch or shrink the TGlue along with the aligned interactors to satisfy the alignment constraints. .PP The tray adopts the shape of the background interactor if there is one; otherwise, the tray's shape depends on the shapes of its components and potentially on their alignments. By default, a tray without a background takes on a width and height equal to the largest of the widths and heights of its components. However, alignments involving the tray can in effect override this default. .PP For example, if the left and right sides of a particular component are aligned to the tray's left and right sides, respectively, then the tray's sides are constrained to coincide with the component's sides. Thus the tray will adopt the width, horizontal shrinkability, and horizontal stretchability of that component. Another example: To ensure that a tray circumscribes a collection of (mutually aligned) components, align the outer edges of the components on the periphery of the collection to the outer edges of the tray, thereby constraining the tray to assume the shape of the collection. .SH TGLUE PUBLIC OPERATIONS .TP .B "TGlue(int w = 0, int h = 0, int hstretch = hfil, int vstretch = vfil); Define TGlue of a minimum size. The TGlue can stretch from the given size but cannot shrink. .TP .B "TGlue(int, int, int hshrink, int hstretch, int vshrink, int vstretch); Define general TGlue with a given natural size (width and height), shrinkability, and stretchability. .SH TRAY PUBLIC OPERATIONS .TP .B "Tray(Interactor* background = nil)" Create a new tray, optionally having an interactor as a background. .TP .B "void Align(Alignment, Interactor*, TGlue* = nil)" .ns .TP .B "void Align(Alignment, Interactor*, Alignment, Interactor*, TGlue* = nil)" Align an interactor to another interactor (the tray itself by default), optionally with TGlue between them. Align operations insert interactors into the tray if they have not been inserted already. .TP .B "void Align(Alignment, Interactor*, ..., Interactor* = nil)" Apply an alignment to a set of interactors. This operation is shorthand for aligning the interactors to each other explicitly. For example, Align(Left, i1, i2, i3, i4) aligns the left sides of interactors i1 through i4. Two to seven interactors can be aligned at once. .TP .B void HBox(Interactor*, ..., Interactor* = nil) .ns .TP .B void VBox(Interactor*, ..., Interactor* = nil) The HBox and VBox operations align the specified interactors such that they tile left-to-right and top-to-bottom, respectively. These operations align in one dimension only. Two to seven interactors can be aligned at once. If the first (last) component is the tray or the background interactor, then the leftmost (rightmost) component will be aligned with the left (right) side of the tray. .TP .B "void Insert(Interactor*)" Insert an interactor into the tray without an alignment. The interactor will appear in the lower left corner of the tray. .TP .B "void Change(Interactor*)" Notify the tray that the given interactor's shape has changed. The tray will recompute the layout of its component interactors to satisfy any alignments. If the tray does not contain a background, then a change in the shape of one of its components may in turn change the tray's shape. If the tray has a background, then the tray's shape will change only if the shape of the background changes. .TP .B "void Remove(Interactor*)" Take an interactor out of a tray and eliminate any alignments that have been made to it. .SH SEE ALSO Interactor(3I), Scene(3I), Shape(3I) ivtools-1.2.11a1/src/man/man3/UArray.3000066400000000000000000000030171214471147700172150ustar00rootroot00000000000000.TH UArray 3U "6 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME UArray \- dynamic array class .SH SYNOPSIS .B #include .SH DESCRIPTION UArray implements a dynamic array, that is, one that grows as elements are added. It can also act as a linked list, allowing insertion and removal of objects, though the overhead for such operations is generally greater than that for conventional doubly-linked list implementations. However, the overhead per stored object is potentially much less for a UArray, and objects can be accessed by index in constant time. .SH PUBLIC OPERATIONS .TP .B "UArray(int = 16)" Create a new UArray instance, optionally providing an estimate of its maximum size. While specifying the size is not required, supplying an accurate estimate will improve performance. .TP .B "void*& operator[](int index)" Overloading the brackets operator allows access to the UArray's elements with the standard array notation. Note that type information is lost when retrieving objects from the UArray, requiring casting. .TP .B "void Insert(void*, int index)" .ns .TP .B "void Remove(int index)" Insert and remove an object at a particular index, moving the succeeding objects up or down one position as required. .TP .B "int Index(void*)" Return the given object's index in the UArray, returning -1 if the object does not appear in the UArray. .TP .B "int Count()" Return the number of objects inserted in the UArray. .TP .B "void Clear()" Clear the UArray, reducing the number of object it contains to zero. ivtools-1.2.11a1/src/man/man3/UControl.3000066400000000000000000000054341214471147700175640ustar00rootroot00000000000000.TH UControl 3U "20 November 1990" "Unidraw" "InterViews Reference Manual" .SH NAME UControl, UControlInteractor \- base classes for menu and button interfaces that work with ControlInfo objects .SH SYNOPSIS .B #include .SH DESCRIPTION UControl is an abstract class that augments InterViews' Control base class to deal with Unidraw's ControlInfo objects, which define a keyboard equivalent for the control. UControlInteractor is an abstract base class for interactors that base their appearance on the information in a ControlInfo object. UControl subclasses can use UControlInteractor subclasses to define their appearance. Unidraw-based applications needn't use UControls and UControlInteractors to help define their look and feel if Unidraw's keyboard equivalent mechanism is not needed. .SH UCONTROL PUBLIC OPERATIONS .TP .B "virtual void SetControlInfo(ControlInfo*)" .ns .TP .B "ControlInfo* GetControlInfo()" Assign and retrieve the UControl's ControlInfo object. .SH UCONTROL PROTECTED OPERATIONS .TP .B "UControl(ControlInfo*)" .ns .TP .B "UControl(const char*, ControlInfo*)" UControl provides protected constructors that let subclasses initialize the ControlInfo object and optionally specify their instance name. .SH UCONTROLINTERACTOR PUBLIC OPERATIONS .TP .B "virtual void SetControlInfo(ControlInfo*)" .ns .TP .B "ControlInfo* GetControlInfo()" Assign and retrieve the UControlInteractor's ControlInfo object. .TP .B "virtual void Highlight(boolean)" The UControlInteractor's appearance is defined by a Graphic object, which it builds from information in its ControlInfo object. By default, UControlInteractor highlights itself by drawing this graphic with its foreground and background colors reversed. .SH UCONTROLINTERACTOR PROTECTED OPERATIONS .TP .B "UControlInteractor(ControlInfo*)" .ns .TP .B "UControlInteractor()" UControlInteractor defines two protected constructors. One takes the ControlInfo object to use as an argument. This constructor also initializes the UControlInteractor's \fI_label\fP protected member by calling InitLabel (described below) with the ControlInfo object. The parameterless constructor initializes \fI_label\fP to nil. Both constructors initialize the UControlInteractor's \fI_picture\fP protected member to point to an instance of a Picture object, which defines the UControlInteractor's appearance. .TP .B "virtual void Invert()" Invert reverses \fI_picture's\fP colors without drawing it. .TP .B "Graphic* InitLabel(ControlInfo*)" Create a graphic from the information stored in a ControlInfo object that defines the UControlInteractor's appearance. This operation creates a GraphicView of the ControlInfo's GraphicComp and returns a copy of the view's graphic. .SH SEE ALSO Control(3I), ControlInfo(3U), Graphic(3U), GraphicComp(3U), GraphicView(3U), KeyMap(3U) ivtools-1.2.11a1/src/man/man3/UHashTable.3000066400000000000000000000051271214471147700177760ustar00rootroot00000000000000.TH UHashTable 3U "3 October 1990" "Unidraw" "InterViews Reference Manual" .SH NAME UHashTable, UHashElem \- hash table classes .SH SYNOPSIS .B #include .SH DESCRIPTION UHashTable implements a simple open hash table. The number of slots can be specified when the table is created. UHashTable stores UHashElem instances, which contain the key that is hashed. Code that uses UHashTables may derive from UHashElem to store data in addition to the key. UHashTable also provides operations for iterating over the elements in the hash table. .SH UHASHELEM OPERATIONS .TP .B "UHashElem(void* = nil)" Create a UHashElem with the given key value. .TP .B "void* GetKey()" .ns .TP .B "void SetKey(void*)" Explicitly get and set the element's key value. .SH UHASHTABLE PUBLIC OPERATIONS .TP .B "UHashTable(int nslots)" Create a new UHashTable, specifying its number of slots. .TP .B "virtual void Register(void* key, UHashElem* = nil)" Make an entry into the hash table. If no UHashElem is supplied, this function call the CreateElem function (described below) to create one, and it will call SetKey (with \fIkey\fP as its argument) on the result. .TP .B "virtual void Unregister(void* key)" Remove the element with the matching key from the hash table and delete it. .TP .B "void First(Iterator&)" .ns .TP .B "void Next(Iterator&)" .ns .TP .B "boolean Done(Iterator)" .ns .TP .B "UHashElem* GetElem(Iterator)" Operations for iterating over the elements in the hash table. These operation do not guarantee a particular ordering for the iteration. First initializes an iterator to point to the first element in the traversal, Next increments the iterator to point to the following element, and Done returns whether or not the iterator points beyond the last element in the traversal. GetElem returns the element to which the given iterator points. .TP .B "UHashElem* Find(void* key)" Find the element with the matching key (as defined by the Equal operation, described below) in the hash table. .SH UHASHTABLE PROTECTED OPERATIONS .TP .B "virtual UHashElem* CreateElem()" Return a new UHashElem instance. Subclasses of UHashTable should redefine this function if they use subclasses of UHashElem. .TP .B "virtual int Hash(void* key)" Hash the specified key to return a slot index. This value should be less than the value of the \fI_nslots\fP member variable. .TP .B "virtual boolean Equal(void* key1, void* key2)" Return whether the specified keys are equivalent. By default, Equal simply compares the pointers for equality. Subclasses may redefine this operation to make more sophisticated comparisons. .SH SEE ALSO Iterator(3U) ivtools-1.2.11a1/src/man/man3/ULabel.3000066400000000000000000000014761214471147700171650ustar00rootroot00000000000000.TH ULabel 3U "1 February 1991" "Unidraw" "InterViews Reference Manual" .SH NAME ULabel \- structured graphic displaying one line of text .SH SYNOPSIS .B #include .SH DESCRIPTION A ULabel is a Graphic that displays one line of text. It stores a PSFont to define the font in which the text appears. With no transformation, the text will be drawn with its bounding box's lower-left corner at the origin. .SH PUBLIC OPERATIONS .TP .B "ULabel(const char* text, Graphic* = nil)" Construct a label, supplying a null-terminated string in \fItext\fP and an optional graphic from which to obtain an initial set of graphics state. ULabel stores a copy \fItext\fP internally. .TP .B "const char* GetOriginal()" Return a pointer to the text that the label stores internally. .SH SEE ALSO Graphic(3U), pspaint(3U) ivtools-1.2.11a1/src/man/man3/UList.3000066400000000000000000000044261214471147700170570ustar00rootroot00000000000000.TH UList 3U "3 October 1990" "Unidraw" "InterViews Reference Manual" .SH NAME UList \- circular, doubly-linked list class .SH SYNOPSIS .B #include .SH DESCRIPTION UList implements a circular, doubly-linked list. The sentinel and each entry in the list are instances of the UList class, each containing a void pointer to the data they contain as well as pointers to the next and previous UList instance in the list. The sentinel UList instance is considered to represent the list. .SH PUBLIC OPERATIONS .TP .B "UList(void* = nil)" Create a new UList instance, optionally supplying the value for the void pointer it stores. .TP .B "virtual ~UList()" Delete the entire list. Normally the sentinel, which represents the list, is the entry that is deleted explicitly. Note that the data on the list, stored as void*'s, cannot be deleted in this manner. .TP .B "void Append(UList*)" .ns .TP .B "void Prepend(UList*)" When performed on the sentinel, Append appends an element to the end of the list and Prepend prepends it to the beginning of the list. When performed on a UList instance other than the sentinel, Append has the effect of inserting its argument \fIbefore\fP the instance, while Prepend has the effect of inserting it \fIafter\fP the instance. .TP .B "void Remove(UList*)" Unlink the specified UList instance from the list it is in. The object on which this operation is called is irrelevant. .TP .B "void Delete(void*)" Find the UList instance in this list containing the given void pointer, remove it from the list it is in, and delete it. .TP .B "UList* Find(void*)" Return the UList instance in this list containing the given void pointer. .TP .B "UList* First()" .ns .TP .B "UList* Last()" .ns .TP .B "UList* End()" .ns .TP .B "UList* Next()" .ns .TP .B "UList* Prev()" Return various UList instance in the list relative to \fIthis\fP, i.e., as if it were the sentinel. End returns the sentinel (\fIthis\fP) and is useful for detecting the end of an iteration through the list; the other operations are self-explanatory. .TP .B "boolean IsEmpty()" Return whether or not the list has any elements. .TP .B "void* operator()()" Return the void pointer that the UList stores. .TP .B "UList* operator[](int i)" Return the \fIi\fPth UList in the list, where the next element is the first, etc. ivtools-1.2.11a1/src/man/man3/UMap.3000066400000000000000000000047661214471147700166700ustar00rootroot00000000000000.TH UMap 3U "4 October 1990" "Unidraw" "InterViews Reference Manual" .SH NAME UMap \- maintains a mapping between two sets of pointers .SH SYNOPSIS .B #include .SH DESCRIPTION UMap is an abstract class for objects that store an arbitrary number of pointer pairs and can search to find either member of a pair given the other. A UMapElem object stores each pointer pair in the UMap. UMapElem is an abstract class that defines virtuals for returning either member of the pair, referred to as the \fIid\fP and the \fItag\fP. Subclasses of UMapElem redefine these virtuals to return either member of the pair they store. .SH UMAPELEM PUBLIC OPERATIONS .TP .B "UMapElem()" The base class constructor does nothing by default. .TP .B "virtual void* id()" .ns .TP .B "virtual void* tag()" Return the id or the tag that the UMapElem stores. Subclasses typically define two member variables that store pair's values and redefine these operations to return them. .SH UMAP PUBLIC OPERATIONS .TP .B "virtual ~UMap()" The destructor deletes all UMapElem objects in the UMap. .TP .B "int Count()" Return the number of mappings in the UMap, corresponding to the number of UMapElems that have been registered. .TP .B "void Clear()" Delete all the UMapElem mappings in the UMap without destroying the UMap. .SH UMAP PROTECTED OPERATIONS .TP .B "UMap()" The base class constructor does nothing by default. .TP .B "void Register(UMapElem*)" .ns .TP .B "void Unregister(UMapElem*)" Register or remove a UMapElem from the UMap. .TP .B "int Index(UMapElem*)" .ns .TP .B "UMapElem* Elem(int index)" A UMap stores its UMapElem in its \fI_elems\fP UArray protected member variable. The Index operations returns the index of the given UMapElem in the UArray, while Elem returns the UMapElem at a specified index. These operations simply perform the corresponding operations on the UArray. .TP .B "virtual UMapElem* FindId(void* id)" .ns .TP .B "virtual UMapElem* FindTag(void* tag)" FindId searches the UMap for the UMapElem element containing the given id, while FindTag searches for the one with the given tag. These operations perform linear searches by default, comparing their arguments against the values that the UMapElems' id and tag operations return. The comparison is based on the pointer values; subclasses can redefine these operations to make more sophisticated comparisons based on the id or tags actual type. For example, if either the id is a string, then FindId might do a string comparison to detect a match. .SH SEE ALSO UArray(3U) ivtools-1.2.11a1/src/man/man3/UStencil.3000066400000000000000000000023741214471147700175450ustar00rootroot00000000000000.TH UStencil 3U "2 February 1991" "Unidraw" "InterViews Reference Manual" .SH NAME UStencil \- structured graphic displaying a bitmap .SH SYNOPSIS .B #include .SH DESCRIPTION A UStencil is a Graphic that displays a bitmapped image. Two Bitmap objects, an \fIimage\fP and a \fImask\fP, define a stencil's appearance. The stencil potentially paints foreground color where \fIimage\fP has a \fItrue\fP value and background color where \fIimage\fP is \fIfalse\fP, but only pixels that have a corresponding \fItrue\fP value in \fImask\fP are thus affected. The stencil's origin coincides with the origins of the \fIimage\fP and \fImask\fP bitmaps. The \fImask\fP's bounding box defines the stencil's extent. .SH PUBLIC OPERATIONS .TP .B "UStencil(Bitmap* image, Bitmap* mask = nil, Graphic* = nil)" Construct a UStencil, supplying an \fIimage\fP and an optional \fImask\fP bitmap and an optional graphic from which to obtain an initial set of graphics state. Specifying \fInil\fP for \fImask\fP is equivalent to supplying a mask of the same size and shape as \fIimage\fP that contains all \fItrue\fP values. .TP .B "void GetOriginal(Bitamp*&, Bitmap*&)" Return the bitmap parameters supplied in the constructor. .SH SEE ALSO Bitmap(3I), Graphic(3U) ivtools-1.2.11a1/src/man/man3/Unidraw.3000066400000000000000000000212101214471147700174160ustar00rootroot00000000000000.TH Unidraw 3U "4 October 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Unidraw \- one-of-a-kind object for coordinating and controlling a Unidraw application .SH SYNOPSIS .B #include .SH DESCRIPTION Unidraw applications create a single instance of a Unidraw object, which does several things. It creates a World, establishing the connection to the underlying window system. It initializes the catalog and other objects, manages editor instances, and defines the application main loop. It also maintains histories of commands that have be executed and reverse-executed for each component hierarchy being edited. Finally, it cleans up internal state when it is deleted to ensure orderly program termination. The Unidraw object must be created before opening any editors but after creating a catalog. Below is the main program for a typical Unidraw application: .TP int main (int argc, char** argv) { .ns .TP AppSpecificCreator creator; .ns .TP Unidraw* unidraw = new Unidraw( .ns .TP new Catalog("appName", &creator), .ns .TP argc, argv, options, properties .ns .TP ); .TP unidraw->Open(new AppSpecificEditor); .ns .TP unidraw->Run(); .ns .TP delete unidraw; .ns .TP return 0; .ns .TP } .SH PUBLIC OPERATIONS .TP .B "Unidraw( .ns .TP .B " Catalog*, int argc, char** argv," .ns .TP .B " OptionDesc* = nil, PropertyData* = nil .ns .TP .B ")" .ns .TP .B "Unidraw(Catalog*, World*)" .br The first constructor form requires a catalog object and command line argument information. Other arguments include pointers to PropertyData and OptionDesc arrays. This constructor creates a World instance, passing whichever of these arguments are supplied (except the catalog). To specify a World instance explicitly, use the second constructor form. .TP .B "virtual void Run()" .ns .TP .B "virtual void Quit()" Run initiates the main loop of the program. The call to Run returns when Quit is called. .TP .B "virtual void Update(boolean immedate = false)" Bring the screen up to date with the state of the application's objects. By default, this involves moving connectors to their proper positions (by calling Solve on the global csolver object) and telling editors to update themselves (by calling their Update functions). Because Update may carry out potentially lengthy operations, Unidraw batches Update calls by default. This ensures that multiple consecutive calls do not induce redundant computations. To force an immediate update, simply call Update(\fItrue\fP). .TP .B "virtual void Open(Editor*)" .ns .TP .B "virtual boolean Opened(Editor*)" Open inserts an editor into the world, making it visible on the display. The user positions the editor's window by default. Opened returns whether an editor has been opened already. .TP .B "virtual void Close(Editor*)" .ns .TP .B "virtual void CloseDependents(Component*)" .ns .TP .B "virtual void CloseAll()" Close closes a specified editor, removing it from the user's view \fIand deleting it\fP. CloseDependents closes those editors that report a dependence on the given component via their DependsOn operation. CloseAll closes all open editors. ~Unidraw calls CloseAll. .TP .B "void First(Iterator&)" .ns .TP .B "void Next(Iterator&)" .ns .TP .B "boolean Done(Iterator)" Operations for iterating over the Unidraw object's list of open editors. First initializes an iterator to point to the beginning of the list, Next increments the iterator to point to the following editor, and Done returns whether or not the iterator points beyond the first or last editor in the list. .TP .B "Editor* GetEditor(Iterator)" Return the editor to which an iterator points. .TP .B "Editor* Find(Component*)" .ns .TP .B "Editor* FindAny(Component*)" Operations for finding an (or the) editor associated with a given component. Find searches the list of editors for the one whose GetComponent operation returns the given component. FindAny returns the first editor in the list whose GetComponent operation returns a component in the same hierarchy as the the given component. .TP .B "Catalog* GetCatalog()" Return the catalog passed to the constructor. .TP .B "World* GetWorld()" Return the world object, which the Unidraw object creates when it is instantiated. .TP .B "void Log(Command*)" .ns .TP .B "void Undo(Component*, int i = 1)" .ns .TP .B "void Redo(Component*, int i = 1)" The Unidraw object maintains histories of commands associated with a given component hierarchy. There are two command histories per hierarchy: the \fIpast\fP history and the \fIfuture\fP history. These histories normally contain commands that have been executed and unexecuted to support arbitrary level undo and redo. For example, after a viewer executes the command that a tool generates by interpreting a manipulator, it will record that command in a past history for possible undoing in the future. The Log operation logs a command, placing it on the past history for the component hierarchy being edited. Log determines the past that is approprate from the command's editor, which specifies the component (hence the hierarchy) that it is editing. Undo reverse-executes the last \fIi\fP commands that were logged for a given component's hierarchy and moves them from their past history to the corresponding future history. Redo re-executes the future \fIi\fP commands and moves them to the past. Note that calling Redo without a preceding Undo is meaningless; thus calling Log will clear the future history associated with the affected component hierarchy. .TP .B "void SetHistoryLength(int)" .ns .TP .B "int GetHistoryLength()" Assign and retrieve the maximum command history length. No more than this many commands can be undone and redone. The default length is 20. Older commands are deleted automatically as new commands are logged. .TP .B "void ClearHistory(Component* = nil)" Clear the past and future for a given component hierarchy, deleting the corresponding commands. All histories are cleared if no component is specified. .ns .TP .B "void ClearHistory(Editor*)" Clear the history associated with the given editor's component if no other editor is editing the same hierarchy. For example, Unidraw::Close calls this operation to avoid clearing histories when a component hierarchy is being edited in multiple editors. .SH PROTECTED OPERATIONS .TP .B "virtual void Process()" Process is called once in the main loop defined by the Run operation. It does nothing by default. Subclasses may redefine Process to carry out any processing that should be done in each pass through the main loop. .TP .B "boolean IsClean(Editor*)" This convenience function queries the given editor for a ModifStatusVar instance. If it has one, then it returns its status (modified or unmodified); otherwise it returns \fIfalse\fP. .TP .B "void Mark(Editor*)" .ns .TP .B "void Sweep(Editor*) These operations support deferred editor deletion, a mechanism to avoid deleting editors prematurely. For example, if a command to close the editor is invoked from a pull-down menu, then the command must not delete the editor, since that will delete the pull-down menu before it has a chance to close. Thus Close and similar operations do not delete editors directly; instead, they call Mark to indicate that an editor should be deleted sometime in the future. Sweep actually deletes the editors that have been marked. By default, Unidraw::Run calls Sweep each time an event is handled. .TP .B "void DoUpdate()" A helper function that performs an immediate update independent of the batching mechanism. .TP .B "void GetHistory(Component*, UList*& past, UList*& future)" .ns .TP .B "void ClearHistory(UList*, int i = 1)" Command histories are stored as ULists. These operations provide a low-level interface to the lists themselves; the corresponding public operations are built on top. GetHistory returns the past and future lists for a given component, while ClearHistory deletes the first \fIi\fP commands on the given list. .TP .B "UList* elem(Iterator)" .ns .TP .B "Command* command(UList*)" Convenience functions for extracting the list element in an iterator and the command object from the list element. These are useful in conjunction with protected history operations described above. .TP .B "boolean updated()" .ns .TP .B "void updated(boolean)" The first form of this function returns \fItrue\fP if there are pending Update(s) to be performed. The second form sets this value explicitly. .TP .B "boolean alive()" .ns .TP .B "void alive(boolean)" The first form of this function returns \fItrue\fP if the program is in the run loop defined by Run. The second form sets this value explicitly. .SH SEE ALSO Catalog(3U), Creator(3U), Editor(3U), Interactor(3U), Iterator(3U), Viewer(3I), UList(3U), World(3I), statevars(3U) ivtools-1.2.11a1/src/man/man3/UnidrawIntro.3000066400000000000000000000043601214471147700204410ustar00rootroot00000000000000.TH UnidrawIntro 3U "11 June 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Unidraw library for graphical object editor development .SH SYNOPSIS .B #include .br .B #include .br .B #include .br .B #include .br .B #include .LP .B "CC ... \-lUnidraw ... -lInterViews -lX -lm" .SH DESCRIPTION Unidraw is an architecture for creating object-oriented graphical editors in domains such as technical and artistic drawing, music composition, and circuit design. Unidraw simpifies the construction of these editors by providing programming abstractions that are common across domains. Unidraw defines four basic abstractions: \fBcomponents\fP encapsulate the appearance and semantics of objects in a domain, \fBtools\fP support direct manipulation of components, \fBcommands\fP define operations on components and other objects, and \fBexternal representations\fP define the mapping between components and the file format generated by the editor. Unidraw also supports multiple views, graphical connectivity and confinement, and dataflow between components. .PP The Unidraw library contains a collection of classes that implement the Unidraw architecture. The Unidraw library is used together with the rest of InterViews, except the \fIgraphic\fP structured graphics library, to develop domain-specific graphical object editors. InterViews interactors and composition mechanisms support an application's look and feel, while the Unidraw library supports functionality unique to graphical object editors. Currently, the Unidraw library provides its own structured graphics classes, which are similar to but incompatible with the graphic library classes. Therefore you must not use both graphic and Unidraw classes in the same application. .PP General Unidraw classes are declared in header files in the Unidraw include file subdirectory. Component, command, tool, and structured graphics classes are declared in corresponding subdirectories under the Unidraw subdirectory. .SH SEE ALSO InterViews(3I) .LP .IR "Generalized Graphical Object Editing", John M. Vlissides, Technical Report CSL-TR-90-427, Stanford University, June 1990. ivtools-1.2.11a1/src/man/man3/Vertices.3000066400000000000000000000042151214471147700175770ustar00rootroot00000000000000.TH Vertices 3U "2 February 1991" "Unidraw" "InterViews Reference Manual" .SH NAME Vertices \- abstract base class for graphics defined by a set of coordinate pairs .SH SYNOPSIS .B #include .SH DESCRIPTION Vertices is an abstract base class for graphics such as polygons and splines whose geometry is specified by a set of coordinate pairs. The Vertices class supports vertex-related operations common to all such graphical objects and also supports extent caching. .SH PUBLIC OPERATIONS .TP .B "virtual ~Vertices()" The destructor deallocates the list of coordinate pairs stored in the graphic. .TP .B "virtual int GetOriginal(const Coord*& x, const Coord*& y)" Return pointers to the arrays of Coords stored internally that define the graphic's vertices. GetOriginal's return value reflects the size of the arrays. .TP .B "virtual boolean operator == (Vertices&)" .ns .TP .B "virtual boolean operator != (Vertices&)" Compare \fIthis\fP to the given Vertices instance and return whether they (do not) store identical sets of vertices. .SH PROTECTED OPERATIONS .TP .B "Vertices(Graphic* = nil)" .ns .TP .B "Vertices(Coord* x, Coord* y, int count, Graphic* = nil)" The constructors are protected to disallow instantiation of the abstract class. Subclasses can pass a set of vertices to copy into internal storage and an optional graphic from which to obtain an initial set of graphics state. Vertices itself stores no additional graphics state over that in the Graphic base class. .TP .B "void s_getExtent(" .ns .TP .B " float&, float&, float&, float&, float&, Graphic*" .ns .TP .B ")" .ns .TP .B "void f_getExtent(" .ns .TP .B " float&, float&, float&, float&, float&, Graphic*" .ns .TP .B ")" .br Helper functions that return extent information based on the bounding box that the vertices define. s_getExtent returns an extent that accounts for the width of a brush, as would be necessary if the vertices defined a stroked path, while f_getExtent assumes that the vertices define the graphic's extremities, as would be the case if the vertices defined a filled path. These operations cache the extent they compute initially. .SH SEE ALSO Graphic(3U) ivtools-1.2.11a1/src/man/man3/VerticesComp.3000066400000000000000000000052771214471147700204270ustar00rootroot00000000000000.TH VerticesComp 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME VerticesComp, VerticesView, PSVertices \- abstract base classes for vertexed graphical component subjects and their views and PostScript external representations .SH SYNOPSIS .B #include .SH DESCRIPTION VerticesComp is an abstract base class for graphical components whose geometry can be expressed as a list of coordinate pairs. VerticesComp uses a Vertices graphic to store its graphical attributes. VerticesView is an abstract GraphicView subclass for displaying a VerticesComp. PSVertices is an abstract PostScriptView for subclasses that externalize VerticesComp information in PostScript form. .SH VERTICESCOMP PUBLIC OPERATIONS .TP .B "Vertices* GetVertices()" Return the Vertices graphic that defines the vertices's attributes. GetVertices is simply a more specific form of the GetGraphic operation. .SH VERTICESCOMP PROTECTED OPERATIONS .TP .B "VerticesComp(Vertices* = nil)" The constructor takes an optional vertices graphic that defines the component's graphical attributes. .SH VERTICESVIEW PUBLIC OPERATIONS .TP .B "virtual void Interpret(Command*)" VerticesView interprets AlignToGridCmd to align its first vertex to the grid. .TP .B "virtual void GetVertices(Coord*& x, Coord*& y, int& count)" Return the view's vertices in canvas coordinates. GetVertices allocates new arrays each time it is called. .TP .B "VerticesComp* GetVerticesComp()" Return the subject. .SH VERTICESVIEW PROTECTED OPERATIONS .TP .B "VerticesView(VerticesComp* = nil)" Initialize a VerticesView, optionally supplying the subject. .TP .B "virtual void CreateHandles()" VerticesView redefines CreateHandles to create a RubberHandles object that draws a handle coinciding with each vertex. .TP .B "virtual boolean VertexChanged()" Returns whether or not the vertices as stored in the view are different in any way from those stored in the subject. The Update function relies on the result to determine whether to recreate the view's structured graphic based on the subject's. VerticesView::VertexChanged (conservatively) returns \fIfalse\fP by default; subclasses should redefine this function to make a more discerning decision, thereby increasing the efficiency of the update operation. .SH PSVERTICES PROTECTED OPERATIONS .TP .B "PSVertices(VerticesComp* = nil)" Initialize a PostScript external representation of the given subject, if any. .TP .B "virtual const char* Name()" Subclasses should redefine Name to return the proper tag for the object in the PostScript output as required for idraw compatibility. .SH SEE ALSO GraphicComp(3U), GraphicView(3U), Grid(3U), PatternCmd(3U), PostScriptView(3U), Vertices(3U), align(3U), idraw(3I) ivtools-1.2.11a1/src/man/man3/Viewer.3000066400000000000000000000206461214471147700172620ustar00rootroot00000000000000.TH Viewer 3U "6 October 1990" "Unidraw" "InterViews Reference Manual" .SH NAME Viewer \- displays a graphical component view hierarchy .SH SYNOPSIS .B #include .SH DESCRIPTION A Viewer displays a graphical component view and provides an interface to scrolling and zooming it. The viewer also processes user input events and generates the appropriate calls on Unidraw objects in response. The Viewer class is a derived from GraphicBlock; thus it can draw the structured graphics hierarchy embodied in GraphicView's graphic. A viewer uses a damage object to keep the screen up to date. Viewer's sensor catches up and down events, and its Handle implements implements the tool manipulation loop. .SH PUBLIC OPERATIONS .TP .B "Viewer(" .ns .TP .B " Editor*, GraphicView*, Page*, Grid* = nil," .ns .TP .B " Coord width = 0, Coord height = 0, Orientation = Normal," .ns .TP .B " Alignment = Center, Zooming = Binary" .ns .TP .B ")" .ns .TP .B "Viewer(" .ns .TP .B " const char*, Editor*, GraphicView*, Page*, Grid* = nil," .ns .TP .B " Coord width = 0, Coord height = 0" .ns .TP .B " Alignment = Center, Zooming = Binary" .ns .TP .B ")" .br Both constructors take the enclosing editor, the GraphicView object that the viewer will display, a page object, and optionally a grid, a natural width and height, initial page orientation, alignment, and zooming specifications. The second form adds a parameter for specifying the Viewer's instance name. .TP .B "virtual void Update()" Viewer augments GraphicBlock's Update semantics by repairing any damage that has been accumulated. In addition, Update will replace its graphical view if its subject differs from the editor's component; in that case, it will create a graphical view of the editor's component, delete its own view, and replace it with the new one. .TP .B "virtual void Adjust(Perspective&)" Viewer's Adjust operation will automatically update the editor's MagnifVar (if it defines one) to reflect the current magnification. .TP .B "virtual void Handle(Event&)" By default, Handle employs the editor's current tool on a LEFTMOUSE down event. On MIDDLEMOUSE or RIGHTMOUSE down events, it momentarily engages the editor's MoveTool or SelectTool, respectively, allowing the user to move or select a graphical component without changing the current tool explicitly. Nothing happens if the editor does not define a keyboard equivalent for engaging these tools. The Handle function calls either the UseTool or MomentaryUseTool protected member functions (described below) in response to these events. .TP .B "virtual void SetGraphicView(GraphicView*)" .ns .TP .B "virtual void SetPage(Page*)" .ns .TP .B "virtual void SetGrid(Grid*)" .ns .TP .B "virtual GraphicView* GetGraphicView()" .ns .TP .B "virtual Page* GetPage()" .ns .TP .B "virtual Grid* GetGrid()" .ns .TP .B "virtual Editor* GetEditor()" Explicitly set or get a constructor-specified parameter. The Set operations delete the value they replace if it is different from the given one. .TP .B "virtual void SetMagnification(float)" Viewer's SetMagnification operation amends GraphicBlock::SetMagnification to set the value of the enclosing editor's MagnifVar, if it defines one. .TP .B "virtual void SetOrientation(Orientation)" .ns .TP .B "virtual Orientation GetOrientation()" Set and get the viewer's orientation parameter, which specifies whether the graphical view, page, and grid will appear in portrait or landscape mode. No transformation will be applied in portrait mode, while landscape mode will rotate the page -90 degrees and translate it vertically by an amout equal to the width of the page's bounding box. .TP .B "virtual Selection* GetSelection()" Return the enclosing editor's selection object; it is equivalent to calling GetEditor and then calling GetSelection on the result. .TP .B "virtual Damage* GetDamage()" Return the viewer's damage object. .TP .B "virtual void InitRubberband(Rubberband*)" .ns .TP .B "virtual void InitTextDisplay(TextDisplay*, Painter*)" These operations let Rubberband and TextDisplay instances appear to work in a viewer by allowing them to draw on the viewer's canvas. InitRubberband sets the rubberband's canvas to the viewer's and initializes its painter as well. InitTextDisplay likewise sets the TextDisplay's canvas to the viewer's. It also modifies the given painter's background color to match the viewer's and supplies the painter to the TextDisplay for its use. .TP .B "virtual void IncurTextDisplayDamage(TextDisplay*, Painter*)" Incur minimal damage on the viewer's damage object to account for the TextDisplay's current size. The TextDisplay's painter must be passed explicitly. .TP .B "virtual void CenterOp()" .ns .TP .B "virtual void Magnify(Coord, Coord, Coord, Coord)" .ns .TP .B "virtual void ReduceToFit()" Convenience functions for adjusting the viewer's perspective. CenterOp centers the page in the viewer's canvas without changing the magnification. Magnify scrolls and magnifies the given area (in canvas coordinates) so that it fills the viewer's canvas. Magnify ensures that the area will remain fully visible in the viewer. ReduceToFit scrolls and reduces the view so that the entire page is visible. .TP .B "virtual void Constrain(Coord&, Coord&)" Constrain the supplied coordinates to fall on the nearest grid point if the viewer defines a grid and if the enclosing editor defines an active GravityVar. .TP .B "virtual void UseTool(Tool*)" Commence direct-manipulation with the given tool without an explicit action on the user's part. Normally, direct manipulation with the currently engaged tool (as returned by the editor's GetCurTool operation) starts automatically when the user clicks in the viewer. .TP .B "virtual void Align(GraphicComp*, Alignment)" Align the graphical component with respect to viewer's canvas, assuming a view of the component appears in the viewer. For example, a ``Center'' alignment will align the component's center with the canvas'; a ``BottomLeft'' alignment will align the component's bottom-left corner to the canvas'. .SH PROTECTED OPERATIONS .TP .B "void Init(" .ns .TP .B " Editor*, GraphicView*, Page*, Grid*," .ns .TP .B " Coord, Coord, Orientation" .ns .TP .B ")" .ns .TP .B "void Init(Editor*, GraphicView*, Page*, Grid*)" .br Initialize the viewer's member variables. The first form of this operation initializes all parameters that can be passed to a constructor. The first form calls the second form, which initializes a subset of the attributes that may change independently of the others. .TP .B "Tool* CurTool()" A convenience function equivalent to calling the same operation on the enclosing editor. .TP .B "Transformer* GetTransformer()" Return the transformer that the viewer uses to implement scrolling and zooming. .TP .B "virtual void Manipulate(Manipulator*, Event&)" This operation implements a direct manipulation loop governed by the given manipulator. First it calls Grasp on the manipulator with the given event. Then it reads events in a loop, calling the manipulator's Manipulating operation with each new event. When Manipulating returns false, it calls Effect on the manipulator with the event read last. .TP .B "virtual void UseTool(Tool*, Event&)" .ns .TP .B "virtual void MomentaryUseTool(Tool*, Event&)" Helper functions for initiating direct manipulation with tools and executing their effect. UseTool first instructs the given tool to create a manipulator, and then it calls Manipulate to carry the manipulation through to completion. Next it asks the tool to interpret the manipulator, which in turn may produce a command. Finally, UseTool executes and logs the command produced. MomentaryUseTool simply engages the given tool, calls UseTool, and re-engages the original tool. .TP .B "virtual void Reorient()" A helper function that rotates the viewer's graphic to reflect its current orientation. .TP .B "virtual void UpdateMagnifVar()" A helper function used in SetMagnification to notify the enclosing viewer's MagnifVar (if it defines one) of the change in magnification. .TP .B "virtual ClassId ViewCategory()" Returns the view category (see classes(3U)) the viewer will use to instantiate a view if it is not given one explicitly. ViewCategory returns COMPONENT_VIEW by default. .SH SEE ALSO Damage(3U), Editor(3U), Event(3I), Graphic(3U), GraphicBlock(3U), GraphicComp(3U), GraphicView(3U), Grid(3U), Manipulator(3U), MoveTool(3U), Page(3U), Perspective(3I), Rubband(3I), SelectTool(3U), Selection(3U), Sensor(3I), TextDisplay(3I), Tool(3U), classes(3U), globals(3U), statevars(3U) ivtools-1.2.11a1/src/man/man3/Viewport.3000066400000000000000000000043261214471147700176350ustar00rootroot00000000000000.TH Viewport 3I "10 February 1988" "InterViews" "InterViews Reference Manual" .SH NAME Viewport \- scrollable view .SH SYNOPSIS .B #include .SH DESCRIPTION .B Viewport is a subclass of MonoScene that allocates its component exactly as much space as it wants (determined from its shape). This space will be clipped to the viewport's size and the viewport maintains a perspective to adjust the portion of the component that is actually displayed. If the component is smaller than the viewport's canvas, then the viewport background will be filled with a light gray pattern. .SH PUBLIC OPERATIONS .TP .B "Viewport(Interactor* = nil, Alignment = Center)" Construct a new viewport. If the interactor is not nil, it is inserted as the viewport's component. The second parameter determines where the component is placed relative to the viewport. .TP .B "Insert(Interactor*)" Set the component interactor. .TP .B "void Change(Interactor*)" A viewport does not propagate changes. Thus, if the component's shape changes the viewport simply resizes the component according to the new shape. .TP .B "void Remove(Interactor*)" Take out the component interactor. .TP .B "virtual void Adjust(Perspective&)" Change the viewport's perspective to the given one. This operation will cause the desired area of the component to be drawn. .TP .B "void AdjustTo(float px, float py, float zx, float zy)" .ns .TP .B "void AdjustBy(float dpx, float dpy, float dzx, float dzy)" .ns .TP .B "void ScrollTo(float px, float py)" .ns .TP .B "void ScrollXTo(float px)" .ns .TP .B "void ScrollYTo(float py)" .ns .TP .B "void ScrollBy(float dpx, float dpy)" .ns .TP .B "void ScrollXBy(float dpx)" .ns .TP .B "void ScrollYBy(float dpy)" .ns .TP .B "void ZoomTo(float zx, float zy)" .ns .TP .B "void ZoomXTo(float zx)" .ns .TP .B "void ZoomYTo(float zy)" .ns .TP .B "void ZoomBy(float dzx, float dzy)" .ns .TP .B "void ZoomXBy(float dzx)" .ns .TP .B "void ZoomYBy(float dzy)" Short-hand operations for explicit manipulation of the viewport's perspective. .TP .B "float XPos()" .ns .TP .B "float YPos()" .ns .TP .B "float XMag()" .ns .TP .B "float YMag()" Short-hand for retrieving information about the current perspective. .SH SEE ALSO Perspective(3I), Scene(3I), Shape(3I) ivtools-1.2.11a1/src/man/man3/World.3000066400000000000000000000137051214471147700171060ustar00rootroot00000000000000.TH World 3I "7 Mar 1989" "InterViews" "InterViews Reference Manual" .SH NAME World \- control a display .SH SYNOPSIS .B #include .SH DESCRIPTION A world was an application's connection to a particular display. It is currently provided for backward compatibility. .SH PUBLIC OPERATIONS .TP .B "World(" .ns .TP .B " const char* classname, int& argc, char** argv" .ns .TP .B " OptionDesc* = nil, PropertyData* = nil" .ns .TP .B ")" .br Construct the world object for a display. The world's instance name comes from the -name option if it was given; otherwise the instance name comes from the environment variable RESOURCE_NAME if it is nonnil. If the name has still not been defined, then argv[0] with all leading directories stripped is used. The following arguments are interpreted automatically and are removed from \fIargv\fP: .PP .RS .nf .ta 1.5i \-background next argument sets the background color \-bg same as \-background \-display next argument specifies the target workstation display \-foreground next argument sets the foreground color \-fg same as \-foreground \-fn same as \-font \-font next argument sets the text font \-geometry next argument sets the first top-level interactor's position and size \-iconic starts up the first top-level interactor in iconic form \-name next argument sets the instance name of all top-level interactors that don't have their own instance names \-reverse swaps default foreground and background colors \-rv same as \-reverse \-synchronous force synchronous operation with the window system \-title next argument sets the first top-level interactor's title bar name \-xrm next argument sets an ``attribute: value'' property .fi .RE The geometry specification has the form ``=WxH+XOFF+YOFF''. A negative XOFF (YOFF) specifies the offset of the interactor's right (bottom) edge from the right (bottom) side of the screen. The constructor sets \fIargc\fP to the number of uninterpreted arguments that remain. .PP If non-nil, the OptionDesc* parameter is an array of option descriptors used to parse application-specific attributes. OptionDesc contains four fields: a \fIname\fP used on the command line, a \fIpath\fP specifying the attribute, a \fIstyle\fP specifying where the value is, and a default \fIvalue\fP. Valid styles are \fIOptionPropertyNext\fP (use next argument as an attribute:value pair, not just the value), \fIOptionValueNext\fP (use next argument as value), \fIOptionValueImplicit\fP (use default value), \fIOptionValueIsArg\fP (use argument as value), and \fIOptionValueAfter\fP (use remainder of argument as value). If non-nil, the PropertyData* parameter is an array of structures that each contain three string fields: a \fIpath\fP specifying the attribute, a \fIvalue\fP specifying the value, and a \fItype\fP specifying the type name. Attributes are entered in the following order: first any application defaults (specified by the PropertyData array), then application defaults from /usr/lib/X11/app-defaults/\fIclassname\fP, then user defaults (usually in $HOME/.Xdefaults), and finally command-line arguments. Thus, command-line arguments override user defaults, and both override application defaults. .TP .B "const char* name()" Return the instance name associated with the world. .TP .B "const char* classname()" Return the class name associated with the world. .TP .B "int argc()" Return the number of arguments passed to the world (not counting those that were interpreted by the constructor). .TP .B "char** argv()" Return the argument vector passed to the world. .TP .B "Font* font()" Return the default font associated with the display. If a value for ``font'' is defined at the top-level of the property sheet, then it is used. Otherwise, a system default is used. .TP .B "Color* foreground()" Return the default foreground color associated with the display. If a value for ``foreground'' is defined at the top-level of the property sheet, then it is used. Otherwise, a system default is used. .TP .B "Color* background()" Return the default background color associated with the display. If a value for ``background'' is defined at the top-level of the property sheet, then it is used. Otherwise, a system default is used. .TP .B "boolean shaped_windows()" Return whether the display supports non-rectangular windows. .TP .B "boolean double_buffered()" Return whether windows on the display should by default be double-buffered. .TP .B "virtual void flush()" Repair all damaged windows on the display and then send any pending requests to the window system. .TP .B "virtual void sync()" Repair all damaged windows on the display, send any pending requests to the window system, and wait for an acknowledgement from the window system. .TP .B "Coord width()" Return the width in coordinates of the current screen associated with the display. .TP .B "Coord height()" Return the height in coordinates of the current screen associated with the display. .TP .B "virtual void run()" Read events from the display, handling them as they arrive, and stopping when quit is called. .TP .B "virtual void quit()" Terminate the run loop. .TP .B "virtual boolean pending()" Return whether any events are waiting to be read. .TP .B "virtual void read(Event&)" Read the next event from the world associated with the event. .TP .B "virtual boolean read(long sec, long usec, Event&)" Read the next event from the world associated with the event, but do not wait more than \fIsec\fP seconds and \fIusec\fP microseconds. Return whether an event was found in the given time. .TP .B "virtual void unread(Event&)" Put the event back on the input queue for the world associated with the event. .TP .B "virtual void poll(Event&)" Set the event to an artificial motion event based on the current pointer position and the state of the buttons and meta-keys. .B "virtual void SetScreen(int s)" Set the current screen to \fIs\fP. .TP .B "static World* current()" Return the current world. The current world is set when a world is created or an event is received for the display associated with a world. ivtools-1.2.11a1/src/man/man3/align.3000066400000000000000000000071271214471147700171120ustar00rootroot00000000000000.TH align 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME AlignCmd, AlignToGridCmd \- commands for aligning interactors to each other and to a grid .SH SYNOPSIS .B #include .SH DESCRIPTION AlignCmd is a purely interpretive command for aligning selected components with respect to one another. For example, it can align the left sides of selected components so that they coincide. AlignToGridCmd is interpreted by selected GraphicView objects to align themselves to the grid (if any) associated with the viewer in which they appear. Each component can thus define what it means to align itself to the grid. .SH ALIGNCMD PUBLIC OPERATIONS .TP .B "AlignCmd(" .ns .TP .B " ControlInfo*," .ns .TP .B " Alignment reference = Left, Alignment affected = Left" .ns .TP .B ")" .ns .TP .B "AlignCmd(Editor* = nil, Alignment = Left, Alignment = Left)" The constructor takes optional arguments for specifying the alignment desired. The \fIreference\fP parameter specifies a point on a fixed reference component. The \fIaffected\fP parameter specifies a point on components that will move to realize the alignment. The defaults for these parameters specify that all affected components should align their left sides to reference's left side. .TP .B "void GetAlignment(Alignment&, Alignment&)" Return the alignment parameters specified in the constructor. .TP .B "GraphicComp* GetReference(GraphicComp* affected)" Return the reference component given a potentially affected component. If \fIaffected\fP appears in the AlignCmd's clipboard, then GetReference returns the GraphicComp preceding it in the clipboard. If \fIaffected\fP is the first component in the clipboard or if it is not on the clipboard, then GetReference returns the first component on the clipboard. .SH ALIGNTOGRIDCMD PUBLIC OPERATIONS .TP .B "AlignToGridCmd(ControlInfo*)" .ns .TP .B "AlignToGridCmd(Editor* = nil)" Construct an AlignToGridCmd. .TP .B "virtual void Execute()" .ns .TP .B "virtual void Unexecute()" AlignToGridCmd redefines Execute to let the selected GraphicView objects interpret the command the first time. This lets the components determine the proper grid with which to align themselves and the amount of movement required. Execute assumes that GraphicView objects will use the Align operation (described below) to compute the amount of movement, store it in a MoveData object, and finally issue a MoveCmd to the subject for interpretation. Unexecute simply calls Unmove (described below) to reverse the Align's effects. .TP .B "virtual void Align(GraphicView*, float, float)" .ns .TP .B "virtual void Unalign(GraphicView*)" GraphicView objects interpreting the AlignToGridCmd should use the Align operation to specify a point to align to the grid that affects them. Align will effectively move the component so that the given point falls on the grid. It will also store the amount of movement in \fIthis\fP by calling Store with a MoveData object. Finally, Align calls Move (described below) to actually move the component that amount. Unalign provides a public interface to reversing the effects of Align by simply calling Unmove with its argument's subject. .SH ALIGNTOGRIDCMD PROTECTED OPERATIONS .TP .B "void Move(GraphicComp*)" .ns .TP .B "void Unmove(GraphicComp*)" Move produces a MoveCmd based on the MoveData stored for the given GraphicComp and tells the GraphicComp to interpret the MoveCmd. Conversely, Unmove produces a MoveCmd based on the the same information and tells the GraphicComp to uninterpret it. .SH SEE ALSO Command(3U), GraphicComp(3U), GraphicView(3U), Grid(3U), Viewer(3U), datas(3U), transforms(3U) ivtools-1.2.11a1/src/man/man3/catcmds.3000066400000000000000000000072171214471147700174360ustar00rootroot00000000000000.TH catcmds 3U "23 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME NewCompCmd, PrintCmd, QuitCmd, RevertCmd, SaveCompCmd, SaveCompAsCmd, ViewCompCmd \- catalog-oriented commands .SH SYNOPSIS .B #include .SH DESCRIPTION The Unidraw library predefines a set of non-interpretive commands that let a user specify components to open, view, and save, plus commands for generating a PostScript external representation and for quitting the application. NewCompCmd re-initializes its editor's component to let the user start editing afresh. If the existing component is modified, NewCompCmd prompts the user to save it. PrintCmd generates a PostScriptView of the editor's component and lets the user send it to a file or to a printer. QuitCmd quits the application, prompting the user to save modified components. RevertCmd lets the user re-open the current component, discarding changes since it was last saved. SaveCompAsCmd lets the user save a component under a particular name, while SaveCompCmd saves a component named previously. Finally, ViewCompCmd lets the user specify another component to view in its editor. .SH NEWCOMPCMD PUBLIC OPERATIONS .TP .B "NewCompCmd(ControlInfo*, Component* prototype = nil)" .ns .TP .B "NewCompCmd(Editor* = nil, Component* = nil)" Create a new NewCompCmd instance, optionally supplying a prototype component. When executed, NewCompCmd will make its editor edit a copy of the prototype. The editor's original component will be deleted if no other editor refers to it. .TP .B "virtual boolean Reversible()" NewCompCmd is not reversible. .TP .B "Component* GetPrototype()" Return the prototype component specified in the constructor. .SH PRINTCMD PUBLIC OPERATIONS .TP .B "PrintCmd(ControlInfo*, PrintDialog* = nil)" .ns .TP .B "PrintCmd(Editor* = nil, PrintDialog* = nil)" Create a new PrintCmd instance, optionally supplying the PrintDialog to display when executed. .TP .B "virtual boolean Reversible()" PrintCmd is not reversible. .SH PRINTCMD PROTECTED OPERATIONS .TP .B "void print(const char* print_cmd, const char* file)" Concatenates \fIprint_cmd\fP and \fIfile\fP and calls system(3) on the result. .SH QUITCMD PUBLIC OPERATIONS .TP .B "QuitCmd(ControlInfo*)" .ns .TP .B "QuitCmd(Editor* = nil)" Create a new QuitCmd instance. .TP .B "virtual boolean Reversible()" QuitCmd is not reversible. .SH REVERTCMD PUBLIC OPERATIONS .TP .B "RevertCmd(ControlInfo*)" .ns .TP .B "RevertCmd(Editor* = nil)" Create a new RevertCmd instance. .TP .B "virtual boolean Reversible()" RevertCmd is not reversible. .SH SAVECOMPCMD PUBLIC OPERATIONS .TP .B "SaveCompCmd(ControlInfo*)" .ns .TP .B "SaveCompCmd(Editor* = nil)" Create a new SaveCompCmd instance. .TP .B "virtual boolean Reversible()" SaveCompCmd is not reversible. .SH SAVECOMPASCMD PUBLIC OPERATIONS .TP .B "SaveCompAsCmd(ControlInfo*, FileChooser* = nil)" .ns .TP .B "SaveCompAsCmd(Editor* = nil, FileChooser* = nil)" Create a new SaveCompAsCmd instance, optionally supplying the FileChooser that will prompt the user to name the component. .TP .B "virtual boolean Reversible()" SaveCompAsCmd is not reversible. .SH VIEWCOMPCMD PUBLIC OPERATIONS .TP .B "ViewCompCmd(ControlInfo*, FileChooser* = nil)" .ns .TP .B "ViewCompCmd(Editor* = nil, FileChooser* = nil)" Create a new ViewCompCmd instance, optionally supplying the FileChooser that will prompt the user to specify the component to view. After the new component is opened successfully, the editor's original component will be deleted if no other editor refers to it. .TP .B "virtual boolean Reversible()" ViewCompCmd is not reversible. .SH SEE ALSO BasicDialog(3U), Command(3U), Component(3U), Editor(3U), PostScriptView(3U), lpr(1). ivtools-1.2.11a1/src/man/man3/classes.3000066400000000000000000000050161214471147700174500ustar00rootroot00000000000000.TH classes 3U "12 June 1990" "Unidraw" "InterViews Reference Manual" .SH NAME classes \- unique identifiers for catalog-managed objects and component views .SH SYNOPSIS .B #include .SH DESCRIPTION Classes for catalog-managed objects, including components, commands, tools, state variables, and transfer functions, must be associated with mutually-unique class identifiers that can be written onto disk. This allows a creator object to call the appropriate constructor as part of recreating an object from disk. Also, there must be a mechanism for creating an appropriate view given a subject; that is, there must be an association between a subject class and allowable view classes for that subject. This association is established by defining class identifiers for component views. These identifiers are formed by concatenating the identifier for a given component subject class with an identifier that specifies a ``view category.'' For example, the class identifier for the PostScript external view of a line component is the concatenation of the identifier for the line component subject class and POSTSCRIPT_VIEW identifier, which specifies the category of external views for generating PostScript. This makes it possible to create an instance of the appropriate PostScript external view subclass given a line component subject. The class identifiers for the Unidraw base and predefined derived classes are specified in the \fIclasses.h\fP include file. Applications that define new catalog-managed objects or component views should define unique class identifiers in a similar manner. Class identifiers for catalog-managed objects are simply integers with mnemonic macro definitions, usually the class name in all-uppercase. For example, the identifier for the LineComp component subject class is .sp #define LINE_COMP 9030 .sp View class identifiers are specified using the Combine macro, which takes as its first argument the macro definition of the corresponding component subject identifier; its second argument is an identifier for the view category. The Combine macro itself is then defined with a mnemonic name. For example, the identifier for the PostScript external view class PSLine (which generates PostScript for the line component subject) is defined as .sp #define PS_LINE Combine(LINE_COMP, POSTSCRIPT_VIEW) .sp where the POSTSCRIPT_VIEW view category identifier is defined as .sp #define POSTSCRIPT_VIEW 9103 .sp N.B.: \fIAll\fP class identifiers in a given application must be unique. .SH SEE ALSO Catalog(3U), Creator(3U) ivtools-1.2.11a1/src/man/man3/datas.3000066400000000000000000000035541214471147700171140ustar00rootroot00000000000000.TH datas 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME ColorData, GSData, MobilityData, MoveData, VoidData \- Data subclasses for storing common undo information .SH SYNOPSIS .B #include .SH DESCRIPTION The Unidraw library predefines several Data subclasses for storing common undo information: ColorData stores two PSColors (usually representing foreground and background colors), while GSData stores a complete set of graphics state in a FullGraphic object. MobilityData stores the mobility and graphics state information needed to undo a change in mobility. MoveData stores a horizontal and vertical distance. VoidData stores a void pointer as a useful alternative to deriving trivially from Data just to store one word of information. .SH COLORDATA PUBLIC OPERATIONS .TP .B "ColorData(PSColor*, PSColor*)" Create a ColorData instance, supplying the PSColor objects it stores. .SH GSDATA PUBLIC OPERATIONS .TP .B "GSData(Graphic*)" Create a GSData instance, supplying the Graphic object from which to copy a complete set of graphics state. The GSData constructor copies this information into its \fI_gs\fP member, from whence it can be retrieved later. .SH MOBILITYDATA PUBLIC OPERATIONS .TP .B "MobilityData(Mobility, Graphic*)" Create a MobilityData instance, supplying the mobility and a Graphic object from which to copy a complete set of graphics state. The MobilityData constructor copies the graphic into its \fI_gs\fP member, from whence it can be retrieved later. .SH MOVEDATA PUBLIC OPERATIONS .TP .B "MoveData(float, float)" Create a MoveData instance, supplying two floating point numbers that normally represent horizontal and vertical movement. .SH VOIDDATA PUBLIC OPERATIONS .TP .B "VoidData(void*)" Create a VoidData instance, supplying a pointer to an object of unknown type. .SH SEE ALSO Data(3U), Graphic(3U), globals(3U) ivtools-1.2.11a1/src/man/man3/edit.3000066400000000000000000000137141214471147700167440ustar00rootroot00000000000000.TH edit 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME ConnectCmd, CopyCmd, CutCmd, DeleteCmd, DupCmd, MobilityCmd, PasteCmd, RedoCmd, ReplaceCmd, SlctAllCmd, UndoCmd \- editing commands .SH SYNOPSIS .B #include .SH DESCRIPTION The Unidraw library defines several commands that offer common component editing functionality. ConnectCmd is a non-interpretive command that connects two connectors. CopyCmd copies selected components onto its clipboard (if it defines one) or onto the global clipboard. CutCmd, DeleteCmd, DupCmd, and PasteCmd are purely interpretive commands that are always interpreted by their editor's component. MobilityCmd gives selected components the opportunity to set their mobility based on the value it provides. UndoCmd and RedoCmd are non-interpretive commands that simply undo and redo the last command that affected their editor's component. ReplaceCmd replaces selected components with the component it stores. Finally, SlctAllCmd is a non-interpretive command that selects all the components displayed in its editor. .SH CONNECTCMD PUBLIC OPERATIONS .TP .B "ConnectCmd(" .ns .TP .B " ControlInfo*," .ns .TP .B " Connector* source = nil, Connector* target = nil" .ns .TP .B ")" .ns .TP .B "ConnectCmd(Editor* = nil, Connector* = nil, Connector* = nil)" The ConnectCmd constructor optionally takes two connectors as parameters, the \fIsource\fP and the \fItarget\fP. When executed, it will call Connect on \fIsource\fP with \fItarget\fP as its argument. It will also set the source's mobility to floating. .TP .B "void GetConnectors(Connector*& source, Connector*& target)" Return the connectors supplied in the constructor. .SH COPYCMD PUBLIC OPERATIONS .TP .B "CopyCmd(ControlInfo*, Clipboard* = nil)" .ns .TP .B "CopyCmd(Editor* = nil, Clipboard* = nil)" Create a CopyCmd instance, optionally specifying a clipboard in which to store copied components. .TP .B "virtual void Execute()" Execute does nothing if no components are selected. Otherwise, Execute places a copy of the selected components onto the CopyCmd's clipboard if is non-nil or else onto the global clipboard (obtained from the catalog). .TP .B "virtual boolean Reversible()" CopyCmd is not reversible. .SH CUTCMD PUBLIC OPERATIONS .TP .B "CutCmd(ControlInfo*, Clipboard* = nil)" .ns .TP .B "CutCmd(Editor* = nil, Clipboard* = nil)" Create a CutCmd instance, optionally specifying a clipboard in which to store the components that were cut. .TP .B "virtual void Execute()" .ns .TP .B "virtual void Unexecute()" CutCmd redefines these operations to let the editor's component interpret it. Execute will set the value of the \fI_executed\fP protected member variable to \fItrue\fP as a side effect. Similarly, Unexecute will reset the value to \fIfalse\fP as a side effect. .SH DELETECMD PUBLIC OPERATIONS .TP .B "DeleteCmd(ControlInfo*, Clipboard* = nil)" .ns .TP .B "DeleteCmd(Editor* = nil, Clipboard* = nil)" Create a DeleteCmd instance, optionally specifying a clipboard in which to store the components that were deleted. .TP .B "virtual void Execute()" .ns .TP .B "virtual void Unexecute()" DeleteCmd redefines these operations to let the editor's component interpret it. Execute will set the value of the \fI_executed\fP protected member variable to \fItrue\fP as a side effect. Similarly, Unexecute will reset the value to \fIfalse\fP as a side effect. .SH DUPCMD PUBLIC OPERATIONS .TP .B "DupCmd(ControlInfo*, Clipboard* = nil)" .ns .TP .B "DupCmd(Editor* = nil, Clipboard* = nil)" Create a DupCmd instance, optionally specifying a clipboard in which to store the components that were duplicated. .TP .B "virtual void Execute()" .ns .TP .B "virtual void Unexecute()" DupCmd redefines these operations to let the editor's component interpret it. Execute will set the value of the \fI_executed\fP protected member variable to \fItrue\fP as a side effect. Similarly, Unexecute will reset the value to \fIfalse\fP as a side effect. .SH MOBILITYCMD PUBLIC OPERATIONS .TP .B "MobilityCmd(ControlInfo*, Mobility = Fixed)" .ns .TP .B "MobilityCmd(Editor* = nil, Mobility = Fixed)" Create a MobilityCmd instance, optionally specifying the mobility that interpreting components may use. .TP .B "Mobility GetMobility()" Return the mobility specified in the constructor. .SH PASTECMD PUBLIC OPERATIONS .TP .B "PasteCmd(ControlInfo*, Clipboard* = nil)" .ns .TP .B "PasteCmd(Editor* = nil, Clipboard* = nil)" Create a PasteCmd instance, optionally specifying a clipboard in which to store the components that will be pasted. .TP .B "virtual void Execute()" .ns .TP .B "virtual void Unexecute()" PasteCmd redefines these operations to let the editor's component interpret it. Execute will set the value of the \fI_executed\fP protected member variable to \fItrue\fP as a side effect. Similarly, Unexecute will reset the value to \fIfalse\fP as a side effect. .TP .B "virtual boolean Reversible()" PasteCmd is reversible if either its clipboard or the global clipboard is non-empty. .SH REDOCMD PUBLIC OPERATIONS .TP .B "RedoCmd(ControlInfo*)" .ns .TP .B "RedoCmd(Editor* = nil)" Construct a new RedoCmd. .TP .B "virtual boolean Reversible()" RedoCmd is not reversible. .SH REPLACECMD PUBLIC OPERATIONS .TP .B "ReplaceCmd(ControlInfo*, GraphicComp* replacement = nil)" .ns .TP .B "ReplaceCmd(Editor* = nil, GraphicComp* replacement = nil)" Create a new ReplaceCmd, optionally supplying the GraphicComp that will replace those that are selected. .TP .B "GraphicComp* GetReplacement()" Return the replacement GraphicComp supplied in the constructor. .SH SLCTALLCMD PUBLIC OPERATIONS .TP .B "SlctAllCmd(ControlInfo*)" .ns .TP .B "SlctAllCmd(Editor* = nil)" Construct a new SlctAllCmd. .TP .B "virtual boolean Reversible()" SlctAllCmd is not reversible. .SH UNDOCMD PUBLIC OPERATIONS .TP .B "UndoCmd(ControlInfo*)" .ns .TP .B "UndoCmd(Editor* = nil)" Construct a new UndoCmd. .TP .B "virtual boolean Reversible()" UndoCmd is not reversible. .SH SEE ALSO Catalog(3U), Clipboard(3U), Command(3U), Connector(3U), GraphicComp(3U), globals(3U) ivtools-1.2.11a1/src/man/man3/ellipses.3000066400000000000000000000056671214471147700176470ustar00rootroot00000000000000.TH ellipses 3U "2 February 1991" "Unidraw" "InterViews Reference Manual" .SH NAME Ellipse, S_Ellipse, F_Ellipse, SF_Ellipse, S_Circle, F_Circle, SF_Circle \- abstract base class and predefined subclasses for elliptical structured graphics .SH SYNOPSIS .B #include .SH DESCRIPTION Ellipse is an abstract base class for elliptical structured graphics objects. It stores geometric information that such graphics require and provides helper functions for calculating extents and for hit detection. Predefined subclasses include S_Ellipse, F_Ellipse, and SF_Ellipse, which draw stroked, filled, and stroked-filled ellipses, respectively; and S_Circle, F_Circle, and SF_Circle, which draw stroked, filled, and stroked-filled circles, respectively. The stroked subclasses store a PSBrush, the filled subclasses store a PSPattern, and the stroked-filled subclasses store one of each. .SH ELLIPSE PUBLIC OPERATIONS .TP .B "void GetOriginal(Coord& x, Coord& y, int& rx, int& ry)" Return the ellipse's geometry. (\fIx, y\fP) defines the ellipse's center, while \fIrx\fP and \fIry\fP define its horizontal and vertical radii, respectively. .SH ELLIPSE PROTECTED OPERATIONS .TP .B "Ellipse(Coord x, Coord y, int rx, int ry, Graphic* = nil)" The constructor is protected to disallow instantiation of the abstract base class. An ellipse's geometry is defined in terms of its center and its horizontal and vertical radii. The constructor also takes an optional graphic from which to obtain an initial set of graphics state. .TP .B "void s_getExtent(" .ns .TP .B " float&, float&, float&, float&, float&, Graphic*" .ns .TP .B ")" .ns .TP .B "void f_getExtent(" .ns .TP .B " float&, float&, float&, float&, float&, Graphic*" .ns .TP .B ")" .ns .TP .B "boolean s_contains(PointObj&, Graphic*)" .ns .TP .B "boolean f_contains(PointObj&, Graphic*)" .ns .TP .B "boolean s_intersects(BoxObj&, Graphic*)" .ns .TP .B "boolean f_intersects(BoxObj&, Graphic*)" Helper functions that return extent and hit detection information based on the bounding box that the ellipse defines. s_getExtent, s_contains, and s_intersects return information that accounts for the width of a brush, as would be necessary if the ellipse is stroked, while f_getExtent, f_contains, and f_intersects assumes that the ellipse is filled. Subclasses can use the operations to help implement their getExtent, contains, and intersects operations. .SH SUBCLASS PUBLIC OPERATIONS .TP .B "S_Ellipse(Coord x, Coord y, int rx, int ry, Graphic* = nil)" .ns .TP .B "F_Ellipse(Coord x, Coord y, int rx, int ry, Graphic* = nil)" .ns .TP .B "SF_Ellipse(Coord x, Coord y, int rx, int ry, Graphic* = nil)" .ns .TP .B "S_Circle(Coord x, Coord y, int radius, Graphic* = nil)" .ns .TP .B "F_Circle(Coord x, Coord y, int radius, Graphic* = nil)" .ns .TP .B "SF_Circle(Coord x, Coord y, int radius, Graphic* = nil)" Constructors for the various predefined Ellipse subclasses. .SH SEE ALSO Graphic(3U), geomobjs(3U), pspaint(3U) ivtools-1.2.11a1/src/man/man3/geomobjs.3000066400000000000000000000166311214471147700176250ustar00rootroot00000000000000.TH geomobjs 3U "2 February 1991" "Unidraw" "InterViews Reference Manual" .SH NAME PointObj, LineObj, BoxObj, MultiLineObj, FillPolygonObj, Extent \- helper classes that manage geometric information for structured graphics .SH SYNOPSIS .B #include .SH DESCRIPTION Unidraw defines several helper classes that store and manage geometric information. Structured graphics objects may use these helper classes to support their semantics. PointObj stores a point, LineObj stores two points, and MultiLineObj stores any number of points. BoxObj and FillPolygonObj define rectangular and polygonal areas, respectively. Extent stores extent information, that is, the lower left corner and center of a bounding box plus a fixed amount of extra space around the bounding box. All these classes provide operations for computing geometric information. .SH POINTOBJ PUBLIC OPERATIONS .TP .B "PointObj(Coord = 0, Coord = 0)" .ns .TP .B "PointObj(PointObj*)" Construct a PointObj, supplying either two Coords or another PointObj to specify the instance's coordinates, which are stored in its \fI_x\fP and \fI_y\fP public members. .TP .B "float Distance(PointObj&)" Return the distance between \fIthis\fP and the given PointObj. .SH LINEOBJ PUBLIC OPERATIONS .TP .B "LineObj(Coord = 0, Coord = 0, Coord = 0, Coord = 0)" .ns .TP .B "LineObj(LineObj*)" Construct a LineObj, supplying either two coordinate pairs or another LineObj to specify the instance's endpoints, which are stored in its \fI_p1\fP and \fI_p2\fP public members. .TP .B "boolean Contains(PointObj&)" .ns .TP .B "boolean Intersects(LineObj&)" Return whether \fIthis\fP contains the given point and intersects the given line, respectively. .TP .B "int Same(PointObj& p1, PointObj& p2)" A helper function used in Intersects. Same returns a positive value if \fIp1\fP and \fIp2\fP fall on the same side of the line, 0 if both points fall on the line, or a negative value if the points are on opposite sides of the line. .SH BOXOBJ PUBLIC OPERATIONS .TP .B "BoxObj(Coord = 0, Coord = 0, Coord = 0, Coord = 0)" .ns .TP .B "BoxObj(BoxObj*)" Construct a BoxObj, supplying either two coordinate pairs or another BoxObj to specify the instance's bottom-left and top-right corners, which are stored in its \fI_left\fP, \fI_bottom\fP, \fI_right\fP, and \fI_top\fP public members. .TP .B "boolean Contains(PointObj&)" .ns .TP .B "boolean Intersects(BoxObj&)" .ns .TP .B "boolean Intersects(LineObj&)" Return whether \fIthis\fP contains the given point and intersects the given box or line, respectively. .TP .B "BoxObj operator - (BoxObj&)" .ns .TP .B "BoxObj operator + (BoxObj&)" Compute the intersection (-) or union (+) of \fIthis\fP and the given box, returning the result. These operations do not affect \fIthis\fP or their argument. .TP .B "boolean Within(BoxObj&)" Return \fItrue\fP if \fIthis\fP falls completely within the given box. Within will also return \fItrue\fP if the boxes are identical. .SH MULTILINEOBJ PUBLIC OPERATIONS .TP .B "MultiLineObj(Coord* = nil, Coord* = nil, int = 0)" Create a MultiLineObj, optionally supplying coordinate arrays (and their size) that define the vertices of the multiline. The MultiLineObj does \fInot\fP copy these arrays but stores them directly. The MultiLineObj stores this information in its \fI_x\fP, \fI_y\fP, and \fI_count\fP public members. .TP .B "void GetBox(BoxObj&)" Calculate the bounding box circumscribing the MultiLineObj's vertices and store it in the argument. .TP .B "boolean Contains(PointObj&)" .ns .TP .B "boolean Intersects(BoxObj&)" .ns .TP .B "boolean Intersects(LineObj&)" Return whether \fIthis\fP contains the given point and intersects the given box or line, respectively. .TP .B "boolean Within(BoxObj&)" Return \fItrue\fP if \fIthis\fP falls completely within the MultiLineObj's bounding box. Within will also return \fItrue\fP if the boxes are identical. .TP .B "void SplineToMultiLine(Coord* cpx, Coord* cpy, int count)" .ns .TP .B "void ClosedSplineToMultiLine(Coord* cpx, Coord* cpy, int count)" Linearize the open or closed B-Spline defined by the given set of control points and store the result in \fIthis\fP. These operations store the linearized result in internal buffers and assign the addresses of these buffers to \fI_x\fP and \fI_y\fP; they do \fInot\fP delete \fI_x\fP and \fI_y\fP if they are non-nil prior to assignment. .SH MULTILINEOBJ PROTECTED OPERATIONS .TP .B "void GrowBuf()" Increase the size of the internal buffers used to store linearized splines. .TP .B "boolean CanApproxWithLine(" .ns .TP .B " double x0, double, y0," .ns .TP .B " double x1, double y1," .ns .TP .B " double x2, double y2" .ns .TP .B ")" .br Return whether two connected line segments defined by the given three points can be approximated visually with a single line between the endpoints. .TP .B "void AddLine(double x0, double y0, double x1, double y1)" Add a line to the internal buffer of vertices. .TP .B "void AddBezierArc(" .ns .TP .B " double x0, double y0, double x1, double y1," .ns .TP .B " double x2, double y2, double x3, double y3" .ns .TP .B ")" .br Add lines approximating the appearance of a Bezier arc defined by the given points to the internal buffer of vertices. .TP .B "void CalcSection(" .ns .TP .B " Coord cminus1x, Coord cminus1y, Coord cx, Coord cy," .ns .TP .B " Coord cplus1x, Coord cplus1y, Coord cplus2x, Coord cplus2y" .ns .TP .B ")" .br Add a Bezier arc to the internal buffer of vertices based on a series of four B-spline control points, the one before and the two after (\fIcx, cy\fP). .SH FILLPOLYGONOBJ PUBLIC OPERATIONS .TP .B "FillPolygonObj(Coord* = nil, Coord* = nil, int = 0)" Create a new FillPolygonObj, optionally specifying its vertices. If vertices are supplied, then the constructor uses Normalize (described below) to store a normalized set of vertices in the FillPolygonObj's \fI_normx\fP, \fI_normy\fP, and \fI_normCount\fP public members. FillPolygonObj is a subclass of MultiLineObj; thus it stores the constructor arguments in its \fI_x\fP, \fI_y\fP, and \fI_count\fP public members. .TP .B "virtual ~FillPolygonObj()" The destructor deletes the \fI_normx\fP and \fI_normy\fP arrays. .TP .B "boolean Contains(PointObj&)" .ns .TP .B "boolean Intersects(BoxObj&)" .ns .TP .B "boolean Intersects(LineObj&)" Return whether \fIthis\fP contains the given point and intersects the given box or line, respectively. .SH FILLPOLYGONOBJ PROTECTED OPERATIONS .TP .B "void Normalize()" Copy the vertices defined by \fI_x\fP, \fI_y\fP, and \fI_count\fP into \fI_normx\fP, \fI_normy\fP, and \fI_normCount\fP such that (\fI_normx[0], _normy[0]\fP) is the lower-leftmost vertex and there are no redundant vertices. .SH EXTENT PUBLIC OPERATIONS .TP .B "Extent(" .ns .TP .B " float left = 0, float bottom = 0," .ns .TP .B " float cx = 0, float cy = 0, float tol = 0" .ns .TP .B ")" .ns .TP .B "Extent(Extent&)" Construct a new Extent, optionally supplying its parameters explicitly or providing a existing Extent to copy. The parameters are stored in the Extent's \fI_left\fP, \fI_bottom\fP, \fI_cx\fP, \fI_cy\fP, and \fI_tol\fP public members. .TP .B "boolean Undefined()" Return whether the extent is undefined, that is, if (\fI_left, _bottom\fP) and (\fI_cx, _cy\fP) are the same point. .TP .B "boolean Within(Extent&)" Return \fItrue\fP if the given extent circumscribes \fIthis\fP. Within will also return \fItrue\fP if the extents are identical. .TP .B "void Merge(Extent&)" Enlarge this extent to subsume area of the given extent. .SH SEE ALSO Graphic(3U) ivtools-1.2.11a1/src/man/man3/globals.3000066400000000000000000000106571214471147700174450ustar00rootroot00000000000000.TH globals 3U "30 July 1990" "Unidraw" "InterViews Reference Manual" .SH NAME globals \- Unidraw global constants, types, instances, and functions. .SH SYNOPSIS .B #include .SH DESCRIPTION Several constants and types are used throughout the Unidraw library. It also provides global access to one-of-a-kind instances such as the unidraw object as well as shared graphics resources. Finally, there are several global functions for common data manipulations. All of these are declared one file for inclusion into other files where they are needed. .SH CONSTANTS .TP .B "static const int CHARBUFSIZE" Size of standard character buffer. .TP .B "static const int HANDLE_SIZE" Size of selection handles, in pixels. .TP .B "static const char MARK[]" String that delineates data boundaries in the ASCII representation that Catalog generates. Used for error checking. .TP .B "static const int PIN_RAD" The radius of a pin, used in its default graphical representation, in pixels. .TP .B "static const int SLOP" Tolerance within which a hit on a graphical object will be detected, in pixels. .SH TYPES .TP .B "enum DragConstraint" Enumerates orthogonal ways in which cursor movement may be constrained, usually during direct manipulation. Possible values include \fBNone\fP, \fBXFixed\fP, \fBYFixed\fP, \fBXYEqual\fP, \fBHorizOrVert\fP, or \fBGravity\fP. .TP .B "enum Mobility" Enumerates the three possible component mobilities: \fBFixed\fP, \fBFloating\fP, or \fBUndef\fP (undefined). .TP .B "typedef unsigned Orientation" Specifies two kinds of orientation: \fBPortrait\fP or \fBVertical\fP (synonymous), and \fBLandscape\fP or \fBHorizontal\fP (synonymous). .TP .B "enum TransMethod" Enumerates the three possible transmission methods for connectors: \fBIn\fP, \fBOut\fP, or \fBInOut\fP. .TP .B "typedef unsigned long ClassId" Type for representing unique class names for catalog-managed objects. .SH INSTANCES .TP .B "extern Unidraw* unidraw" .ns .TP .B "extern CSolver* csolver" The global unidraw and csolver objects. These and all other global instances are initialized automatically. .TP .B "extern PSColor* psblack" .ns .TP .B "extern PSColor* pswhite" .ns .TP .B "extern PSPattern* pssolid" .ns .TP .B "extern PSPattern* psclear" .ns .TP .B "extern PSPattern* psnonepat" .ns .TP .B "extern PSBrush* pssingle" .ns .TP .B "extern PSBrush* psnonebr" .ns .TP .B "extern PSFont* psstdfont" Predefined graphics resource objects. The None operation on \fIpsnonepat\fP and \fIpsnonebr\fP returns \fItrue\fP. .TP .B "extern Graphic* stdgraphic" A FullGraphic instance with its graphics state set to the global values listed above, excluding \fIpsnonepat\fP and \fIpsnonebr\fP. .SH FUNCTIONS .TP .B "extern void NormalRect(Coord& l, Coord& b, Coord& r, Coord& t)" Given two coordinate pairs (\fIl\fP, \fIb\fP) and (\fIr\fP, \fIt\fP), it checks whether \fIl\fP < \fIr\fP and \fIb\fP < \fIt\fP. If not, it swaps the values in the offending inequalities. This function is useful for ensuring that a rectangle is defined by its lower-left and upper-right vertices. .TP .B "extern void GetLine(" .ns .TP .B " const char* buf, int len, int beg, int& end," .ns .TP .B " int& size, int& nextBeg" .ns .TP .B ")" .br This function is convenient for extracting lines from a buffer with a minimum of additional math operations. Given a buffer of characters \fIbuf\fP of length \fIlen\fP, search for the first newline character (or the last character in the buffer) after the character at index \fIbeg\fP; return the newline's position in \fIend\fP, the size of the run of text terminated by a newline (\fIend\fP + 1 - \fIbeg\fP), and the index with which to begin a search for the next newline character (\fInextBeg\fP). .TP .B "extern void GetAlignmentPoint(" .ns .TP .B " Graphic*, Alignment, float&, float&" .ns .TP .B ")" .br Return the point (in floating point canvas coordinates) on a graphic corresponding to the given alignment. For example, to obtain the coordinates of the lower-left of a rectangle graphic, specify the graphic and a \fIBottomLeft\fP alignment. .TP .B "extern void Ref(Resource*)" Call the Reference operation on the given instance of a resource subclass if the pointer is non-nil. .TP .B "extern char* strnew(const char*)" Duplicate the given null-terminated string, creating a buffer of the appropriate size and returning the null-terminated result. .SH SEE ALSO CSolver(3U), Catalog(3U), Graphic(3U), GraphicView(3U), Pin(3U), Resource(3I), Unidraw(3U), InterViews(3I), pspaint(3U) ivtools-1.2.11a1/src/man/man3/iostreamb.3000066400000000000000000000014431214471147700200000ustar00rootroot00000000000000.TH iostreamb 3I "21 December 1990" "InterViews" "InterViews Reference Manual" .SH NAME istreamb, ostreamb, iostreamb \- unformatted streams .SH SYNOPSIS .B #include .SH DESCRIPTION istreamb, ostreamb, and iostreamb are streams just like istream, ostream, and iostream except for two features. First, they automatically insert and extract delimiters around datums where necessary so you never have to separate datums by whitespace yourself. Second, they can insert and extract integers as either unformatted (binary) bytes or formatted characters so you can eliminate the time needed to convert integers to strings and back. Both of these features make these classes easier to use than the base stream classes for inter-process communication (IPC). .SH SEE ALSO IOS.INTRO(3C++) ivtools-1.2.11a1/src/man/man3/kybd.3000066400000000000000000000012401214471147700167370ustar00rootroot00000000000000.TH kybd 3U "1 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME kybd \- predefined keyboard equivalents .SH SYNOPSIS .B #include .SH DESCRIPTION The hybd header file provides external declarations for predefined keyboard equivalents corresponding to the predefined components, commands, and tools in the Unidraw library. These declarations take the form #extern const char* KLBL_\fIname\fP, *CODE_\fIname\fP where KLBL denotes the printable representation of the keyboard equivalent, and CODE denotes the code against which the key event is matched to find the corresponding control. .SH SEE ALSO ControlInfo(3U), KeyMap(3U), UControl(3U) ivtools-1.2.11a1/src/man/man3/lines.3000066400000000000000000000037441214471147700171330ustar00rootroot00000000000000.TH lines 3U "2 February 1991" "Unidraw" "InterViews Reference Manual" .SH NAME Point, Line, MultiLine, S_MultiLine, SF_MultiLine \- structured graphics classes for points, lines, and open polygons .SH SYNOPSIS .B #include .SH DESCRIPTION Point and Line are subclasses of Graphic that draw a point and a line, respectively. MultiLine is a Vertices subclass that serves as an abstract base class for open polygons: S_MultiLine is a MultiLine subclass for stroked open polygons, while SF_MultiLine is a stroked-filled open polygon. Point, Line, and S_MultiLine store a PSBrush, while SF_MultiLine also stores a PSPattern. .SH POINT PUBLIC OPERATIONS .TP .B "Point(Coord x, Cord y, Graphic* = nil)" Construct a Point object, optionally supplying a graphic from which to obtain an initial set of graphics state. .TP .B "void GetOriginal(Coord&, Coord&)" Return the coordinates supplied in the constructor. .SH LINE PUBLIC OPERATIONS .TP .B "Line(Coord x0, Cord y0, Coord x1, Coord y1, Graphic* = nil)" Construct a Line object, optionally supplying a graphic from which to obtain an initial set of graphics state. .TP .B "void GetOriginal(Coord& x0, Coord& y0, Coord& x1, Coord& y1)" Return the line's endpoints as supplied in the constructor. .SH MULTILINE PROTECTED OPERATIONS .TP .B "MultiLine(Coord* x, Coord* y, int count, Graphic* = nil)" MultiLine's constructor is protected to prevent instantiation of the abstract base class. The parameters are passed directly to the Vertices constructor. .SH S_MULTILINE PUBLIC OPERATIONS .TP .B "S_MultiLine(Coord* x, Coord* y, int count, Graphic* = nil)" Construct an S_MultiLine object, optionally supplying a graphic from which to obtain an initial set of graphics state. .SH SF_MULTILINE PUBLIC OPERATIONS .TP .B "SF_MultiLine(Coord* x, Coord* y, int count, Graphic* = nil)" Construct an SF_MultiLine object, optionally supplying a graphic from which to obtain an initial set of graphics state. .SH SEE ALSO Graphic(3U), Vertices(3U), pspaint(3U) ivtools-1.2.11a1/src/man/man3/manips.3000066400000000000000000000364441214471147700173130ustar00rootroot00000000000000.TH manips 3U "1 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME ConnectManip, DragManip, ManipGroup, TextManip, VertexManip \- Manipulator subclasses for defining common direct-manipulation semantics .SH SYNOPSIS .B #include .SH DESCRIPTION Manipulator is an abstract base class for objects that encapsulate the mechanics of direct manipulation. Subclasses support different manipulation semantics. The DragManip subclass implements a downclick-drag-upclick style of interaction, with optional constraints on motion (for example, horizontal or vertical only). ConnectManip is a DragManip subclass that adds a gravitational bias towards connector views. VertexManip is a DragManip that supports multiple downclick-and-drag interactions terminated by a distinguished downclick. TextManip provides a text editing interface. Finally, ManipGroup composes manipulator instances so that their interaction may proceed concurrently. .SH DRAGMANIP PUBLIC OPERATIONS .TP .B "DragManip(" .ns .TP .B " Viewer*, Rubberband*, Transformer* = nil, Tool* = nil," .ns .TP .B " DragConstraint = None" .ns .TP .B ")" .ns .TP .B "DragManip(" .ns .TP .B " Viewer*, Rubberband*, Transformer*, Tool*," .ns .TP .B " DragConstraint, Coord, Coord" .ns .TP .B ")" .br A DragManip uses a rubberband to animate the manipulation. The constructor takes the rubberband as a parameter along with the viewer in which it should appear, a transformer reflecting the transformation that component views undergo in the viewer, the tool that created the manipulator, and a DragConstraint that effectively restricts mouse motion in one or more ways. By default, motion is constrained when the Shift key is held down. The second constructor adds two Coord parameters. The DragManip will use these values to override the event coordinates when Grasp is first called. .TP .B "virtual void Grasp(Event&) DragManip redefines Grasp operation to call the rubberband's Track operation, supplying the coordinates in the event. Grasp calls Constrain (described below) on the event prior to passing the coordinate information. The rubberband will not be drawn until Grasp is called. .TP .B "virtual boolean Manipulating(Event&)" If the event is a MotionEvent, Manipulating calls Track with the event's coordinates and returns \fItrue\fP. Manipulating simply returns \fIfalse\fP if the event is an UpEvent. Like DragManip::Grasp, this operation calls Constrain on the event prior to passing the coordinate information. .TP .B "virtual void Effect(Event&)" Effect simply erases the rubberband by calling its Erase operation. .TP .B "virtual void SetViewer(Viewer*)" .ns .TP .B "virtual void SetRubberband(Rubberband*)" .ns .TP .B "virtual void SetTransformer(Transformer*)" .ns .TP .B "virtual void SetTool(Tool*)" .ns .TP .B "virtual void SetConstraint(DragConstraint)" .TP .B "virtual Viewer* GetViewer()" .ns .TP .B "virtual Rubberband* GetRubberband()" .ns .TP .B "virtual Transformer* GetTransformer()" .ns .TP .B "virtual Tool* GetTool()" .ns .TP .B "virtual DragConstraint GetConstraint()" Set and get the various parameters supplied to the DragManip in its constructor. .TP .B "const Event& GraspEvent()" Return the event supplied to the last call to Grasp. .SH DRAGMANIP PROTECTED OPERATIONS .TP .B "void Init(" .ns .TP .B " Viewer*, Rubberband*, Transformer*, Tool*, DragConstraint" .ns .TP .B ")" .br Assign the various constructor values common to both DragManip constructors. .TP .B "virtual void Constrain(Event&)" Constrain the event to reflect the DragConstraint. The event coordinates are constrained when the event indicates that the shift key is held down for all DragConstraint values except Gravity, which constrains the coordinates unconditionally with the viewer's Constrain operation. .SH CONNECTMANIP PUBLIC OPERATIONS .TP .B "ConnectManip(" .ns .TP .B " Viewer*, Rubberband*, Transformer* = nil, Tool* = nil" .ns .TP .B ")" .br ConnectManip supports the same type of interaction as DragManip, except the rubberband tracking is affected by a graviational bias towards connector views. Whenever the user drags near a connector view, the tracking coordinates are suddenly constrained to coincide with the center of the connector view. The rubberband will not change its appearance thereafter until the user drags beyond the gravity threshold, which corresponds to SLOP (see globals(3U)) units beyond the nearest point on the connector view. .TP .B "virtual boolean Manipulating(Event&)" ConnectManip redefines Manipulating to support the gravitational effect. .TP .B "ConnectorView* GetTarget()" Return the connector view that has captured the rubberband, if any. .SH VERTEXMANIP PUBLIC OPERATIONS .TP .B "VertexManip(" .ns .TP .B " Viewer*, GrowingVertices*, Transformer* = nil," .ns .TP .B " Tool* = nil, DragConstraint = None" .ns .TP .B ")" .br VertexManip is like DragManip but supports multiple drags and clicks in one manipulation. The VertexManip constructor restricts the rubberband to be an instance of GrowingVertices. .TP .B "virtual boolean Manipulating(Event&)" This operation is similar to DragManip's, except it calls AppendVertex on the GrowingVertices rubberband on each down-click and returns \fIfalse\fP if and only if the middle button is pressed. .TP .B "GrowingVertices* GetGrowingVertices()" Return the GrowingVertices instance. Use this operation as an alternative to GetRubberband when that operation isn't specific enough. .SH TEXTMANIP PUBLIC OPERATIONS .TP .B "TextManip(Viewer*, Painter*, Coord tabwidth, Tool* = nil)" .ns .TP .B "TextManip(" .ns .TP .B " Viewer*, Painter*, Coord lineheight, Coord tabwidth," .ns .TP .B " Tool* = nil" .ns .TP .B ")" .br Create a TextManip, supplying (at minimum) a viewer, a painter with which to draw (usually reflecting graphics attributes defined by the enclosing editor object), and the width of a tab character. Tab characters in the text will position the following character at an integral multiple of \fItabwidth\fP from the beginning of the line. The distance between baselines in the text can be specified with the second constructor; this value corresponds to the font height by default. These constructors create text manipulators containing no text initially; the lower left corner of the first line of text (including the descender) will be positioned at the coordinates in the event passed to the Grasp operation. .TP .B "TextManip(" .ns .TP .B " Viewer*, const char* buf, int bufsize, Coord x, Coord y," .ns .TP .B " Painter*, Coord tabwidth, Tool* = nil" .ns .TP .B ")" .ns .TP .B "TextManip(" .ns .TP .B " Viewer*, const char* buf, int bufsize, Coord x, Coord y," .ns .TP .B " Painter*, Coord lineheight, Coord tabwidth, Tool* = nil" .ns .TP .B ")" .br Create text manipulators initialized with text by passing a buffer of text and its size. A copy of the buffer is used internally. The \fIx\fP and \fIy\fP parameters specify the position of the lower left corner of the first line of text (including the descender). These coordinates will override the coordinates specified by the event passed to Grasp. .TP .B "virtual void Grasp(Event&)" Positions and draws the text. If the position-specifing constructors were used to create the instance, then the manipulator will use the event coordinates to set the insertion point's position in the text. .TP .B "virtual boolean Manipulating(Event&)" Handle keystrokes and/or mouse motion events to support basic text editing. Motion events are interpreted to support text selection; selected text is displayed in reverse colors. The Manipulating operation returns \fIfalse\fP if a downclick is detected outside the text or if HandleKey (described below) returns \fIfalse\fP. .TP .B "virtual void Effect(Event&)" Effect damages the viewer area that TextManip corrupted during editing. .TP .B "virtual Painter* GetPainter()" .ns .TP .B "virtual Coord GetLineHeight()" .ns .TP .B "virtual Coord GetTabWidth()" .ns .TP .B "virtual const char* GetText(int&)" .ns .TP .B "virtual void GetPosition(Coord&, Coord&)" Return various parameters specified in the constructor. GetText returns a pointer to the internal buffer containing the text; the reference parameter returns the buffer's size. .TP .B "const Event& GraspEvent()" Return the event supplied to the last call to Grasp. .SH TEXTMANIP PROTECTED OPERATIONS .TP .B "virtual boolean HandleKey(Event&)" This operation defines TextManip's default key bindings as described below. Unless otherwise noted below, this function returns \fItrue\fP. .sp .B "(^P)" backward line .sp .B "(^N)" forward line .sp .B "(^B)" backward character .sp .B "(^F)" forward character .sp .B "(ESC)" terminate text entry, causing HandleKey to return \fIfalse\fP .sp .B "(^A)" beginning of line .sp .B "(^E)" end of line .sp .B "(^D)" delete character .sp .B "(DEL) (^H)" delete backward character .TP .B "int Dot()" .ns .TP .B "int Mark()" The current selection is bounded by two indices into the text buffer. By convention these indices are called dot and mark. Dot is the position at which text will be inserted and deleted. Mark locates the end of the selection that moves as the selection is modified. When the selection is empty (an insertion point), dot and mark are equal. .TP .B "void InsertText(const char* string, int count)" .ns .TP .B "void InsertCharacter(char)" .ns .TP .B "void DeleteText(int count)" .ns .TP .B "void DeleteCharacter(int)" .ns .TP .B "void DeleteLine()" .ns .TP .B "void DeleteSelection()" Edit the text buffer at the current selection. InsertText inserts count characters from string after dot. The selection becomes an insertion point following the newly inserted text. InsertCharacter replaces the selected characters with a single character. DeleteText deletes count characters at dot. If count is positive, the characters following dot are deleted; if count is negative the characters before dot are deleted. The selection becomes an insertion point in the place of the deleted text. DeleteSelection deletes the text between dot and mark, changing the selection to an insertion point. DeleteCharacter is identical to DeleteText if the dot and mark are not the same; otherwise it is identical to DeleteSelection. DeleteCharacter provides a convenient way to express the behavior of the backspace and delete operations. Finally, DeleteLine deletes the line of text containing mark. The selection becomes an insertion point at mark. .TP .B "void BackwardCharacter(int count)" .ns .TP .B "void ForwardCharacter(int count)" .ns .TP .B "void BackwardLine(int count)" .ns .TP .B "void ForwardLine(int count)" .ns .TP .B "void BackwardWord(int count)" .ns .TP .B "void ForwardWord(int count)" Move the current selection forward or backward by the specified number of the specified units. The default movement is one unit. The selection is not moved before the beginning of after the end of the text. .TP .B "void BeginningOfLine()" .ns .TP .B "void EndOfLine()" .ns .TP .B "void BeginningOfWord()" .ns .TP .B "void EndOfWord()" .ns .TP .B "void BeginningOfSelection()" .ns .TP .B "void EndOfSelection()" .ns .TP .B "void BeginningOfText()" .ns .TP .B "void EndOfText()" Move the current selection forwards or backwards to the specified feature of the text. .TP .B "void Select(int dot)" .ns .TP .B "void Select(int dot, int mark)" .ns .TP .B "void SelectMore(int mark)" .ns .TP .B "void SelectAll()" Modify the current selection in terms of text indices. With a single parameter, Select moves both dot and mark to the specified index. With two parameters, dot and mark can be controlled independently. SelectMore leaves dot unchanged and moves mark. SelectAll sets dot to the end of the text and mark to the beginning. .TP .B "int Locate(Coord x, Coord y)" .ns .TP .B "boolean Contains(Coord, Coord)" Locate returns the text index most closely matching the point (\fIx\fP, \fIy\fP). Contains returns whether the text contains the point (\fIx\fP, \fIy\fP). .SH MANIPGROUP PUBLIC OPERATIONS .TP .B "ManipGroup(Viewer* = nil, Tool* = nil)" Create a ManipGroup, optionally supplying a viewer and a tool. .TP .B "virtual void Grasp(Event&)" The Grasp operation simply calls Grasp on each child in insertion order. .TP .B "virtual boolean Manipulating(Event&)" Manipulating calls the corresponding operation on each child, skipping those children that have returned \fIfalse\fP in previous calls (up to the last Grasp). This function returns \fIfalse\fP when all children have done so. .TP .B "virtual void Effect(Event&)" ManipGroup's Effect operation calls Effect on each child. .TP .B "virtual void SetViewer(Viewer*)" .ns .TP .B "virtual void SetTool(Tool*)" .ns .TP .B "virtual Viewer* GetViewer()" .ns .TP .B "virtual Tool* GetTool()" Set and get the ManipGroup's viewer and tool. The set operations set the ManipGroup's values for these parameters and call the corresponding operations on their children. The get operations simply return the ManipGroup's values. .TP .B "virtual void First(Iterator&)" .ns .TP .B "virtual void Last(Iterator&)" .ns .TP .B "virtual void Next(Iterator&)" .ns .TP .B "virtual void Prev(Iterator&)" .ns .TP .B "virtual boolean Done(Iterator)" Operations for iterating over the ManipGroup's children, if any. First and Last initialize an iterator to point to the beginning and end of the list of children, respectively. Next increments the iterator to point to the following child, while Prev decrements the iterator to point to the preceding child. Done returns whether or not the iterator points beyond the first or last child in the list. .TP .B "Manipulator* GetManip(Iterator)" .ns .TP .B "void SetManip(Manipulator*, Iterator&)" GetManip returns the child manipulator to which an iterator points. SetManip initializes an iterator to point to a particular child; it initializes the iterator to point to a nil instance if the given Manipulator is not a child of the ManipGroup. .TP .B "void Append(" .ns .TP .B " Manipulator*," .ns .TP .B " Manipulator* = nil, Manipulator* = nil, Manipulator* = nil" .ns .TP .B ")" .ns .TP .B "void Prepend(" .ns .TP .B " Manipulator*," .ns .TP .B " Manipulator* = nil, Manipulator* = nil, Manipulator* = nil" .ns .TP .B ")" .ns .TP .B "void InsertBefore(Iterator, Manipulator*)" .ns .TP .B "void InsertAfter(Iterator, Manipulator*)" .ns .TP .B "void Remove(Manipulator*)" .ns .TP .B "void Remove(Iterator&)" Operations for modifying the ManipGroup's list of children. Append and Prepend add up to four child manipulators, in order, to the end and the beginning of the list, respectively. InsertAfter and InsertBefore insert a child after and before the manipulator pointed to by the iterator, respectively. The Remove operations remove a child from the list (without deleting it). You can remove a child by referring to it explicitly or by specifying an iterator. If an iterator is supplied, the Remove operation will advance it to point to the following child as a side effect. .SH MANIPGROUP PROTECTED OPERATIONS .TP .B "UList* Elem(Iterator)" .ns .TP .B "Manipulator* Manip(UList*)" ManipGroup stores its children on a UList, which is accessible via the \fI_kids\fP protected member. The Selection's iteration operations store the UList containing the current child in their iterator. Elem is a convenience function for returning the UList to which an iterator points, and Manip extracts the child that a UList element contains. .SH SEE ALSO Connector(3U), Event(3I), Iterator(3U), Manipulator(3U), Painter(3I), Rubband(3I), Tool(3U), Transformer(3I), UList(3U), Viewer(3U), globals(3U) ivtools-1.2.11a1/src/man/man3/polygons.3000066400000000000000000000063661214471147700176760ustar00rootroot00000000000000.TH polygons 3U "2 February 1991" "Unidraw" "InterViews Reference Manual" .SH NAME Rect, S_Rect, F_Rect, SF_Rect, Polygon, S_Polygon, F_Polygon, SF_Polygon \- structured graphics classes for rectangles and polygons .SH SYNOPSIS .B #include .SH DESCRIPTION Rect and Polygon serve as abstract base classes for rectangle and polygon structured graphics. They are derived from Graphic and Vertices, respectively. Predefined subclasses include S_Rect, F_Rect, and SF_Rect, which draw stroked, filled, and stroked-filled rectangles, respectively; and S_Polygon, F_Polygon, and SF_Polygon, which draw stroked, filled, and stroked-filled polygons, respectively. The stroked subclasses store a PSBrush, the filled subclasses store a PSPattern, and the stroked-filled subclasses store one of each. .SH RECT PUBLIC OPERATIONS .TP .B "void GetOriginal(Coord& x0, Coord& y0, Coord& x1, Coord& y1)" Return the rectangle's geometry, as specified in the constructor. (\fIx0, y0\fP) defines one corner of the rectangle, while (\fIx1\fP, \fIy1\fP) defines the opposing corner. .SH RECT PROTECTED OPERATIONS .TP .B "Rectangle(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* = nil)" The constructor is protected to disallow instantiation of the abstract base class. A rectangle's geometry is defined by two points, corresponding to opposing corners of the rectangle. The constructor also takes an optional graphic from which to obtain an initial set of graphics state. .TP .B "void s_getExtent(" .ns .TP .B " float&, float&, float&, float&, float&, Graphic*" .ns .TP .B ")" .ns .TP .B "void f_getExtent(" .ns .TP .B " float&, float&, float&, float&, float&, Graphic*" .ns .TP .B ")" .ns .TP .B "boolean s_contains(PointObj&, Graphic*)" .ns .TP .B "boolean f_contains(PointObj&, Graphic*)" .ns .TP .B "boolean s_intersects(BoxObj&, Graphic*)" .ns .TP .B "boolean f_intersects(BoxObj&, Graphic*)" Helper functions that return extent and hit detection information based on the bounding box that the rectangle defines. s_getExtent, s_contains, and s_intersects return information that accounts for the width of a brush, as would be necessary if the rectangle is stroked, while f_getExtent, f_contains, and f_intersects assumes that the rectangle is filled. Subclasses can use the operations to help implement their getExtent, contains, and intersects operations. .SH RECT SUBCLASS PUBLIC OPERATIONS .TP .B "S_Rect(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* = nil)" .ns .TP .B "F_Rect(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* = nil)" .ns .TP .B "SF_Rect(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* = nil)" Constructors for the various predefined Rect subclasses. .SH POLYGON PROTECTED OPERATIONS .TP .B "Polygon(Coord* x, Coord* y, int count, Graphic* = nil)" Polygon's constructor is protected to prevent instantiation of the abstract base class. The parameters are passed directly to the Vertices constructor. .SH POLYGON SUBCLASS PUBLIC OPERATIONS .TP .B "S_Polygon(Coord* x, Coord* y, int count, Graphic* = nil)" .ns .TP .B "F_Polygon(Coord* x, Coord* y, int count, Graphic* = nil)" .ns .TP .B "SF_Polygon(Coord* x, Coord* y, int count, Graphic* = nil)" Constructors for the various predefined Rect subclasses. .SH SEE ALSO Graphic(3U), Vertices(3U), geomobjs(3U), pspaint(3U) ivtools-1.2.11a1/src/man/man3/pspaint.3000066400000000000000000000063331214471147700174740ustar00rootroot00000000000000.TH pspaint 3U "2 February 1991" "Unidraw" "InterViews Reference Manual" .SH NAME PSBrush, PSColor, PSFont, PSPattern \- graphics state objects with added PostScript information .SH SYNOPSIS .B #include .SH DESCRIPTION PSBrush, PSColor, PSFont, and PSPattern are subclasses of Brush, Color, Font, and Pattern, respectively, that store added information needed to generate idraw-compatible PostScript. Unidraw's structured graphics objects use these subclasses exclusively. .SH PSBRUSH PUBLIC OPERATIONS .TP .B "PSBrush()" .ns .TP .B "PSBrush(int pattern, int width)" Create an undefined PSBrush (the parameterless constructor) or one having the specified line pattern and width. Structured graphics having an undefined brush will not render their stroked portions. .TP .B "int GetLinePattern()" .ns .TP .B "int Width()" Return constructor-specified brush parameters. .TP .B "boolean None()" Return \fItrue\fP if this is an undefined brush. .TP .B "const int* GetDashPattern()" .ns .TP .B "int GetDashPatternSize()" .ns .TP .B "int GetDashOffset()" Return values required to characterize the brush in PostScript. The equivalent PostScript dash pattern is computed from the brush's line pattern. .SH PSBRUSH PROTECTED OPERATIONS .TP .B "void CalcDashPat(int)" Compute the equivalent PostScript dash pattern from the line pattern specified in the constructor. .SH PSCOLOR PUBLIC OPERATIONS .TP .B "PSColor(" .ns .TP .B " Color_Intensity, Color_Intensity, Color_Intensity," .ns .TP .B " const char* name" .ns .TP .B ")" .br Create a PSColor, supplying color intensity information and a name to associate with the intensities. The name is used solely to generate idraw-compatible PostScript. .SH PSFONT PUBLIC OPERATIONS .TP .B "PSFont(" .ns .TP .B " const char* name, const char* PS_name, const char* PS_size" .ns .TP .B ")" .br Construct a PSFont, supplying the window-system-specified font name and the corresponding PostScript font name and its size. .TP .B "const char* GetName()" .ns .TP .B "const char* GetPrintFont()" .ns .TP .B "const char* GetPrintSize()" .ns .TP .B "const char* GetPrintFontAndSize()" Return constructor-supplied parameters. GetPrintFontAndSize returns the concatenation of the PostScript font name and its size, with a space interposed for legibility. .TP .B "int GetLineHt()" Return an integer version of the PostScript font's size (as supplied to the constructor). .SH PSPATTERN PUBLIC OPERATIONS .TP .B "PSPattern()" .ns .TP .B "PSPattern(int dither, float graylevel)" .ns .TP .B "PSPattern(const int* pattern, int)" Create an undefined PSPattern (the parameterless constructor), or one having specific dither and graylevel values, or one that replicates a pattern defined by the given array. Structured graphics having an undefined pattern will not render their filled portions. .TP .B "boolean None()" Return \fItrue\fP if this is an undefined pattern. .TP .B "float GetGrayLevel()" Return the graylevel that the pattern approximates, if one was specified in the constructor. .TP .B "const int* GetData()" .ns .TP .B "int GetSize()" Return the array that defines the replicated pattern and its size, if the pattern was constructed with one. .SH SEE ALSO idraw(1I), pspaint(3I), and the InterViews 3.1 reference manual ivtools-1.2.11a1/src/man/man3/rpcbuf.3000066400000000000000000000101071214471147700172710ustar00rootroot00000000000000.TH rpcbuf 3I "27 March 1991" "InterViews" "InterViews Reference Manual" .SH NAME rpcbuf \- streambuf specialized for sending and receiving RPC requests .SH SYNOPSIS .B #include .SH DESCRIPTION An rpcbuf is a streambuf specialized in two ways: to use an IPC connection as a source or sink of characters and to send and receive RPC requests. The rpcbuf encloses RPC requests in packets which begin with a length field so that the rpcbuf can buffer requests until they are complete if the user uses non-blocking I/O. .SH CONSTRUCTORS .TP .B "rpcbuf(iostreamb* = nil)" Construct an unopened rpcbuf, giving it a pointer to an iostreamb so that the rpcbuf can read and write the length field of RPC requests. .SH IPC OPERATIONS .TP .B "const char* host()" .ns .TP .B "int port()" .ns .TP .B "int fd()" .ns .TP .B "boolean opened()" .ns .TP .B "boolean nonblocking()" Return information about the IPC connection. .TP .B "enum { anyport = 0 }" .ns .TP .B "rpcbuf* listen(int port)" Create a socket, bind the socket to a address, and prepare to accept incoming connections. anyport can be used in place of a specific port number. Return the rpcbuf's address if successful, nil otherwise. .TP .B "rpcbuf* connect(const char* host, int port)" Create a socket and connect it to a peer at the address. Return the rpcbuf's address if successful, nil otherwise. .TP .B "rpcbuf* accept(int& fd)" Accept an incoming connection, allocate a new file descriptor for it, and assign the new file descriptor to the parameter. Return the rpcbuf's address if successful, nil otherwise. Can be called only for rpcbufs that have already called listen. .TP .B "rpcbuf* attach(int fd)" Attach the rpcbuf to a file descriptor. The rpcbuf will not be allowed to close the file descriptor. .TP .B "rpcbuf* nonblocking(boolean)" Enable or disable non-blocking I/O on the file descriptor (disabled by default). .TP .B "rpcbuf* verbose(boolean)" Enable or disable printing of error messages when anything goes wrong (enabled by default). .TP .B "rpcbuf* close()" Flush the get and put areas, close the file descriptor if it was created by the rpcbuf, and detach the rpcbuf from the file descriptor. .SH RPC OPERATIONS .TP .B "int start_request()" If a current request exists, compute its length and insert the length into the request's length field. Then start a new request, making sure to leave space for the request's length field. Return 0 if no problem occurred, EOF otherwise. .TP .B "int read_request()" Return 0 if a complete request is buffered in the get area, EOF otherwise. The rpcbuf moves the get pointer back to the beginning of the request after extracting the length field and checking that the get area contains that many bytes. .SH STREAMBUF OPERATIONS .TP .B "virtual int overflow(int c=EOF)" If given EOF, terminate the current request. Flush all requests buffered in the put area except for the last request if it's still incomplete. Shift any still incomplete request to the beginning of the put area. If given a character, append it to the request. .TP .B "virtual int underflow()" Flush the put area. Shift any still unread or incomplete requests to the beginning of the get area and position the get pointer at the beginning of the get area. Read as much data as available to fill the rest of the get area. Return the get area's first character or EOF if a problem occurred. .TP .B "virtual int sync()" Discard any still unread requests from the get area. Flush all buffered requests from the put area. .TP .B "virtual streampos seekoff(streamoff, ios::seek_dir, int)" Allow the user to find the get pointer's current position so the user can compute how many bytes the get pointer moved between calls to seekoff. Return EOF if the user tries to do anything else than find the get pointer's current position. .TP .B "virtual streambuf* setbuf(char*, int)" Reject any attempt to set the buffer used to store incoming and outgoing requests. The rpcbuf dynamically allocates separate buffers for both areas and automatically resizes the buffers whenever necessary. .SH SEE ALSO IOS.INTRO(3C++), rpcstream(3I) ivtools-1.2.11a1/src/man/man3/rpcstream.3000066400000000000000000000026471214471147700200220ustar00rootroot00000000000000.TH rpcstream 3I "27 March 1991" "InterViews" "InterViews Reference Manual" .SH NAME rpcstream \- iostreamb specialized to RPC requests .SH SYNOPSIS .B #include .SH DESCRIPTION rpcstream, irpcstream, and orpcstream specialize iostream, istream, and ostream, respectively, to RPC requests. That is, the associated streambuf will be an rpcbuf. Conversions will be formatted (that is, ASCII) so datums will need to be separated by space characters. .SH CONSTRUCTORS .TP .B "rpcstream()" Construct an unopened rpcstream. .SH PUBLIC OPERATIONS .TP .B "void listen(int port)" .ns .TP .B "void connect(const char* host, int port)" Create a connection. Any failure sets ios::failbit in the error state. .TP .B "int accept()" Accept a pending connection and return the new file descriptor. .TP .B "void attach(int fd)" Attach to a pre-existing connection. .TP .B "void close()" Break a connection. The error state is cleared except on failure. .TP .B "void nonblocking(boolean)" .ns .TP .B "void verbose(boolean)" Enable or disable non-blocking I/O and/or printing of error messages. .TP .B "rpcbuf* rdbuf()" Return a pointer to the rpcbuf created by the rpcstream. .TP .B "boolean incomplete_request()" .ns .TP .B "void incomplete_request(boolean)" Get or set a flag. Used by the operations that insert an RpcHdr into an rpcstream or extract an RpcHdr from an rpcstream. .SH SEE ALSO IOS.INTRO(3C++), iostreamb(3I), rpcbuf(3I) ivtools-1.2.11a1/src/man/man3/splines.3000066400000000000000000000047671214471147700175040ustar00rootroot00000000000000.TH splines 3U "2 February 1991" "Unidraw" "InterViews Reference Manual" .SH NAME OpenBSpline, S_OpenBSpline, F_OpenBSpline, SF_OpenBSpline, SFH_OpenBSpline, ClosedBSpline, S_ClosedBSpline, F_ClosedBSpline, SF_ClosedBSpline, SFH_ClosedBSpline \- structured graphics classes for open and closed B-splines .SH SYNOPSIS .B #include .SH DESCRIPTION OpenBSpline and ClosedBSpline are Vertices subclasses that serve as abstract base classes for open and closed B-spline structured graphics. Predefined subclasses include S_OpenBSpline, F_OpenBSpline, and SF_OpenBSpline, which draw stroked, filled, and stroked-filled open B-splines, respectively; and S_ClosedBSpline, F_ClosedBSpline, and SF_ClosedBSpline, which draw stroked, filled, and stroked-filled closed B-splines, respectively. The SFH_OpenBSpline and SFH_ClosedBSpline subclasses are identical to their SF_-prefixed counterparts, except they can detect hits on their control points in addition to detecting hits on their visible parts. The stroked subclasses store a PSBrush, the filled subclasses store a PSPattern, and the stroked-filled subclasses store one of each. .SH OPENBSPLINE PROTECTED OPERATIONS .TP .B "OpenBSpline(Coord* x, Coord* y, int count, Graphic* = nil)" OpenBSpline's constructor is protected to prevent instantiation of the abstract base class. The parameters are passed directly to the Vertices constructor. .SH OPENBSPLINE SUBCLASS PUBLIC OPERATIONS .TP .B "S_OpenBSpline(Coord* x, Coord* y, int count, Graphic* = nil)" .ns .TP .B "F_OpenBSpline(Coord* x, Coord* y, int count, Graphic* = nil)" .ns .TP .B "SF_OpenBSpline(Coord* x, Coord* y, int count, Graphic* = nil)" .ns .TP .B "SFH_OpenBSpline(Coord* x, Coord* y, int count, Graphic* = nil)" Constructors for the various predefined Rect subclasses. .SH CLOSEDBSPLINE PROTECTED OPERATIONS .TP .B "ClosedBSpline(Coord* x, Coord* y, int count, Graphic* = nil)" ClosedBSpline's constructor is protected to prevent instantiation of the abstract base class. The parameters are passed directly to the Vertices constructor. .SH CLOSEDBSPLINE SUBCLASS PUBLIC OPERATIONS .TP .B "S_ClosedBSpline(Coord* x, Coord* y, int count, Graphic* = nil)" .ns .TP .B "F_ClosedBSpline(Coord* x, Coord* y, int count, Graphic* = nil)" .ns .TP .B "SF_ClosedBSpline(Coord* x, Coord* y, int count, Graphic* = nil)" .ns .TP .B "SFH_ClosedBSpline(Coord* x, Coord* y, int count, Graphic* = nil)" Constructors for the various predefined Rect subclasses. .SH SEE ALSO Graphic(3U), Vertices(3U), geomobjs(3U), pspaint(3U) ivtools-1.2.11a1/src/man/man3/statevars.3000066400000000000000000000101731214471147700200270ustar00rootroot00000000000000.TH statevars 3U "6 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME BrushVar, ColorVar, CompNameVar, FontVar, GravityVar, MagnifVar, ModifStatusVar, NameVar, PatternVar \- state variable subject subclasses .SH SYNOPSIS .B #include .SH DESCRIPTION Unidraw predefines several state variable subject subclasses: BrushVar, ColorVar, FontVar, and PatternVar store the graphics state information their names suggest; GravityVar records whether gravity is in effect; MagnifVar records the current viewer magnification; ModifStatusVar records whether state-modifying operations have been applied to a component being edited; NameVar stores a string of interest; and CompNameVar is a NameVar that stores a component and keeps track of its catalog name. These variables represent state that is basic to graphical components and state that is often globally accessible in graphics applications. .SH PUBLIC OPERATIONS .TP .B "BrushVar(PSBrush* = nil)" .ns .TP .B "virtual PSBrush* BrushVar::GetBrush()" .ns .TP .B "virtual void BrushVar::SetBrush(PSBrush*)" .TP .B "ColorVar(PSColor* = nil)" .ns .TP .B "virtual PSColor* ColorVar::GetColor()" .ns .TP .B "virtual void ColorVar::SetColor(PSColor*)" .TP .B "FontVar(PSFont* = nil)" .ns .TP .B "virtual PSFont* FontVar::GetFont()" .ns .TP .B "virtual void FontVar::SetFont(PSFont*)" .TP .B "PatternVar(PSPattern* = nil)" .ns .TP .B "virtual PSPattern* PatternVar::GetPattern()" .ns .TP .B "virtual void PatternVar::SetPattern(PSPattern*)" Each graphics state state variable subclass defines a constructor that takes an initial value for the state it represents and adds operations for assigning and retrieving that state. .TP .B "GravityVar(boolean = false)" .ns .TP .B "virtual boolean GravityVar::IsActive(); .ns .TP .B "virtual void GravityVar::Activate(boolean)" The GravityVar constructor takes an initial value that specifies whether gravity is on or off. IsActive returns the current value, and Activate changes it to the one supplied. .TP .B "MagnifVar(float = 1)" .ns .TP .B "virtual float MagnifVar::GetMagnif()" .ns .TP .B "virtual void MagnifVar::SetMagnif(float)" The MagnifVar constructor takes an initial value for the magnification factor, and SetMagnify and GetMagnif assign and return the current value. .TP .B "ModifStatusVar(Component* = nil, boolean = false)" .ns .TP .B "virtual boolean ModifStatusVar::GetModifStatus()" .ns .TP .B "virtual void ModifStatusVar::SetModifStatus(boolean)" .ns .TP .B "virtual Component* ModifStatusVar::GetComponent()" .ns .TP .B "virtual void ModifStatusVar::SetComponent(Component*)" The ModifStatusVar constructor takes a component instance and an initial value as arguments. The ModifStatusVar is responsible for indicating whether the given component is modified. GetModifStatus, SetModifStatus, GetComponent, and SetComponent get and set these arguments. The modification status will be set automatically (in editors that maintain a ModifStatusVar instance) when an reversible operation is performed on the component. .TP .B "NameVar(const char* = nil)" .ns .TP .B "virtual const char* NameVar::GetName()" .ns .TP .B "virtual void NameVar::SetName(const char*)" The NameVar constructor takes a string as an optional arguement, while GetName and SetName retrieve and assign the string. .TP .B "CompNameVar(Component* = nil)" .ns .TP .B "virtual Component* CompNameVar::GetComponent()" .ns .TP .B "virtual void CompNameVar::SetComponent(Component*)" .ns .TP .B "virtual void CompNameVar::UpdateName()" .ns .TP .B "virtual const char* PartOf()" The CompNameVar constructor takes a component as an optional argument. CompNameVar inherits the GetName operation from NameVar; calling GetName returns the name associated with the component that the CompNameVar stores. The GetComponent and SetComponent calls get and set the component. UpdateName updates the string that GetName returns to reflect the component's catalog name. SetComponent calls this operation automatically when it changes the CompNameVar's component. PartOf returns the name of the root component in the CompNameVar component's hierarchy. .SH SEE ALSO Catalog(3U), Component(3U), Editor(3U), StateVar(3U), pspaint(3U) ivtools-1.2.11a1/src/man/man3/stateviews.3000066400000000000000000000053651214471147700202200ustar00rootroot00000000000000.TH stateviews 3U "6 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME BrushVarView, CompNameVarView, FileNameVarView, FontVarView, GravityVarView, MagnifVarView, ModifStatusVarView, NameVarView, PatternVarView \- various state variable view subclasses .SH SYNOPSIS .B #include .SH DESCRIPTION Unidraw predefines several state variable view subclasses for the the state variable subjects it predefines, as described below. .SH PUBLIC OPERATIONS .TP .B "BrushVarView(BrushVar*, ColorVar* = nil)" .ns .TP .B "FontVarView(FontVar*, Alignment = Center)" .ns .TP .B "PatternVarView(PatternVar*, ColorVar* = nil)" Views of graphics state state variable subjects. BrushVarView displays a short line drawn in the subject's brush and in a color specified by the given ColorVar (black if no ColorVar is supplied). The BrushVarView displays ``None'' if the BrushVar's brush is invisible. Similarly, PatternVarView displays a filled rectangle drawn in the subject's pattern and in a color specified by the given ColorVar (black if no ColorVar is supplied). The PatternVarView displays ``None'' if the PatternVar's pattern is invisible. FontVarView displays the name of its subject's font, aligned as specified in its canvas. .TP .B "GravityVarView(GravityVar*, Alignment = Center)" Displays either ``gravity on'' or a blank, depending on whether the subject indicates that gravity is on or not. .TP .B "MagnifVarView(MagnifVar*, Alignment = Center)" Displays ``mag \fIx\fPx'', where \fIx\fP is the current modification factor recorded in the subject. .TP .B "ModifStateVarView(ModifStateVar*, Alignment = Center)" Displays either an asterisk or a blank, depending on whether the subject records that its component is modified. .TP .B "NameVarView(" .ns .TP .B " NameVar*, Alignment = Center, const char* sample = nil" .ns .TP .B ")" .ns .TP .B "FileNameVarView(" .ns .TP .B " NameVar*, Alignment = Center," .ns .TP .B " boolean relative = true, const char* sample = nil" .ns .TP .B ")" .ns .TP .B "CompNameVarView(" .ns .TP .B " CompNameVarView*, Alignment = Center," .ns .TP .B " boolean relative = true, const char* sample = nil" .ns .TP .B ")" .br Display the subject's string aligned as specified with respect to the canvas. Each constructor takes an optional sample string that defines the view's natural size. FileNameVarView provides a specialized view of a NameVar for displaying file names. It adds a \fIrelative\fP argument for displaying the file name either as a relative or full path. CompNameVarView provides similar functionality for CompNameVar subjects, except it precedes its subject's component's name with ``[part of]'' for components that have a named parent but that are not named themselves. .SH SEE ALSO statevars(3U), StateVarView(3U) ivtools-1.2.11a1/src/man/man3/struct.3000066400000000000000000000046661214471147700173510ustar00rootroot00000000000000.TH struct 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME BackCmd, FrontCmd, GroupCmd, UngroupCmd \- commands for modifying components structurally .SH SYNOPSIS .B #include .SH DESCRIPTION BackCmd, FrontCmd, GroupCmd, and UngroupCmd are purely interpretive commands for altering the structure of their editor's component. All redefine their Execute and Unexecute operations to let the editor's component interpret them as it wishes. .SH BACKCMD PUBLIC OPERATIONS .TP .B "BackCmd(ControlInfo*)" .ns .TP .B "BackCmd(Editor* = nil)" Construct a new BackCmd. .SH FRONTCMD PUBLIC OPERATIONS .TP .B "FrontCmd(ControlInfo*)" .ns .TP .B "FrontCmd(Editor* = nil)" Construct a new FrontCmd. .SH GROUPCMD PUBLIC OPERATIONS .TP .B "GroupCmd(ControlInfo*, GraphicComp* = nil)" .ns .TP .B "GroupCmd(Editor* = nil, GraphicComp* = nil)" Create a new GroupCmd, optionally specifying the component into which components will be grouped. .TP .B "virtual void Execute()" .ns .TP .B "virtual void Unexecute()" Execute will set the value of the \fI_executed\fP protected member variable to \fItrue\fP as a side effect if anything was grouped. Similarly, Unexecute will set reset the value to \fIfalse\fP as a side effect the operation was undone. .TP .B "GraphicComp* GetGroup()" .ns .TP .B "void SetGroup(GraphicComp*)" Get or set the component into which components will be grouped. SetGroup will \fInot\fP delete the old value. .SH UNGROUPCMD PUBLIC OPERATIONS .TP .B "UngroupCmd(ControlInfo*)" .ns .TP .B "UngroupCmd(Editor* = nil)" Construct a new UngroupCmd. .TP .B "virtual void Execute()" .ns .TP .B "virtual void Unexecute()" Execute will set the value of the \fI_executed\fP protected member variable to \fItrue\fP as a side effect if anything was ungrouped. Similarly, Unexecute will set reset the value to \fIfalse\fP as a side effect the operation was undone. .TP .B "Clipboard* GetKids()" .ns .TP .B "void SetKids(Clipboard*)" Explicitly set and get a clipboard containing the child components that were ungrouped, which is stored in the \fI_kids\fP protected member. UngroupCmd does not initialize this member; it merely provides the storage as a convenience to components that interpret the command and need a place to store the ungrouped children to support reverse execution. However, UngroupCmd deletes the clipboard (if it exists) in ~UngroupCmd. SetKids will \fInot\fP delete the old value. .SH SEE ALSO Command(3U), GraphicComp(3U) ivtools-1.2.11a1/src/man/man3/transfns.3000066400000000000000000000066751214471147700176650ustar00rootroot00000000000000.TH transfns 3U "6 August 1990" "Unidraw" "InterViews Reference Manual" .SH NAME TF_2Port, TF_Direct \- transfer function subclasses .SH SYNOPSIS .B #include .SH DESCRIPTION The TransferFunct abstract base class defines the transfer function protocol. The library predefines two subclasses. TF_2Port is a subclass that acts as an abstract base class for transfer functions having two sets of state variables, ``input'' and ``output'', with output variables always dependent on input variables. TF_Direct is a subclass of TF_2Port that defines a one-to-one assignment relationship between an input and an output state variable. .SH TF_2PORT PUBLIC OPERATIONS .TP .B "void Evaluate(Path* = nil)" Evaluate first carries out information transfer between dependent state variables by calling the Transfer operation (described below). Then it iterates through its output state variables; those that have changed (according to the ChangedOutput operation, described below) get Transmit called on the connector they're bound to. Subclasses needn't redefine this operation if they implement Transfer and ChangedOutput appropriately. .TP .B "virtual StateVar* GetInput(int index)" .ns .TP .B "virtual StateVar* GetOutput(int index)" .ns .TP .B "virtual void SetInput(StateVar*, int index)" .ns .TP .B "virtual void SetOutput(StateVar*, int index)" Retrieve and assign the TF_2Port's input and output state variables, identified serially. These operations do nothing by default; subclasses must allocate the storage they require. .TP .B "virtual int Inputs()" .ns .TP .B "virtual int Outputs()" Return the number of input and output state variables. These operations return zero by default. .SH TF_2PORT PROTECTED OPERATIONS .TP .B "TF_2Port()" The constructor is protected to prevent instantiation. .TP .B "virtual void Transfer()" Enforce the subclass-specific dependencies between the TF_2Port's state variables. This operation does nothing by default. .TP .B "virtual boolean ChangedOutput(int index = 0)" Return whether the output state variable with the given index has changed its value since the last call to Transfer. Subclasses redefine this operation according to the semantics of their Transfer operation. .SH TF_DIRECT PUBLIC OPERATIONS .TP .B "TF_Direct(StateVar* input = nil, StateVar* output = nil)" Instantiate a new object, optionally specifying the input state variable and its dependent output state variable. .TP .B "virtual StateVar* GetInput(int index = 0)" .ns .TP .B "virtual StateVar* GetOutput(int index = 0)" .ns .TP .B "virtual void SetInput(StateVar*, int index = 0)" .ns .TP .B "virtual void SetOutput(StateVar*, int index = 0)" Retrieve and assign the TF_Direct's input and output state variables. Specifying an index greater than zero does nothing, since TF_Direct defines a dependency between one input and one output state variable. .TP .B "virtual int Inputs()" .ns .TP .B "virtual int Outputs()" Return the number of input and output state variables. These operations return zero by default. .TP .B "virtual int Inputs()" .ns .TP .B "virtual int Outputs()" These operations return 1. .SH TF_DIRECT PROTECTED OPERATIONS .TP .B "virtual void Transfer()" Assign the input state variable to the output state variable, setting a flag indicating that the output value has changed. .TP .B "virtual boolean ChangedOutput(int index = 0)" Return the status of the flag set by Transfer. The flag is reset as a side-effect of this operation. .SH SEE ALSO TransferFunct(3U) ivtools-1.2.11a1/src/man/man3/transforms.3000066400000000000000000000032461214471147700202140ustar00rootroot00000000000000.TH transforms 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME MoveCmd, RotateCmd, ScaleCmd \- coordinate transformation commands .SH SYNOPSIS .B #include .SH DESCRIPTION The Unidraw library predefines three purely interpretive commands for performing coordinate transformations: MoveCmd defines a translation, RotateCmd defines a rotation, and ScaleCmd defines a two-dimensional scaling. .SH MOVECMD PUBLIC OPERATIONS .TP .B "MoveCmd(ControlInfo*, float dx = 0, float dy = 0)" .ns .TP .B "MoveCmd(Editor* = nil, float = 0, float = 0)" Construct a new MoveCmd, specifying the translation distances in the horizontal (\fIdx\fP) and vertical (\fIdy\fP) dimensions. .TP .B "void GetMovement(float&, float&)" Return the translation distances specified in the constructor. .SH ROTATECMD PUBLIC OPERATIONS .TP .B "RotateCmd(ControlInfo*, float = 0)" .ns .TP .B "RotateCmd(Editor* = nil, float = 0)" Construct a new RotateCmd, specifying the rotation angle in degrees. .TP .B "float GetRotation()" Return the rotation angle specified in the constructor. .SH SCALECMD PUBLIC OPERATIONS .TP .B "ScaleCmd(" .ns .TP .B " ControlInfo*, float sx = 1, float sy = 1, Alignment = Center" .ns .TP .B ")" .ns .TP .B "ScaleCmd(Editor* = nil, float = 1, float = 1, Alignment = Center)" Construct a new ScaleCmd, specifying the scaling factors in the horizontal (\fIsx\fP) and vertical (\fIsy\fP) dimensions and an alignment suggesting the point about which the component should be scaled. .TP .B "void GetScaleing(float&, float&)" .ns .TP .B "Alignment GetAlignment()" Return the scaling factors and alignment specified in the constructor. .SH SEE ALSO Command(3U) ivtools-1.2.11a1/src/man/man3/uctrls.3000066400000000000000000000071641214471147700173350ustar00rootroot00000000000000.TH uctrls 3U "20 November 1990" "Unidraw" "InterViews Reference Manual" .SH NAME CommandControl, PanelControl, HPanelControl, VPanelControl, CommandInteractor, PanelInteractor \- predefined UControl and UControlInteractor subclasses for common controls .SH SYNOPSIS .B #include .SH DESCRIPTION CommandControl is a UControl subclass that executes a Command. CommandControl instances are most commonly used in menus. CommandInteractor is a UControlInteractor subclass that CommandControls create to define their appearance. PanelControl is a subclass of UControl that provides a radiobutton-like interface to selecting from a set of mutually-exclusive choices. A PanelControl is passed an interactor when it is created to define its appearance. PanelControls are often used to create ``palettes'' of interactors that engage the current Tool instance. PanelInteractor is a UControlInteractor subclass that defines an appearance that is often appropriate for PanelControls. HPanelControl and VPanelControl are subclasses of PanelControl that use PanelInteractor instances by default. .SH COMMANDCONTROL PUBLIC OPERATIONS .TP .B "CommandControl(ControlInfo*)" .ns .TP .B "CommandControl(const char*, ControlInfo*)" Create a CommandControl, optionally supplying an instance name. The constructors automatically create and insert a ControlInteractor to define the CommandControl's appearance. .TP .B "virtual void Do()" If the ControlInfo's owner is a reversible command, then Do will create a copy of the command, execute it, and log it (if it remains reversible following execution). If the owner is an irreversible command, then Do will execute it without copying or logging it. .SH COMMANDINTERACTOR PUBLIC OPERATIONS .TP .B "CommandInteractor(ControlInfo*)" Create a CommandInteractor with the given ControlInfo object. The CommandInteractor displays the ControlInfo's label and keylabel side-by-side as would befit a menu entry. .SH PANELCONTROL PUBLIC OPERATIONS .TP .B "PanelControl(Interactor*, ControlInfo*, ControlState* = nil)" .ns .TP .B "PanelControl(" .ns .TP .B " const char*, Interactor*, ControlInfo*," .ns .TP .B " ControlState* = nil" .ns .TP .B ")" .br Create a PanelControl, supplying an interactor that defines its appearance, a ControlInfo object, and optionally an instance name and a ControlState, which all PanelControls in a palette should share to ensure mutual exclusion. .TP .B "virtual void Do()" Do simply calls Down. Thus when the KeyMap executes the keyboard equivalent specified in the ControlInfo, it has the same effect as clicking on the PanelControl instance. .SH PANELCONTROL SUBCLASS PUBLIC OPERATIONS .TP .B "HPanelControl(ControlInfo*, ControlState* = nil)" .ns .TP .B "HPanelControl(const char*, ControlInfo*, ControlState* = nil)" .TP .ns .B "VPanelControl(ControlInfo*, ControlState* = nil)" .ns .TP .B "VPanelControl(const char*, ControlInfo*, ControlState* = nil)" HPanelControls and VPanelControls simply create an instance of PanelInteractor and pass it to the PanelControl constructor. HPanelControls should be used in row-oriented palettes, and VPanelControls should be used in column-oriented palettes. .SH PANELINTERACTOR PUBLIC OPERATIONS .TP .B "PanelInteractor(ControlInfo*, Orientation)" Create a PanelInteractor with the given orientation and ControlInfo object. The PanelInteractor will draw the ControlInfo's label in the center of its canvas and the keylabel in the lower right. Horizontal orientation is appropriate for row-oriented instances, while Vertical orientation is appropriate for column-oriented instances. .SH SEE ALSO Command(3U), ControlInfo(3U), KeyMap(3U), Tool(3U), UControl(3U), globals(3U) ivtools-1.2.11a1/src/man/man3/viewcmds.3000066400000000000000000000101001214471147700176220ustar00rootroot00000000000000.TH viewcmds 3U "24 January 1991" "Unidraw" "InterViews Reference Manual" .SH NAME CenterCmd, CloseEditorCmd, GravityCmd, GridCmd, GridSpacingCmd, NormSizeCmd, OrientationCmd, RedToFitCmd \- commands for modifying editor attributes .SH SYNOPSIS .B #include .SH DESCRIPTION The Unidraw library predefines several commands for altering the attributes of editors and their viewers. CenterCmd centers each of the editor's viewers. CloseEditorCmd closes the editor, removing it from the screen. GravityCmd turns gravity on by activating the editor's GravityVar, if it defines one. GridCmd toggles the visibility of each viewer's grid, while GridSpacingCmd lets the user specify the grid spacing for all grids. Finally, NormSizeCmd sets each viewer's magnification to a factor of one, OrientationCmd toggles each viewer's orientation between landscape mode and portrait mode, and RedToFitCmd changes each viewer's magnification so that its component view is fully visible. .SH CENTERCMD PUBLIC OPERATIONS .TP .B "CenterCmd(ControlInfo*)" .ns .TP .B "CenterCmd(Editor* = nil)" Construct a new CenterCmd. .TP .B "virtual void Execute()" Execute simply calls CenterOp on each of the editor's viewers. .TP .B "virtual boolean Reversible()" CenterCmd is not reversible. .SH CLOSEEDITORCMD PUBLIC OPERATIONS .TP .B "CloseEditorCmd(ControlInfo*)" .ns .TP .B "CloseEditorCmd(Editor* = nil)" Construct a new CloseEditorCmd. .TP .B "virtual void Execute()" Execute calls Close on the global unidraw object with the CloseEditorCmd's editor as its argument. Execute prompts the use to save the component if it does not appear in any other open editors. If no other editors are open at all, Execute creates and executes a QuitCmd. .TP .B "virtual boolean Reversible()" CloseEditorCmd is not reversible. .SH GRAVITYCMD PUBLIC OPERATIONS .TP .B "GravityCmd(ControlInfo*)" .ns .TP .B "GravityCmd(Editor* = nil)" Construct a new GravityCmd. .TP .B "virtual void Execute()" Execute calls Activate on the editor's GravityVar (if it defines one) with the inverse of the value returned by GravityVar's IsActive operation. .TP .B "virtual boolean Reversible()" GravityCmd is not reversible. .SH GRIDCMD PUBLIC OPERATIONS .TP .B "GridCmd(ControlInfo*)" .ns .TP .B "GridCmd(Editor* = nil)" Construct a new GridCmd. .TP .B "virtual void Execute()" Execute calls the Visibility operation on the grid from each of the editor's viewers, supplying the inverse of the value returned by Grid's IsVisible oepation. .TP .B "virtual boolean Reversible()" GridCmd is not reversible. .SH GRIDSPACINGCMD PUBLIC OPERATIONS .TP .B "GridSpacingCmd(ControlInfo*)" .ns .TP .B "GridSpacingCmd(Editor* = nil)" Construct a new GridSpacingCmd. .TP .B "virtual void Execute()" Execute prompts the user to specify grid spacing information through a GridDialog. If the user does not cancel the dialog, then Execute will pass the specified grid spacing to a SetSpacing call on each viewer's grid. .TP .B "virtual boolean Reversible()" GridSpacingCmd is not reversible. .SH NORMSIZECMD PUBLIC OPERATIONS .TP .B "NormSizeCmd(ControlInfo*)" .ns .TP .B "NormSizeCmd(Editor* = nil)" Construct a new NormSizeCmd. .TP .B "virtual void Execute()" Execute simply calls SetMagnification with an argument of 1 on each of the editor's viewers. .TP .B "virtual boolean Reversible()" NormSizeCmd is not reversible. .SH ORIENTATIONCMD PUBLIC OPERATIONS .TP .B "OrientationCmd(ControlInfo*)" .ns .TP .B "OrientationCmd(Editor* = nil)" Construct a new OrientationCmd. .TP .B "virtual void Execute()" Execute switches the orientation of each of the editor's viewers via their SetOrientation operation. .TP .B "virtual boolean Reversible()" OrientationCmd is not reversible. .SH REDTOFITCMD PUBLIC OPERATIONS .TP .B "RedToFitCmd(ControlInfo*)" .ns .TP .B "RedToFitCmd(Editor* = nil)" Construct a new RedToFitCmd. .TP .B "virtual void Execute()" Execute simply calls ReduceToFit on each of the editor's viewers. .TP .B "virtual boolean Reversible()" RedToFitCmd is not reversible. .SH SEE ALSO BasicDialog(3U), Command(3U), Grid(3U), Unidraw(3U), Viewer(3U), catcmds(3U), globals(3U), statevars(3U) ivtools-1.2.11a1/src/man/refman3.1/000077500000000000000000000000001214471147700165615ustar00rootroot00000000000000ivtools-1.2.11a1/src/man/refman3.1/refman.PS000066400000000000000000010663221214471147700203070ustar00rootroot00000000000000%!PS-Adobe-2.0 %%Creator: ./title.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 168.004 202.52(Copyright \(c\) 1992) 4 259.996 ws 61.1918 183.08(The Board of Trustees of the Leland Stanford Junior University) 18 366.808 ws 12 /Times-Roman sf 16 108.2(Permission to copy this manual or any portion thereof as necessary for use of) 26 412 ws 16 94.4599(this software is hereby granted provided this copyright notice and statement of) 22 412 ws 16 80.7199(permission are included.) 4 133.649 ws 24 /Times-Bold sf 54.4 531.92(InterViews Reference Manual) 4 358.32 ws 148.364 504.56(Version 3.1) 2 264.356 ws 14 /Times-Italic sf 151.347 463.28(December 14, 1992) 4 261.373 ws 18 /Times-Roman sf 149.615 422(Mark A. Linton) 4 263.105 ws 153.611 401.96(Paul R. Calder) 4 259.109 ws 141.128 381.92(John A. Interrante) 4 271.592 ws 161.117 361.88(Steven Tang) 2 251.603 ws 141.605 341.84(John M. Vlissides) 4 271.115 ws showpage %%Trailer end restore %%Pages: 1 %!PS-Adobe-2.0 %%Creator: ./cover.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 143.692 643.28(Release Notes) 2 284.308 ws 12 /Times-Roman sf 16 614.96(The InterViews 3.1 distribution contains a README file and a single) 20 412 ws 16 601.22(subdirectory, \252) 2 87.615 ws 10 /Times-Roman sf 87.615 601.22(iv) 2 95.395 as 12 /Times-Roman sf 95.395 601.22(\272, that contains the source and documentation. InterViews can be) 19 412 ws 16 587.48(compiled with any C++ compiler that accepts the 2.0, 2.1, or 3.0 revisions of the) 28 412 ws 16 573.74(language, and can run on X11R4 or X11R5. You can specify your compiler and) 27 412 ws 16 560(other site definitions in the file \252iv/src/config/InterViews/local.de) 12 330.293 ws 10 /Helvetica sf 330.293 560(f) 1 333.073 as 12 /Times-Roman sf 333.073 560(\272.) 2 341.401 as 26.668 545.36(The README) 2 101.589 ws 12 /Helvetica sf 101.589 545.36( ) 2 107.814 ws 12 /Times-Roman sf 107.814 545.36(file describes how to build InterViews. Under \252iv/src\272, the) 17 412 ws 16 531.62(directory \252include) 2 103.73 ws 10 /Helvetica sf 103.73 531.62(\272 ) 2 110.538 ws 12 /Times-Roman sf 110.538 531.62(contains include directories, \252bin\272 contains applications \(each) 12 412 ws 16 517.88(in its own subdirectory\), \252lib\272 contains libraries \(each in its own subdirectory\),) 22 412 ws 16 504.14(\252config\272 contains configuration-specific files, \252man\272 contains PostScript or troff) 16 412 ws 16 490.4(for the manual, and \252papers\272 contains PostScript for user tutorials.) 18 334.949 ws 37.336 475.76(The work at Stanford has been supported by Fujitsu America, Digital) 20 412 ws 16 462.02(Equipment Corporation, and NASA CASIS project under Contract NAGW 419,) 18 412 ws 16 448.28(and a grant from the Charles Lee Powell Foundation. Special thanks to Ira) 25 412 ws 16 434.54(Machefsky of Digital and Charles Brauer of Fujitsu America for their assistance.) 22 412 ws 16 420.8(We are also grateful to the ever-growing InterViews user community for its) 22 412 ws 16 407.06(encouragement and support.) 4 151.637 ws 26.668 392.42(Please address questions or comments about InterViews to) 14 308.297 ws 48.004 372.98(Mark Linton) 2 109 ws 48.004 358.34(linton@sgi.com) 14 124.732 as showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 52.6958 643.28(Differences between 3.0 and 3.1) 8 375.304 ws 12 /Times-Roman sf 16 614.96(InterViews 3.1 contains several improvements over 3.0.1. WidgetKit is an) 19 412 ws 16 601.22(improved implementation of the Kit class that was in 3.0.1. DialogKit is a class) 27 412 ws 16 587.48(that provides a file chooser dialog using WidgetKit compoments. LayoutKit is a) 23 412 ws 16 573.74(class that provides convenient operations for creating layout objects such as boxes) 22 412 ws 16 560(and glue, replacing the many independent classes such as LRBox and VGlue) 22 412 ws 16 546.26(in 3.0.1. Chapter 9 of the reference manual describes WidgetKit, Chapter 10) 23 412 ws 16 532.52(describes DialogKit, and Chapter 11 describes LayoutKit.) 12 293.957 ws 26.668 517.88(Glyph and other subclasses of Resource are no longer derived as virtual base) 24 412 ws 16 504.14(classes. This change was made primarily for efficiency and convenience because) 21 412 ws 16 490.4(many C++ compilers do not generate particularly efficient code for virtual base) 22 412 ws 16 476.66(classes \(especially in space\), and some compilers have bugs in this area.) 22 362.261 ws 26.668 462.02(The Glyph protocol has been extended with an ) 16 257.104 ws 12 /Times-Italic sf 257.104 462.02(undraw) 6 293.776 as 12 /Times-Roman sf 293.776 462.02( operation that notifies a) 8 412 ws 16 448.28(glyph that it no longer has an allocation on the canvas. This operation is primarily) 29 412 ws 16 434.54(for objects that cache information or perform computation when they are visible.) 22 403.924 ws 26.668 419.9(A new monoglyph subclass, called InputHandler, replaces the old Listener) 18 412 ws 16 406.16(class. InputHandler is much simpler to use than the previous combination of) 23 412 ws 16 392.42(Listener and PointerHandler, as well as providing limited support for focus) 20 412 ws 16 378.68(management.) 11 80.32 as 26.668 364.04(The Window class now has a style object as one of its attributes. The style can) 31 412 ws 16 350.3(be set to defined attributes such as name and geometry, as well as a \252visual\272 type) 30 412 ws 16 336.56(for the window. On systems that support overlay planes, the attribute \252overlay\272) 23 412 ws 16 322.82(can be used to request the window be allocated in the window planes.) 26 353.273 ws 26.668 308.18(InterViews 3.1 also includes a new faster implementation of the Style class and) 24 412 ws 16 294.44(a copy of the latest version of Sam Leffler's TIFF library \(v3.0\) for reading) 26 412 ws 16 280.7(images. The old 2.6 structured graphics library is no longer included, though it) 25 412 ws 16 266.96(probably would still work with this distribution.) 12 246.353 ws 26.668 252.32(The documentation has been reorganized to reflect some of the 3.1 changes, as) 24 412 ws 16 238.58(well as provide a structure for future releases. In addition to the reference manual,) 27 412 ws 16 224.84(a new collection of example programs is provided under iv/src/examples.) 18 367.937 ws 395.44 39.92(0-2) 3 411.436 as showpage %%Trailer end restore %%Pages: 2 %!PS-Adobe-2.0 %%Creator: ./ch1.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 16 662.72(Chapter 1) 2 119.321 ws 16 625.76(Introduction) 12 146.68 as 12 /Times-Roman sf 16 597.44(InterViews is a software system for window-based applications. Like most user) 21 412 ws 16 583.7(environments, InterViews is ) 6 155.44 ws 12 /Times-Italic sf 155.44 583.7(object-oriented) 15 228.76 as 12 /Times-Roman sf 228.76 583.7( in that components such as windows,) 12 412 ws 16 569.96(buttons, menus, and documents are active elements with inherited behavior. The) 21 412 ws 16 556.22(name \252InterViews\272 comes from the idea of a user interface object presenting) 22 412 ws 16 542.48(an ) 2 33.2522 ws 12 /Times-Italic sf 33.2522 542.48(inter) 5 55.9202 as 12 /Times-Roman sf 55.9202 542.48(active ) 2 90.5003 ws 12 /Times-Italic sf 90.5003 542.48(view) 4 112.496 as 12 /Times-Roman sf 112.496 542.48( of some data. For example, a text editor implements an) 21 412 ws 16 528.74(interactive view of the contents of a text file.) 16 230.958 ws 26.668 514.1(InterViews provides a set of classes that define the behavior of user interface) 24 412 ws 16 500.36(objects. We distinguish InterViews classes into two groups: ) 18 309.983 ws 12 /Times-Italic sf 309.983 500.36(protocols) 9 355.319 as 12 /Times-Roman sf 355.319 500.36( and ) 4 378.945 ws 12 /Times-Italic sf 378.945 500.36(kits) 4 395.613 as 12 /Times-Roman sf 395.613 500.36(. A) 3 412 ws 16 486.62(protocol defines the set of operations that an object can perform, such as drawing) 26 412 ws 16 472.88(or handling input. A kit defines a set of operations for creating other objects. The) 30 412 ws 16 459.14(idea of a kit is also sometimes referred to as an \252object factory\272. Using kits hides) 31 412 ws 16 445.4(the details of object construction and subclassing-instancing tradeoffs made by) 18 412 ws 16 431.66(the implementation, as well as providing a higher-level organizational structure to) 20 412 ws 16 417.92(the system.) 2 70.0004 ws 18 /Times-Bold sf 16 376.64(1.1) 3 38.5 as 51 376.64(Organization) 12 153.006 as 12 /Times-Roman sf 16 344.24(In this first chapter, we define the basic notation and classes, as well as give) 28 412 ws 16 330.5(an overview of the system by way of several example programs. Chapter 2) 25 412 ws 16 316.76(defines the base protocol for user interface objects, called ) 18 302.144 ws 12 /Times-Italic sf 302.144 316.76(Glyph) 5 331.472 as 12 /Times-Roman sf 331.472 316.76(, which supports) 4 412 ws 16 303.02(geometry management, rendering, picking, and structuring multiple glyphs into) 16 412 ws 16 289.28(an aggregate. Chapter 3 describes the input event processing model and the) 23 412 ws 12 /Times-Italic sf 16 275.54(InputHandler) 12 81.328 as 12 /Times-Roman sf 81.328 275.54( protocol. InputHandler is a descendant of Glyph that receives input) 21 412 ws 16 261.8(events. Chapter 4 presents the ) 11 165.207 ws 12 /Times-Italic sf 165.207 261.8(View) 4 189.207 as 12 /Times-Roman sf 189.207 261.8( protocol, which is derived from InputHandler) 12 412 ws 16 248.06(and adds additional operations for creating and updating multiple views of a) 22 412 ws 16 234.32(shared data object.) 4 105.641 ws 26.668 219.68(Chapter 5 defines the ) 8 137.448 ws 12 /Times-Italic sf 137.448 219.68(Window) 6 176.784 as 12 /Times-Roman sf 176.784 219.68( protocol for associating glyphs with a window) 14 412 ws 16 205.94(on the screen and communicating with a window manager. Chapter 6 presents the) 25 412 ws 16 192.2(basic protocols for rendering to the screen or a printer.) 18 277.266 ws 26.668 177.56(Chapter 7 is reserved for the future to describe the ) 20 309.544 ws 12 /Times-Italic sf 309.544 177.56(FigureKit) 9 356.884 as 12 /Times-Roman sf 356.884 177.56( class that) 4 412 ws 16 163.82(will create common 2D graphic objects, such as rectangles, circles, and) 20 412 ws 16 150.08(polygons. In traditional graphics terminology, FigureKit will support \252structured\272) 17 412 ws 16 136.34(graphics, while the basic rendering protocols described in Chapter 6 support) 20 412 ws 16 122.6(\252immediate-mode\272 graphics.) 2 154.636 ws 26.668 107.96(Chapter 8 defines the ) 8 141.702 ws 12 /Times-Italic sf 141.702 107.96(Style) 5 165.03 as 12 /Times-Roman sf 165.03 107.96( protocol, which manages a collection of named) 14 412 ws 16 94.2201(attributes with string values. Chapter 9 presents the ) 17 275.257 ws 12 /Times-Italic sf 275.257 94.2201(WidgetKit) 9 323.929 as 12 /Times-Roman sf 323.929 94.2201( class for creating) 6 412 ws 16 80.4801(common user interface components such as buttons, menus, and scrollbars.) 18 412 ws 16 66.7401(The precise appearance and input behavior of a widget can be adjusted by the) 26 412 ws showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 671.36(attributes in a style. Chapter 10 presents the ) 17 231.961 ws 12 /Times-Italic sf 231.961 671.36(DialogKit) 9 279.973 as 12 /Times-Roman sf 279.973 671.36( class for building common) 8 412 ws 16 657.62(dialogs.) 8 53.668 as 26.668 642.98(Chapter 11 defines the ) 8 157.194 ws 12 /Times-Italic sf 157.194 642.98(LayoutKit) 9 205.206 as 12 /Times-Roman sf 205.206 642.98( class for creating glyphs that control) 12 412 ws 16 629.24(formatting. These objects are based on the TeX document preparation system.) 21 412 ws 16 615.5(Chapter 12 describes the ) 8 137.308 ws 12 /Times-Italic sf 137.308 615.5(DocumentKit) 11 201.304 as 12 /Times-Roman sf 201.304 615.5( class for creating and editing documents.) 12 400.936 ws 26.668 600.86(Appendix A defines classes for interfacing to the underlying operating system.) 20 412 ws 16 587.12(These classes are not intended to provide a complete or standard interface to the) 26 412 ws 16 573.38(operating system, but merely a more convenient and portable set of protocols.) 22 389.608 ws 18 /Times-Bold sf 16 532.1(1.2) 3 38.5 as 51 532.1(Notation) 8 117.996 as 12 /Times-Italic sf 16 499.7(N.B.: The notation in this manual is somewhere between C++ and the OMG) 25 412 ws 16 485.96(Interface Definition Language \(IDL\). We expect to use IDL in the future.) 23 367.121 ws 12 /Times-Roman sf 16 466.52(We use a syntax similar to C++ to specify the InterViews classes and operations.) 26 412 ws 16 452.78(However, the specification of a class here is ) 16 231.527 ws 12 /Times-Italic sf 231.527 452.78(not) 3 246.863 as 12 /Times-Roman sf 246.863 452.78( identical to its C++ declaration in) 12 412 ws 16 439.04(a header file. To make the distinction clear between our specification and C++,) 25 412 ws 16 425.3(we use the keyword \252interface' instead of \252class\272. We assume inheritance is) 23 412 ws 16 411.56(always \252public\272 in C++ terminology.) 8 194.525 ws 26.668 396.92(All operations are assumed public; we do not list the protected or private) 24 412 ws 16 383.18(members. We also do not list members that are implicitly part of the) 25 412 ws 16 369.44(implementation. For example, C++ destructors are normally public but often) 19 412 ws 16 355.7(simply free storage allocated by the object. Thus, there is no need to document) 27 412 ws 16 341.96(destructors as part of a class interface.) 12 198.942 ws 26.668 327.32(Unless explicitly specified as \252static\272, all operations are virtual functions in) 20 412 ws 16 313.58(C++. In the case of an inherited operation, the choice of whether or not to) 29 412 ws 16 299.84(provide the operation may depend on the implementation. We therefore do not) 23 412 ws 16 286.1(list inherited operations unless the subclass extends the semantics in some way.) 22 397.3 ws 14 /Times-Bold sf 16 259.7(1.2.1) 5 44 as 56 259.7(Names) 5 96.432 as 12 /Times-Roman sf 16 239.26(We use identifiers that begin with an upper case letter for types; we use lower) 28 412 ws 16 225.52(case for operations and parameters. In type names consisting of multiple words,) 23 412 ws 16 211.78(we capitalize the beginning of each word, as in FirstSecondThird. For operations) 23 412 ws 16 198.04(or parameters we use underscores to separate words, as in first_second_third. An) 23 412 ws 16 184.3(operation ) 2 64.3242 ws 12 /Times-Italic sf 64.3242 184.3(f ) 2 70.6604 ws 12 /Times-Roman sf 70.6604 184.3(for a class ) 6 122.309 ws 12 /Times-Italic sf 122.309 184.3(C) 1 130.313 as 12 /Times-Roman sf 130.313 184.3( is denoted by ) 8 200.31 ws 12 /Times-Italic sf 200.31 184.3(C) 1 208.314 as 12 /Times-Roman sf 208.314 184.3(::) 2 214.986 as 12 /Times-Italic sf 214.986 184.3(f) 1 218.322 as 12 /Times-Roman sf 218.322 184.3(.) 1 221.322 as 26.668 169.66(We assume that some mechanism allows us to use whatever names we wish for) 26 412 ws 16 155.92(global symbols; that is, there is no need for a special prefix on all class and) 30 412 ws 16 142.18(type names. Ideally, this capability would be provided by the implementation) 21 412 ws 16 128.44(language, but this is not yet the case for C++. Currently, the implementation uses) 27 412 ws 16 114.7(#define macros to prepend the prefix ``iv'' to all class names and global type) 26 412 ws 16 100.96(names. This redefinition is hidden from the programmer, except inasmuch as it) 23 412 ws 16 87.22(shows up during debugging. To undefine these macros, a source file must include) 25 412 ws 16 73.48(\252\272. After leaving the InterViews scope, InterViews) 13 412 ws 16 59.74(names are specified by \252_lib_iv\() 8 178.552 ws 12 /Times-Italic sf 178.552 59.74(name) 4 204.544 as 12 /Times-Roman sf 204.544 59.74(\)\272, where ) 4 255.478 ws 12 /Times-Italic sf 255.478 59.74(name) 4 281.47 as 12 /Times-Roman sf 281.47 59.74( is the class or type name) 12 412 ws 395.2 38.72(1-2) 3 411.196 as showpage %%Page: 3 3 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 671.36(defined in this manual.) 6 125.993 ws 14 /Times-Bold sf 16 644.96(1.2.2) 5 44 as 56 644.96(Use of const) 4 127.541 ws 12 /Times-Roman sf 16 624.52(C++ allows the type modifier \252const\272 to be used in a variety of different ways.) 28 412 ws 16 610.78(For concrete objects \(int, float, char*\), it refers to read-only storage. For abstract) 25 412 ws 16 597.04(objects, however, storage access should not be visible in an interface. For) 23 412 ws 16 583.3(example, an operation on a transformation matrix could be defined that returns) 22 412 ws 16 569.56(whether the matrix is the identity or not. A simple implementation could compute) 25 412 ws 16 555.82(the identity test and could be defined as const in the storage sense. However,) 27 412 ws 16 542.08(another implementation might cache the result of the test to avoid the overhead of) 26 412 ws 16 528.34(the test when the matrix is not changing. This second implementation is not const) 27 412 ws 16 514.6(in the storage sense because it modifies the transformation matrix object.) 20 366.281 ws 26.668 499.96(We use const for operations that do not change the ) 20 298.826 ws 12 /Times-Italic sf 298.826 499.96(behavior) 8 341.486 as 12 /Times-Roman sf 341.486 499.96( of an object.) 6 412 ws 16 486.22(That is, an operation is const if a call to it could be omitted without changing) 30 412 ws 16 472.48(the effect of subsequent operations performed on the object. This definition is) 23 412 ws 16 458.74(consistent with the notion that a compiler could eliminate redundant calls to the) 24 412 ws 16 445(same const function. The one important counter-example is reference counting,) 19 412 ws 16 431.26(where incrementing and decrementing the reference count of a shared object) 20 412 ws 16 417.52(changes its lifetime \(an operation that could not be eliminated by the compiler\)) 24 412 ws 16 403.78(but does not change its behavior \(the operation is considered const\).) 20 342.281 ws 26.668 389.14(Using our semantics of const, the transformation matrix identity function) 18 412 ws 16 375.4(mentioned above should be defined as const. This approach implies that an) 23 412 ws 16 361.66(implementation may be forced to cast the ) 14 223.219 ws 12 /Times-Italic sf 223.219 361.66(this) 4 240.559 as 12 /Times-Roman sf 240.559 361.66( pointer from const to non-const to) 12 412 ws 16 347.92(avoid a compiler error message because C++ compilers normally assume that a) 22 412 ws 16 334.18(function should not be const if the function does modifies storage.) 20 333.641 ws 26.668 319.54(It is also possible \(indeed, likely\) that a function does not follow our semantics) 26 412 ws 16 305.8(of const even though it does not modify the object's storage. If an object contains) 29 412 ws 16 292.06(a pointer to another object and an operation performs a non-const operation on) 24 412 ws 16 278.32(that object, then the first operation may also need to be defined as non-const.) 26 384.94 ws 14 /Times-Bold sf 16 251.92(1.2.3) 5 44 as 56 251.92(Common Symbols) 2 165.284 ws 12 /Times-Roman sf 16 231.48(Several definitions are pervasive throughout the system. These definitions are) 19 412 ws 16 217.74(automatically defined as a side effect of using any other InterViews classes.) 22 412 ws 16 204(The type ) 4 66.3086 ws 12 /Times-Italic sf 66.3086 204(boolean) 7 104.973 as 12 /Times-Roman sf 104.973 204( is defined in the conventional sense of a language such as) 22 412 ws 16 190.26(Pascal, as are the constants ) 10 157.562 ws 12 /Times-Italic sf 157.562 190.26(true) 4 176.894 as 12 /Times-Roman sf 176.894 190.26( and ) 4 203.792 ws 12 /Times-Italic sf 203.792 190.26(false) 5 226.46 as 12 /Times-Roman sf 226.46 190.26(. The constant ) 7 304.864 ws 12 /Times-Italic sf 304.864 190.26(nil) 3 317.536 as 12 /Times-Roman sf 317.536 190.26( is presumed to be) 8 412 ws 16 176.52(type-equivalent to any pointer type and represents an invalid pointer value. In) 23 412 ws 16 162.78(C++, we #define nil to zero.) 10 151.182 ws 26.668 148.14(The type ) 4 75.0948 ws 12 /Times-Italic sf 75.0949 148.14(String) 6 104.435 as 12 /Times-Roman sf 104.435 148.14( is used as a parameter to a number of operations, though no) 24 412 ws 16 134.4(specific interface or implementation is presumed. Whereever a string parameter) 19 412 ws 16 120.66(appears, one can assume that a C++ \252const char*\272 type can also be passed.) 26 374.441 ws 14 /Times-Bold sf 16 94.2601(1.2.4) 5 44 as 56 94.2601(Coordinates) 11 129.108 as 12 /Times-Roman sf 16 73.8201(Many objects and operations manipulate coordinates. We define the type ) 20 368.987 ws 12 /Times-Italic sf 368.987 73.8201(Coord) 5 399.659 as 12 /Times-Roman sf 399.659 73.8201( to) 2 412 ws 16 60.0801(represent a position or a distance. The default units for a coordinate are \252printers) 26 412 ws 395.2 38.72(1-3) 3 411.196 as showpage %%Page: 4 4 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 671.36(points\272, or 1/72 of an inch. The scaling factor can be customized on a per-screen) 29 412 ws 16 657.62(basis.) 6 43 as 26.668 642.98(Ideally, Coord would be an abstract type with set of operations and conversions) 24 412 ws 16 629.24(to concrete types. However, current C++ compilers do not make it practical) 23 412 ws 16 615.5(to define a Coord class that is represented as a single word. The current) 27 412 ws 16 601.76(implementation therefore defines Coord as the C++ type \252float'.) 16 324.485 ws 26.668 587.12(For applications with simple graphics needs, the use of floating point) 20 412 ws 16 573.38(coordinates is typically not a problem. Applications with more sophisticated text) 21 412 ws 16 559.64(or graphics usually need to manipulate floating point coordinates anyway.) 18 371.284 ws 26.668 545(The use of non-pixel units allows objects to be resolution-independent, but also) 22 412 ws 16 531.26(means that one cannot rely on precise output at low resolutions. Coordinates are) 25 412 ws 16 517.52(rounded-off to guarantee that objects that abut in coordinates will abut on the) 24 412 ws 16 503.78(screen. This choice means that a one point line might generate one or two pixels,) 29 412 ws 16 490.04(depending on where it is on the screen. Objects that need to generate consistent) 27 412 ws 16 476.3(pixel sizes can explicitly round to whole-pixel coordinate values using Canvas) 20 412 ws 16 462.56(to_pixels_coord.) 16 96.328 as 14 /Times-Bold sf 16 436.16(1.2.5) 5 44 as 56 436.16(Dimensions) 10 125.23 as 12 /Times-Roman sf 16 415.72(Many composition strategies manipulate coordinates in one dimension. To use a) 20 412 ws 16 401.98(single strategy in any dimension, we define the type ) 18 276.314 ws 12 /Times-Italic sf 276.314 401.98(DimensionName ) 2 360.159 ws 12 /Times-Roman sf 360.159 401.98(and values) 2 412 ws 12 /Times-Italic sf 16 388.24(Dimension_X) 11 81.328 as 12 /Times-Roman sf 81.328 388.24(, ) 2 87.5213 ws 12 /Times-Italic sf 87.5213 388.24(Dimension_Y) 11 152.189 as 12 /Times-Roman sf 152.189 388.24(, or ) 4 171.572 ws 12 /Times-Italic sf 171.572 388.24(Dimension_Z) 11 236.24 as 12 /Times-Roman sf 236.24 388.24(. It is possible that other dimensions) 13 412 ws 16 374.5(may be defined in the future. The constant ) 17 227.668 ws 12 /Times-Italic sf 227.668 374.5(Dimension_Undefined) 19 335.656 as 12 /Times-Roman sf 335.656 374.5( is defined after) 6 412 ws 16 360.76(any other dimensions.) 4 121.661 ws 14 /Times-Bold sf 16 334.36(1.2.6) 5 44 as 56 334.36(Parameter conventions) 2 194.026 ws 12 /Times-Roman sf 16 313.92(In specifying an operation, we list only the parameter type unless there are several) 26 412 ws 16 300.18(parameters to the operation with the same type. In this case, we list both the type) 31 412 ws 16 286.44(and a name for the parameter that clarifies what it is.) 20 268.938 ws 26.668 271.8(For parameters that are objects, we use a pointer type if the operation may store) 28 412 ws 16 258.06(a pointer to the object with a lifetime beyond the operation's activation. If the) 27 412 ws 16 244.32(operation will not store a pointer, then we pass a reference type. Therefore, one) 27 412 ws 16 230.58(should never pass the expression \252&x\272 for a local or parameter object \252x\272.) 24 372.905 ws 14 /Times-Bold sf 16 204.18(1.2.7) 5 44 as 56 204.18(Storage management) 2 182.364 ws 12 /Times-Roman sf 16 183.74(Because C++ does not provide garbage collection, it is necessary to manage) 22 412 ws 16 170(shared objects within a program. We make objects easier to share by deriving) 25 412 ws 16 156.26(from class Resource, which manages a reference count. If we had garbage) 23 412 ws 16 142.52(collection, we would not need the resource class. Therefore, we do not consider) 25 412 ws 16 128.78(resource really part of the InterViews programming interface and it does not) 22 412 ws 16 115.04(appear in any function type signatures. However, it is necessary to understand) 22 412 ws 16 101.3(which objects can be shared and as a practical matter the implementation must) 24 412 ws 16 87.5601(manage references correctly.) 4 154.265 ws 26.668 72.9201(Figure 1.1 shows the Resource class interface. Every resource has a reference) 23 412 ws 395.2 38.72(1-4) 3 411.196 as showpage %%Page: 5 5 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 531.61(count that is initially zero and must be explicitly incremented by calling) 22 412 ws 16 517.87(Resource::ref. The reason the count is initially zero is that an object is often) 27 412 ws 16 504.13(created and immediately passed as a parameter to another object that stores the) 24 412 ws 16 490.39(reference. Since the receiver must reference the parameter anyway, it is confusing) 23 412 ws 16 476.65(to force the creator to unreference the resource after passing it.) 20 316.889 ws 16 462.01( The C++ delete operator should not be used on resources directly; instead,) 25 412 ws 16 448.27(Resource::unref or Resource::unref_deferred should be called to decrement the) 16 412 ws 16 434.53(reference count of an object. If the count is no longer positive, then the resource's) 29 412 ws 16 420.79(cleanup operation will be called. In the case of Resource::unref, the object is) 25 412 ws 16 407.05(immediately destroyed. In the case of Resource::unref_deferred, the object will) 19 412 ws 16 393.31(be put on a queue of objects to be destroyed in order the next time Resource::flush) 30 412 ws 16 379.57(is called. Resource deferral is useful when an object initiates a delete on one of its) 31 412 ws 16 365.83(ancestors or some other object with an active member function.) 18 320.609 ws 14 /Times-Bold sf 16 339.43(1.2.8) 5 44 as 56 339.43(Callbacks) 9 115.122 as 12 /Times-Roman sf 16 318.99(C++ provides a pointer-to-function type, but often one wishes to encapsulate an) 22 412 ws 16 305.25(object and a pointer to a member function to call on the object. Our approach is) 31 412 ws 16 291.51(to define a base class containing the callback signature and a parameterized) 22 412 ws 16 277.77(subclass for a callback to an object of a specific type. For example, the ) 29 382 ws 12 /Times-Italic sf 382 277.77(action) 6 412 as 12 /Times-Roman sf 16 264.03(class defines a single operation, Action::execute, with no parameters and no) 20 412 ws 16 250.29(return value. A ) 7 96.779 ws 12 /Times-Italic sf 96.779 250.29(macro) 5 127.439 as 12 /Times-Roman sf 127.439 250.29( is an action that contains a list of actions, each of which) 24 412 ws 16 236.55(is executed in order. An ) 11 149.009 ws 12 /Times-Italic sf 149.009 236.55(action callback) 2 225.127 ws 12 /Times-Roman sf 225.127 236.55( is the subclass that is expanded for) 14 412 ws 16 222.81(each destination type. The current implementation uses preprocessor macros,) 17 412 ws 16 209.07(but will use templates in the future. Figure 1.2 shows the action, macro, and) 27 412 ws 16 195.33(action-callback class interfaces.) 4 168.281 ws 18 /Times-Bold sf 16 154.05(1.3) 3 38.5 as 51 154.05(Basic concepts) 2 162.492 ws 12 /Times-Roman sf 16 121.65(The goal of InterViews is to make it easy to compose user interfaces from) 26 412 ws 16 107.91(reusable components. The central class for physical composition is Glyph because) 21 412 ws 16 94.17(it defines the geometry of a user interface object. The central class for logical) 27 412 ws 16 80.43(composition is InputHandler because it defines the input handling policy and) 20 412 ws 16 66.69(update management. InputHandler is a subclass of glyph, normally delegating its) 21 412 ws 395.2 38.72(1-5) 3 411.196 as newpath 14.08 663.34 moveto 14.08 664.34 lineto 410.08 664.34 lineto 410.08 663.34 lineto closepath gsave eofill grestore 10 /Helvetica sf 35.416 646.78(interface Resource {) 4 125.457 ws 43.746 635.26(static void ref\(const Resource*\);) 6 185.457 ws 43.746 623.74(static void unref\(const Resource*\);) 6 196.577 ws 43.746 612.22(static void unref_deferred\(const Resource*\);) 6 239.376 ws 43.746 600.7(static void flush\(\);) 4 121.547 ws 43.746 589.18(void cleanup\(\);) 2 109.326 ws 35.416 577.66(}; ) 2 44.3164 ws 10 /Helvetica sf 132.611 561.14(Figure 1.1:) 2 180.411 ws 188.741 561.14(Resource class interface) 4 298.221 ws newpath 14.08 552.97 moveto 14.08 553.97 lineto 410.08 553.97 lineto 410.08 552.97 lineto closepath gsave eofill grestore showpage %%Page: 6 6 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 429.49(geometry and appearance to another glyph.) 10 223.277 ws 26.668 414.85(The Canvas class defines a 2-dimensional surface upon to which a group of) 24 412 ws 16 401.11(glyphs are attached. The glyphs negotiate for space on the canvas, draw on the) 27 412 ws 16 387.37(canvas to refresh their appearance, and damage the canvas to cause an update) 24 412 ws 16 373.63(traversal.) 10 60.316 as 26.668 358.99(The Window class creates a canvas for a top-level input handler and allows) 24 412 ws 16 345.25(the user to control the canvas on a screen through a window manager. The) 27 412 ws 16 331.51(window class does not define a window management policy, only the mechanism) 22 412 ws 16 317.77(for communicating appropriate information between a window manager and the) 18 412 ws 16 304.03(glyphs.) 7 51.004 as 26.668 289.39(The InterViews input model is ``top-down''. That is, an input event is first) 25 412 ws 16 275.65(received by the appropriate window as determined by the window manager. The) 23 412 ws 16 261.91(receiving window passes the event to the root input handler, which may pass it) 26 412 ws 16 248.17(down to a nested input handler.) 10 166.649 ws 14 /Times-Bold sf 16 221.77(1.3.1) 5 44 as 56 221.77(Main event loop) 4 152.447 ws 12 /Times-Roman sf 16 201.33(Every application creates a Session object to run an event dispatching loop.) 22 412 ws 16 187.59(Sessions initially attach to the user's display and can attach to additional displays.) 24 412 ws 16 173.85(A session defines a root Style object derived from user customization files and) 24 412 ws 16 160.11(command-line arguments. Styles define named attributes with string values,) 17 412 ws 16 146.37(wildcarding for matching classes of objects, and quick access to common) 20 412 ws 16 132.63(attributes such as fonts and colors. Figure 1.3 shows the session protocol.) 23 369.473 ws 26.668 117.99(The session is given an alias \(class name\) for the root style, an array of) 28 412 ws 16 104.25(command-line arguments, an optional argument description, and optional initial) 16 412 ws 16 90.51(style settings. The root style's name comes from the \252-name\272 command-line) 21 412 ws 16 76.77(option \(if given\), or the environment variable RESOURCE_NAME \(if defined\),) 18 412 ws 16 63.03(or the value of argv[0] with leading path entries stripped.) 18 289.949 ws 395.2 38.72(1-6) 3 411.196 as newpath 19.12 679.9 moveto 19.12 680.9 lineto 415.12 680.9 lineto 415.12 679.9 lineto closepath gsave eofill grestore 10 /Helvetica sf 40.456 663.34(typedef long MacroIndex;) 4 152.737 ws 40.456 646.82(interface Action : Resource {) 8 166.627 ws 48.786 635.3(void execute\(\) = 0;) 6 131.327 ws 40.456 623.78(};) 2 46.576 as 40.456 607.26(interface Macro : Action {) 8 151.617 ws 48.786 595.74(Macro\(Action* = nil, Action* = nil, Action* = nil, Action* = nil\);) 22 315.007 ws 48.786 584.22(void prepend\(Action*\);) 2 147.716 ws 48.786 572.7(void append\(Action*\);) 2 144.386 ws 48.786 561.18(void insert\(MacroIndex, Action*\);) 4 193.276 ws 48.786 549.66(void remove\(MacroIndex\);) 2 164.926 ws 48.786 538.14(MacroIndex count\(\) const;) 4 164.387 ws 48.786 526.62(Action* action\(MacroIndex\) const;) 4 198.286 ws 40.456 515.1(};) 2 46.576 as 40.456 498.58(interface ActionCallback\(T\) : Action {) 8 202.737 ws 48.786 487.06(ActionCallback\(T\)\(T*, void \(T::*\)\(\)\);) 4 202.686 ws 40.456 475.54(};) 2 46.576 as 10 /Helvetica sf 114.856 459.02(Figure 1.2:) 2 162.656 ws 170.986 459.02(Action and related class interfaces.) 8 326.056 ws newpath 19.12 450.85 moveto 19.12 451.85 lineto 415.12 451.85 lineto 415.12 450.85 lineto closepath gsave eofill grestore showpage %%Page: 7 7 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 26.668 247.85(The option description is an array of structures that describe command-line) 20 412 ws 16 234.11(arguments. The structure contains four fields: a ) 15 258.256 ws 12 /Times-Italic sf 258.256 234.11(name) 4 284.248 as 12 /Times-Roman sf 284.248 234.11( that is the command-line) 8 412 ws 16 220.37(string, a ) 4 57.896 ws 12 /Times-Italic sf 57.896 220.37(path) 4 79.232 as 12 /Times-Roman sf 79.232 220.37( specifying a style attribute, a ) 12 224.24 ws 12 /Times-Italic sf 224.24 220.37(format) 6 256.244 as 12 /Times-Roman sf 256.244 220.37( specifying where the associated) 8 412 ws 16 206.63(value is, and a default ) 10 126.074 ws 12 /Times-Italic sf 126.074 206.63(value) 5 152.066 as 12 /Times-Roman sf 152.066 206.63(. Valid formats are OptionPropertyNext \(use the next) 15 412 ws 16 192.89(argument as an attribute-value pair\), OptionValueNext \(use the next argument) 18 412 ws 16 179.15(as the value\), OptionValueImplicit \(use the default value\), OptionValueIsArg) 16 412 ws 16 165.41(\(use the agument as the value\), and OptionValueAfter \(use the remainder of the) 24 412 ws 16 151.67(argument as the value\). If a command-line argument is found that matches an) 25 412 ws 16 137.93(option description, it will be interpreted and removed from argv. The agument) 23 412 ws 16 124.19(count \(argc\) will be set to the number of uninterpreted command-line arguments.) 22 404.596 ws 26.668 109.55(In addition to the program-specified options, the Session constructor) 16 412 ws 16 95.81(automatically matches the options listed in Table 1.1. The optional initial style) 23 412 ws 16 82.07(settings are specified by a nil-terminated array of pairs ) 18 292.16 ws 12 /Times-Italic sf 292.16 82.07() 7 332.696 as 12 /Times-Roman sf 332.696 82.07(, where ) 4 373.506 ws 12 /Times-Italic sf 373.506 82.07(s1) 2 384.174 as 12 /Times-Roman sf 384.174 82.07( is an) 4 412 ws 16 68.33(attribute name and ) 6 109.548 ws 12 /Times-Italic sf 109.548 68.33(s2) 2 120.216 as 12 /Times-Roman sf 120.216 68.33( is the value. User defaults will override any initial settings,) 21 412 ws 395.2 38.72(1-7) 3 411.196 as newpath 19.12 676.06 moveto 19.12 677.06 lineto 415.12 677.06 lineto 415.12 676.06 lineto closepath gsave eofill grestore 10 /Helvetica sf 40.456 659.5(struct PropertyData {) 4 132.717 ws 48.786 647.98(const char* path;) 4 123.827 ws 48.786 636.46(const char* value;) 4 128.267 ws 40.456 624.94(};) 2 46.576 as 40.456 608.42(struct OptionDesc {) 4 126.047 ws 48.786 596.9(const char* name;) 4 129.377 ws 48.786 585.38(const char* path;) 4 123.827 ws 48.786 573.86(OptionStyle format;) 2 134.376 ws 48.786 562.34(const char* value;) 4 128.267 ws 40.456 550.82(};) 2 46.576 as 40.456 534.3(interface Session {) 4 123.277 ws 48.786 522.78(Session\() 8 87.686 as 57.116 511.26(const char* name, int& argc, char** argv) 12 234.967 ws 57.116 499.74(const OptionDesc* = nil, const PropertyData* = nil) 14 277.767 ws 48.786 488.22(\);) 2 54.896 as 48.786 476.7(static Session* instance\(\);) 4 163.827 ws 48.786 465.18(int argc\(\) const;) 4 117.697 ws 48.786 453.66(char** argv\(\) const;) 4 134.367 ws 48.786 442.14(Style* style\(\) const;) 4 134.367 ws 48.786 430.62(void default_display\(Display*\);) 2 182.716 ws 48.786 419.1(Display* default_display\(\) const;) 4 191.056 ws 48.786 407.58(Display* connect\(const String&\);) 4 192.166 ws 48.786 396.06(Display* connect\(const char*\);) 4 182.716 ws 48.786 384.54(void disconnect\(Display*\);) 2 163.816 ws 48.786 373.02(int run\(\);) 2 86.0164 ws 48.786 361.5(int run_window\(Window*\);) 2 164.366 ws 48.786 349.98(void quit\(\);) 2 95.4664 ws 48.786 338.46(boolean done\(\);) 2 118.826 ws 40.456 326.94(};) 2 46.576 as 10 /Helvetica sf 155.431 310.42(Figure 1.3:) 2 203.231 ws 211.561 310.42(Session protocol) 2 285.481 ws 192.391 277.38(Figure 1.4:) 2 240.191 ws newpath 19.12 269.21 moveto 19.12 270.21 lineto 415.12 270.21 lineto 415.12 269.21 lineto closepath gsave eofill grestore showpage %%Page: 8 8 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 292.88(and command-line arguments will override user defaults. ) 14 293.285 ws 14 /Times-Bold sf 16 266.48(1.3.2) 5 44 as 56 266.48(Common widgets) 2 159.824 ws 12 /Times-Roman sf 16 246.04(InterViews provides common behavior objects, such as buttons and menus, which) 20 412 ws 16 232.3(are built using glyphs and input handlers. Unlike many other toolkits, InterViews) 23 412 ws 16 218.56(objects are cheap enough that behavior objects are separate from appearance) 20 412 ws 16 204.82(objects. For example, the button class is given a separate glyph that denotes its) 27 412 ws 16 191.08(appearance; the button only implements input behavior.) 12 283.637 ws 26.668 176.44(This approach of separating input and output objects makes the toolkit more) 22 412 ws 16 162.7(flexible and the individual objects simpler, but it can make the task of constructing) 26 412 ws 16 148.96(higher-level user interface objects more confusing. In particular, it becomes less) 21 412 ws 16 135.22(obvious whether it is appropriate to subclass or instance to create a particular) 24 412 ws 16 121.48(component.) 10 72.328 as 26.668 106.84(InterViews provides a widget kit object that encapsulates these decisions in a) 22 412 ws 16 93.1(single programming interface while allowing various appearances and behaviors.) 16 412 ws 16 79.3599(A widget kit is an object that creates common user interface objects such as) 26 412 ws 16 65.6199(buttons, scrollbars, and menus. For example, a push button has button behavior, a) 25 412 ws 395.2 38.72(1-8) 3 411.196 as newpath 35.08 345.56 moveto 35.08 678.68 lineto 36.08 678.68 lineto 36.08 345.56 lineto closepath 0 0 0.0941176 setrgbcolor gsave eofill grestore newpath 111.4 345.56 moveto 111.4 678.68 lineto 112.4 678.68 lineto 112.4 345.56 lineto closepath gsave eofill grestore newpath 384.376 345.56 moveto 384.376 678.68 lineto 385.376 678.68 lineto 385.376 345.56 lineto closepath gsave eofill grestore newpath 35.08 677.68 moveto 35.08 678.68 lineto 385.376 678.68 lineto 385.376 677.68 lineto closepath gsave eofill grestore newpath 35.08 663.24 moveto 35.08 664.24 lineto 385.376 664.24 lineto 385.376 663.24 lineto closepath gsave eofill grestore newpath 35.08 648.8 moveto 35.08 649.8 lineto 385.376 649.8 lineto 385.376 648.8 lineto closepath gsave eofill grestore newpath 35.08 634.36 moveto 35.08 635.36 lineto 385.376 635.36 lineto 385.376 634.36 lineto closepath gsave eofill grestore newpath 35.08 619.92 moveto 35.08 620.92 lineto 385.376 620.92 lineto 385.376 619.92 lineto closepath gsave eofill grestore newpath 35.08 605.48 moveto 35.08 606.48 lineto 385.376 606.48 lineto 385.376 605.48 lineto closepath gsave eofill grestore newpath 35.08 591.04 moveto 35.08 592.04 lineto 385.376 592.04 lineto 385.376 591.04 lineto closepath gsave eofill grestore newpath 35.08 576.6 moveto 35.08 577.6 lineto 385.376 577.6 lineto 385.376 576.6 lineto closepath gsave eofill grestore newpath 35.08 562.16 moveto 35.08 563.16 lineto 385.376 563.16 lineto 385.376 562.16 lineto closepath gsave eofill grestore newpath 35.08 547.72 moveto 35.08 548.72 lineto 385.376 548.72 lineto 385.376 547.72 lineto closepath gsave eofill grestore newpath 35.08 533.28 moveto 35.08 534.28 lineto 385.376 534.28 lineto 385.376 533.28 lineto closepath gsave eofill grestore newpath 35.08 518.84 moveto 35.08 519.84 lineto 385.376 519.84 lineto 385.376 518.84 lineto closepath gsave eofill grestore newpath 35.08 504.4 moveto 35.08 505.4 lineto 385.376 505.4 lineto 385.376 504.4 lineto closepath gsave eofill grestore newpath 35.08 489.96 moveto 35.08 490.96 lineto 385.376 490.96 lineto 385.376 489.96 lineto closepath gsave eofill grestore newpath 35.08 475.52 moveto 35.08 476.52 lineto 385.376 476.52 lineto 385.376 475.52 lineto closepath gsave eofill grestore newpath 35.08 461.08 moveto 35.08 462.08 lineto 385.376 462.08 lineto 385.376 461.08 lineto closepath gsave eofill grestore newpath 35.08 446.64 moveto 35.08 447.64 lineto 385.376 447.64 lineto 385.376 446.64 lineto closepath gsave eofill grestore newpath 35.08 432.2 moveto 35.08 433.2 lineto 385.376 433.2 lineto 385.376 432.2 lineto closepath gsave eofill grestore newpath 35.08 417.76 moveto 35.08 418.76 lineto 385.376 418.76 lineto 385.376 417.76 lineto closepath gsave eofill grestore newpath 35.08 403.32 moveto 35.08 404.32 lineto 385.376 404.32 lineto 385.376 403.32 lineto closepath gsave eofill grestore newpath 35.08 388.88 moveto 35.08 389.88 lineto 385.376 389.88 lineto 385.376 388.88 lineto closepath gsave eofill grestore newpath 35.08 374.44 moveto 35.08 375.44 lineto 385.376 375.44 lineto 385.376 374.44 lineto closepath gsave eofill grestore newpath 35.08 360 moveto 35.08 361 lineto 385.376 361 lineto 385.376 360 lineto closepath gsave eofill grestore newpath 35.08 345.56 moveto 35.08 346.56 lineto 385.376 346.56 lineto 385.376 345.56 lineto closepath gsave eofill grestore 0 0 0 setrgbcolor 40.08 667.12(-background) 11 100.728 as 116.4 667.12(next argument sets the background color) 10 311.364 ws 40.08 652.68(-bg) 3 56.076 as 116.4 652.68(same as -background) 4 217.704 ws 40.08 638.24(-dbu) 4 62.076 as 10 /Times-Roman sf 62.076 638.24(f) 1 65.406 as 12 /Times-Roman sf 116.4 638.24(double-buffer windows by default) 6 280.032 ws 40.08 623.8(-display) 8 78.744 as 116.4 623.8(next argument specifies the target workstation display) 12 375.696 ws 40.08 609.36(-dpi) 4 59.412 as 116.4 609.36(next argument is coordinates-to-pixels ratio) 8 325.704 ws 40.08 594.92(-fg) 3 54.072 as 116.4 594.92(same as -foreground) 4 214.368 ws 40.08 580.48(-flat) 5 60.072 as 116.4 580.48(next argument sets the base color for bevels) 14 326.688 ws 40.08 566.04(-fn) 3 54.072 as 116.4 566.04(same as -font) 4 180.384 ws 40.08 551.6(-font) 5 63.408 as 116.4 551.6(next argument sets the default text font) 12 303.709 ws 40.08 537.16(-foreground) 11 97.392 as 116.4 537.16(next argument sets the foreground color) 10 308.028 ws 40.08 522.72(-geometry) 9 89.4 as 116.4 522.72(next argument sets the first window's position and size) 16 380.376 ws 40.08 508.28(-iconic) 7 73.404 as 116.4 508.28(starts up first window in iconic form) 12 291.721 ws 40.08 493.84(-malloc) 7 76.74 as 116.4 493.84(run with memory-management debugging on) 8 333.708 ws 40.08 479.4(-monochrome) 11 107.4 as 116.4 479.4(use monochrome style) 4 224.388 ws 40.08 464.96(-motif) 6 70.08 as 116.4 464.96(use Motif style) 4 188.4 ws 40.08 450.52(-name) 5 70.068 as 116.4 450.52(next argument sets the instance name of the session) 16 363.696 ws 40.08 436.08(-nodbuf) 7 78.072 as 116.4 436.08(do not double-buffer windows) 6 262.044 ws 40.08 421.64(-openlook) 9 88.74 as 116.4 421.64(use OpenLook style) 4 212.388 ws 40.08 407.2(-synchronous) 12 104.736 as 116.4 407.2(force synchronous operation with the window system) 12 373.032 ws 40.08 392.76(-title) 6 62.748 as 116.4 392.76(next argument sets the session's default title bar name) 16 375.696 ws 40.08 378.32(-visual) 7 72.744 as 116.4 378.32(next argument is visual class to use for windows) 16 349.044 ws 40.08 363.88(-visual_id) 10 88.08 as 116.4 363.88(next argument is visual id number to use for windows) 18 374.712 ws 40.08 349.44(-xrm) 4 63.408 as 12 /Times-Roman sf 116.4 349.44(next argument is \252name:value\272; sets named attribute) 12 367.692 ws 99.2399 323.12(Table 1.1:) 2 147.9 ws 158.568 323.12(Predefined command-line options) 4 321.216 ws showpage %%Page: 9 9 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 671.36(beveled or highlighted appearance when pressed, and a style for customization.) 20 412 ws 16 657.62(The WidgetKit class provides a function to create a push button object; the) 24 412 ws 16 643.88(implementation is free to compose what objects are necessary to provide the) 22 412 ws 16 630.14(appropriate functionality. Each application normally creates a single WidgetKit) 17 412 ws 16 616.4(object, which is typically a subclass defined for a particular look-and-feel) 20 412 ws 16 602.66(such as OpenLook or Motif. The application can call the static function) 23 412 ws 16 588.92(WidgetKit:::instance to return the object and therefore be unaware which specific) 20 412 ws 16 575.18(look-and-feel is being used.) 6 149.309 ws 18 /Times-Bold sf 16 533.9(1.4) 3 38.5 as 51 533.9(A simple example) 4 186.991 ws 12 /Times-Roman sf 16 501.5(Figure 1.5 shows a simple InterViews application that display the text \252hi mom!\272) 24 412 ws 16 487.76(in a window. The application creates a session and runs it starting with a window) 29 412 ws 16 474.02(containing the text over a background. The window is an \252application window\272,) 23 412 ws 16 460.28(meaning it is recognized by other desktop services \(window manager, session) 20 412 ws 16 446.54(manager\) as the main window for the application.) 14 254.621 ws 26.668 431.9(The window contains a background that contains a label. A background glyph) 23 412 ws 16 418.16(paints a given color behind its contents. The label's font and color are obtained) 27 412 ws 16 404.42(from the default style for the session.) 12 194.31 ws 26.668 389.78(This application does not handle user input. It must therefore be terminated) 23 412 ws 16 376.04(externally, either from a window manager menu or through the system.) 20 357.941 ws 18 /Times-Bold sf 16 334.76(1.5) 3 38.5 as 51 334.76(Geometry management) 2 231.45 ws 12 /Times-Roman sf 16 302.36(See iv/src/examples/box[12].) 2 155.98 ws 395.2 38.72(1-9) 3 411.196 as newpath 16.24 302.62 moveto 16.24 303.62 lineto 412.24 303.62 lineto 412.24 302.62 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.576 286.06(#include ) 2 141.516 ws 37.576 274.54(#include ) 2 199.326 ws 37.576 263.02(#include ) 2 180.976 ws 37.576 251.5(#include ) 2 180.416 ws 37.576 234.98(int main\(int argc, char** argv\) {) 10 173.177 ws 45.906 223.46(Session* session = new Session\("Himom", argc, argv\);) 12 288.357 ws 45.906 211.94(WidgetKit& kit = *WidgetKit::instance\(\);) 6 218.467 ws 45.906 200.42(return session->run_window\() 2 174.556 ws 54.236 188.9(new ApplicationWindow\() 2 163.156 ws 62.566 177.38(new Background\() 2 140.376 ws 70.896 165.86(kit.label\("hi mom!"\), kit.background\(\)) 4 231.366 ws 62.566 154.34(\)) 1 65.896 as 54.236 142.82(\)) 1 57.566 as 45.906 131.3(\);) 2 52.016 as 37.576 119.78(}) 1 40.916 as 10 /Helvetica sf 122.056 103.26(Figure 1.5:) 2 169.856 ws 178.186 103.26(InterViews "hi mom!" program.) 6 313.096 ws newpath 16.24 82.57 moveto 16.24 83.57 lineto 412.24 83.57 lineto 412.24 82.57 lineto closepath gsave eofill grestore showpage %%Page: 10 10 90.05 36.94 translate 0 0 0 setrgbcolor 18 /Times-Bold sf 16 667.52(1.6) 3 38.5 as 51 667.52(Creating a push button) 6 229.525 ws 12 /Times-Roman sf 16 635.12(See iv/src/examples/button[123].) 2 174.652 ws 18 /Times-Bold sf 16 593.84(1.7) 3 38.5 as 51 593.84(Summary) 7 126.996 as 12 /Times-Roman sf 16 561.44(This chapter has presented a broad overview of the InterViews architecture,) 20 412 ws 16 547.7(introducing the basic concepts and giving some simple examples. In the next) 23 412 ws 16 533.96(chapter, we focus on the semantics of glyphs as the smallest unit of user interface) 28 412 ws 16 520.22(construction.) 13 78.328 as 395.2 38.72(1-) 2 405.196 as 402.196 38.72(10) 2 414.196 as showpage %%Trailer end restore %%Pages: 10 %!PS-Adobe-2.0 %%Creator: ./ch2.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 16 662.72(Chapter 2) 2 119.321 ws 16 625.76(Glyphs) 6 89.368 as 12 /Times-Roman sf 16 597.44(Glyphs are the basic building blocks for the presentation side of a user) 24 412 ws 16 583.7(interface, providing a unified substrate for interactive objects, structured graphics,) 18 412 ws 16 569.96(and formatted text. The glyph protocol supports geometry, drawing, picking,) 19 412 ws 16 556.22(composition, and structure. Glyph subclasses provide higher-level operations,) 15 412 ws 16 542.48(such as input handling and update management.) 12 246.305 ws 26.668 527.84(The base class defines no storage and operations are passed contextual) 20 412 ws 16 514.1(information during rendering. Thus, glyphs may be shared and a glyph structure) 22 412 ws 16 500.36(need not be strictly hierarchical; it may be a directed acyclic graph. Figure 2.1) 27 412 ws 16 486.62(shows the glyph protocol.) 6 139.997 ws 18 /Times-Bold sf 16 445.34(2.1) 3 38.5 as 51 445.34(Geometry management) 2 231.45 ws 12 /Times-Roman sf 16 412.94(Glyph::request asks a glyph to specify its desired geometry. This operation should) 23 412 ws 16 399.2(be fast to allow a composite glyph to compute rather than store the desired) 26 412 ws 16 385.46(geometry of its components. Glyph::allocate notifies a glyph that a portion of the) 25 412 ws 16 371.72(canvas has been allocated for it and returns an area that represents a conservative) 26 412 ws 16 357.98(estimate of the actual area where the glyph will draw.) 18 273.27 ws 18 /Times-Bold sf 16 316.7(2.2) 3 38.5 as 51 316.7(Drawing) 7 117.996 as 12 /Times-Roman sf 16 284.3(Glyph::draw displays the glyph on the canvas at the position and size specified by) 26 412 ws 16 270.56(the allocation. No clipping or translation is implicit in this operation\261the canvas is) 25 412 ws 16 256.82(the entire drawing area and the allocation is in canvas coordinates. However, a) 25 412 ws 16 243.08(composite glyph may set clipping on the canvas before drawing its children.) 22 381.952 ws 26.668 228.44(There is no guarantee that a call to draw will affect the screen immediately) 26 412 ws 16 214.7(because of the possibility \(indeed, likelihood\) that the canvas is double-buffered.) 20 412 ws 16 200.96(Furthermore, drawing order is important for glyphs when they are partially) 20 412 ws 16 187.22(transparent and are drawn in the same plane. A glyph's draw operation therefore) 25 412 ws 16 173.48(should not be called directly, but rather is implicitly called during screen update.) 24 402.616 ws 26.668 158.84(Glyph::undraw notifies a glyph that its allocation is no longer valid. This) 23 412 ws 16 145.1(operation is generally a performance hint to free cached information associated) 20 412 ws 16 131.36(with drawing or inhibit some operation that is unnecessary while the glyph is not) 26 412 ws 16 117.62(visible, such as cursor blinking. Glyph::undraw is ) 15 264.449 ws 12 /Times-Italic sf 264.449 117.62(not) 3 279.785 as 12 /Times-Roman sf 279.785 117.62( to be used when a glyph's) 12 412 ws 16 103.88(allocation changes; in that case, allocate and draw can simply be called with) 24 412 ws 16 90.14(different parameters.) 2 115.96 ws 26.668 75.5(Glyph::print generates a representation of the glyph graph suitable for printing.) 20 412 ws 16 61.76(The canvas and printer rendering interfaces are identical, and the default) 20 412 ws 388.72 36.08(2-) 2 398.716 as 401.716 36.08(1) 1 407.716 as showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 350.17(implementation of print is simply to call draw. Most glyphs therefore need not) 25 412 ws 16 336.43(define a print operation. The reason for a distinct print operation is to allow) 27 412 ws 16 322.69(a glyph to use different rendering requests for the screen and a printer. For) 27 412 ws 16 308.95(example, a glyph might use 3D requests to the screen, or might compute more) 26 412 ws 16 295.21(precise output for printing.) 6 144.653 ws 26.668 280.57(Glyph::pick finds the glyphs that intersect a point or rectangle specified) 20 412 ws 16 266.83(in canvas-relative coordinates. Conceptually, picking is like drawing and) 16 412 ws 16 253.09(determining what glyphs intersect the specified point or rectangle. The) 19 412 ws 16 239.35(coordinates are contained in the hit parameter. The depth parameter specifies) 21 412 ws 16 225.61(which level in the Hit object to store the intersecting glyphs. When pick returns,) 27 412 ws 16 211.87(the Hit parameter contains the glyphs that were hit.) 16 261.629 ws 26.668 197.23(Figure 2.2 shows the hit protocol. A hit object may be constructed with a point,) 29 412 ws 16 183.49(a rectangle, or an event. In the case of the event, the event pointer coordinates are) 31 412 ws 16 169.75(used to detect intersection and glyphs can associate a handler with the pick result.) 26 407.932 ws 26.668 155.11(Hit::event, Hit::left, Hit::bottom, Hit::right, Hit::top return information about) 14 412 ws 16 141.37(the specified hit area. Hit::event returns nil if the point or rectangle constructors) 25 412 ws 16 127.63(were used.) 2 67.3124 ws 26.668 112.99(Hit::push_transform, Hit::transform, and Hit::pop_transform modify the current) 12 412 ws 16 99.2499(intersection area for picking. These operations are just like the canvas operations) 23 412 ws 16 85.5099(with the same names except they apply to the hit information instead of a canvas.) 28 406.276 ws 26.668 70.8699(Glyphs record information in a hit object with Hit::begin, Hit::target and) 20 412 ws newpath 16 677.74 moveto 16 678.74 lineto 412 678.74 lineto 412 677.74 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.336 661.18(typedef long GlyphIndex;) 4 147.956 ws 37.336 649.66(typedef unsigned int GlyphBreakType;) 6 206.867 ws 37.336 626.62(interface Glyph : Resource {) 8 161.837 ws 45.666 615.1(void request\(Requisition&\) const;) 4 192.386 ws 45.666 603.58(void allocate\(Canvas*, const Allocation&, Extension&\);) 8 286.876 ws 45.666 592.06(void draw\(Canvas*, const Allocation&\) const;) 8 244.627 ws 45.666 580.54(void undraw\(\);) 2 109.016 ws 45.666 569.02(void print\(Printer*, const Allocation&\) const;) 8 237.957 ws 45.666 557.5(void pick\(Canvas*, const Allocation&, int depth, Hit&\);) 12 282.427 ws 45.666 534.46(enum { no_break, pre_break, in_break, post_break };) 12 279.687 ws 45.666 522.94(Glyph* compose\(GlyphBreakType\) const;) 4 229.616 ws 45.666 499.9(void append\(Glyph*\);) 2 139.596 ws 45.666 488.38(void prepend\(Glyph*\);) 2 142.926 ws 45.666 476.86(void insert\(GlyphIndex, Glyph*\);) 4 186.826 ws 45.666 465.34(void remove\(GlyphIndex\);) 2 160.146 ws 45.666 453.82(void replace\(GlyphIndex, Glyph*\);) 4 195.166 ws 45.666 442.3(void change\(GlyphIndext\);) 2 162.386 ws 45.666 430.78(GlyphIndex count\(\) const;) 4 159.606 ws 45.666 419.26(Glyph* component\(GlyphIndex\) const;) 4 214.626 ws 45.666 407.74(void allotment\(GlyphIndext, DimensionName, Allotment&\) const;) 8 330.206 ws 37.336 396.22(}; ) 2 46.2363 ws 10 /Helvetica sf 157.036 379.7(Figure 2.1:) 2 204.836 ws 213.166 379.7(Glyph protocol) 2 277.636 ws newpath 16 371.53 moveto 16 372.53 lineto 412 372.53 lineto 412 371.53 lineto closepath gsave eofill grestore 12 /Times-Roman sf 388.24 36.96(2-) 2 398.236 as 401.236 36.96(2) 1 407.236 as showpage %%Page: 3 3 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 311.21(Hit::end. Hit::target indicates that a glyph's output intersects the hit region.) 21 412 ws 16 297.47(Hit::begin and Hit::end are used by composite glyphs that should be on the hit) 26 412 ws 16 283.73(list if and only if one of their components calls Hit::target. The parameters to) 27 412 ws 16 269.99(Hit::begin and Hit::target have the same meaning. The depth is the level in the hit) 29 412 ws 16 256.25(list where the information should be stored. The glyph is the hit glyph. The index) 30 412 ws 16 242.51(is additional information about the hit. For a composite glyph, this is typically) 25 412 ws 16 228.77(the index of the hit child. Hit::remove and Hit::retarget modify the current hit) 25 412 ws 16 215.03(information.) 12 75.664 as 26.668 200.39(The remaining hit operations return information about a pick. The result is) 23 412 ws 16 186.65(a list of paths, each of which contains a list of glyphs terminating with the) 28 412 ws 16 172.91(glyphs that would draw through the pick region. Hit::count returns the number of) 25 412 ws 16 159.17(paths. Hit::depth returns the index of the last glyph in a specified path. The path) 30 412 ws 16 145.43(corresponding to the top-most glyph is in position zero. Hit::target and Hit::index) 23 412 ws 16 131.69(return the information for a given path and depth.) 16 253.626 ws 26.668 117.05(If a pick is done on a hit object constructed from an event, and one or more) 32 412 ws 16 103.31(glyphs find the event of interest, they will associate a handler with the hit object.) 28 412 ws 16 89.57(Hit::handler returns the top-most, deepest handler, or nil if there is none.) 22 363.953 ws 388.24 36.96(2-) 2 398.236 as 401.236 36.96(3) 1 407.236 as newpath 17.2 647.26 moveto 17.2 648.26 lineto 413.2 648.26 lineto 413.2 647.26 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.536 630.7(interface Hit {) 4 98.0067 ws 46.866 619.18(Hit\(const Event*\);) 2 124.666 ws 46.866 607.66(Hit\(Coord x, Coord y\);) 6 144.107 ws 46.866 596.14(Hit\(Coord left, Coord bottom, Coord right, Coord top\);) 14 282.507 ws 46.866 579.62(const Event* event\(\) const;) 6 166.367 ws 46.866 568.1(Coord left\(\) const, bottom\(\) const, right\(\) const, top\(\) const;) 16 306.957 ws 46.866 551.58(void push_transform\(\);) 2 146.896 ws 46.866 540.06(void transform\(const Transformer&\);) 4 207.456 ws 46.866 528.54(void pop_transform\(\);) 2 141.896 ws 46.866 512.02(void begin\(int depth, Glyph*, GlyphIndex, Handler* = nil\);) 14 297.817 ws 46.866 500.5(void target\(int depth, Glyph*, GlyphIndex, Handler* = nil\);) 14 298.927 ws 46.866 488.98(void end\(\);) 2 94.1064 ws 46.866 477.46(void remove\(int depth, GlyphIndex target = 0\);) 12 250.577 ws 46.866 465.94(void retarget\() 2 105.776 ws 55.196 454.42(int depth, Glyph*, GlyphIndex, Handler* = nil, GlyphIndex = 0) 18 324.227 ws 46.866 442.9(\);) 2 52.976 as 46.866 426.38(boolean any\(\) const;) 4 137.467 ws 46.866 414.86(int count\(\) const;) 4 120.787 ws 46.866 403.34(int depth\(GlyphIndex target = 0\) const;) 10 217.237 ws 46.866 391.82(Glyph* target\(int depth, GlyphIndex target = 0\) const;) 14 281.157 ws 46.866 380.3(GlyphIndex index\(int depth, GlyphIndex = 0\) const;) 12 271.707 ws 46.866 368.78(Handler* handler\(\) const;) 4 158.017 ws 38.536 357.26(};) 2 44.656 as 10 /Helvetica sf 149.626 340.74(Figure 2.2:) 2 197.426 ws 205.756 340.74(Hit class interface.) 4 287.446 ws newpath 17.2 332.57 moveto 17.2 333.57 lineto 413.2 333.57 lineto 413.2 332.57 lineto closepath gsave eofill grestore showpage %%Page: 4 4 90.05 36.94 translate 0 0 0 setrgbcolor 18 /Times-Bold sf 16 667.52(2.3) 3 38.5 as 51 667.52(Composition) 11 149.01 as 12 /Times-Roman sf 16 635.12(BreakType defines the choices for how a composite glyph might break a group of) 26 412 ws 16 621.38(glyphs in a layout. The break may occur before a glyph \(pre_break\), in the glyph) 29 412 ws 16 607.64(\(in_break\), or after the glyph \(post_break\).) 10 221.609 ws 26.668 593(Glyph::compose returns a new glyph that should be used to replace the target) 24 412 ws 16 579.26(glyph when the break occurs. For example, discretionary white space in a) 22 412 ws 16 565.52(document will turn into zero-size glue if a line-break or page-break occurs on it. ) 28 403.576 ws 18 /Times-Bold sf 16 524.24(2.4) 3 38.5 as 51 524.24(Structure) 9 124.98 as 12 /Times-Roman sf 16 491.84(Several operations are provided to manipulate the list of components that make up) 24 412 ws 16 478.1(a composite glyph. Primitive glyphs ignore these operations, while monoglyphs) 19 412 ws 16 464.36(pass the operation through to their body. A monoglyph is therefore ``transparent'') 23 412 ws 16 450.62(with respect to structure, allowing one to put a monoglyph around a composite and) 26 412 ws 16 436.88(pass the result to another object that manipulates the components of the composite.) 24 412 ws 26.668 422.24(Glyph::append \(prepend\) adds a given glyph to the end \(beginning\) of the) 22 412 ws 16 408.5(component list. Glyph::insert adds a given glyph at a specified index in the list.) 27 412 ws 16 394.76(Glyph::remove removes the glyph at the specified index. Glyph::replace replaces) 19 412 ws 16 381.02(the glyph at the specified index with the given glyph. Glyph::change notifies a) 25 412 ws 16 367.28(glyph that its component at the given index has changed, and therefore it might be) 28 412 ws 16 353.54(necessary to reallocate it.) 6 137.297 ws 26.668 338.9(Glyph::count returns the number of glyphs in its component list.) 18 412 ws 16 325.16(Glyph::component returns the glyph in its component list at the given index.) 22 412 ws 16 311.42(Glyph::allotment returns the allocation information in the given dimension for the) 20 412 ws 16 297.68(glyph at the given index in its component list.) 16 235.674 ws 18 /Times-Bold sf 16 256.4(2.5) 3 38.5 as 51 256.4(Requisitions) 12 146.022 as 12 /Times-Roman sf 16 224(Glyphs define their geometric needs with a ) 14 257.632 ws 12 /Times-Italic sf 257.632 224(requisition) 11 309.64 as 12 /Times-Roman sf 309.64 224(, which specifies a) 6 412 ws 12 /Times-Italic sf 16 210.26(requirement) 11 74.656 as 12 /Times-Roman sf 74.656 210.26( in each dimension. Figure 2.3 shows the requisition and requirement) 21 412 ws 16 196.52(class interfaces.) 2 91.9724 ws 26.668 181.88(Requisition::penalty is overloaded to set or get the penalty associated with) 20 412 ws 16 168.14(choosing a break at the position defined by the requisition. Requisition::require) 21 412 ws 16 154.4(sets a requirement in a given dimension. Requisition::requirement returns the) 19 412 ws 16 140.66(requirement for a given dimension.) 8 184.973 ws 26.668 126.02(A requirement consists of a natural size, stretchability, shrinkability, and) 18 412 ws 16 112.28(alignment. The maximum size is the natural size plus the stretchability; the) 23 412 ws 16 98.5401(minimum is the natural minus the shrinkability. It is possible to have negative) 25 412 ws 16 84.8001(minimum sizes. The alignment is a fraction that indicates the origin of the area.) 27 412 ws 16 71.0601(An alignment of zero means the origin is at the lower coordinate value; an) 26 412 ws 388.24 36.96(2-) 2 398.236 as 401.236 36.96(4) 1 407.236 as showpage %%Page: 5 5 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 363.45(alignment of one means it is at the upper coordinate value.) 20 296.957 ws 26.668 348.81(There are four constructors for requirement: with no parameters, which makes) 20 412 ws 16 335.07(the natural size undefined and the other fields zero; with a single coordinate that) 26 412 ws 16 321.33(defines the natural size and makes the other fields zero; with explicit coordinates) 24 412 ws 16 307.59(for the natural size, stretchability, and shrinkability, and a float value for the) 24 412 ws 16 293.85(alignment; and with explicit coordinates for specifying the distances on each side) 22 412 ws 16 280.11(of the origin.) 4 78.3288 ws 26.668 265.47(Requirement::equals compares two requirements \(the target object and the) 16 412 ws 16 251.73(argument\) using a given tolerance for the individual coordinate comparisons.) 18 412 ws 16 237.99(Requirement::defined returns whether the natural size has been defined. The) 19 412 ws 16 224.25(overloaded functions natural, stretch, shrink, and alignment set and get the) 20 412 ws 16 210.51(respective values.) 2 101.308 ws 18 /Times-Bold sf 16 169.23(2.6) 3 38.5 as 51 169.23(Allocations) 11 137.004 as 12 /Times-Roman sf 16 136.83(The actual size a glyph is given is defined by an ) 22 277.876 ws 12 /Times-Italic sf 277.876 136.83(allocation) 10 326.548 as 12 /Times-Roman sf 326.548 136.83(, which specifies) 4 412 ws 16 123.09(an ) 2 32.0257 ws 12 /Times-Italic sf 32.0257 123.09(allotment) 9 77.3617 as 12 /Times-Roman sf 77.3617 123.09( in each dimension. Figure 2.4 shows the allocation and allotment) 21 412 ws 16 109.35(class interfaces. An allotment specifies one dimension of an allocation with three) 22 412 ws 16 95.61(values: an origin, a span, and an alignment. The origin is a position within the) 29 412 ws 16 81.87(allotment and the span is the size of the allotment. The alignment is a fraction) 29 412 ws 16 68.13(specifying the position of the origin. For example, if the origin is 1, span is 10,) 31 412 ws 388.24 36.96(2-) 2 398.236 as 401.236 36.96(5) 1 407.236 as newpath 17.2 677.98 moveto 17.2 678.98 lineto 413.2 678.98 lineto 413.2 677.98 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.536 661.42(interface Requisition {) 4 135.247 ws 46.866 649.9(void penalty\(int\);) 2 120.226 ws 46.866 638.38(int penalty\(\) const;) 4 128.567 ws 46.866 626.86(boolean equals\(const Requisition&, float epsilon\) const;) 10 292.537 ws 46.866 615.34(void require\(DimensionName, const Requirement&\);) 6 278.596 ws 46.866 603.82(const Requirement& requirement\(DimensionName\) const;) 6 303.606 ws 46.866 592.3(Requirement& requirement\(DimensionName\);) 2 250.246 ws 38.536 580.78(};) 2 44.656 as 38.536 564.26(interface Requirement {) 4 143.027 ws 46.866 552.74(Requirement\(Coord natural\);) 2 174.126 ws 46.866 541.22(Requirement\(Coord natural, Coord stretch, Coord shrink, float\);) 12 326.406 ws 46.866 529.7(Requirement\() 12 107.436 as 55.196 518.18(Coord natural_lead, Coord max_lead, Coord min_lead,) 10 298.076 ws 55.196 506.66(Coord natural_trail, Coord max_trail, Coord min_trail) 10 286.927 ws 46.866 495.14(\);) 2 52.976 as 46.866 478.62(boolean equals\(const Requirement&, float epsilon\) const;) 10 300.316 ws 46.866 467.1(boolean defined\(\) const;) 4 154.146 ws 46.866 455.58(void natural\(Coord\), stretch\(Coord\), shrink\(Coord\);) 6 270.806 ws 46.866 444.06(Coord natural\(\) const, stretch\(\) const, shrink\(\) const;) 12 278.047 ws 46.866 432.54(void alignment\(float\);) 2 139.676 ws 46.866 421.02(float alignment\(\) const;) 4 148.017 ws 38.536 409.5(};) 2 44.656 as 10 /Helvetica sf 105.161 392.98(Figure 2.3:) 2 152.961 ws 161.291 392.98(Requisition and Requirement classes. ) 8 331.911 ws newpath 17.2 384.81 moveto 17.2 385.81 lineto 413.2 385.81 lineto 413.2 384.81 lineto closepath gsave eofill grestore showpage %%Page: 6 6 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 393.37(and alignment is 0.5, then the allotment begins at -4 and ends at 6.) 26 333.977 ws 26.668 378.73(The allocation constructor initializes each allotment to have zero values.) 18 412 ws 16 364.99(Allocation::equals compares two allocations using a tolerance for individual) 16 412 ws 16 351.25(coordinate comparisions. Allocation::allot sets the allotment for a given) 17 412 ws 16 337.51(dimension. Allocation::allotment returns the allotment for a specified dimension.) 17 406.144 ws 26.668 322.87(Several operations are provided for convenience when accessing allotments in) 18 412 ws 16 309.13(the X and Y dimensions. Allocation::x and Allocation::y return the X and Y) 25 412 ws 16 295.39(origins. Allocation::left and Allocation::right return the X dimension end-points,) 17 412 ws 16 281.65(Allocation::bottom and Allocation::top return the Y dimension end-points.) 14 373.996 ws 26.668 267.01(The Allotment class also provides an equals operation for comparing two) 20 412 ws 16 253.27(allotments with a given tolerance. Allotment::origin, Allotment::span, and) 15 412 ws 16 239.53(Allotment::alignment are overloaded names for setting and getting the allotment) 18 412 ws 16 225.79(values. Allotment::offset adds to the current origin.) 13 263.477 ws 26.668 211.15(Allotment::begin and Allotment::end return the end-points of an allotment.) 16 412 ws 16 197.41(Allotment::begin is equivalent to the origin minus the alignment times the span.) 22 412 ws 16 183.67(Allotment::end is equivalent to Allotment::begin plus the span.) 14 318.677 ws 18 /Times-Bold sf 16 142.39(2.7) 3 38.5 as 51 142.39(Extensions) 10 134.016 as 12 /Times-Roman sf 16 109.99(The area that defines where a glyph actually draws is called an ) 24 335.848 ws 12 /Times-Italic sf 335.848 109.99(extension) 9 381.172 as 12 /Times-Roman sf 381.172 109.99(. This) 3 412 ws 16 96.25(area is typically used for update. If a glyph needs to be completely redrawn, the) 29 412 ws 16 82.51(glyph's extension must be damaged.) 8 190.985 ws 26.668 67.87(Extensions are represented in device-independent units, but must be rounded) 18 412 ws 388.24 36.96(2-) 2 398.236 as 401.236 36.96(6) 1 407.236 as newpath 16 663.34 moveto 16 664.34 lineto 412 664.34 lineto 412 663.34 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.336 646.78(interface Allocation {) 4 127.937 ws 45.666 635.26(boolean equals\(const Allocation&, float epsilon\) const;) 10 285.227 ws 45.666 623.74(void allot\(DimensionName, const Allotment&\);) 6 249.056 ws 45.666 612.22(Allotment& allotment\(DimensionName\);) 2 220.706 ws 45.666 600.7(const Allotment& allotment\(DimensionName\) const;) 6 274.066 ws 45.666 589.18(Coord x\(\) const, y\(\) const;) 8 160.697 ws 45.666 577.66(Coord left\(\) const, right\(\) const, bottom\(\) const, top\(\) const;) 16 305.757 ws 37.336 566.14(};) 2 43.456 as 37.336 543.1(interface Allotment {) 4 126.267 ws 45.666 531.58(Allotment\(Coord origin, Coord span, float alignment\);) 10 279.087 ws 45.666 520.06(boolean equals\(const Allotment&, float epsilon\) const;) 10 283.557 ws 45.666 508.54(void origin\(Coord\), offset\(Coord\), span\(Coord\);) 6 252.946 ws 45.666 497.02(Coord origin\(\) const, span\(\) const;) 8 196.827 ws 45.666 485.5(void alignment\(float\);) 2 138.476 ws 45.666 473.98(float alignment\(\) const;) 4 146.817 ws 45.666 462.46(Coord begin\(\) const;) 4 136.257 ws 45.666 450.94(Coord end\(\) const;) 4 128.477 ws 37.336 439.42(}; ) 2 46.2364 ws 10 /Helvetica sf 100.346 422.9(Figure 2.4:) 2 148.146 ws 156.476 422.9(Allocation and allotment class interfaces) 8 334.326 ws newpath 16 414.73 moveto 16 415.73 lineto 412 415.73 lineto 412 414.73 lineto closepath gsave eofill grestore showpage %%Page: 7 7 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 503.05(out to the nearest device-dependent units. For example, if one of the bounds for) 27 412 ws 16 489.31(one glyph's extension is 10.2 and another is 10.5, we would need to redraw) 26 412 ws 16 475.57(both glyphs if the bounds translate to the same pixel coordinate. Because) 23 412 ws 16 461.83(extensions are typically used to damage a canvas, the extension coordinates are) 22 412 ws 16 448.09(canvas-relative.) 16 91.636 as 26.668 433.45(A glyph computes its extension as part of the allocate operation. Typically, a) 25 412 ws 16 419.71(glyph will simply return its allocation rounded according to the canvas.) 20 358.301 ws 26.668 405.07(Figure 2.5 shows the Extension protocol. Extension::set initializes an extension) 19 412 ws 16 391.33(to the given allocation transformed and rounded for the given canvas.) 20 412 ws 16 377.59(Extension::clear sets an extension to be an empty area. Extension::merge extends) 21 412 ws 16 363.85(an extension to include a new area in addition to its current one.) 24 322.949 ws 26.668 349.21(Extension::set_xy and Extension::merge_xy are short-hand for adjusting an) 14 412 ws 16 335.47(extension to include a given bounding box. Extension::left, bottom, right, and top) 23 412 ws 16 321.73(return the bounding box.) 6 134.657 ws 18 /Times-Bold sf 16 280.45(2.8) 3 38.5 as 51 280.45(Polyglyphs) 10 135.024 as 12 /Times-Roman sf 16 248.05(A composite glyph contains one or more components. Any glyph subclass) 21 412 ws 16 234.31(may contain subcomponents, but composite glyphs are typically derived from) 18 412 ws 16 220.57(PolyGlyph to be able to store and retrieve their children.) 18 286.625 ws 26.668 205.93(The PolyGlyph protocol, shown in Figure 2.6 adds one operation beyond the) 22 412 ws 16 192.19(base class, PolyGlyph::modified\(GlyphIndex\), which notifies the glyph that the) 16 412 ws 16 178.45(given component has changed. This operation is called when a glyph is inserted) 25 412 ws 16 164.71(or removed from the composite.) 8 170.309 ws 18 /Times-Bold sf 16 123.43(2.9) 3 38.5 as 51 123.43(MonoGlyphs) 10 151.026 as 12 /Times-Roman sf 16 91.03(MonoGlyph is an abstract class for glyphs that contain a single glyph, called its) 26 412 ws 12 /Times-Italic sf 16 77.29(body) 4 39.328 as 12 /Times-Roman sf 39.328 77.29(. The default behavior of monoglyphs is to pass operations on to the body.) 27 412 ws 16 63.55(For example, the implementation of MonoGlyph::draw simply calls draw on) 18 412 ws 388.24 36.96(2-) 2 398.236 as 401.236 36.96(7) 1 407.236 as newpath 20.08 680.86 moveto 20.08 681.86 lineto 416.08 681.86 lineto 416.08 680.86 lineto closepath gsave eofill grestore 10 /Helvetica sf 41.416 664.3(interface Extension { ) 6 135.357 ws 49.746 652.78(void set\(Canvas*, const Allocation&\);) 6 213.697 ws 49.746 641.26(void set_xy\(Canvas*, Coord left, Coord bottom, Coord right, Coord top\);) 18 366.536 ws 49.746 629.74(void clear\(\);) 2 101.976 ws 49.746 618.22(void merge\(const Extension&\);) 4 185.906 ws 49.746 606.7(void merge\(Canvas*, const Allocation&\);) 6 228.697 ws 49.746 595.18(void merge_xy\() 2 118.096 ws 58.076 583.66(Canvas*, Coord left, Coord bottom, Coord right, Coord top) 16 315.407 ws 49.746 572.14(\);) 2 55.856 as 49.746 560.62(Coord left\(\) const, bottom\(\) const, right\(\) const, top\(\) const;) 16 309.837 ws 41.416 549.1(};) 2 47.536 as 10 /Helvetica sf 152.221 532.58(Figure 2.5:) 2 200.021 ws 208.351 532.58(Extension protocol) 2 290.611 ws newpath 20.08 524.41 moveto 20.08 525.41 lineto 416.08 525.41 lineto 416.08 524.41 lineto closepath gsave eofill grestore showpage %%Page: 8 8 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 577.93(the body. This feature is very useful because it means that a monoglyph can) 27 412 ws 16 564.19(affect one aspect of the body's behavior without changing other aspects. In) 23 412 ws 16 550.45(particular, monoglyphs usually do not change structure management. Therefore, a) 19 412 ws 16 536.71(monoglyph can be \252wrapped\272 around a composite glyph and the result passed to) 24 412 ws 16 522.97(an object that modifies the structure of the composite without knowing about the) 24 412 ws 16 509.23(presence of the monoglyph. For example, suppose a prototype menu is built and) 25 412 ws 16 495.49(returned to a function that appends the items. All the function need assume is that) 29 412 ws 16 481.75(the prototype is some glyph; it can use Glyph::append to put in the items. The) 29 412 ws 16 468.01(arrangement of the items will be defined by the aggregate and any additional) 24 412 ws 16 454.27(decoration, such as a 3D borderframe or shadow, can be wrapped around the) 24 412 ws 16 440.53(aggregate independently.) 2 136.636 ws 26.668 425.89(Figure 2.7 shows the MonoGlyph base class interface. A non-nil glyph specifies) 22 412 ws 16 412.15(the initial body. MonoGlyph::body is overloaded to set and return the body.) 23 381.148 ws 14 /Times-Bold sf 16 385.75(2.9.1) 5 44 as 56 385.75(Patches) 7 101.878 as 12 /Times-Roman sf 16 365.31(A patch stores its canvas and allocation for subsequent use to update its body. A) 29 412 ws 16 351.57(patch is useful for objects that need to be redrawn independently, such as those) 26 412 ws 16 337.83(that depend on some external data. Typically, a patch appears in the middle of a) 29 412 ws 16 324.09(glyph instance graph, where a change would be too expensive to redraw the entire) 26 412 ws 16 310.35(graph.) 6 46.324 as 26.668 295.71(Figure 2.8 shows the Patch class interface. Patch::canvas and Patch::allocation) 19 412 ws 16 281.97(return the canvas and allocation most recently passed to Patch::draw.) 18 412 ws 16 268.23(Patch::reallocate calls allocate on the body using the current allocation, usually) 20 412 ws 16 254.49(because the body has changed in some way and will allocate its itself differently.) 26 412 ws 16 240.75(Patch::redraw calls draw on the body using the current allocation. Patch::repick) 21 412 ws 16 227.01(returns the result of calling pick on the body with the current canvas and allocation.) 28 412 ws 388.24 36.96(2-) 2 398.236 as 401.236 36.96(8) 1 407.236 as newpath 16.24 675.1 moveto 16.24 676.1 lineto 412.24 676.1 lineto 412.24 675.1 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.576 658.54(interface PolyGlyph : Glyph {) 8 164.857 ws 45.906 647.02(PolyGlyph\(GlyphIndex initial_size = 10\);) 6 222.917 ws 45.906 635.5(void modified\(GlyphIndex\);) 2 164.836 ws 37.576 623.98(};) 2 43.696 as 10 /Helvetica sf 148.661 607.46(Figure 2.6:) 2 196.461 ws 204.791 607.46(Polyglyph protocol) 2 286.491 ws newpath 16.24 599.29 moveto 16.24 600.29 lineto 412.24 600.29 lineto 412.24 599.29 lineto closepath gsave eofill grestore newpath 16.96 181.42 moveto 16.96 182.42 lineto 412.96 182.42 lineto 412.96 181.42 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.296 164.86(interface MonoGlyph : Glyph {) 8 171.137 ws 46.626 153.34(void body\(Glyph*\);) 2 128.876 ws 46.626 141.82(Glyph* body\(\) const;) 4 137.217 ws 38.296 130.3(}; ) 2 47.1964 ws 10 /Helvetica sf 145.491 113.78(Figure 2.7:) 2 193.291 ws 201.621 113.78(MonoGlyph protocol) 2 291.101 ws newpath 16.96 105.61 moveto 16.96 106.61 lineto 412.96 106.61 lineto 412.96 105.61 lineto closepath gsave eofill grestore showpage %%Page: 9 9 90.05 36.94 translate 0 0 0 setrgbcolor 18 /Times-Bold sf 16 525.85(2.10) 4 47.5 as 51 525.85(Example) 7 119.004 as 12 /Times-Roman sf 16 493.45(See iv/src/examples/circle. ) 4 147.641 ws 388.24 36.96(2-) 2 398.236 as 401.236 36.96(9) 1 407.236 as newpath 14.08 672.94 moveto 14.08 673.94 lineto 410.08 673.94 lineto 410.08 672.94 lineto closepath gsave eofill grestore 10 /Helvetica sf 35.416 656.38(interface Patch : MonoGlyph {) 8 167.707 ws 43.746 644.86(Patch\(Glyph*\);) 14 108.766 as 43.746 633.34(Canvas* canvas\(\) const;) 4 152.117 ws 43.746 621.82(const Allocation& allocation\(\) const;) 6 201.587 ws 43.746 610.3(void reallocate\(\);) 2 117.656 ws 43.746 598.78(void redraw\(\) const;) 4 131.547 ws 43.746 587.26(boolean repick\(int depth, Hit&\);) 6 181.027 ws 35.416 575.74(}; ) 2 44.3164 ws 10 /Helvetica sf 155.391 559.22(Figure 2.8:) 2 203.191 ws 211.521 559.22(Patch protocol) 2 275.441 ws newpath 14.08 551.05 moveto 14.08 552.05 lineto 410.08 552.05 lineto 410.08 551.05 lineto closepath gsave eofill grestore showpage %%Trailer end restore %%Pages: 9 %!PS-Adobe-2.0 %%Creator: ./ch3.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 16 662.72(Chapter 3) 2 119.321 ws 16 625.76(Event processing) 2 190.001 ws 12 /Times-Roman sf 16 597.44(This chapter describes the InterViews mechanisms for processing user input. An) 21 412 ws 12 /Times-Italic sf 16 583.7(event) 5 41.32 as 12 /Times-Roman sf 41.32 583.7( is an object that represents a user input action, such as pressing a mouse) 28 412 ws 16 569.96(button or a keystroke. Events are low-level objects that application code should) 23 412 ws 16 556.22(rarely need to access directly. A ) 13 182.226 ws 12 /Times-Italic sf 182.226 556.22(handler) 7 219.558 as 12 /Times-Roman sf 219.558 556.22( is an object that processes events. An) 15 412 ws 12 /Times-Italic sf 16 542.48(input handler) 2 81.0326 ws 12 /Times-Roman sf 81.0326 542.48( is a glyph that provides a handler that translates events to operations) 24 412 ws 16 528.74(such as press, release, and keystroke.) 10 193.949 ws 18 /Times-Bold sf 16 487.46(3.1) 3 38.5 as 51 487.46(Events) 6 103.002 as 12 /Times-Roman sf 16 455.06(The event class interface is shown in Figure 3.1. Input events arrive in a single) 29 412 ws 16 441.32(stream \(per display\) to an application. EventType is the kind of event \(mouse) 25 412 ws 16 427.58(motion, button down, etc.\). An application receives all window system events,) 21 412 ws 16 413.84(but Event::type is only defined for device input. Other events have the type) 25 412 ws 16 400.1(Event::other_event) 18 107.32 as 10 /Helvetica sf 107.32 400.1(.) 1 110.1 as 12 /Times-Roman sf 110.1 400.1( EventButton is the number of a button on a pointing device,) 23 412 ws 16 386.36(where Event::any refers to any one of the buttons.) 16 255.617 ws 26.668 371.72(Event::window returns the window that received the event. Event::pending) 17 412 ws 16 357.98(tests if more events are waiting to be read. Event::unread puts the event at the) 29 412 ws 16 344.24(front of the input queue for the display.) 14 204.642 ws 393.52 37.04(3-) 2 403.516 as 406.516 37.04(1) 1 412.516 as newpath 17.68 328.78 moveto 17.68 329.78 lineto 413.68 329.78 lineto 413.68 328.78 lineto closepath gsave eofill grestore 10 /Helvetica sf 39.016 312.22(typedef unsigned int EventType;) 6 181.877 ws 39.016 300.7(typedef unsigned long EventTime;) 6 190.207 ws 39.016 289.18(typedef unsigned int EventButton;) 6 188.557 ws 39.016 277.66(typedef unsigned int EventModifierKey;) 6 212.437 ws 39.016 261.14(interface Event {) 4 111.837 ws 47.346 249.62(enum { undefined, motion, down, up, key, other_event };) 16 295.277 ws 47.346 238.1(enum { none, any, left, middle, right, other_button };) 16 274.707 ws 47.346 226.58(enum { control, shift, capslock, meta };) 12 216.317 ws 47.346 210.06(Window* window\(\) const;) 4 159.037 ws 47.346 198.54(boolean pending\(\);) 2 130.726 ws 47.346 187.02(void unread\(\);) 2 109.036 ws 47.346 175.5(EventType type\(\) const;) 4 152.947 ws 47.346 163.98(EventTime time\(\) const;) 4 152.927 ws 47.346 152.46(Coord pointer_x\(\) const, pointer_y\(\) const;) 8 234.637 ws 47.346 140.94(EventButton pointer_button\(\) const;) 4 204.656 ws 47.346 129.42(boolean button_is_down\(EventButton\) const;) 4 246.346 ws 47.346 117.9(boolean modifier_is_down\(EventModifierKey\) const;) 4 277.986 ws 47.346 106.38(unsigned char keycode\(\) const;) 6 186.297 ws 47.346 94.86(unsigned int mapkey\(char*, unsigned int len\) const;) 12 274.117 ws 39.016 83.34(};) 2 45.136 as 10 /Helvetica sf 158.991 66.82(Figure 3.1:) 2 206.791 ws 215.121 66.82(Event protocol) 2 279.041 ws newpath 17.68 58.65 moveto 17.68 59.65 lineto 413.68 59.65 lineto 413.68 58.65 lineto closepath gsave eofill grestore showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 26.668 671.36(Event::time returns a timestamp in milliseconds for the event. Event::pointer_x) 19 412 ws 16 657.62(and Event::pointer_y return the pointer location for the event in coordinates) 20 412 ws 16 643.88(relative to the lower-left corner of the window. Pointer locations are defined) 23 412 ws 16 630.14(for motion, button, and keyboard events. Event::pointer_button returns the) 17 412 ws 16 616.4(EventButton for a down or up event, Event::none for all other events.) 22 412 ws 16 602.66(Event::button_is_down \(Event::modifier_is_down\) returns whether the given) 10 412 ws 16 588.92(button \(modifier key\) was down ) 10 173.645 ws 12 /Times-Italic sf 173.645 588.92(before) 6 204.305 as 12 /Times-Roman sf 204.305 588.92( the event occurred.) 6 298.937 ws 26.668 574.28(Event::keycode returns the code associated with a keystroke. Key codes are) 21 412 ws 16 560.54(potentially platform-specific and should be avoided if possible. Event::mapkey) 17 412 ws 16 546.8(finds the string binding for a given key. Event::mapkey is passed a buffer for) 27 412 ws 16 533.06(the result and the size of the buffer; it returns the number of characters in the) 30 412 ws 16 519.32(translated string. If the event is not a key event, Event::mapkey returns -1.) 25 373.109 ws 18 /Times-Bold sf 16 478.04(3.2) 3 38.5 as 51 478.04(Handlers) 8 122.01 as 12 /Times-Roman sf 16 445.64(A handler is an object that is passed an event to process. The only operation) 29 412 ws 16 431.9(is Handler::event, which translates a raw event into an abstract operation.) 20 412 ws 16 418.16(InputHandler is a monoglygph subclass that uses a handler to translate events.) 22 412 ws 16 404.42(ActiveHandler is a subclass of input handler that detects when the input pointer) 24 412 ws 16 390.68(enters or leaves its body. Figure 3.2 shows the handler, input handler, and active) 27 412 ws 16 376.94(handler protocols.) 2 102.652 ws 26.668 362.3(The InputHandler constructor is passed the glyph body \(which can also) 20 412 ws 16 348.56(be set with MonoGlyph::body\) and a style. Though a glyph can in general) 25 412 ws 16 334.82(have multiple parents, input handlers form a hierarchy for focus management.) 20 412 ws 16 321.08(InputHandler::append_focusable adds a child, setting the child's parent to) 16 412 ws 16 307.34(the target input handler. InputHandler::remove_focusable removes a child.) 15 412 ws 16 293.6(InputHandler::focus sets the current focus for the input handler. The effect of) 23 412 ws 16 279.86(setting focus is that key events \(or in general any focusable event\) will be) 26 412 ws 16 266.12(processed by the focus input handler as opposed to an input handler under the) 26 412 ws 16 252.38(input pointer coordinates.) 4 138.989 ws 26.668 237.74(InputHandler::next_focus and InputHandler::prev_focus move the focus) 10 412 ws 16 224(forward and backward through the children of an input handler.) 18 412 ws 16 210.26(InputHandler::focus_in moves the focus \252down\272 the hierarchy and returns the) 18 412 ws 16 196.52(handler that now has focus. InputHandler::focus_out notifies an input handler) 19 412 ws 16 182.78(that it no longer will receive focusable events, in case it wishes to change its) 28 412 ws 16 169.04(appearance.) 11 72.964 as 26.668 154.4(InputHandler::move, press, drag, release, and keystroke are called by the) 18 412 ws 16 140.66(handler in response to motion, button down, motion while a button is down,) 24 412 ws 16 126.92(button up, and key events. InputHandler::double_click is called when two) 19 412 ws 16 113.18(button down events occurs within a threshold time. The threshold is set by the) 27 412 ws 16 99.4401(\252clickDelay\272 style attribute; the default is 250 milliseconds.) 14 303.305 ws 26.668 84.8001(InputHandler::allocation_changed is a notification that the glyph's size or) 16 412 ws 16 71.0601(position has changed; subclasses can override this operation and therefore) 18 412 ws 393.52 37.04(3-) 2 403.516 as 406.516 37.04(2) 1 412.516 as showpage %%Page: 3 3 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 259.61(typically do not need to define an allocate operation. InputHandler::redraw) 19 412 ws 16 245.87(damages the canvas and area where the input handler was most recently drawn.) 24 396.892 ws 26.668 231.23(The implementation of ActiveHandler notices when motion events first) 16 412 ws 16 217.49(intersect the glyph's body, in which case ActiveHandler::enter is called, and when) 22 412 ws 16 203.75(the motion next leaves the body, in which case ActiveHandler::leave is called.) 22 412 ws 16 190.01(The default enter and leave operations do nothing; subclasses should define these) 22 412 ws 16 176.27(operations as desired.) 4 119.645 ws 18 /Times-Bold sf 16 134.99(3.3) 3 38.5 as 51 134.99(Targets) 7 109.986 as 12 /Times-Roman sf 16 102.59(A ) 2 30.1608 ws 12 /Times-Italic sf 30.1608 102.59(target) 6 58.8288 as 12 /Times-Roman sf 58.8288 102.59( controls the behavior of picking on its body. A target is useful for) 27 412 ws 16 88.8502(defining a pick area that is not identical to the underlying object. For example, if) 29 412 ws 16 75.1102(one wanted to pick in a line of characters then one might wish to interpret the pick) 32 412 ws 16 61.3702(based on the line height instead of the heights of the individual characters. So, a) 29 412 ws 393.52 37.04(3-) 2 403.516 as 406.516 37.04(3) 1 412.516 as newpath 17.68 676.3 moveto 17.68 677.3 lineto 413.68 677.3 lineto 413.68 676.3 lineto closepath gsave eofill grestore 10 /Helvetica sf 39.0159 659.74(interface Handler : Resource {) 8 172.407 ws 47.3459 648.22(boolean event\(Event&\) ;) 4 154.626 ws 39.0159 636.7(};) 2 45.1359 as 39.0159 613.66(interface InputHandler : MonoGlyph {) 8 202.987 ws 47.3459 602.14(InputHandler\(Glyph*, Style*\);) 2 175.726 ws 47.3459 585.62(Handler* handler\(\) const;) 4 158.496 ws 47.3459 574.1(InputHandler* parent\(\) const;) 4 175.736 ws 47.3459 562.58(Style* style\(\) const;) 4 132.927 ws 47.3459 551.06(void append_input_handler\(InputHandler*\);) 2 238.556 ws 47.3459 539.54(void remove_input_handler\(InputHandler*\);) 2 238.536 ws 47.3459 528.02(void focus\(InputHandler*\);) 2 162.946 ws 47.3459 516.5(void next_focus\(\);) 2 126.266 ws 47.3459 504.98(void prev_focus\(\);) 2 126.816 ws 47.3459 493.46(InputHandler* focus_in\(\);) 2 157.946 ws 47.3459 481.94(void focus_out\(\);) 2 121.266 ws 47.3459 465.42(void move\(const Event&\);) 4 161.276 ws 47.3459 453.9(void press\(const Event&\);) 4 161.276 ws 47.3459 442.38(void drag\(const Event&\);) 4 156.836 ws 47.3459 430.86(void release\(const Event&\);) 4 169.616 ws 47.3459 419.34(void keystroke\(const Event&\);) 4 179.616 ws 47.3459 407.82(void double_click\(const Event&\);) 4 191.846 ws 47.3459 391.3(void allocation_changed\(Canvas*, const Allocation&\);) 6 284.116 ws 47.3459 379.78(void redraw\(\) const;) 4 135.147 ws 39.0159 368.26(};) 2 45.1359 as 39.0159 351.74(interface ActiveHandler : InputHandler {) 8 214.097 ws 47.3459 340.22(ActiveHandler\(Glyph*, Style*\);) 2 180.716 ws 47.3459 328.7(void enter\(\);) 2 100.696 ws 47.3459 317.18(void leave\(\);) 2 101.806 ws 39.0159 305.66(};) 2 45.1359 as 10 /Helvetica sf 112.026 289.14(Figure 3.2:) 2 159.826 ws 168.156 289.14(Handler and InputHandler protocols) 6 326.006 ws newpath 17.68 280.97 moveto 17.68 281.97 lineto 413.68 281.97 lineto 413.68 280.97 lineto closepath gsave eofill grestore showpage %%Page: 4 4 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 671.36(pick lower than the top of the ``h'' in ``the'' but above the ``e'' will not miss.) 32 388.264 ws 26.668 656.72(Figure 3.3 shows the target class interface. The target behavior is controlled by) 25 412 ws 16 642.98(the sensitivity parameter to the constructor. TargetPrimitiveHit means the body is) 21 412 ws 16 629.24(hit if the pick region intersects the target's allocation. TargetCharacterHit means) 21 412 ws 16 615.5(the body is hit if the area intersects the target's allocation in the X dimension.) 28 388.288 ws 393.52 37.04(3-) 2 403.516 as 406.516 37.04(4) 1 412.516 as newpath 16.72 414.22 moveto 16.72 415.22 lineto 412.72 415.22 lineto 412.72 414.22 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.056 397.66(enum TargetSensitivity {) 4 145.877 ws 46.386 386.14(TargetPrimitiveHit,) 19 128.616 as 46.386 374.62(TargetCharacterHit) 18 131.406 as 38.056 363.1(};) 2 44.176 as 38.056 346.58(interface Target : MonoGlyph {) 8 173.677 ws 46.386 335.06(Target\(Glyph* body, TargetSensitivity\);) 4 218.666 ws 38.056 323.54(};) 2 44.176 as 10 /Helvetica sf 142.196 307.02(Figure 3.3:) 2 189.996 ws 198.326 307.02(Target class interface) 4 293.916 ws newpath 16.72 298.85 moveto 16.72 299.85 lineto 412.72 299.85 lineto 412.72 298.85 lineto closepath gsave eofill grestore showpage %%Trailer end restore %%Pages: 4 %!PS-Adobe-2.0 %%Creator: ./ch4.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 16 662.72(Chapter 4) 2 119.321 ws 16 625.76(Views) 5 77.32 as 12 /Times-Roman sf 16 597.44(This chapter describes the mechanisms for supporting multiple views of data.) 20 412 ws 16 583.7(Currently, this support consists of three protocols: ) 15 282.301 ws 12 /Times-Italic sf 282.301 583.7(observable) 10 334.957 as 12 /Times-Roman sf 334.957 583.7(, ) 2 343.82 ws 12 /Times-Italic sf 343.82 583.7(observer) 8 385.808 as 12 /Times-Roman sf 385.808 583.7(, and) 2 412 ws 12 /Times-Italic sf 16 569.96(adjustable) 10 66.004 as 12 /Times-Roman sf 66.004 569.96(. An observable object is one that has one or more observers that it can) 29 412 ws 16 556.22(notify \(typically when it changes\). An adjustable object uses an observable for) 23 412 ws 16 542.48(each dimension to keep track of observers that can scroll or zoom the visible areas) 28 412 ws 16 528.74(of the object.) 4 78.9888 ws 18 /Times-Bold sf 16 487.46(4.1) 3 38.5 as 51 487.46(Observable and Observer) 4 249.001 ws 12 /Times-Roman sf 16 455.06(Figure 4.1 shows the observable and observer protocols. An observer can be) 23 412 ws 16 441.32(attached or detached to an observable. Observable::notify calls Observer::update) 17 412 ws 16 427.58(on each of the attached observers. When an observable object is destroyed, it will) 27 412 ws 16 413.84(call Observer::disconnect on any attached observers.) 10 268.601 ws 18 /Times-Bold sf 16 372.56(4.2) 3 38.5 as 51 372.56(Adjustable) 10 135.006 as 12 /Times-Roman sf 16 340.16(An adjustable is an object that handles requests to modify its viewing area. For) 27 412 ws 16 326.42(example, a scrollable list is adjustable in that a scrollbar or other object can) 26 412 ws 16 312.68(request that a particular subrange of items in the list be shown.) 22 316.625 ws 26.668 298.04(Figure 4.2 shows the adjustable protocol. Adjustable::attach and) 15 412 ws 16 284.3(Adjustable::detach add an observer to the list of objects notified when a particular) 24 412 ws 16 270.56(dimension changes. Adjustable::notify calls update on those observers attached to) 19 412 ws 16 256.82(the given dimension. Adjustable::notify_all is equivalent to calling notify on) 19 412 ws 16 243.08(every dimension.) 2 98.6564 ws 393.52 37.04(4-) 2 403.516 as 406.516 37.04(1) 1 412.516 as newpath 16.24 221.98 moveto 16.24 222.98 lineto 412.24 222.98 lineto 412.24 221.98 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.576 205.42(interface Observable {) 4 135.957 ws 45.906 193.9(void attach\(Observer*\);) 2 148.716 ws 45.906 182.38(void detach\(Observer*\);) 2 151.496 ws 45.906 170.86(void notify\(\);) 2 100.366 ws 37.576 159.34(};) 2 43.696 as 37.576 142.82(interface Observer {) 4 125.947 ws 45.906 131.3(void update\(Observable*\);) 2 162.066 ws 45.906 119.78(void disconnect\(Observable*\);) 2 179.286 ws 37.576 108.26(};) 2 43.696 as 10 /Helvetica sf 111.701 91.7399(Figure 4.1:) 2 159.501 ws 167.831 91.7399(Observable and observer protocols) 6 323.451 ws newpath 16.24 83.57 moveto 16.24 84.57 lineto 412.24 84.57 lineto 412.24 83.57 lineto closepath gsave eofill grestore showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 26.668 357.29(Adjustable::lower and Adjustable::upper define a coordinate range for) 14 412 ws 16 343.55(adjustment in a specific dimension. Adjustable::length is equivalent) 15 412 ws 16 329.81(to Adjustable::upper minus Adjustable::lower. Adjustable::cur_lower and) 11 412 ws 16 316.07(Adjustable::cur_upper define the region within a coordinate range that is currently) 20 412 ws 16 302.33(in view. Adjustable::cur_length is equivalent to Adjustable::cur_upper minus) 15 412 ws 16 288.59(Adjustable::cur_lower.) 22 126.316 as 26.668 273.95(Adjustable::scroll_forward and Adjustable::scroll_backward add a small fixed) 12 412 ws 16 260.21(amount to Adjustable::cur_lower \(where the amount is determined by the) 18 412 ws 16 246.47(adjustable object\). Adjustable::page_forward and Adjustable::page_backward) 9 412 ws 16 232.73(add a larger fixed amount. Adjustable::scroll_to sets the adjustable's current) 19 412 ws 16 218.99(lower coordinate to a specific value. Adjustable::scale_to sets the current length) 21 412 ws 16 205.25(to a given fraction of the total length. Adjustable::zoom_to sets the scale in) 25 412 ws 16 191.51(all dimensions at once. Adjustable::constrain restricts a value to be within the) 23 412 ws 16 177.77(adjustable's lower and upper bounds.) 8 194.969 ws 12 /Times-Italic sf 26.668 163.13(Example: see iv/src/examples/bvalue/main.c.) 4 242.62 ws 18 /Times-Bold sf 16 121.85(4.3) 3 38.5 as 51 121.85(View) 4 89.988 as 12 /Times-Italic sf 16 89.4501(This section will be completed in the future.) 14 226.002 ws 12 /Times-Roman sf 393.52 37.04(4-) 2 403.516 as 406.516 37.04(2) 1 412.516 as newpath 17.2 670.3 moveto 17.2 671.3 lineto 413.2 671.3 lineto 413.2 670.3 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.536 653.74(interface Adjustable {) 4 132.477 ws 46.866 642.22(Observable* observable\(DimensionName\) const;) 4 263.596 ws 46.866 630.7(void attach\(DimensionName, Observer*\);) 4 229.136 ws 46.866 619.18(void detach\(DimensionName, Observer*\);) 4 231.916 ws 46.866 607.66(void notify\(DimensionName\) const;) 4 201.906 ws 46.866 596.14(void notify_all\(\) const;) 4 143.567 ws 46.866 579.62(Coord lower\(DimensionName\) const;) 4 210.786 ws 46.866 568.1(Coord upper\(DimensionName\) const;) 4 212.466 ws 46.866 556.58(Coord length\(DimensionName\) const;) 4 214.136 ws 46.866 545.06(Coord cur_lower\(DImensionName\) const;) 4 230.796 ws 46.866 533.54(Coord cur_upper\(DimensionName\) const;) 4 231.916 ws 46.866 522.02(Coord cur_length\(DimensionName\) const;) 4 233.586 ws 46.866 505.5(void scroll_forward\(DimensionName\);) 2 213.556 ws 46.866 493.98(void scroll_backward\(DimensionName\);) 2 223.006 ws 46.866 482.46(void page_forward\(DimensionName\);) 2 212.466 ws 46.866 470.94(void page_backwards\(DimensionName\);) 2 226.916 ws 46.866 454.42(void scroll_to\(DImensionName, Coord lower\);) 6 248.576 ws 46.866 442.9(void scale_to\(DimensionName, float fraction\);) 6 248.596 ws 46.866 431.38(void zoom_to\(float magnification\);) 4 196.366 ws 46.866 414.86(void constrain\(DimensionName, Coord&\) const;) 6 258.036 ws 38.536 403.34(};) 2 44.656 as 10 /Helvetica sf 147.951 386.82(Figure 4.2:) 2 195.751 ws 204.081 386.82(Adjustable protocol) 2 289.121 ws newpath 17.2 378.65 moveto 17.2 379.65 lineto 413.2 379.65 lineto 413.2 378.65 lineto closepath gsave eofill grestore showpage %%Page: 3 3 90.05 36.94 translate 0 0 0 setrgbcolor 18 /Times-Bold sf 16 667.52(4.4) 3 38.5 as 51 667.52(Data) 4 87.99 as 12 /Times-Italic sf 16 635.12(This section will be completed in the future.) 14 226.002 ws 18 /Times-Bold sf 16 593.84(4.5) 3 38.5 as 51 593.84(Inset) 5 88.998 as 12 /Times-Italic sf 16 561.44(This section will be completed in the future.) 14 226.002 ws 12 /Times-Roman sf 393.52 37.04(4-) 2 403.516 as 406.516 37.04(3) 1 412.516 as showpage %%Trailer end restore %%Pages: 3 %!PS-Adobe-2.0 %%Creator: ./ch5.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 16 662.72(Chapter 5) 2 119.321 ws 16 625.76(Windows) 7 112.024 as 12 /Times-Roman sf 16 597.44(The previous chapters covered the composition of physical \(glyphs\) and logical) 20 412 ws 16 583.7(\(views\) objects. This chapter discusses the other objects necessary to manage) 20 412 ws 16 569.96(where glyphs are drawn. A ) 11 151.512 ws 12 /Times-Italic sf 151.512 569.96(window) 6 188.856 as 12 /Times-Roman sf 188.856 569.96( is an object that can be mapped onto a ) 20 380.68 ws 12 /Times-Italic sf 380.68 569.96(screen) 6 412 as 12 /Times-Roman sf 16 556.22(and receive input. Associated with a window is the root of a directed acyclic graph) 29 412 ws 16 542.48(of glyphs. The window creates a ) 13 182.573 ws 12 /Times-Italic sf 182.573 542.48(canvas) 6 215.897 as 12 /Times-Roman sf 215.897 542.48( that is bound to a portion of the screen) 18 412 ws 16 528.74(when the window is mapped. The window calls Glyph::draw on the root glyph to) 27 412 ws 16 515(refresh the canvas and Glyph::pick to determine what to do with input events) 24 385.948 ws 26.668 500.36(Figure 5.1 shows the Window base class interface. Window::style sets or) 21 412 ws 16 486.62(gets the style associated with the window. Several style attributes control) 21 412 ws 16 472.88(characteristics of a window: \252double_buffered\272 controls whether the window is) 19 412 ws 16 459.14(double-buffered by default, \252visual\272 specifies the name of a visual to use for the) 26 412 ws 16 445.4(window, \252visual_id\272 specifies the id of the desired visual, and \252overlay\272 specifies) 22 412 ws 16 431.66(whether overlay planes should be used for the window.) 16 280.949 ws 390.64 37.04(5-) 2 400.636 as 403.636 37.04(1) 1 409.636 as newpath 17.92 402.22 moveto 17.92 403.22 lineto 413.92 403.22 lineto 413.92 402.22 lineto closepath gsave eofill grestore 10 /Helvetica sf 39.256 385.66(interface Window {) 4 122.067 ws 47.586 374.14(Window\(Glyph* = nil\);) 4 143.997 ws 47.586 362.62(void style\(Style*\);) 2 124.826 ws 47.586 351.1(Style* style\(\) const;) 4 133.167 ws 47.586 339.58(void display\(Display*\);) 2 145.936 ws 47.586 328.06(Display* display\(\) const;) 4 154.277 ws 47.586 316.54(Canvas* canvas\(\) const;) 4 155.956 ws 47.586 305.02(void cursor\(Cursor*\);) 2 139.816 ws 47.586 293.5(Cursor* cursor\(\) const;) 4 148.157 ws 47.586 281.98(void push_cursor\(\);) 2 133.166 ws 47.586 270.46(void pop_cursor\(\);) 2 128.166 ws 47.586 247.42(void place\(Coord left, Coord bottom\);) 8 211.537 ws 47.586 235.9(void align\(float x, float y\);) 8 158.187 ws 47.586 224.38(Coord left\(\) const, bottom\(\) const, width\(\) const, height\(\) const;) 16 324.907 ws 47.586 201.34(void map\(\), unmap\(\);) 4 140.387 ws 47.586 189.82(boolean is_mapped\(\) const;) 4 170.976 ws 47.586 178.3(void raise\(\), lower\(\);) 4 135.927 ws 47.586 166.78(void move\(Coord left, Coord bottom\);) 8 212.087 ws 47.586 155.26(void resize\(\);) 2 104.816 ws 47.586 132.22(void receive\(const Event&\);) 4 169.296 ws 47.586 120.7(void grab_pointer\(Cursor* = nil\) const;) 8 216.257 ws 47.586 109.18(void ungrab_pointer\(\) const;) 4 172.086 ws 47.586 97.6601(void repair\(\);) 2 103.706 ws 39.256 86.1401(}; ) 2 48.1564 ws 10 /Helvetica sf 154.236 69.6201(Figure 5.1:) 2 202.036 ws 210.366 69.6201(Window protocol) 2 284.276 ws newpath 17.92 61.45 moveto 17.92 62.45 lineto 413.92 62.45 lineto 413.92 61.45 lineto closepath gsave eofill grestore showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 26.668 671.36(Window::display sets or gets the display that a window is mapped on \(or nil if) 28 412 ws 16 657.62(the window is not currently mapped\). Window::canvas returns the canvas that the) 23 412 ws 16 643.88(window passes to its glyph for drawing.) 12 207.653 ws 26.668 629.24(Window::cursor sets or gets the image that tracks a pointing device's position) 22 412 ws 16 615.5(when the it is inside the window. Cursors are defined by two bitmaps and) 27 412 ws 16 601.76(a ``hot spot''. The mask bitmap specifies which pixels are to be drawn,) 25 412 ws 16 588.02(and the pattern bitmap specifies which pixels are in foreground color and) 22 412 ws 16 574.28(which are in background color. The hot spot specifies the location of the) 25 412 ws 16 560.54(pointing device relative to the cursor's lower-left corner. The foreground and) 21 412 ws 16 546.8(background colors for a cursor are defined by the attributes \252pointerColor\272 and) 22 412 ws 16 533.06(\252pointerColorBackground\272 in the window's style.) 8 255.641 ws 26.668 518.42(Figure 5.2 shows the cursor protocol. A cursor can be created from specific) 24 412 ws 16 504.68(data, pattern and mask bitmaps, a character in a font, or an index into the standard) 30 412 ws 16 490.94(cursor information for the target window system. If the cursor is specified with) 25 412 ws 16 477.2(bitmaps, the hot spot is the origin of the pattern bitmap; if specified with a) 28 412 ws 16 463.46(character, it is the origin of the character's bitmap in the font. An index implies) 29 412 ws 16 449.72(both bitmaps as well as the hot spot. Specific values for the index are usually) 29 412 ws 16 435.98(defined in an include file. For example, standard X11 cursors are defined in the) 27 412 ws 16 422.24(file .) 2 133.852 ws 26.668 407.6(Window::place specifies the desired screen coordinates for a window.) 16 412 ws 16 393.86(Window::align specifies a desired alignment. The alignment values are fractions) 19 412 ws 16 380.12(that indicate where the window should appear relative to its coordinates as) 22 412 ws 16 366.38(specified by a call to Window::place. For example, an alignment of 0.0,1.0 means) 25 412 ws 16 352.64(the placement specifies the upper-left corner of the window. An alignment of) 23 412 ws 16 338.9(0.5,0.5 means the placement specifies the center of the window. Unless specified,) 23 412 ws 16 325.16(the alignment will be 0.0,0.0, meaning the placement coordinates specify the) 20 412 ws 16 311.42(lower-left corner of the window.) 8 172.289 ws 26.668 296.78(Window::map requests the window to be mapped onto the screen. If no display) 25 412 ws 16 283.04(has been set, then the session's default display is used. Window::map may be) 25 412 ws 16 269.3(asynchronous\261one cannot assume the window is usable immediately after calling) 18 412 ws 16 255.56(map. Window::unmap requests that the window be removed from the screen.) 21 387.436 ws 26.668 240.92(Window::raise and Window::lower control the stacking order of a window on) 20 412 ws 16 227.18(the screen. Window::raise makes the window above all the other windows on the) 25 412 ws 16 213.44(screen; Window::lower make the window below all the others. These operations) 21 412 ws 16 199.7(usually are neither necessary nor appropriate, as stacking order should normally) 20 412 ws 390.96 37.2(5-) 2 400.956 as 403.956 37.2(2) 1 409.956 as newpath 16.9601 172.78 moveto 16.9601 173.78 lineto 412.96 173.78 lineto 412.96 172.78 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.2961 156.22(interface Cursor {) 4 115.547 ws 46.6261 144.7(Cursor\(short x, short y, const int* pattern, const int* mask\);) 18 305.607 ws 46.6261 133.18(Cursor\(const Bitmap* pat, const Bitmap* mask\);) 10 258.357 ws 46.6261 121.66(Cursor\(const Font*, int pattern, int mask\);) 10 229.467 ws 46.6261 110.14(Cursor\(int index\);) 2 123.306 ws 38.2961 98.62(}; ) 2 47.1964 ws 10 /Helvetica sf 141.886 82.1(Figure 5.2:) 2 189.686 ws 198.016 82.1(Cursor class interface) 4 294.706 ws newpath 16.9601 73.93 moveto 16.9601 74.93 lineto 412.96 74.93 lineto 412.96 73.93 lineto closepath gsave eofill grestore showpage %%Page: 3 3 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 671.36(be under control of the user through a window manager.) 18 285.941 ws 26.668 656.72(The window systems delivers input events to a particular window, which in turn) 24 412 ws 16 642.98(tries to find a handler to process each event. Window::receive examines an event,) 25 412 ws 16 629.24(handling window maintenance events internally. For example, X expose and) 19 412 ws 16 615.5(configure events are handled directly by Window::receive.) 12 297.593 ws 26.668 600.86(Window::grab_pointer takes control of pointer input events for the display.) 18 412 ws 16 587.12(Other applications will not receive pointer events until Window::ungrab_pointer) 16 412 ws 16 573.38(is called to release control. If a cursor is passed to Window::grab_pointer, it will) 27 412 ws 16 559.64(be used when the pointer is outside the window during the grab.) 22 323.297 ws 26.668 545(If any part of a window's canvas has been damaged, Window::repair will) 22 412 ws 16 531.26(call draw on the root glyph and perform the necessary screen update when) 24 412 ws 16 517.52(double-buffering. All windows on a display will be repaired automatically) 19 412 ws 16 503.78(before blocking for input from the display, so applications usually need not call) 24 412 ws 16 490.04(Window::repair directly. ) 4 137.645 ws 18 /Times-Bold sf 16 448.76(5.1) 3 38.5 as 51 448.76(ManagedWindow) 13 188.016 as 12 /Times-Roman sf 16 416.36(A managed window specifies information for a window manager to use.) 20 412 ws 16 402.62(ManagedWindow is an abstract base class with four predefined descendants:) 18 412 ws 16 388.88(ApplicationWindow, TopLevelWindow, TransientWindow, and IconWindow.) 8 412 ws 16 375.14(An application should create one application window, which makes information) 18 412 ws 16 361.4(about command-line arguments available to a session manager, if present on the) 22 412 ws 16 347.66(system. After the application window, normal windows are top-level. A top-level) 22 412 ws 16 333.92(window can have a ``group leader'', which is typically the application window. A) 25 412 ws 16 320.18(window manager may allow quick control of all windows with the same group) 24 412 ws 16 306.44(leader, such as when iconifying or deiconifying.) 12 247.289 ws 26.668 291.8(A transient window is often treated specially by window managers. It may be) 25 412 ws 16 278.06(decorated differently \(or not at all\), or automatically unmapped when the main) 22 412 ws 16 264.32(window is iconified. Transient windows are used for temporary controls, such as) 23 412 ws 16 250.58(dialog boxes, but not for unmanaged windows such as popups or pulldowns. A) 25 412 ws 16 236.84(transient is usually associated with another managed window.) 14 312.629 ws 26.668 222.2(An icon window is a window that is mapped when its associated window) 24 412 ws 16 208.46(is iconified and unmapped when its associated window is deiconified. Calling) 21 412 ws 16 194.72(Window::map on an icon window will therefore bind it to the window system, but) 26 412 ws 16 180.98(will not map it on the screen.) 12 155.658 ws 26.668 166.34(Figure 5.3 shows the ManagedWindow protocol. Most of the operations on) 20 412 ws 16 152.6(a managed window set or return information associated with the window. In) 23 412 ws 16 138.86(addition, ManagedWindow interprets additional attributes in its style inherited) 16 412 ws 16 125.12(from the base class. The attribute \252name\272 specifies a string name for the) 25 412 ws 16 111.38(window manager to use, \252iconName\272 specifies a string for the window's icon,) 22 412 ws 16 97.6401(\252geometry\272 specifies the desired geometry, and \252iconGeometry\272 specifies the) 16 412 ws 16 83.9001(desired geometry for the window's icon. Geometry specifications are strings of) 21 412 ws 16 70.1601(the form ``WxH+X+Y'' where W is the width, H the height, X the left corner, and) 30 412 ws 390.96 37.2(5-) 2 400.956 as 403.956 37.2(3) 1 409.956 as showpage %%Page: 4 4 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 422.93(Y the top corner of the window. Either the position or the size may be omitted,) 31 412 ws 16 409.19(and the position can use ``\261'' instead of ``+'' to denote distance from the opposite) 28 412 ws 16 395.45(of the display to the opposite side of the window. For example, a \261X value) 29 412 ws 16 381.71(specifies that the right side of the window should be a distance of X from the right) 32 412 ws 16 367.97(edge of the screen.) 6 105.965 ws 26.668 353.33(ManagedWindow::icon_bitmap and ManagedWindow::icon_mask specify two) 8 412 ws 16 339.59(bitmaps to use to draw an icon. The mask defines the area to be drawn and the) 33 412 ws 16 325.85(bitmap defines the foreground and background areas. Pixels that correspond to a) 23 412 ws 16 312.11(one in the bitmap and a one in the mask are drawn with the foreground color.) 30 412 ws 16 298.37(Pixels that correspond to a zero in the bitmap and a one in the mask are draw with) 34 412 ws 16 284.63(the background color. Pixels that correspond to a zero in the mask are not drawn.) 29 406.756 ws 26.668 269.99(ManagedWindow::icon specifies a second window to map when the first) 18 412 ws 16 256.25(window is iconified. Using a window as an icon overrides the other icon) 25 412 ws 16 242.51(information. Therefore, it does not make sense to use ManagedWindow::icon) 19 412 ws 16 228.77(in conjunction with icon_bitmap, icon_mask, or the \252iconName\272 and) 16 412 ws 16 215.03(\252iconGeometry\272 attributes.) 2 145.972 ws 26.668 200.39(ManagedWindow::iconic specifies the initial state of a window. If iconic is true,) 23 412 ws 16 186.65(mapping a window will actually map its icon instead. ManagedWindow::iconic) 19 412 ws 16 172.91(need not be called directly by an application; it is called automatically if specified) 26 412 ws 16 159.17(by user customization information.) 6 183.989 ws 26.668 144.53(ManagedWindow::iconify requests the window be unmapped and the window's) 16 412 ws 16 130.79(icon be mapped to the screen. ManagedWindow::deiconify reverses the operation,) 19 412 ws 16 117.05(unmapping the icon and mapping the original window. It does not make sense to) 27 412 ws 16 103.31(iconify or deiconify an icon window.) 10 193.973 ws 26.668 88.67(ManagedWindow::focus_event specifies handlers for the window receiving and) 14 412 ws 16 74.93(losing keyboard focus from the window manager. ManagedWindow::wm_delete) 15 412 ws 16 61.19(specifies a handler for a request from the window manager to delete the window.) 26 412 ws 390.96 37.2(5-) 2 400.956 as 403.956 37.2(4) 1 409.956 as newpath 15.04 663.34 moveto 15.04 664.34 lineto 411.04 664.34 lineto 411.04 663.34 lineto closepath gsave eofill grestore 10 /Helvetica sf 36.376 646.78(interface ManagedWindow : Window {) 8 204.777 ws 44.706 635.26(void icon_bitmap\(Bitmap*\);) 2 164.186 ws 44.706 623.74(Bitmap* icon_bitmap\(\) const;) 4 172.526 ws 44.706 612.22(void icon_mask\(Bitmap*\);) 2 158.066 ws 44.706 600.7(Bitmap* icon_mask\(\) const;) 4 166.407 ws 44.706 584.18(void icon\(ManagedWindow*\);) 2 174.746 ws 44.706 572.66(ManagedWindow* icon\(\) const;) 4 183.086 ws 44.706 549.62(void iconic\(boolean\);) 2 136.406 ws 44.706 538.1(boolean iconic\(\) const;) 4 144.747 ws 44.706 526.58(void iconify\(\);) 2 103.606 ws 44.706 515.06(void deiconify\(\);) 2 114.726 ws 44.706 492.02(void focus_event\(Handler* in, Handler* out\);) 8 239.787 ws 44.706 480.5(void wm_delete\(Handler*\);) 2 162.516 ws 36.376 468.98(}; ) 2 45.2764 ws 10 /Helvetica sf 116.341 452.46(Figure 5.3:) 2 164.141 ws 172.471 452.46(ManagedWindow class interface) 4 316.411 ws newpath 15.04 444.29 moveto 15.04 445.29 lineto 411.04 445.29 lineto 411.04 444.29 lineto closepath gsave eofill grestore showpage %%Page: 5 5 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 399.13(If the handler is nil \(which is the initial value\), then the response to this event will) 32 412 ws 16 385.39(be to call Session::quit.) 6 128.009 ws 26.668 370.75(Figure 5.4 shows the operations on the ManagedWindow subclasses.) 16 412 ws 16 357.01(ApplicationWindow and IconWindow provide no additional operations beyond a) 16 412 ws 16 343.27(constructor. TopLevelWindow provides an operation to set or return its group) 21 412 ws 16 329.53(leader. TransientWindow is a subclass to TopLevelWindow that can additionally) 19 412 ws 16 315.79(be associated with a primary window with TransientWindow::transient_for. ) 16 382.948 ws 18 /Times-Bold sf 16 274.51(5.2) 3 38.5 as 51 274.51(PopupWindow) 11 166.038 as 12 /Times-Roman sf 16 242.11(A popup window is mapped directly to a screen without window manager) 22 412 ws 16 228.37(interaction \(or knowledge\). In the X Window System, a popup window will) 24 412 ws 16 214.63(override the normal redirection of map requests to window managers. Popups on) 23 412 ws 16 200.89(X also will request that the pixels under the popup be saved to avoid a subsequent) 30 412 ws 16 187.15(exposure when the popup is unmapped.) 10 205.973 ws 26.668 172.51(Popups should only be used for temporary windows, such as popup or pulldown) 24 412 ws 16 158.77(menus. Because they do not go through the window manager, popups should be) 25 412 ws 16 145.03(placed explicitly. Here is an example of using a popup that appears below a) 27 412 ws 16 131.29(menubar, aligning the top of the popup to the lower left corner of the menubar:) 28 394.936 ws 10 /Helvetica sf 32.66 112.81(void pulldown\(Window* menubar, Glyph* g\) {) 10 231.621 ws 40.99 101.29(PopupWindow* popup = new PopupWindow\(g\);) 8 251.921 ws 49.32 89.77(popup->place\(menubar->left\(\), menubar\(\)->bottom\(\)\);) 2 286.34 ws 49.32 78.25(popup->align\(0.0, 1.0\);) 2 150.21 ws 49.32 66.73(popup->map\(\); ) 2 117.96 ws 12 /Times-Roman sf 390.96 37.2(5-) 2 400.956 as 403.956 37.2(5) 1 409.956 as newpath 16.9601 669.1 moveto 16.9601 670.1 lineto 412.96 670.1 lineto 412.96 669.1 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.2961 652.54(interface ApplicationWindow : ManagedWindow {) 8 255.607 ws 46.6261 641.02(ApplicationWindow\(Glyph*\);) 26 170.546 as 38.2961 629.5(};) 2 44.416 as 38.2961 606.46(interface TopLevelWindow : ManagedWindow {) 8 247.827 ws 46.6261 594.94(TopLevelWindow\(Glyph*\);) 23 162.766 as 46.6261 583.42(void group_leader\(ManagedWindow*\);) 2 217.246 ws 46.6261 571.9(ManagedWindow* group_leader\(\) const;) 4 225.586 ws 38.2961 560.38(};) 2 44.416 as 38.2961 537.34(interface TransientWindow : TopLevelWindow {) 8 247.817 ws 46.6261 525.82(TransientWindow\(Glyph*\);) 24 163.316 as 46.6261 514.3(void transient_for\(ManagedWindow*\);) 2 213.906 ws 46.6261 502.78(void ManagedWindow* transient_for\(\) const;) 6 243.367 ws 38.2961 491.26(};) 2 44.416 as 38.2961 468.22(interface IconWindow : ManagedWindow {) 8 225.597 ws 46.6261 456.7(IconWindow\(Glyph*\);) 19 140.536 as 38.2961 445.18(}; ) 2 47.1964 ws 10 /Helvetica sf 125.486 428.66(Figure 5.4:) 2 173.286 ws 181.616 428.66(ManagedWindow subclasses) 2 311.106 ws newpath 16.9601 420.49 moveto 16.9601 421.49 lineto 412.96 421.49 lineto 412.96 420.49 lineto closepath gsave eofill grestore showpage %%Page: 6 6 90.05 36.94 translate 0 0 0 setrgbcolor 10 /Helvetica sf 32.66 672.32(}) 1 36 as 18 /Times-Bold sf 16 617.56(5.3) 3 38.5 as 51 617.56(Display) 7 109.014 as 12 /Times-Roman sf 16 585.16(A ) 2 29.0449 ws 12 /Times-Italic sf 29.0449 585.16(display) 7 63.7129 as 12 /Times-Roman sf 63.7129 585.16( is the unit of window system control; typically it consists of a single) 26 412 ws 16 571.42(screen, keyboard, and a mouse or other pointing device. Application objects) 21 412 ws 16 557.68(typically need not deal directly with a display; the functionality of the window) 24 412 ws 16 543.94(class is normally sufficient.) 6 147.989 ws 26.668 529.3(Figure 5.5 shows the display class interface. Display::open is a static member) 23 412 ws 16 515.56(function that opens a connection to the display with the given name. The) 25 412 ws 16 501.82(interpretation of a display name is system-dependent. On X, the name is) 23 412 ws 12 /Times-Italic sf 16 488.08(host:number) 11 76.66 as 12 /Times-Roman sf 76.66 488.08( where ) 4 112.96 ws 12 /Times-Italic sf 112.96 488.08(host) 4 132.964 as 12 /Times-Roman sf 132.964 488.08( is a machine's hostname and ) 12 279.892 ws 12 /Times-Italic sf 279.892 488.08(number) 6 316.552 as 12 /Times-Roman sf 316.552 488.08( is the index for the) 10 412 ws 16 474.34(display connected to that host \(typically 0\). If successful, Display::open returns) 21 412 ws 16 460.6(a pointer to a display object. If not successful, it returns nil. Display::close) 26 412 ws 16 446.86(terminates the connection.) 4 142.313 ws 26.668 432.22(Display::width and Display::height return the dimensions in coordinates of) 16 412 ws 16 418.48(the display's current screen. Display::a_width and Display::a_height return the) 17 412 ws 16 404.74(dimensions in points \(72 points = one inch\).) 14 227.442 ws 390.96 37.2(5-) 2 400.956 as 403.956 37.2(6) 1 409.956 as newpath 17.2 383.26 moveto 17.2 384.26 lineto 413.2 384.26 lineto 413.2 383.26 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.536 366.7(interface Display {) 4 118.567 ws 46.866 355.18(static Display* open\(const String&\);) 6 203.587 ws 46.866 343.66(static Display* open\(\);) 4 144.117 ws 46.866 332.14(virtual void close\(\);) 4 130.217 ws 46.866 315.62(virtual Coord width\(\) const;) 6 165.787 ws 46.866 304.1(virtual Coord height\(\) const;) 6 169.687 ws 46.866 292.58(virtual Coord a_width\(\) const;) 6 176.907 ws 46.866 281.06(virtual Coord a_height\(\) const;) 6 180.807 ws 46.866 269.54(int to_pixels\(Coord\) const;) 4 163.017 ws 46.866 258.02(Coord to_coord\(int\) const;) 4 162.467 ws 46.866 241.5(virtual void set_screen\(int\);) 4 166.347 ws 46.866 224.98(virtual void style\(Style*\);) 4 153.557 ws 46.866 213.46(virtual Style* style\(\) const;) 6 161.897 ws 46.866 196.94(virtual void repair\(\);) 4 132.437 ws 46.866 185.42(virtual void flush\(\);) 4 127.997 ws 46.866 173.9(virtual void sync\(\)) 4 124.657 ws 46.866 157.38(virtual void ring_bell\(int\);) 4 155.227 ws 46.866 145.86(virtual void set_key_click\(int\);) 4 176.896 ws 46.866 134.34(virtual void set_auto_repeat\(boolean\);) 4 214.726 ws 46.866 122.82(virtual void set_pointer_feedback\(int thresh, int scale\);) 10 285.857 ws 46.866 111.3(virtual void move_pointer\(Coord x, Coord y\);) 10 243.037 ws 38.536 99.7801(};) 2 44.656 as 10 /Helvetica sf 139.346 83.2601(Figure 5.5:) 2 187.146 ws 195.476 83.2601(Display class interface.) 4 297.726 ws newpath 17.2 75.09 moveto 17.2 76.09 lineto 413.2 76.09 lineto 413.2 75.09 lineto closepath gsave eofill grestore showpage %%Page: 7 7 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 26.668 671.36(Display::to_pixels and Display::to_coord convert between coordinates and) 12 412 ws 16 657.62(pixels. The conversion is a function of the ) 17 231.582 ws 12 /Times-Italic sf 231.582 657.62(dpi) 3 246.918 as 12 /Times-Roman sf 246.918 657.62( attribute, which is 75 by default.) 12 412 ws 16 643.88(One coordinate unit length is a printer's point, defined as 72/) 20 308.297 ws 12 /Times-Italic sf 308.297 643.88(dpi) 3 323.633 as 12 /Times-Roman sf 323.633 643.88( pixels.) 2 358.301 ws 26.668 629.24(Display::set_screen sets the current screen to use for display operations.) 18 412 ws 16 615.5(Initially, current screen is set to 0.) 12 179.31 ws 26.668 600.86(Display::repair calls Window::repair for each window on the display that has) 20 412 ws 16 587.12(a canvas with damage. It is not necessary to call Display::repair directly, as) 25 412 ws 16 573.38(windows will automatically be repaired before blocking for input events.) 18 365.945 ws 26.668 558.74(Display::flush and Display::sync are used to synchronize with the window) 18 412 ws 16 545(system. Display::flush repairs all damaged windows on the display and ensures) 21 412 ws 16 531.26(that any pending requests have been sent to the window system. Display::sync is) 25 412 ws 16 517.52(the same as Display::flush, but additionally waits for an acknowledgement from) 20 412 ws 16 503.78(the window system.) 4 111.665 ws 26.668 489.14(Display::ring_bell sounds the workstation's bell at a specified volume. The) 19 412 ws 16 475.4(parameter should be between 0 and 100, where 0 is silent and 100 is the loudest) 30 412 ws 16 461.66(possible bell.) 2 79.3364 ws 26.668 447.02(The operations set_key_click, set_auto_repeat, and set_pointer_feedback) 10 412 ws 16 433.28(modify the key click volume, the flag determining whether keys should repeat,) 22 412 ws 16 419.54(and the pointer interpretation parameters, respectively. Display::move_pointer) 13 412 ws 16 405.8(changes the position of the input pointer. This operation can have surprising) 23 412 ws 16 392.06(effects to the user and should generally be avoided.) 16 262.277 ws 390.96 37.2(5-) 2 400.956 as 403.956 37.2(7) 1 409.956 as showpage %%Trailer end restore %%Pages: 7 %!PS-Adobe-2.0 %%Creator: ./ch6.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 16 662.72(Chapter 6) 2 119.321 ws 16 625.76(Rendering) 9 124 as 12 /Times-Roman sf 16 597.44(This chapter describes the InterViews classes for drawing on the screen and on a) 26 412 ws 16 583.7(printer. The two primary classes are Canvas, which represents an area on the) 25 412 ws 16 569.96(screen, and Printer, which sends output suitable for printing to an output stream.) 24 412 ws 16 556.22(The drawing classes are intended to be simple and resolution-independent. The) 21 412 ws 16 542.48(programming interface resembles the PostScript drawing operations.) 12 345.617 ws 26.668 527.84(Printer is a subclass of Canvas, and as such implements the same drawing) 24 412 ws 16 514.1(operations as Canvas. However, it is possible that glyphs may use other rendering) 25 412 ws 16 500.36(operations than those provided by Canvas, such as for 3D. In this case, glyphs) 27 412 ws 16 486.62(should provide distinct draw and print operations. If a glyph does not need) 25 412 ws 16 472.88(operations other than those provided by Canvas then the glyph can rely on default) 26 412 ws 16 459.14(implementation of drawing on a printer, which just calls the canvas-directed draw) 22 412 ws 16 445.4(with the printer as the target. ) 12 156.978 ws 18 /Times-Bold sf 16 404.12(6.1) 3 38.5 as 51 404.12(Graphics Attributes) 2 205.494 ws 12 /Times-Roman sf 16 371.72(InterViews provides classes that represent graphics attributes such as colors) 18 412 ws 16 357.98(and fonts. The instances are all sharable, meaning the classes are derived) 23 412 ws 16 344.24(from Resource. The objects are also display-independent, meaning they will) 19 412 ws 16 330.5(correspond to several underlying objects in applications that run on multiple) 20 412 ws 16 316.76(displays. For example, a single InterViews color object might have different pixel) 23 412 ws 16 303.02(values on different displays. ) 8 154.313 ws 14 /Times-Bold sf 16 276.62(6.1.1) 5 44 as 56 276.62(Brush) 5 92.568 as 12 /Times-Roman sf 16 256.18(A brush defines the line thickness and line style for drawing operations. The) 25 412 ws 16 242.44(effect of these operations is as if a line segment equal in length to the) 28 412 ws 16 228.7(brush's width were dragged along an infinitely thin path between the specified) 22 412 ws 16 214.96(coordinates. At each point along the path the brush is angled perpendicular to the) 27 412 ws 16 201.22(path. As a special case, a brush width of zero specifies a minimal-width line.) 27 412 ws 16 187.48(Many devices can render minimal-width lines more quickly than wide lines, but) 22 412 ws 16 173.74(the resulting display may vary slightly across devices. A solid brush style paints) 25 412 ws 16 160(all pixels along the path with a single color. A dashed brush defines alternating) 27 412 ws 16 146.26(foreground and background segments, measured along the length of the path.) 20 412 ws 16 132.52(Foreground segments are painted, while background segments are not.) 16 354.605 ws 26.668 117.88(Figure 6.1 shows the Brush class interface. The first constructor creates a solid) 25 412 ws 16 104.14(brush of the given width. The second constructor creates a brush with the given) 27 412 ws 16 90.4(width and line style. The pattern is an array of integers that specifies the length of) 31 412 ws 16 76.66(successive foreground and background segments. Even-numbered array indices) 15 412 ws 16 62.92(\(starting from 0\) specify the length of foreground segments; odd-numbered) 18 412 ws 388.72 38.96(6-) 2 398.716 as 401.716 38.96(1) 1 407.716 as showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 565.21(indices specify background segments. The ) 11 231.65 ws 10 /Helvetica sf 231.65 565.21(count) 5 256.11 as 12 /Times-Roman sf 256.11 565.21( is the number of entries in the) 14 412 ws 16 551.47(array. The count can be zero, which specifies a solid brush. The last constructor) 28 412 ws 16 537.73(defines a brush with a given width and a style specified by a bit vector. The) 31 412 ws 16 523.99(least significant 16 bits of ) 10 151.537 ws 10 /Helvetica sf 151.537 523.99(pattern) 7 182.667 as 12 /Times-Roman sf 182.667 523.99( are interpreted as a bit pattern, with one bits) 18 412 ws 16 510.25(specifying foreground segments and zero bits specifying background segments. ) 18 400.6 ws 14 /Times-Bold sf 16 483.85(6.1.2) 5 44 as 56 483.85(Color) 5 90.216 as 12 /Times-Roman sf 16 463.41(A color object defines an output color, which is specified by a mix of RGB \(red,) 30 412 ws 16 449.67(green, and blue\) intensities, and an alpha value for blending. Figure 6.2 shows the) 27 412 ws 16 435.93(Color class interface. RGB and alpha values are represented as floating point) 23 412 ws 16 422.19(numbers between 0 and 1, where 1 is full intensity \(or visibility in the case of) 30 412 ws 16 408.45(alpha\). A color object is created with the RGB intensities, an alpha value \(default) 27 412 ws 16 394.71(is 1.0\), and a drawing operation. A color drawing operation need be specified) 25 412 ws 16 380.97(only on rare occasions. The default operation, Copy) 15 270.988 ws 12 /Helvetica sf 270.988 380.97(,) 1 274.324 as 12 /Times-Roman sf 274.324 380.97( blends the color in directly.) 10 412 ws 16 367.23(The Xor operation uses a pixel value computed by taking the exclusive-or of the) 26 412 ws 16 353.49(color and the existing pixel value. Xor is only useful on a monochrome system.) 27 398.464 ws 26.668 338.85(Color::lookup returns the color with the given name as defined on the given) 24 412 ws 16 325.11(display or nil if the name is not defined. Color::distinguished determines if two) 25 412 ws 16 311.37(colors are distinct on a particular display. A common use of Color::distinguished) 23 412 ws 16 297.63(is to check if a highlighting color is distinct from foreground and background) 24 412 ws 16 283.89(colors. Color::intensities returns the RGB values for a given color on a given) 25 412 ws 16 270.15(display. Color::brightness creates a new color that is brighter or darker than) 24 412 ws 16 256.41(the given color by a certain adjustment. If the adjust parameter is positive, it) 27 412 ws 16 242.67(indicates the new intensity should be the given fraction of the distance between) 24 412 ws 16 228.93(the current intensity and full intensity. If the parameter is negative, its absolute) 25 412 ws 16 215.19(value specifies a distance to zero intensity.) 12 220.961 ws 26.668 200.55(InterViews automatically translates an RGB specification to the appropriate) 16 412 ws 16 186.81(pixel value for a window. This approach hides the system-dependent details of) 23 412 ws 16 173.07(color management from applications, making them more portable and giving) 18 412 ws 16 159.33(greater flexibility to graphics system implementors. Under the X Window System,) 21 412 ws 16 145.59(color-intensive applications might not find the default color implementation) 16 412 ws 16 131.85(acceptable. To assist such applications, InterViews provides a way to specify an) 23 412 ws 16 118.11(X visual, either on the command-line with the ``-visual'' flag, or with a ``visual'') 26 412 ws 16 104.37(X resource defined to the desired visual type. For example, on displays that) 25 412 ws 16 90.6301(support TrueColor \(which means pixel values can be computed directly from) 20 412 ws 16 76.8901(RGB values\) but for which the default visual is not TrueColor, a user could run an) 30 412 ws 16 63.1501(application with ``-visual TrueColor'' or define ``*app*visual:TrueColor'' in the) 16 412 ws 388.72 38.96(6-) 2 398.716 as 401.716 38.96(2) 1 407.716 as newpath 16 673.9 moveto 16 674.9 lineto 412 674.9 lineto 412 673.9 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.336 657.34(interface Brush : Resource {) 8 161.837 ws 45.666 645.82(Brush\(Coord width\);) 2 134.576 ws 45.666 634.3(Brush\(int* pattern, int count, Coord width\);) 10 231.857 ws 45.666 622.78(Brush\(int pattern, Coord width\);) 6 184.607 ws 37.336 611.26(}; ) 2 46.2364 ws 10 /Helvetica sf 142.866 594.74(Figure 6.1:) 2 190.666 ws 198.996 594.74(Brush class interface) 4 291.806 ws newpath 16 586.57 moveto 16 587.57 lineto 412 587.57 lineto 412 586.57 lineto closepath gsave eofill grestore 12 /Times-Roman sf 389.04 39.12(6-) 2 399.036 as 402.036 39.12(2) 1 408.036 as showpage %%Page: 3 3 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 413.53(application defaults file. ) 6 135.317 ws 14 /Times-Bold sf 16 387.13(6.1.3) 5 44 as 56 387.13(Font) 4 84 as 12 /Times-Roman sf 16 366.69(A font defines a mapping between character codes and their appearance on the) 24 412 ws 16 352.95(screen. PSFont is a subclass of Font that uses PostScript metrics for character) 25 412 ws 16 339.21(widths, if the metrics are available on the system. Figure 6.3 shows the Font and) 29 412 ws 16 325.47(PSFont class interfaces. The Font constructor is given the full name of the font) 27 412 ws 16 311.73(and a scaling factor. If the font is used on a display that does not recognize the) 33 412 ws 16 297.99(name, then a default font will be used. Font::find can be used to compute a valid) 31 412 ws 16 284.25(fullname for a font from a given font family name, desired point size, and font) 28 412 ws 16 270.51(style \(such as italic or bold\). If a font is available that matches all but the point) 33 412 ws 16 256.77(size, Font::find will return the font with ) 14 214.938 ws 10 /Helvetica sf 214.938 256.77(scale) 5 238.278 as 12 /Times-Roman sf 238.278 256.77( set to the ratio of the desired point) 16 412 ws 16 243.03(size to the actual point size.) 10 148.65 ws 26.668 228.39(Font::name returns the full name of the font. Font::encoding returns the) 21 412 ws 16 214.65(character set identification, such as ``iso8859'' for ISO Latin. Font::size returns) 21 412 ws 16 200.91(the point size of the font.) 10 135.99 ws 26.668 186.27(Font::font_bbox, Font::char_bbox, and Font::string_bbox return information) 10 412 ws 16 172.53(about the overall font, a specific character in the font, or a string of characters.) 28 412 ws 16 158.79(Each operation returns a FontBoundingBox object, which has operations to return) 20 412 ws 16 145.05(detailed information.) 2 116.656 ws 26.668 130.41(FontBoundingBox::ascent returns the extent above the font's baseline;) 14 412 ws 16 116.67(FontBoundingBox::descent returns the extent below the font's baseline.) 14 412 ws 16 102.93(FontBoundingBox::left_bearing returns the left edge of the bitmap associated) 16 412 ws 16 89.1899(with a character; FontBoundingBox::right_bearing returns the right edge.) 14 367.96 ws 26.668 74.5499(Font::width on a single character returns the width of a character's bitmap) 22 412 ws 16 60.8099(and on a string it returns the sum of the widths of the individual characters.) 28 412 ws 388.72 38.96(6-) 2 398.716 as 401.716 38.96(3) 1 407.716 as 389.04 39.12(6-) 2 399.036 as 402.036 39.12(3) 1 408.036 as newpath 16 671.98 moveto 16 672.98 lineto 412 672.98 lineto 412 671.98 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.336 655.42(typedef float ColorIntensity;) 4 158.507 ws 37.336 643.9(typedef unsigned int ColorOp;) 6 169.627 ws 37.336 620.86(interface Color : Resource {) 8 159.607 ws 45.666 609.34(enum { Copy, Xor };) 8 132.937 ws 45.666 597.82(Color\() 6 72.8861 as 53.996 586.3(ColorIntensity r, ColorIntensity g, ColorIntensity b,) 10 274.077 ws 53.996 574.78(float alpha = 1.0, ColorOp = Copy) 12 202.967 ws 45.666 563.26(\);) 2 51.776 as 45.666 551.74(Color\(const Color&, float alpha = 1.0, ColorOp = Copy\);) 16 290.767 ws 45.666 540.22(static const Color* lookup\(Display*, const String& name\);) 12 297.417 ws 45.666 528.7(static const Color* lookup\(Display*, const char*\);) 10 260.177 ws 45.666 517.18(boolean distinguished\(Display*, Color*\);) 4 221.836 ws 45.666 505.66(void intensities\() 2 114.576 ws 53.996 494.14(Display*, ColorIntensity& r, ColorIntensity& g, ColorIntensity& b) 12 333.536 ws 45.666 482.62(\) const;) 2 78.4564 ws 45.666 471.1(const Color* brightness\(float adjust\) const;) 8 233.517 ws 37.336 459.58(}; ) 2 46.2364 ws 10 /Helvetica sf 143.981 443.06(Figure 6.2:) 2 191.781 ws 200.111 443.06(Color class interface) 4 290.691 ws newpath 16 434.89 moveto 16 435.89 lineto 412 435.89 lineto 412 434.89 lineto closepath gsave eofill grestore showpage %%Page: 4 4 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 242.05(Font::index returns the index of the character in a string that would be ) 26 387.54 ws 10 /Helvetica sf 387.54 242.05(offset) 6 412 as 12 /Times-Roman sf 16 228.31(coordinates from the left if the string were displayed. If ) 21 310.113 ws 10 /Helvetica sf 310.113 228.31(between) 7 347.913 as 12 /Times-Roman sf 347.913 228.31( is false, the) 6 412 ws 16 214.57(index of the character that contains ) 12 194.342 ws 10 /Helvetica sf 194.342 214.57(offset) 6 218.802 as 12 /Times-Roman sf 218.802 214.57( is returned; otherwise the index of the) 14 412 ws 16 200.83(character following the between-character space that is nearest ) 16 328.419 ws 10 /Helvetica sf 328.419 200.83(offset) 6 352.879 as 12 /Times-Roman sf 352.879 200.83( is returned.) 4 412 ws 16 187.09(In either case a negative offset will return an index of zero and an offset beyond) 30 412 ws 16 173.35(the end of the string will return an index equal to the length of the string. ) 32 368.297 ws 14 /Times-Bold sf 16 146.95(6.1.4) 5 44 as 56 146.95(Transformer) 11 133.756 as 12 /Times-Roman sf 16 126.51(A transformer object represents a 3x2 matrix for use in translating 2D coordinates.) 24 412 ws 16 112.77(Figure 6.4 shows the Transformer class interface. The transformer constructor) 19 412 ws 16 99.0299(with no parameters creates an identity matrix. The other constructor takes the) 23 412 ws 16 85.2899(explicit matrix values as parameters. Transformer::identity returns whether the) 17 412 ws 16 71.5499(matrix is currently the identity matrix.) 10 199.325 ws 388.72 38.96(6-) 2 398.716 as 401.716 38.96(4) 1 407.716 as 389.04 39.12(6-) 2 399.036 as 402.036 39.12(4) 1 408.036 as newpath 16 676.78 moveto 16 677.78 lineto 412 677.78 lineto 412 676.78 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.336 660.22(interface FontBoundingBox {) 4 164.077 ws 45.666 648.7(Coord left_bearing\(\) const, right_bearing\(\) const;) 8 261.307 ws 45.666 637.18(Coord width\(\) const, ascent\(\) const, descent\(\) const;) 12 277.417 ws 45.666 625.66(Coord font_ascent\(\) const, font_descent\(\) const;) 8 259.657 ws 37.336 614.14(};) 2 43.456 as 37.336 597.62(typedef long FontCharCode;) 4 162.957 ws 37.336 581.1(interface Font : Resource {) 8 155.727 ws 45.666 569.58(Font\(const String&, float scale = 1.0\);) 10 210.467 ws 45.666 558.06(Font\(const char* fullname, float scale = 1.0\);) 12 241.587 ws 45.666 546.54(static boolean find\() 4 129.597 ws 53.996 535.02(const char* family, int size, const char* style,) 14 251.287 ws 53.996 523.5(const char*& fullname, float& scale) 8 208.507 ws 45.666 511.98(\);) 2 51.776 as 45.666 500.46(static const Font* lookup\(const char*\);) 8 214.067 ws 45.666 488.94(static const Font* lookup\(const String&\);) 8 223.517 ws 45.666 472.42(const char* name\(\) const;) 6 159.597 ws 45.666 460.9(const char* encoding\(\) const;) 6 175.167 ws 45.666 449.38(Coord size\(\);) 2 102.896 ws 45.666 426.34(void font_bbox\(FontBoundingBox&\) const;) 4 232.986 ws 45.666 414.82(void char_bbox\(FontCharCode, FontBoundingBox&\) const;) 6 306.896 ws 45.666 403.3(void stringt_bbox\(const char*, int, FontBoundingBox&\);) 8 288.556 ws 45.666 391.78(virtual Coord width\(FontCharCode\);) 4 203.486 ws 45.666 380.26(virtual Coord width\(const char*, int\);) 8 204.047 ws 45.666 368.74(virtual int index\(const char*, int, float offset, boolean between\);) 16 321.357 ws 37.336 357.22(};) 2 43.456 as 37.336 334.18(interface PSFont : Font {) 8 146.287 ws 45.666 322.66(PSFont\() 7 82.346 as 53.996 311.14(const char* psname, Coord size, const char* encoding, float scale) 18 345.237 ws 45.666 299.62(\);) 2 51.776 as 37.336 288.1(}; ) 2 46.2364 ws 10 /Helvetica sf 115.626 271.58(Figure 6.3:) 2 163.426 ws 171.756 271.58(Font and PSFont class interfaces) 8 319.046 ws newpath 16 263.41 moveto 16 264.41 lineto 412 264.41 lineto 412 263.41 lineto closepath gsave eofill grestore showpage %%Page: 5 5 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 26.668 671.36(Transformer::premultiply and Transformer::postmultiply set the matrix to be) 15 412 ws 16 657.62(the result of multiplying the matrix and the given matrix. Two operations are) 25 412 ws 16 643.88(necessary because matrix multiplication is not commutative for 2D coordinates.) 18 412 ws 16 630.14(Premultiply means the current matrix is on the left-hand side of the multiplication,) 24 412 ws 16 616.4(postmultiply means the current matrix is on the right. Transformer::invert sets the) 23 412 ws 16 602.66(matrix to its inverse.) 6 114.665 ws 26.668 588.02(Transformer::translate modifies the matrix to add ) 12 270.766 ws 10 /Helvetica sf 270.766 588.02(dx) 2 281.326 as 12 /Times-Roman sf 281.326 588.02( to the x coordinate and ) 12 401.44 ws 10 /Helvetica sf 401.44 588.02(dy) 2 412 as 12 /Times-Roman sf 16 574.28(to the y coordinate. Transformer::scale modifies the matrix to multiply the x and) 25 412 ws 16 560.54(y coordinates by ) 6 100.481 ws 10 /Helvetica sf 100.481 560.54(sx) 2 110.481 as 12 /Times-Roman sf 110.481 560.54( and ) 4 135.25 ws 10 /Helvetica sf 135.25 560.54(sy) 2 145.25 as 12 /Helvetica sf 145.25 560.54(,) 1 148.586 as 12 /Times-Roman sf 148.586 560.54( respectively. Transformer::rotate modifies the matrix) 11 412 ws 16 546.8(to rotate x and y coordinates by a given angle in degrees. Transformer::skew) 25 412 ws 16 533.06(modifies the matrix to skew coordinates by ) 14 226.313 ws 10 /Helvetica sf 226.313 533.06(sx) 2 236.313 as 12 /Times-Roman sf 236.313 533.06( and ) 4 259.641 ws 10 /Helvetica sf 259.642 533.06(sy) 2 269.642 as 12 /Times-Roman sf 269.642 533.06(.) 1 272.642 as 26.668 518.42(Transformer::transform multiplies the given coordinates by the matrix to) 16 412 ws 16 504.68(compute transformed coordinates. The coordinates can either transformed in) 17 412 ws 16 490.94(place stored in specific out parameters \(tx, ty\). Transformer::inverse_transform) 17 412 ws 16 477.2(performs the inverse mapping; taking transformed coordinates and returning the) 18 412 ws 16 463.46(original coordinates.) 2 114.652 ws 26.668 448.82(The following example shows how to use transformers:) 14 293.633 ws 10 /Helvetica sf 40.99 430.34(Transformer t;) 2 103.78 ws 120.44 430.34(// start with identity) 6 203.251 ws 40.99 418.82(t.rotate\(90.0\);) 15 101.02 as 40.99 406.3(t.translate\(20.0, 10.0\);) 2 138.82 ws 40.99 394.78(t.scale\(0.5, 0.5\);) 2 112.69 ws 40.99 383.26(float x = 1.0, y = 0.0;) 12 131.612 ws 40.99 371.74(float tx, ty;) 4 86.5707 ws 12 /Times-Roman sf 388.72 38.96(6-) 2 398.716 as 401.716 38.96(5) 1 407.716 as 389.04 39.12(6-) 2 399.036 as 402.036 39.12(5) 1 408.036 as newpath 17.92 344.62 moveto 17.92 345.62 lineto 413.92 345.62 lineto 413.92 344.62 lineto closepath gsave eofill grestore 10 /Helvetica sf 39.256 328.06(interface Transformer : Resource {) 8 192.087 ws 47.586 316.54(Transformer\(\);) 14 111.476 as 47.586 305.02(Transformer\() 12 105.366 as 55.916 293.5(float a00, float a01, float a10, float a11, float a20, float a21) 22 313.877 ws 47.586 281.98(\);) 2 53.696 as 47.586 270.46(boolean identity\(\) const;) 4 153.747 ws 47.586 258.94(void premultiply\(const Transformer&\);) 4 214.286 ws 47.586 247.42(void postmultiply\(const Transformer&\);) 4 218.736 ws 47.586 235.9(void invert\(\);) 2 102.596 ws 47.586 224.38(void translate\(float dx, float dy\);) 8 186.537 ws 47.586 212.86(void scale\(float sx, float sy\);) 8 170.407 ws 47.586 201.34(void rotate\(float angle\);) 4 149.857 ws 47.586 189.82(void skew\(float sx, float sy\);) 8 169.847 ws 47.586 178.3(void transform\(floatx, floaty\);) 4 173.737 ws 47.586 166.78(void transform\(float x, float y, floattx, floatty\);) 12 243.777 ws 47.586 155.26(void inverse_transform\(floatx, floaty\);) 4 211.526 ws 47.586 143.74(void inverse_transform\(float tx, float ty, floatx, floaty\);) 12 281.567 ws 47.586 132.22(void matrix\(floata00, floata01, floata10, floata11, floata20, floata21\);) 12 346.646 ws 39.256 120.7(}; ) 2 48.1564 ws 10 /Helvetica sf 144.791 104.18(Figure 6.4:) 2 192.591 ws 200.921 104.18(Transformer protocol) 2 293.721 ws newpath 17.92 96.01 moveto 17.92 97.01 lineto 413.92 97.01 lineto 413.92 96.01 lineto closepath gsave eofill grestore showpage %%Page: 6 6 90.05 36.94 translate 0 0 0 setrgbcolor 10 /Helvetica sf 40.99 672.32(t.transform\(x, y, tx, ty\);) 6 140.461 ws 40.99 659.84(// now tx = 10.0, ty = 5.5) 14 147.732 ws 12 /Times-Roman sf 16 645.2(Although the transformation is a single step, one can think of it as individual steps) 28 412 ws 16 631.46(for each of the rotate, translate, and scale steps. First the given point \(1.0,0.0\) is) 29 412 ws 16 617.72(rotated to \(0.0,1.0\), then it is translated to \(20.0,11.0\), finally it is scaled to) 26 412 ws 16 603.98(\(10.0,5.5\). ) 2 68.9924 ws 14 /Times-Bold sf 16 577.58(6.1.5) 5 44 as 56 577.58(Bitmap) 6 100.338 as 12 /Times-Roman sf 16 557.14(A bitmap is a two-dimensional array of boolean values. A bitmap is useful for) 27 412 ws 16 543.4(stenciling; that is, drawing through a mask that allows some pixels to be drawn) 26 412 ws 16 529.66(but prevents others from being changed. The Stencil class can be used to put a) 29 412 ws 16 515.92(bitmap in a glyph graph.) 8 133.661 ws 26.668 501.28(Figure 6.5 shows the Bitmap class interface. There are two constructors) 21 412 ws 16 487.54(for bitmaps. One takes the bitmap data, width, height, and origin. The other) 26 412 ws 16 473.8(constructor creates a bitmap for a given character in a font, optionally scaling by a) 28 412 ws 16 460.06(given factor. In this case, the bitmap width and height will reflect the actual size) 29 412 ws 16 446.32(of the character glyph and the bitmap origin will be the same as the character) 28 412 ws 16 432.58(origin.) 7 47.668 as 26.668 417.94(Bitmap::open operation tries to open a file containing a bitmap definition in the) 24 412 ws 16 404.2(format produced by the X bitmap program. If the file is found and is a valid) 31 412 ws 16 390.46(format, open returns true and sets the bitmap information.) 16 293.297 ws 26.668 375.82(Bitmap::peek and Bitmap::poke are used to read and write at specified positions) 22 412 ws 16 362.08(in the bitmap. Bitmap::width and Bitmap::height return the width and height of) 23 412 ws 16 348.34(the bitmap in coordinates, while Bitmap::pwidth and Bitmap::pheight return the) 18 412 ws 16 334.6(number of bits defined in each dimension.) 12 218.309 ws 26.668 319.96(Treating the bitmap origin as \(0,0\), Bitmap::left_bearing, Bitmap::right_bearing,) 14 412 ws 16 306.22(Bitmap::ascent, and Bitmap::descent return the left, right, top, and bottom) 18 412 ws 16 292.48(coordinates of the bitmap, respectively. For example, a 16x16 bitmap with its) 23 412 ws 16 278.74(origin at \(7,5\) would have a left_bearing of -7, a right_bearing of 9, an ascent of) 30 412 ws 16 265(12, and a descent of -5. ) 12 130.638 ws 388.72 38.96(6-) 2 398.716 as 401.716 38.96(6) 1 407.716 as 389.04 39.12(6-) 2 399.036 as 402.036 39.12(6) 1 408.036 as newpath 15.0401 248.62 moveto 15.0401 249.62 lineto 411.04 249.62 lineto 411.04 248.62 lineto closepath gsave eofill grestore 10 /Helvetica sf 36.3761 232.06(interface Bitmap : Resource {) 8 165.877 ws 44.7061 220.54(Bitmap\() 7 79.1561 as 53.0361 209.02(void*, unsigned int width, unsigned int height, int x0 = -1, int y0 = -1) 28 349.867 ws 44.7061 197.5(\);) 2 50.8161 as 44.7061 185.98(Bitmap\(Font*, int code, float scale = 1.0\);) 12 225.627 ws 44.7061 174.46(static Bitmap* open\(const char* filename\);) 8 230.887 ws 44.7061 162.94(void poke\(boolean set, unsigned int x, unsigned int y\);) 16 283.167 ws 44.7061 151.42(void peek\(unsigned int x, unsigned int y\);) 12 225.907 ws 44.7061 139.9(Coord width\(\) const, height\(\) const;) 8 200.317 ws 44.7061 128.38(unsigned int pwidth\(\) const, pheight\(\) const;) 10 238.127 ws 44.7061 116.86(Coord left_bearing\(\) const, right_bearing\(\) const;) 8 260.347 ws 44.7061 105.34(Coord ascent\(\) const, descent\(\) const;) 8 214.217 ws 36.3761 93.82(};) 2 42.4961 as 10 /Helvetica sf 153.576 77.3(Figure 6.5:) 2 201.376 ws 209.706 77.3(Bitmap protocol) 2 279.176 ws newpath 15.0401 69.13 moveto 15.0401 70.13 lineto 411.04 70.13 lineto 411.04 69.13 lineto closepath gsave eofill grestore showpage %%Page: 7 7 90.05 36.94 translate 0 0 0 setrgbcolor 14 /Times-Bold sf 16 670.4(6.1.6) 5 44 as 56 670.4(Raster) 6 95.648 as 12 /Times-Roman sf 16 649.96(A raster is a color image specified by a two-dimensional array of colors. The) 27 412 ws 16 636.22(Image class can be used to put a raster in a glyph graph. The TIFFRaster class) 31 412 ws 16 622.48(provides a single operation, load, for reading a TIFF image file and creating a) 26 412 ws 16 608.74(raster for it. If the file is not readable or not a valid TIFF file, TIFFRaster::load) 31 412 ws 16 595(will return nil.) 4 85.0008 ws 26.668 580.36(Figure 6.6 shows the Raster and TIFFRaster class interfaces. The raster) 20 412 ws 16 566.62(constructor is given the size of the array of colors. Raster::width and) 23 412 ws 16 552.88(Raster::height return the dimensions of the raster in coordinates, while) 18 412 ws 16 539.14(Raster::pwidth and Raster::pheight return the dimensions of the array. A raster's) 21 412 ws 16 525.4(origin is always the lower left corner.) 12 195.63 ws 26.668 510.76(Raster::peek and Raster::poke read and write the color array, accessing colors) 20 412 ws 16 497.02(in terms of the RGB intensities and an alpha value. Peek and poke operations are) 29 412 ws 16 483.28(guaranteed to be cheap; that is, any processing \(especially interaction with the) 23 412 ws 16 469.54(window system\) will be deferred until the raster is next displayed.) 21 334.457 ws 18 /Times-Bold sf 16 428.26(6.2) 3 38.5 as 51 428.26(Canvas) 6 108.006 as 12 /Times-Roman sf 16 395.86(A canvas is a 2-dimensional area on which to draw. The base implementation) 25 412 ws 16 382.12(draws on a portion of the screen, normally created by a window object rather) 26 412 ws 16 368.38(than directly by an application. The Printer subclass uses the same rendering) 23 412 ws 16 354.64(operations to generate PostScript to a file. Thus, it is possible to write a single) 29 412 ws 16 340.9(drawing routine that can be used to generate screen or printer output.) 24 349.589 ws 26.668 326.26(Figure 6.7 shows the canvas and printer operations. For screen canvases,) 21 412 ws 16 312.52(Canvas::window returns the window containing the canvas; otherwise it returns) 18 412 ws 388.72 38.96(6-) 2 398.716 as 401.716 38.96(7) 1 407.716 as 389.04 39.12(6-) 2 399.036 as 402.036 39.12(7) 1 408.036 as newpath 15.04 287.02 moveto 15.04 288.02 lineto 411.04 288.02 lineto 411.04 287.02 lineto closepath gsave eofill grestore 10 /Helvetica sf 36.376 270.46(interface Raster : Resource {) 8 164.207 ws 44.706 258.94(Raster\(unsigned int pwidth, unsigned int pheight\);) 10 264.257 ws 44.706 247.42(Coord width\(\) const, height\(\) const;) 8 200.317 ws 44.706 235.9(unsigned int pwidth\(\) const, pheight\(\) const;) 10 238.127 ws 44.706 224.38(void peek\() 2 90.8363 ws 53.036 212.86(unsigned int x, unsigned int y,) 10 184.777 ws 53.036 201.34(ColorIntensity& r, ColorIntensity& g, ColorIntensity& b, float& alpha) 14 348.716 ws 44.706 189.82(\) const;) 2 77.4963 ws 44.706 178.3(void poke\() 2 90.8363 ws 53.036 166.78(unsigned int x, unsigned int y,) 10 184.777 ws 53.036 155.26(ColorIntensity r, ColorIntensity g, ColorIntensity b, float alpha) 14 322.037 ws 44.706 143.74(\);) 2 50.816 as 36.376 132.22(};) 2 42.496 as 36.376 115.7(interface TIFFRaster {) 4 134.187 ws 44.706 104.18(static Raster* load\(const char* filename\);) 8 225.877 ws 36.376 92.66(}; ) 2 45.2764 ws 10 /Helvetica sf 115.511 76.14(Figure 6.6:) 2 163.311 ws 171.641 76.14(Raster and TIFFRaster protocols) 6 317.241 ws newpath 15.04 67.97 moveto 15.04 68.97 lineto 411.04 68.97 lineto 411.04 67.97 lineto closepath gsave eofill grestore showpage %%Page: 8 8 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 671.36(nil. Canvas::width and Canvas::height return the dimensions of the canvas in) 21 412 ws 16 657.62(coordinates.) 12 74.32 as 26.668 642.98(The canvas rendering operations are similar to the PostScript) 16 412 ws 16 629.24(drawing operations. Canvas::new_path, Canvas::move_to, Canvas::line_to,) 9 412 ws 16 615.5(Canvas::curve_to, and Canvas::close_path are used to define a list of coordinates) 20 412 ws 16 601.76(on which to perform a drawing operation. Canvas::move_to sets the position in) 23 412 ws 16 588.02(the path, and Canvas::line_to extends the path to a new position. Canvas::curve_to) 23 412 ws 16 574.28(also extends the path, but with a Bezier curve between the old and new positions.) 28 412 ws 16 560.54(Canvas::close_path closes the path. Canvas::stroke draws along the current path) 19 412 ws 16 546.8(with a given brush and color. Canvas::fill draws inside the path with a given) 27 412 ws 16 533.06(color. Canvas::clip restricts subsequent drawing to be inside the path. Clipping is) 24 412 ws 16 519.32(cumulative; that is, two consecutive clip operations will result in a clipping region) 24 412 ws 16 505.58(that is the intersection of the paths specified by the two requests.) 22 325.961 ws 26.668 490.94(Canvas::line, Canvas::rect, Canvas::fill_rect, and Canvas::clip_rect are provided) 12 412 ws 16 477.2(for convenience. Canvas::line is equivalent to stroking a path with two points,) 23 412 ws 16 463.46(Canvas::rect strokes a rectangular path, Canvas::fill_rect fills a rectangular path,) 18 412 ws 16 449.72(and Canvas::clip_rect restricts subsequent output to be within a rectangular path.) 20 403.612 ws 26.668 435.08(Drawing operations are typically batched to improve performance. For) 17 412 ws 16 421.34(example, a series of Canvas::character operations might be combined into a single) 22 412 ws 16 407.6(request on many graphics systems. An application cannot determine if or when a) 25 412 ws 16 393.86(particular operation has completed. No synchronization operations are defined on) 19 412 ws 16 380.12(a canvas, as several canvases may be active at the same time. Display::flush or) 27 412 ws 16 366.38(Display::sync can be used to wait until the display starts or finishes drawing,) 24 412 ws 16 352.64(respectively.) 13 76.984 as 26.668 338(As an example of the drawing operations, the following code draws a filled) 24 412 ws 16 324.26(triangle with corners \(x1,y1\), \(x2,y2\), and \(x3,y3\):) 12 258.953 ws 10 /Helvetica sf 40.99 305.78(canvas->new_path\(\);) 19 134.64 as 40.99 294.26(canvas->move_to\(x1, y1\);) 2 156.31 ws 40.99 282.74(canvas->line_to\(x2, y2\);) 2 147.42 ws 40.99 271.22(canvas->line_to\(x3, y3\);) 2 147.42 ws 40.99 259.7(canvas->close_path\(\);) 21 139.64 as 40.99 247.22(canvas->fill\(color\); ) 2 125.17 ws 18 /Times-Bold sf 16 205.94(6.3) 3 38.5 as 51 205.94(Printer) 7 106.98 as 12 /Times-Roman sf 16 173.54(A printer is a 2-D drawing surface like a canvas, but that generates output for) 28 412 ws 16 159.8(hardcopy or previewing. The printer class normally generates PostScript text to a) 23 412 ws 16 146.06(file; other printer formats may be available at a particular site.) 20 313.601 ws 26.668 131.42(Printer is a subclass of Canvas with different implementations for the drawing) 22 412 ws 16 117.68(operations. Thus, a printer can be passed to an operation expecting a canvas. The) 28 412 ws 16 103.94(printer class also provides a few additional operations.) 14 277.289 ws 26.668 89.3001(The printer constructor takes a pointer to an output stream where the print) 24 412 ws 16 75.5601(representation will be written. Printer::resize specifies the boundaries of the) 19 412 ws 16 61.8201(printed page. Printer::comment generates text that will appear in the output) 21 412 ws 388.72 38.96(6-) 2 398.716 as 401.716 38.96(8) 1 407.716 as 389.04 39.12(6-) 2 399.036 as 402.036 39.12(8) 1 408.036 as showpage %%Page: 9 9 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 151.89(stream, but will not show on the printed page. Printer::page generates information) 23 412 ws 16 138.15(about the current page. This operation will not result in any printed output, but is) 29 412 ws 16 124.41(used by previewers. Printer::flush forces any locally-buffered data to be written. ) 24 406.576 ws 388.72 38.96(6-) 2 398.716 as 401.716 38.96(9) 1 407.716 as 389.04 39.12(6-) 2 399.036 as 402.036 39.12(9) 1 408.036 as newpath 16.72 677.26 moveto 16.72 678.26 lineto 412.72 678.26 lineto 412.72 677.26 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.056 660.7(interface Canvas {) 4 119.207 ws 46.386 649.18(Window* window\(\) const;) 4 158.077 ws 46.386 637.66(Coord width\(\) const, height\(\) const;) 8 201.997 ws 46.386 621.14(PixelCoord to_pixels\(Coord\) const;) 4 200.876 ws 46.386 609.62(Coord to_coord\(PixelCoord\) const;) 4 200.326 ws 46.386 598.1(Coord to_pixels_coord\(Coord\) const;) 4 209.776 ws 46.386 581.58(void new_path\(\);) 2 120.306 ws 46.386 570.06(void move_to\(Coord x, Coord y\);) 8 190.877 ws 46.386 558.54(void line_to\(Coord x, Coord y\);) 8 181.987 ws 46.386 547.02(void curve_to\(Coord x, Coord y, Coord x1, Coord y1, Coord x2, Coord y2\);) 24 375.396 ws 46.386 535.5(void close_path\(\);) 2 125.306 ws 46.386 523.98(void stroke\(const Color*, const Brush*\);) 8 220.887 ws 46.386 512.46(void rect\(Coord l, Coord b, Coord r, Coord t, const Color*, const Brush*\);) 24 366.496 ws 46.386 500.94(void fill\(const Color*\);) 4 140.847 ws 46.386 489.42(void fill_rect\(Coord l, Coord b, Coord r, Coord t, const Color*\);) 20 319.247 ws 46.386 477.9(void character\() 2 112.516 ws 54.716 466.38(const Font*, int ch, Coord width, const Color*, Coord x, Coord y) 22 334.827 ws 46.386 454.86(\);) 2 52.496 as 46.386 443.34(void stencil\(const Bitmap*, const Color*, Coord x, Coord y\);) 16 308.137 ws 46.386 431.82(void image\(const Raster*, Coord x, Coord y\);) 12 245.337 ws 46.386 415.3(void push_transform\(\), pop_transform\(\);) 4 223.106 ws 46.386 403.78(void transform\(const Transformer&\);) 4 206.976 ws 46.386 392.26(void transformer\(const Transformer&\);) 4 215.866 ws 46.386 380.74(const Transformer& transformer\(\) const;) 6 224.207 ws 46.386 369.22(void push_clipping\(\), pop_clipping\(\);) 4 206.446 ws 46.386 357.7(void clip\(\);) 2 91.9464 ws 46.386 346.18(void clip_rect\(Coord l, Coord b, Coord r, Coord t\);) 16 264.787 ws 46.386 329.66(void damage\(const Extension&\);) 4 190.336 ws 46.386 318.14(void damage\(Coord l, Coord b, Coord r, Coord t\);) 16 263.687 ws 46.386 306.62(boolean damaged\(const Extension&\) const;) 6 239.817 ws 46.386 295.1(boolean damaged\(Coord l, Coord b, Coord r, Coord t\) const;) 18 313.167 ws 38.056 283.58(};) 2 44.176 as 38.056 267.06(interface Printer : Canvas {) 8 156.997 ws 46.386 255.54(Printer\(ostream*\);) 18 125.286 as 46.386 244.02(void resize\(Coord left, Coord bottom, Coord right, Coord top\);) 17 318.987 ws 46.386 232.5(void comment\(const char*\);) 4 168.087 ws 46.386 220.98(void page\(const char*\);) 4 149.207 ws 46.386 209.46(void flush\(\);) 2 98.0664 ws 38.056 197.94(}; ) 2 46.9564 ws 10 /Helvetica sf 126.076 181.42(Figure 6.7:) 2 173.876 ws 182.206 181.42(Canvas and printer protocols) 6 310.036 ws newpath 16.72 173.25 moveto 16.72 174.25 lineto 412.72 174.25 lineto 412.72 173.25 lineto closepath gsave eofill grestore showpage %%Trailer end restore %%Pages: 9 %!PS-Adobe-2.0 %%Creator: ./ch8.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 16 662.72(Chapter 8) 2 119.321 ws 16 625.76(Styles) 6 76 as 12 /Times-Roman sf 16 597.44(User interface toolkits traditionally have coupled the management of style) 18 412 ws 16 583.7(attributes such as color and font with the composition of objects in a window.) 26 412 ws 16 569.96(This coupling is too rigid and inefficient for many applications because attributes) 23 412 ws 16 556.22(are ) 2 36.6217 ws 12 /Times-Italic sf 36.6217 556.22(logical) 7 69.9577 as 12 /Times-Roman sf 69.9577 556.22( information, whereas composition is a ) 12 277.424 ws 12 /Times-Italic sf 277.424 556.22(physical) 8 317.42 as 12 /Times-Roman sf 317.42 556.22( organization. For) 5 412 ws 16 542.48(example, a document logically contains text and graphics organized into chapters,) 20 412 ws 16 528.74(sections, subsections, and paragraphs. Physically, the document contains lines,) 17 412 ws 16 515(columns, and pages. The font of a string of characters in the document is) 27 412 ws 16 501.26(independent of whether there is a line break within the string or not, thus the style) 30 412 ws 16 487.52(information is orthogonal to the layout.) 10 204.665 ws 26.668 472.88(InterViews provides a ) 6 142.761 ws 12 /Times-Italic sf 142.761 472.88(style) 5 164.757 as 12 /Times-Roman sf 164.757 472.88( class for organizing user interface attributes. A) 15 412 ws 16 459.14(style is similar to an environment in a text formatting system such as Scribe.) 26 412 ws 16 445.4(Styles may be nested hierarchically, and attributes defined in an outer style are) 24 412 ws 16 431.66(visible in an inner style if not otherwise defined. A style consists of an optional) 29 412 ws 16 417.92(name, an optional list of prefixes for wildcard-matching, a collection of attributes) 22 412 ws 16 404.18(\(name-value pairs\), a collection of styles nested inside the style, and a parent style.) 26 412 ws 18 /Times-Bold sf 16 362.9(8.1) 3 38.5 as 51 362.9(Defining a style) 4 169.999 ws 12 /Times-Roman sf 16 330.5(Figure 8.1 shows the style class operations for creating and accessing simple) 22 412 ws 16 316.76(style information. When a style is created, its name and parent style may be) 27 412 ws 16 303.02(specified. The default parent style is nil. Style::name sets or gets the style's) 26 412 ws 16 289.28(name. Style::parent gets the style's parent. The parent cannot be set directly, but) 26 412 ws 16 275.54(can be changed by appending the style to its \(new\) parent.) 20 294.941 ws 26.668 260.9(Style::append and Style::remove add and delete a style from the list of styles) 24 412 ws 16 247.16(nested inside another style. Style::children returns the number of nested styles.) 21 412 ws 16 233.42(Style::child returns the indexed child in the list. Style::find_style returns the) 21 412 ws 16 219.68(nested style with the given name or nil if there is none.) 22 279.306 ws 26.668 205.04(Style::attribute adds a <) 6 142.876 ws 12 /Times-Italic sf 142.876 205.04(name,value) 10 197.86 as 12 /Times-Roman sf 197.86 205.04(> pair to the list of attributes in the style. If) 21 412 ws 16 191.3(an attribute is already defined with the name, the value will be updated unless) 26 412 ws 16 177.56(the specified priority is lower than the already-defined priority of the attribute) 22 412 ws 16 163.82(Style::remove_attribute deletes the named attribute from the style's attribute list.) 18 412 ws 16 150.08(Style::attributes and the get form of Style::attribute can be used to retrieve all the) 26 412 ws 16 136.34(attributes defined on a style. The order of the list is arbitrary.) 24 311.285 ws 18 /Times-Bold sf 16 95.0601(8.2) 3 38.5 as 51 95.0601(Finding an attribute) 4 207.025 ws 12 /Times-Roman sf 16 62.6601(The style class provides two overloaded functions for finding an attribute value) 22 412 ws 394.8 38.16(8-) 2 404.796 as 407.796 38.16(1) 1 413.796 as showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 262.05(given the name. Style::find_attribute takes two parameters and returns a boolean) 21 412 ws 16 248.31(value that is true if the attribute is found and false otherwise. The first parameter) 29 412 ws 16 234.57(is the desired name, which can either be passed as a String object or a ) 30 386.668 ws 12 /Times-Italic sf 386.668 234.57(const) 5 412 as 16 220.83(char*) 5 43.996 as 12 /Times-Roman sf 43.996 220.83(. The second parameter is a reference to where the value of the attribute) 27 412 ws 16 207.09(should be stored if found. If the parameter is a string, then the value is simply) 31 412 ws 16 193.35(copied directly. If it is a long or double, then value string is converted to a) 31 412 ws 16 179.61(number. If the result parameter is a Coord, then the value string is converted to a) 31 412 ws 16 165.87(number and multiplied by the units specified in the value string after the number.) 26 412 ws 16 152.13(The unit specification can be \252in\272 for inches, \252cm\272 for centimeters, \252mm\272 for) 24 412 ws 16 138.39(millimeters, \252em\272 for the width in points of the character \252m\272 in the style's font,) 28 412 ws 16 124.65(and \252pt\272 for points.) 6 108.653 ws 26.668 110.01(The other function for finding an attribute is Style::value_is_on. This function) 21 412 ws 16 96.27(is equivalent to calling Style::find_attribute and testing if the value string is \252on\272) 24 412 ws 16 82.53(or \252true\272. The test is case-insensitive.) 11 197.129 ws 394.8 38.16(8-) 2 404.796 as 407.796 38.16(2) 1 413.796 as newpath 16.24 672.22 moveto 16.24 673.22 lineto 412.24 673.22 lineto 412.24 672.22 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.576 655.66(interface Style : Resource {) 8 158.187 ws 45.906 644.14(Style\(\);) 8 77.576 as 45.906 632.62(Style\(const String& name\);) 4 164.836 ws 45.906 621.1(Style\(Style* parent\);) 2 134.826 ws 45.906 609.58(Style\(const String& name, Style* parent\);) 8 227.647 ws 45.906 593.06(void name\(const String&\);) 4 160.947 ws 45.906 581.54(const String* name\(\) const;) 6 166.507 ws 45.906 570.02(void alias\(const String&\);) 4 156.497 ws 45.906 558.5(long alias_count\(\) const;) 4 154.287 ws 45.906 546.98(const String* alias\(long\) const;) 6 180.957 ws 45.906 535.46(Style* parent\(\) const;) 4 139.277 ws 45.906 518.94(void append\(Style*\);) 2 135.946 ws 45.906 507.42(void remove\(Style*\);) 2 135.926 ws 45.906 495.9(long children\(\) const;) 4 138.717 ws 45.906 484.38(Style* child\(long\) const;) 4 150.387 ws 45.906 467.86(void attribute\(const String& name, const String& value, int priority = 0\);) 20 357.426 ws 45.906 456.34(void remove_attribute\(const String& name\);) 6 238.757 ws 45.906 444.82(long attributes\(\) const;) 4 144.837 ws 45.906 433.3(boolean attribute\(long, String& name, String& value\) const;) 12 306.587 ws 45.906 416.78(void add_trigger\(const String& , Action*\);) 8 226.537 ws 45.906 405.26(void remove_trigger\(const String&, Action* = nil\);) 10 261.817 ws 45.906 393.74(void add_trigger_any\(Action*\);) 2 180.406 ws 45.906 382.22(void remove_trigger_any\(Action*\);) 2 197.066 ws 45.906 365.7(boolean find_attribute\(const String&, String& value\) const;) 10 302.696 ws 45.906 354.18(boolean find_attribute\(const String&, long&\) const;) 8 268.797 ws 45.906 342.66(boolean find_attribute\(const String&, double&\) const;) 8 279.916 ws 45.906 331.14(boolean find_attribute\(const String&, Coord&\) const;) 8 277.126 ws 45.906 319.62(boolean value_is_on\(const String&\);) 4 206.536 ws 37.576 308.1(};) 2 43.696 as 10 /Helvetica sf 157.831 291.58(Figure 8.1:) 2 205.631 ws 213.961 291.58(Style protocol.) 2 277.321 ws newpath 16.24 283.41 moveto 16.24 284.41 lineto 412.24 284.41 lineto 412.24 283.41 lineto closepath gsave eofill grestore showpage %%Page: 3 3 90.05 36.94 translate 0 0 0 setrgbcolor 18 /Times-Bold sf 16 667.52(8.3) 3 38.5 as 51 667.52(Wildcard matching) 2 200.508 ws 12 /Times-Roman sf 16 635.12(Attribute names may contain \252*\272 characters to specify wildcard matching. A) 21 412 ws 16 621.38(name of the form A*B will match an attribute B in a nested style named A.) 30 412 ws 16 607.64(Wildcard names also may begin with a \252*\272, which matches in any descendant) 24 412 ws 16 593.9(style. Thus, *A*B will match an attribute B in any descendant style named A.) 27 412 ws 16 580.16(Because attributes are inherited, specifying the wildcard name *B is identical to) 23 412 ws 16 566.42(specifying the normal attribute B.) 8 177.653 ws 26.668 551.78(In addition to a name, styles may have a list of associated aliases. Style::alias) 27 412 ws 16 538.04(prepends a string to the list. Wildcard matches search using a style's name first,) 27 412 ws 16 524.3(then search using the style's aliases in the reverse order in which they are defined.) 28 412 ws 16 510.56(Aliases are typically used for indicating a subclass relationship and allowing) 20 412 ws 16 496.82(styles to inherit attributes specified for a superclass.) 14 264.629 ws 26.668 482.18(For example, suppose the root style defines the following attributes:) 18 353.309 ws 10 /Helvetica sf 48.004 467.54(*Mover*autorepeat:off) 21 145.274 as 48.004 453.1(*UpMover*autorepeat:on) 22 158.054 as 12 /Times-Roman sf 26.668 433.66(Consider descendant styles S and T: S's aliases are UpMover and Mover; T's) 25 412 ws 16 419.92(aliases are DownMover and Mover. Style::find_attribute for \252autorepeat\272 will) 17 412 ws 16 406.18(return \252on\272 for S, \252off\272 for T.) 12 157.95 ws 26.668 391.54(The wildcard matching algorithm is compatible with the X resource manager to) 22 412 ws 16 377.8(support the same user customization functionality. Wildcard attributes typically) 17 412 ws 16 364.06(are defined only on the root style, as loaded from the window system, application) 26 412 ws 16 350.32(defaults files, or command-line arguments.) 8 221.969 ws 18 /Times-Bold sf 16 309.04(8.4) 3 38.5 as 51 309.04(Using styles with glyphs) 6 234.529 ws 12 /Times-Roman sf 16 276.64(Glyphs that draw typically contain the specific style information they need to) 22 412 ws 16 262.9(render. For example, a character glyph contains the font and color it uses to draw.) 29 412 ws 16 249.16(Higher level glyphs, such as a slider for scrolling, contain a style from which) 26 412 ws 16 235.42(they construct their components. When styles support trigger routines to detect) 21 412 ws 16 221.68(attribute value changes, these higher-level components will be able to reconstruct) 20 412 ws 16 207.94(their contents automatically.) 4 152.321 ws 26.668 193.3(Figure 8.2 shows a function that builds a vertical scrollbar by creating a) 24 412 ws 16 179.56(box containing an up-mover \(button with up-arrow\), a scroller \(slider\), and a) 22 412 ws 16 165.82(down-mover \(button with down-arrow\). The function creates a new style and) 21 412 ws 16 152.08(gives it the prefixes VScrollBar and ScrollBar for customization. If the attribute) 23 412 ws 16 138.34(\252mover_size\272 is defined on the style, then its value will override the default \(15.0\).) 26 412 ws 18 /Times-Bold sf 16 97.0601(8.5) 3 38.5 as 51 97.0601(Summary) 7 126.996 as 12 /Times-Roman sf 16 64.6601(User interface geometry and attribute management are two different problems that) 20 412 ws 394.8 38.16(8-) 2 404.796 as 407.796 38.16(3) 1 413.796 as showpage %%Page: 4 4 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 671.36(are best solved independently. Whereas glyphs define a physical organization) 19 412 ws 16 657.62(with a directed acyclic graph, styles define a logical organization with a strict) 24 412 ws 16 643.88(hierarchy. Both structures are simple and the connection between them is) 21 412 ws 16 630.14(straightforward.) 16 92.98 as 26.668 615.5(Styles provide a unified framework for managing user-customizable attributes,) 16 412 ws 16 601.76(document formatting information, and structured graphics state. Style prefixes) 17 412 ws 16 588.02(support wildcarding and allow the decoupling of the implementation class) 18 412 ws 16 574.28(hierarchy from the logical class hierarchy offered to the user for the purposes) 24 412 ws 16 560.54(of customization. This approach makes applications simpler to develop, more) 19 412 ws 16 546.8(consistent to use, and easier to integrate.) 12 209.969 ws 394.8 38.16(8-) 2 404.796 as 407.796 38.16(4) 1 413.796 as showpage %%Page: 5 5 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 394.8 38.16(8-) 2 404.796 as 407.796 38.16(5) 1 413.796 as newpath 14.32 613.66 moveto 14.32 614.66 lineto 410.32 614.66 lineto 410.32 613.66 lineto closepath gsave eofill grestore 10 /Helvetica sf 35.656 597.1(Glyph* vscroll_bar\(Adjustable* a\) {) 6 188.487 ws 43.986 585.58(WidgetKit& kit = *WidgetKit::instance\(\);) 6 216.547 ws 43.986 574.06(const LayoutKit& layout = *LayoutKit::instance\(\);) 8 257.707 ws 43.986 562.54(kit.begin_style\("VScrollBar"\);) 30 171.116 as 43.986 550.02(kit.alias\("ScrollBar"\);) 23 134.426 as 43.986 538.5(Style* s = kit.style\(\);) 6 132.067 ws 43.986 526.98(Coord mover_size = 15.0;) 6 158.757 ws 43.986 515.46(s->find_attribute\("mover_size", mover_size\);) 2 240.306 ws 43.986 503.94(Glyph* sep = layout.vspace\(1.0\);) 6 188.777 ws 43.986 492.42(return kit.inset_frame\() 2 141.236 ws 52.316 480.9(layout.vbox\() 12 106.226 as 60.646 469.38(layout.v_fixed_span\(up_mover\(a, s\), mover_size\),) 4 282.386 ws 60.646 457.86(sep,) 4 79.546 as 60.646 446.34(new VScroller\(a, s\),) 4 147.887 ws 60.646 434.82(sep,) 4 79.546 as 60.646 423.3(layout.v_fixed_span\(down_mover\(a, s\), mover_size\)) 4 292.386 ws 52.316 411.78(\),) 2 58.426 as 52.316 400.26(s) 1 57.316 as 43.986 388.74(\);) 2 50.096 as 35.656 377.22(}) 1 38.996 as 10 /Helvetica sf 125.901 360.7(Figure 8.2:) 2 173.701 ws 182.031 360.7(Using styles to build glyphs.) 8 305.411 ws newpath 14.32 352.53 moveto 14.32 353.53 lineto 410.32 353.53 lineto 410.32 352.53 lineto closepath gsave eofill grestore showpage %%Trailer end restore %%Pages: 5 %!PS-Adobe-2.0 %%Creator: ./ch9.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 16 662.72(Chapter 9) 2 119.321 ws 16 625.76(WidgetKit) 9 124 as 12 /Times-Roman sf 16 597.44(WidgetKit defines operations for creating user interface objects with a concrete) 20 412 ws 16 583.7(look-and-feel. Typically, an application uses a widget kit to create specific) 21 412 ws 16 569.96(components, such as pulldown menus, push buttons, and scrollbars. WidgetKit) 19 412 ws 16 556.22(isolates the application from specific look-and-feel issues and the details of how) 22 412 ws 16 542.48(a concrete component is implemented. Many components are defined using) 19 412 ws 16 528.74(instances of existing classes. For example, a push button with a string label is) 27 412 ws 16 515(created using a button, label, and two bevel objects.) 16 264.293 ws 26.668 500.36(InterViews provides a base widget kit class for creating common user interface) 22 412 ws 16 486.62(objects. Subclasses are provided for implementing concrete objects based on the) 21 412 ws 16 472.88(Motif \(default\) and OpenLook user interfaces.) 10 237.941 ws 26.668 458.24(WidgetKit::instance is a static member function that returns a default kit. If a) 25 412 ws 16 444.5(kit has not yet been created, WidgetKit::instance creates one using the session's) 22 412 ws 16 430.76(style to determine which kit subclass to construct.) 14 255.317 ws 18 /Times-Bold sf 16 389.48(9.1) 3 38.5 as 51 389.48(Style management) 2 192.48 ws 12 /Times-Roman sf 16 357.08(WidgetKit maintains a current style for use in customizing widgets. The initial) 23 412 ws 16 343.34(style is the root style for all windows. WidgetKit defines the operations shown in) 27 412 ws 16 329.6(Figure 9.1 for querying and modifying the style.) 14 247.649 ws 26.668 314.96(WidgetKit::style sets or gets the current style. When the style is set or changed) 27 412 ws 16 301.22(via a Style::attribute call, WidgetKit::style_changed is called to allow WidgetKit) 18 412 ws 16 287.48(subclasses to recompute information associated with the current style \(such as) 20 412 ws 16 273.74(colors for shading\).) 4 109.649 ws 26.668 259.1(WidgetKit::begin_style sets the current style to a newly-created style that is) 20 412 ws 16 245.36(a child of the current style. The given string is the name of the new style.) 31 412 ws 16 231.62(WidgetKit::alias adds an alias name for the current style. Widget::end_style) 19 412 ws 394.8 39.12(9-) 2 404.796 as 407.796 39.12(1) 1 413.796 as newpath 16.24 207.58 moveto 16.24 208.58 lineto 412.24 208.58 lineto 412.24 207.58 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.576 191.02(void style\(Style*\);) 2 114.816 ws 37.576 179.5(Style* style\(\) const;) 4 123.157 ws 37.576 167.98(void begin_style\(const String&\), end_style\(\);) 6 233.207 ws 37.576 156.46(void alias\(const String&\);) 4 148.167 ws 37.576 144.94(void push_style\(\), pop_style\(\);) 4 170.957 ws 37.576 133.42(void style_changed\(Style*\);) 2 158.736 ws 37.576 121.9(const Font* font\(\) const;) 6 143.737 ws 37.576 110.38(const Color* foreground\(\) const;) 6 179.297 ws 37.576 98.86(const Color* background\(\) const;) 6 183.187 ws 10 /Helvetica sf 93.9159 82.34(Figure 9.1:) 2 141.716 ws 150.046 82.34(WidgetKit operations for style management) 8 341.236 ws newpath 16.24 74.17 moveto 16.24 75.17 lineto 412.24 75.17 lineto 412.24 74.17 lineto closepath gsave eofill grestore showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 524.17(returns the current style to what it was before the call to WidgetKit::begin_style.) 24 412 ws 16 510.43(WidgetKit::push_style and pop_style save and restore the current style on a stack.) 22 409.276 ws 26.668 495.79(WidgetKit::font, foreground, and background return specific attribute) 12 412 ws 16 482.05(information for the current style. These operations are equivalent to \(though) 21 412 ws 16 468.31(potentially faster than\) finding the string value of a style attribute and then) 24 412 ws 16 454.57(looking up the resource with the given name. For example, WidgetKit::font is) 23 412 ws 16 440.83(the same as finding the attribute named \252font\272 and calling Font::lookup on the) 24 412 ws 16 427.09(attribute's value.) 2 96.6524 ws 18 /Times-Bold sf 16 385.81(9.2) 3 38.5 as 51 385.81(Common cursors) 2 183.48 ws 12 /Times-Roman sf 16 353.41(WidgetKit provides operations to retrieve commonly-used cursors that might be) 18 412 ws 16 339.67(shared among several widgets. Figure 9.2 shows the currently-defined operations.) 19 412 ws 16 325.93(WidgetKit::hand_cursor is the outline of a small hand. WidgetKit::lfast_cursor) 17 412 ws 16 312.19(is a double-arrow pointing to the left that is typically used in continuous rate) 26 412 ws 16 298.45(scrolling. Similarly, the other \252fast\272 cursors are double-arrows pointing in various) 21 412 ws 16 284.71(directions.) 11 66.328 as 18 /Times-Bold sf 16 243.43(9.3) 3 38.5 as 51 243.43(Bevels) 6 99.996 as 12 /Times-Roman sf 16 211.03(On color displays, it is often desirable to frame objects with a beveled look to give) 30 412 ws 16 197.29(a 3D appearance. WidgetKit provides the following three functions for creating) 21 412 ws 16 183.55(beveled frames:) 2 92.3084 ws 26.668 164.11(Glyph* inset_frame\(Glyph*\) const;) 4 197.981 ws 26.668 150.67(Glyph* outset_frame\(Glyph*\) const;) 4 203.98 ws 26.668 137.23(Glyph* bright_inset_frame\(Glyph*\) const;) 4 232.648 ws 16 117.79(WidgetKit:inset_frame uses dark shading in the upper left and light shading) 20 412 ws 16 104.05(in the lower right to make the contents of the frame appear to be recessed.) 28 412 ws 16 90.31(WidgetKit::outset_frame reverses the shading to make the contents appear to) 18 412 ws 16 76.57(project out of the frame. WidgetKit::bright_inset_frame is like inset_frame but) 19 412 ws 16 62.83(uses a brighter background color and is thinner.) 14 244.625 ws 394.8 39.12(9-) 2 404.796 as 407.796 39.12(2) 1 413.796 as newpath 17.2 678.94 moveto 17.2 679.94 lineto 413.2 679.94 lineto 413.2 678.94 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.536 662.38(Cursor* hand_cursor\(\) const;) 4 166.906 ws 38.536 650.86(Cursor* lfast_cursor\(\) const;) 4 163.007 ws 38.536 639.34(Cursor* lufast_cursor\(\) const;) 4 168.567 ws 38.536 627.82(Cursor* ufast_cursor\(\) const;) 4 166.346 ws 38.536 616.3(Cursor* rufast_cursor\(\) const;) 4 169.676 ws 38.536 604.78(Cursor* rfast_cursor\(\) const;) 4 164.117 ws 38.536 593.26(Cursor* rdfast_cursor\(\) const;) 4 169.676 ws 38.536 581.74(Cursor* dfast_cursor\(\) const;) 4 166.346 ws 38.536 570.22(Cursor* ldfast_cursor\(\) const;) 4 168.567 ws 10 /Helvetica sf 151.296 553.7(Figure 9.2:) 2 199.096 ws 207.426 553.7(WidgetKit cursors) 2 285.776 ws newpath 17.2 545.53 moveto 17.2 546.53 lineto 413.2 546.53 lineto 413.2 545.53 lineto closepath gsave eofill grestore showpage %%Page: 3 3 90.05 36.94 translate 0 0 0 setrgbcolor 18 /Times-Bold sf 16 667.52(9.4) 3 38.5 as 51 667.52(Labels) 6 102.012 as 12 /Times-Roman sf 16 635.12(A label is a string of text with the current style's font and color. WidgetKit) 29 412 ws 16 621.38(provides two operations for creating labels:) 10 224.297 ws 37.336 601.94(Glyph* label\(const char*\) const;) 6 194.309 ws 37.336 588.5(Glyph* label\(const String&\) const;) 6 206.333 ws 18 /Times-Bold sf 16 547.22(9.5) 3 38.5 as 51 547.22(Buttons) 7 111.012 as 12 /Times-Roman sf 16 514.82(A button is an input handler that can perform an action when pressed. Buttons) 26 412 ws 16 501.08(manipulate a ) 4 83.8489 ws 12 /Times-Italic sf 83.8489 501.08(telltale state) 2 144.449 ws 12 /Times-Roman sf 144.449 501.08( object so that views \(which are typically part of the) 21 412 ws 16 487.34(button's body\) can reflect the current state visually. The button itself is a view so) 29 412 ws 16 473.6(that it can damage the canvas when appropriate, freeing other views from the need) 26 412 ws 16 459.86(to store update information.) 6 149.321 ws 26.668 445.22(A telltale state can be part of a ) 16 180.277 ws 12 /Times-Italic sf 180.277 445.22(telltale group) 2 245.821 ws 12 /Times-Roman sf 245.821 445.22(. When one member of a group is) 15 412 ws 16 431.48(chosen, then the currently chosen state becomes unchosen. Telltale groups are) 21 412 ws 16 417.74(useful for implementing radio buttons.) 8 200.993 ws 26.668 403.1(Figure 9.3 shows the button, telltale state, and telltale group protocols.) 20 412 ws 16 389.36(Button just provides operations to access the associated telltale state and action.) 22 412 ws 16 375.62(TelltaleState defines a set of flags that define the current state. TelltaleState::set) 23 412 ws 16 361.88(and TelltaleState::test modify and query the current state, respectively.) 16 412 ws 16 348.14(TelltaleState::join and TelltaleState::leave_group allow the state to be associated) 16 412 ws 16 334.4(with a group.) 4 79.6608 ws 26.668 319.76(Figure 9.4 shows the WidgetKit operations that return buttons. Push button,) 21 412 ws 16 306.02(default button, and palette button typically have a similar appearance. Neither a) 23 412 ws 16 292.28(push button or a default button can be chosen, whereas a palette button can. A) 29 412 ws 16 278.54(default button might have a different appearance to indicate to the user that it is) 28 412 ws 16 264.8(the common choice.) 4 112.985 ws 26.668 250.16(A check box is a toggle button: choosing it when already chosen will cause it to) 30 412 ws 16 236.42(become unchosen. A radio button must belong to a telltale group so that within) 27 412 ws 16 222.68(the group only one button is chosen at any given time.) 20 276.318 ws 26.668 208.04(For application-specific actions, it is necessary to define action callbacks for the) 22 412 ws 16 194.3(relevant application classes. In the case of quitting the application WidgetKit::quit) 21 412 ws 16 180.56(can be used to return an action that calls Session::quit.) 18 276.641 ws 18 /Times-Bold sf 16 139.28(9.6) 3 38.5 as 51 139.28(Menus) 5 103.002 as 12 /Times-Roman sf 16 106.88(A menu is similar to a group of related buttons, called menu items. Like a button,) 31 412 ws 16 93.1401(the look of a menu item is dependant on a telltalestate. Menu items can have) 29 412 ws 16 79.4(associated actions that are executed when the item is chosen. Menus items can) 25 412 ws 16 65.66(also have associated nested menus, in which case the submenu is opened when the) 26 412 ws 394.8 39.12(9-) 2 404.796 as 407.796 39.12(3) 1 413.796 as showpage %%Page: 4 4 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 260.33(item is highlighted. Figure 9.5 shows the WidgetKit menu operations and the) 24 412 ws 16 246.59(menu item and menu protocols.) 8 167.657 ws 26.668 231.95(WidgetKit::menubar creates a horizontal menu with a small amount of white) 20 412 ws 16 218.21(space between items. WidgetKit::pulldown and WidgetKit::pullright create) 13 412 ws 16 204.47(vertical menus. The top of a pulldown menu will be aligned to the bottom of the) 31 412 ws 16 190.73(menubar, while a pullright's top will be aligned to the top right of its containing) 28 412 ws 16 176.99(item.) 5 40.336 as 26.668 162.35(WidgetKit::menubar_item creates an item centered horizontally with a small) 16 412 ws 16 148.61(amount of white space on each side. WidgetKit::menu_item creates a left-adjusted) 21 412 ws 16 134.87(item, WidgetKit::check_menu_item creates a toggle item that looks like a check) 20 412 ws 16 121.13(box when chosen. WidgetKit::radio_menu_item creates an item that looks like) 19 412 ws 16 107.39(a radio button. WidgetKit::menu_item_separator returns an item for visually) 17 412 ws 16 93.65(separating other items \(such as a horizontal line\).) 14 251.957 ws 394.8 39.12(9-) 2 404.796 as 407.796 39.12(4) 1 413.796 as newpath 16.24 642.46 moveto 16.24 643.46 lineto 412.24 643.46 lineto 412.24 642.46 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.576 625.9(interface Button : ActiveHandler, Observer {) 10 230.997 ws 45.906 614.38(Button\(Glyph*, Style*, TelltaleState*, Action*\);) 7 249.607 ws 45.906 602.86(TelltaleState* state\(\) const;) 4 165.957 ws 45.906 591.34(Action* action\(\) const;) 4 143.167 ws 37.576 579.82(};) 2 43.696 as 37.576 563.3(typedef unsigned int TelltaleFlags;) 6 189.317 ws 37.576 546.78(interface TelltaleState : Resource, Observable {) 10 248.227 ws 45.906 535.26(TelltaleState\(const TelltaleFlags = 0\);) 6 211.247 ws 45.906 523.74(enum {) 2 77.0364 ws 54.236 512.22(is_enabled, is_visible, is_enabled_visible, is_active, is_enabled_active,) 8 368.816 ws 54.236 500.7(is_visible_active, is_enabled_visible_active, is_chosen, is_enabled_chosen,) 6 390.496 ws 54.236 489.18(is_visible_chosen, is_enabled_visible_chosen,) 2 260.436 ws 54.236 477.66(is_enabled_active_chosen, is_active_chosen,) 2 257.116 ws 54.236 466.14(is_visible_active_chosen, is_enabled_visible_active_chosen,) 2 323.796 ws 54.236 454.62(is_running, is_choosable, is_toggle,) 4 212.646 ws 54.236 443.1(max_flags) 9 99.806 as 45.906 431.58(};) 2 52.026 as 45.906 415.06(TelltaleFlags flags\(\) const;) 4 162.607 ws 45.906 403.54(void set\(const TelltaleFlags, boolean\);) 6 214.307 ws 45.906 392.02(boolean test\(const TelltaleFlags\) const;) 6 219.867 ws 45.906 380.5(void join\(TelltaleGroup*\);) 2 155.936 ws 45.906 368.98(void leave_group\(\);) 2 131.496 ws 37.576 357.46(};) 2 43.696 as 37.576 340.94(interface TelltaleGroup : Resource {) 8 195.977 ws 45.906 329.42(void update\(TelltaleState*\);) 2 166.516 ws 45.906 317.9(void remove\(TelltaleState*\);) 2 169.276 ws 37.576 306.38(};) 2 43.696 as 10 /Helvetica sf 78.9009 289.86(Figure 9.3:) 2 126.701 ws 135.031 289.86(Button, TelltaleState, and TelltaleGroup protocols.) 8 356.251 ws newpath 16.24 281.69 moveto 16.24 282.69 lineto 412.24 282.69 lineto 412.24 281.69 lineto closepath gsave eofill grestore showpage %%Page: 5 5 90.05 36.94 translate 0 0 0 setrgbcolor 18 /Times-Bold sf 16 452.17(9.7) 3 38.5 as 51 452.17(Adjusters) 9 125.988 as 12 /Times-Roman sf 16 419.77(Scrollbars and mover buttons are examples of interactive objects that \252adjust\272 the) 22 412 ws 16 406.03(view shown by another object. WidgetKit provides the operations shown in) 21 412 ws 16 392.29(Figure 9.6 to create common adjusters.) 10 202.973 ws 26.668 377.65(WidgetKit::hscroll_bar and WidgetKit::vscroll_bar return controls for scrolling) 12 412 ws 16 363.91(a view in the horizontal and vertical dimensions, respectively. WidgetKit::panner) 19 412 ws 16 350.17(returns a control for scrolling two adjustables at once. One adjustable is controlled) 25 412 ws 16 336.43(by the horizontal position of the panner, one by the vertical position. Typically,) 25 412 ws 16 322.69(the same adjustable is passed to both parameters when creating a panners.) 22 370.589 ws 394.8 39.12(9-) 2 404.796 as 407.796 39.12(5) 1 413.796 as newpath 18.16 679.9 moveto 18.16 680.9 lineto 414.16 680.9 lineto 414.16 679.9 lineto closepath gsave eofill grestore 10 /Helvetica sf 39.496 663.34(Button* push_button\(const String&, Action*\) const;) 8 262.947 ws 39.496 651.82(Button* push_button\(Glyph*, Action*\) const;) 6 233.487 ws 39.496 640.3(Button* default_button\(const String&, Action*\) const;) 8 271.287 ws 39.496 628.78(Button* default_button\(Glyph*, Action*\) const;) 6 241.827 ws 39.496 617.26(Button* palette_button\(const String&, Action*\) const;) 8 271.287 ws 39.496 605.74(Button* palette_button\(Glyph*, Action*\) const;) 6 241.827 ws 39.496 594.22(Button* check_box\(const String&, Action*\) const;) 8 255.707 ws 39.496 582.7(Button* check_box\(Glyph*, Action*\) const;) 7 227.637 ws 39.496 571.18(Button* radio_button\(TelltaleGroup*, const String&, Action*\) const;) 10 332.966 ws 39.496 548.14(Glyph* push_button_look\(Glyph*, TelltaleState*\) const;) 6 282.386 ws 39.496 536.62(Glyph* default_button_look\(Glyph*, TelltaleState*\) const;) 6 290.726 ws 39.496 525.1(Glyph* palette_button_look\(Glyph*, TelltaleState*\) const;) 6 290.726 ws 39.496 513.58(Glyph* check_box_look\(Glyph*, TelltaleState*\) const;) 6 275.146 ws 39.496 502.06(Glyph* radio_button_look\(Glyph*, TelltaleState*\) const;) 6 282.936 ws 10 /Helvetica sf 130.011 485.54(Figure 9.4:) 2 177.811 ws 186.141 485.54(WidgetKit button operations) 4 308.981 ws newpath 18.16 477.37 moveto 18.16 478.37 lineto 414.16 478.37 lineto 414.16 477.37 lineto closepath gsave eofill grestore showpage %%Page: 6 6 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 394.8 39.12(9-) 2 404.796 as 407.796 39.12(6) 1 413.796 as newpath 14.3201 653.98 moveto 14.3201 654.98 lineto 410.32 654.98 lineto 410.32 653.98 lineto closepath gsave eofill grestore 10 /Helvetica sf 35.6561 637.42(Menu* menubar\(\) const, * pulldown\(\) const, * pullright\(\) const;) 16 308.527 ws 35.6561 625.9(MenuItem* menubar_item\(const String&\) const;) 6 246.287 ws 35.6561 614.38(MenuItem* menubar_item\(Glyph*\) const;) 4 216.826 ws 35.6561 602.86(MenuItem* menu_item\(const String&\) const;) 6 231.837 ws 35.6561 591.34(MenuItem* menu_item\(Glyph*\) const;) 4 202.376 ws 35.6561 579.82(MenuItem* check_menu_item\(const String&\) const;) 6 263.516 ws 35.6561 568.3(MenuItem* check_menu_item\(Glyph*\) const;) 4 234.056 ws 35.6561 556.78(MenuItem* radio_menu_item\(TelltaleGroup*, Glyph*\) const;) 6 299.636 ws 35.6561 545.26(MenuItem* menu_item_separator\(\) const;) 4 220.166 ws 35.6561 528.74(Glyph* menubar_look\(\) const, pulldown_look\(\) const, pullright_look\(\) const;) 12 367.996 ws 35.6561 517.22(Glyph* menubar_item_look\(Glyph*, TelltaleState*\) const;) 6 287.416 ws 35.6561 505.7(Glyph* menu_item_look\(Glyph*, TelltaleState*\) const;) 6 272.966 ws 35.6561 494.18(Glyph* check_menu_item_look\(Glyph*, TelltaleState*\) const;) 6 304.646 ws 35.6561 482.66(Glyph* radio_menu_item _look\(Glyph*, TelltaleState*\) const;) 8 303.536 ws 35.6561 471.14(Glyph* menu_item_separator_look\(\) const;) 4 225.726 ws 35.6561 449.62(interface MenuItem : Observer {) 8 176.827 ws 43.9861 438.1(MenuItem\(Glyph*, TelltaleState*\);) 2 192.926 ws 43.9861 426.58(Glyph* body\(\) const;) 4 134.577 ws 43.9861 415.06(TelltaleState* state\(\) const;) 4 164.037 ws 43.9861 403.54(void action\(Action*\);) 2 132.906 ws 43.9861 392.02(Action* action\(\) const;) 4 141.247 ws 43.9861 380.5(void menu\(Menu*, Window* = nil\);) 8 194.867 ws 43.9861 368.98(Menu* menu\(\) const;) 4 136.797 ws 43.9861 357.46(Window* window\(\) const;) 4 155.677 ws 35.6561 345.94(};) 2 41.7761 as 35.6561 329.42(interface Menu : InputHandler {) 8 173.507 ws 43.9861 317.9(Menu\(Glyph*, Style*, float x1, float y1, float x2, float y2\);) 18 291.327 ws 43.9861 306.38(void append_item\(MenuItem*\);) 2 180.706 ws 43.9861 294.86(void prepend_item\(MenuItem*\);) 2 184.036 ws 43.9861 283.34(void insert_item\(GlyphIndex, MenuItem*\);) 4 227.936 ws 43.9861 271.82(void remove_item\(GlyphIndex\);) 2 182.916 ws 43.9861 260.3(void replace_item\(GlyphIndex, MenuItem*\);) 4 236.276 ws 43.9861 248.78(GlyphIndex item_count\(\) const;) 4 182.377 ws 43.9861 237.26(MenuItem* item\(GlyphIndex\) const;) 4 200.706 ws 43.9861 225.74(void select\(GlyphIndex\);) 2 151.246 ws 43.9861 214.22(GlyphIndex selected\(\) const;) 4 170.707 ws 35.6561 202.7(};) 2 41.7761 as 10 /Helvetica sf 53.366 186.18(Figure 9.5:) 2 101.166 ws 109.496 186.18(WidgetKit menu operations, menu, and menu item protocols.) 14 377.946 ws newpath 14.3201 178.01 moveto 14.3201 179.01 lineto 410.32 179.01 lineto 410.32 178.01 lineto closepath gsave eofill grestore showpage %%Page: 7 7 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 394.8 39.12(9-) 2 404.796 as 407.796 39.12(7) 1 413.796 as newpath 15.28 597.34 moveto 15.28 598.34 lineto 411.28 598.34 lineto 411.28 597.34 lineto closepath gsave eofill grestore 10 /Helvetica sf 36.616 580.78(Glyph* hslider\(Adjustable*\) const;) 4 185.556 ws 36.616 569.26(Glyph* hscroll_bar\(Adjustable*\) const;) 4 205.006 ws 36.616 557.74(Glyph* vslider\(Adjustable*\) const;) 4 184.996 ws 36.616 546.22(Glyph* vscroll_bar\(Adjustable*\) const;) 4 204.446 ws 36.616 534.7(Glyph* panner\(Adjustable*, Adjustable*\) const;) 6 243.376 ws 36.616 518.18(Stepper* enlarger\(Adjustable*\) const;) 4 201.686 ws 36.616 506.66(Stepper* reducer\(Adjustabel*\) const;) 4 198.906 ws 36.616 495.14(Stepper* up_mover\(Adjustable*\) const;) 4 209.466 ws 36.616 483.62(Stepper* down_mover\(Adjustable*\) const;) 4 222.246 ws 36.616 472.1(Stepper* left_mover\(Adjustable*\) const;) 4 211.686 ws 36.616 460.58(Stepper* right_mover\(Adjustable*\) const;) 4 217.796 ws 36.616 444.06(Glyph* slider_look\(DimensionName, Adjustable*\) const;) 6 283.356 ws 36.616 432.54(Glyph* scroll_bar_look\(DimensionName, Adjustable*\) const;) 6 302.806 ws 36.616 421.02(Glyph* panner_look\(Adjustable*, Adjustable*\) const;) 6 267.276 ws 36.616 409.5(Glyph* enlarger_look\(TelltaleState*\);) 2 198.896 ws 36.616 397.98(Glyph* reducer_look\(TelltaleState*\);) 2 196.116 ws 36.616 386.46(Glyph* up_mover_look\(TelltaleState*\);) 2 206.676 ws 36.616 374.94(Glyph* down_mover_look\(TelltaleState*\);) 2 219.456 ws 36.616 363.42(Glyph* left_mover_look\(TelltaleState*\);) 2 208.896 ws 36.616 351.9(Glyph* right_mover_look\(TelltaleState*\);) 2 215.006 ws 10 /Helvetica sf 123.246 335.38(Figure 9.6:) 2 171.046 ws 179.376 335.38(WidgetKit adjuster operations) 4 309.986 ws newpath 15.28 327.21 moveto 15.28 328.21 lineto 411.28 328.21 lineto 411.28 327.21 lineto closepath gsave eofill grestore showpage %%Trailer end restore %%Pages: 7 %!PS-Adobe-2.0 %%Creator: ./ch10.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 16 662.72(Chapter 10) 2 131.321 ws 16 625.76(DialogKit) 9 116.008 as 12 /Times-Roman sf 16 597.44(Whereas WidgetKit provides operations for creating common look-and-feel) 14 412 ws 16 583.7(components such as scrollbars, menus, and buttons, DialogKit is creates) 18 412 ws 16 569.96(higher-level dialog objects. The current implementation of DialogKit provides) 17 412 ws 16 556.22(only field editors and file choosers, but in the future this kit will provide) 26 412 ws 16 542.48(operations for creating confirmers, quit dialogs, and information messages. Figure) 19 412 ws 16 528.74(10.1 shows the operations provided by DialogKit.) 12 255.317 ws 18 /Times-Bold sf 16 487.46(10.1) 4 47.5 as 51 487.46(Field editor) 2 140.496 ws 12 /Times-Roman sf 16 455.06(Many application need simple editors for entering or browsing data. A field editor) 25 412 ws 16 441.32(is suitable for incorporating into other components, such as a dialog box. Figure) 25 412 ws 16 427.58(10.2 shows the field editor class interface.) 12 217.961 ws 26.668 412.94(Clicking inside the editor \(or calling FieldEditor::edit\) initiates an edit.) 18 412 ws 16 399.2(Subsequent keyboard events, regardless of the pointer location, are interpreted as) 20 412 ws 16 385.46(editing operations on the text. Clicking outside the editor terminates the editing.) 23 401.152 ws 26.668 370.82(Text is selected with the pointer or with the keyboard. A single click of the left) 31 412 ws 16 357.08(button selects a new insertion point between characters. Dragging across the text) 23 412 ws 16 343.34(selects a range of characters. A set of control characters is mapped into common) 27 412 ws 16 329.6(editing operations. A character not specifically associated with commands is) 19 412 ws 16 315.86(inserted in place of the current selection, the replaced text is discarded, and) 24 412 ws 16 302.12(the selection becomes an insertion point following the inserted character. The) 21 412 ws 16 288.38(commands defined are:) 4 127.973 ws 37.336 268.94(character-left \(^B\)) 2 125.92 ws 37.336 255.5(character-right \(^F\)) 2 131.26 ws 37.336 242.06(beginning-of-text \(^A\)) 2 146.608 ws 37.336 228.62(end-of-text \(^E\)) 2 114.604 ws 37.336 215.18(erase \(^H or DEL\)) 6 126.593 ws 37.336 201.74(delete \(^D\)) 2 91.2764 ws 37.336 188.3(select-all \(^U\)) 2 105.94 ws 37.336 174.86(select-word\(^W\)) 15 118.264 as 16 155.42(Strings that are too long to fit into the editor can be scrolled horizontally. Clicking) 29 412 ws 16 141.68(the middle button inside the editor initiates \252grab-scrolling\272. While the button is) 23 412 ws 16 127.94(down the editor scrolls the text to follow the pointer, giving the appearance that) 26 412 ws 16 114.2(the user is dragging the text. Clicking the right button engages \252rate-scrolling\272, a) 25 412 ws 16 100.46(joy-stick-like scrolling interface in which the scrolling rate increases as the user) 22 412 ws 16 86.72(drags the pointer away from the initial click location.) 16 270.965 ws 26.668 72.08(The field editor constructor is passed a sample string, used to compute its) 24 412 ws 394.8 39.12(10-) 3 410.796 as 413.796 39.12(1) 1 419.796 as showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 523.17(natural size, a style for customization, and a field editor action to execute when) 26 412 ws 16 509.43(editing returns. Editing normally completes when a carriage return or tab is) 23 412 ws 16 495.69(entered; abnormally when an escape character is entered.) 14 289.901 ws 26.668 481.05(FieldEditor::field sets the contents of the string being edited. FieldEditor::select) 19 412 ws 16 467.31(sets the insertion point or subrange within the edit string. FieldEditor::edit) 21 412 ws 16 453.57(initiates an edit. Specifying a string and selection range is short-hand for first) 25 412 ws 16 439.83(calling FieldEditor::field and FieldEditor::select. FieldEditor::text returns the) 13 412 ws 16 426.09(current value of the string being edited. The caller must copy the string to save) 29 412 ws 16 412.35(the contents, as it will be modified by a subsequent edit.) 20 285.318 ws 394.8 39.12(10-) 3 410.796 as 413.796 39.12(2) 1 419.796 as newpath 16.24 678.94 moveto 16.24 679.94 lineto 412.24 679.94 lineto 412.24 678.94 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.576 662.38(interface DialogKit {) 4 124.837 ws 45.906 650.86(static DialogKit* instance\(\);) 4 165.387 ws 45.906 639.34(FieldEditor* field_editor\() 2 152.606 ws 54.236 627.82(const String& sample, Style*, FieldEditorAction* = nil) 12 286.827 ws 45.906 615.3(\) const;) 2 78.6964 ws 45.906 603.78(FileChooser* file_chooser\() 2 163.716 ws 54.236 592.26(constString& dir, Style*, FileChooserAction* = nil) 10 269.037 ws 45.906 580.74(\) const;) 2 78.6964 ws 37.576 569.22(};) 2 43.696 as 10 /Helvetica sf 141.991 552.7(Figure 10.1:) 2 195.351 ws 203.681 552.7(DialogKit operations) 2 293.161 ws newpath 16.24 544.53 moveto 16.24 545.53 lineto 412.24 545.53 lineto 412.24 544.53 lineto closepath gsave eofill grestore newpath 13.36 369.82 moveto 13.36 370.82 lineto 409.36 370.82 lineto 409.36 369.82 lineto closepath gsave eofill grestore 10 /Helvetica sf 34.696 353.26(interface FieldEditorAction Resource {) 7 204.487 ws 43.026 341.74(void execute\(FieldEditor*, boolean accept\);) 6 233.667 ws 34.696 330.22(};) 2 40.816 as 34.696 313.7(interface FieldEditorCallback\(T\) : FieldEditorAction {) 8 264.767 ws 43.026 302.18(FieldEditorCallback\(T\)\(T*, void \(T::*\)\(FieldEditor*, boolean accept\)\);) 8 341.986 ws 34.696 290.66(};) 2 40.816 as 34.696 274.14(interface FieldEditor : InputHandler {) 8 195.327 ws 43.026 262.62(FieldEditor\(const char* sample, Style*, FieldEditorAction* = nil\);) 12 323.396 ws 43.026 251.1(FieldEditor\(const String& sample, Style*, FieldEditorAction* = nil\);) 12 332.846 ws 43.026 234.58(void field\(const char*\);) 4 141.947 ws 43.026 223.06(void field\(const String&\);) 4 151.397 ws 43.026 211.54(void select\(int pos\);) 4 129.167 ws 43.026 200.02(void select\(int left, int right\);) 8 164.737 ws 43.026 188.5(void edit\(\);) 2 89.7064 ws 43.026 176.98(void edit\(const char*, int left, int right\);) 12 210.317 ws 43.026 165.46(void edit\(const String&, int left, int right\);) 12 219.767 ws 43.026 153.94(const char* text\(\) const;) 6 148.067 ws 43.026 142.42(void text\(String&\) const;) 4 149.177 ws 34.696 130.9(};) 2 40.816 as 10 /Helvetica sf 124.386 114.38(Figure 10.2:) 2 177.746 ws 186.076 114.38(Field editor class interface.) 6 305.006 ws newpath 13.36 106.21 moveto 13.36 107.21 lineto 409.36 107.21 lineto 409.36 106.21 lineto closepath gsave eofill grestore showpage %%Page: 3 3 90.05 36.94 translate 0 0 0 setrgbcolor 18 /Times-Bold sf 16 544.33(10.2) 4 47.5 as 51 544.33(Dialog) 6 101.004 as 12 /Times-Roman sf 16 511.93(A dialog is an object that can be posted temporarily and grabs input until it is) 30 412 ws 16 498.19(dismissed. Figure 10.3 shows the Dialog protocol. Dialog::post_for creates a) 20 412 ws 16 484.45(transient window for the dialog and aligns over the given window using the given) 26 412 ws 16 470.71(x and y alignment. The default is for the dialog to be centered over the window.) 31 400.432 ws 26.668 456.07(Dialog::post_at creates a top-level window aligned around the given position.) 18 412 ws 16 442.33(Dialog::run blocks until Dialog::dismiss is called, and Dialog::run returns the) 18 412 ws 16 428.59(value of the parameter that is passed to Dialog::dismiss.) 16 284.309 ws 18 /Times-Bold sf 16 387.31(10.3) 4 47.5 as 51 387.31(FileChooser) 11 143.988 as 12 /Times-Roman sf 16 354.91(A file chooser is a dialog subclass that allows the user to select a file in a directory) 34 412 ws 16 341.17(and returns the file name. Figure 10.4 shows the FileChooser protocol.) 21 356.465 ws 394.8 39.12(10-) 3 410.796 as 413.796 39.12(3) 1 419.796 as newpath 14.32 679.9 moveto 14.32 680.9 lineto 410.32 680.9 lineto 410.32 679.9 lineto closepath gsave eofill grestore 10 /Helvetica sf 35.656 663.34(interface DIalog : InputHandler {) 8 177.397 ws 43.986 651.82(Dialog\(Glyph*, Style*\);) 2 143.456 ws 43.986 640.3(boolean post_for\(Window*, float = 0.5, float = 0.5\);) 14 266.887 ws 43.986 628.78(boolean post_at\(Coord x, Coord y, float = 0.5, float = 0.5\);) 20 299.687 ws 43.986 617.26(boolean run\(\);) 2 106.236 ws 43.986 605.74(void dismiss\(boolean accept\);) 4 175.697 ws 35.656 594.22(};) 2 41.776 as 10 /Helvetica sf 151.466 577.7(Figure 10.3:) 2 204.826 ws 213.156 577.7(Dialog protocol) 2 279.846 ws newpath 14.32 569.53 moveto 14.32 570.53 lineto 410.32 570.53 lineto 410.32 569.53 lineto closepath gsave eofill grestore newpath 16.24 277.66 moveto 16.24 278.66 lineto 412.24 278.66 lineto 412.24 277.66 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.576 261.1(interface FileChooserAction : Resource {) 8 217.647 ws 45.906 249.58(void execute\(FileChooser*, boolean accept\);) 6 242.656 ws 37.576 238.06(};) 2 43.696 as 37.576 221.54(interface FileChooserCallback\(T\) : FileChooserAction {) 8 279.867 ws 45.906 210.02(FileChooserCallback\(T\)\(T*, void \(T::*\)\(FileChooser*, boolean accept\)\);) 8 357.086 ws 37.576 198.5(};) 2 43.696 as 37.576 181.98(interface FileChooser : Dialog {) 8 175.407 ws 45.906 170.46(const String* selected\(\) const;) 6 178.737 ws 45.906 158.94(void reread\(\);) 2 105.366 ws 37.576 147.42(};) 2 43.696 as 10 /Helvetica sf 140.606 130.9(Figure 10.4:) 2 193.966 ws 202.296 130.9(FileChooser protocol) 2 294.546 ws newpath 16.24 122.73 moveto 16.24 123.73 lineto 412.24 123.73 lineto 412.24 122.73 lineto closepath gsave eofill grestore showpage %%Trailer end restore %%Pages: 3 %!PS-Adobe-2.0 %%Creator: ./ch11.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 16 662.72(Chapter 11) 2 131.321 ws 16 625.76(LayoutKit) 9 122.68 as 12 /Times-Roman sf 16 597.44(Composite glyphs usually manage the physical layout of their children.) 18 412 ws 16 583.7(LayoutKit provides operations for creating objects that are useful in managing the) 22 412 ws 16 569.96(arrangement of one or more glyphs. The LayoutKit objects are modelled after the) 25 412 ws 16 556.22(Knuth's TeX document processing system.) 8 222.977 ws 18 /Times-Bold sf 16 514.94(11.1) 4 47.5 as 51 514.94(Boxes) 5 96 as 12 /Times-Roman sf 16 482.54(A box is a polyglyph that uses a layout object to arrange its components. A layout) 30 412 ws 16 468.8(object is not a glyph, but helps a glyph manage the requests and allocations of) 28 412 ws 16 455.06(component glyphs. Figure 11.1 shows the Layout protocol and the LayoutKit) 20 412 ws 16 441.32(operations that create boxes.) 6 152.633 ws 26.668 426.68(Layout::request is given an array of requisitions for the individual components) 20 412 ws 16 412.94(and computes a single requisition for the result. Layout::allocate is given the) 23 412 ws 16 399.2(requisitions of the components and the overall allocation, returning the allocations) 20 412 ws 16 385.46(of the individual components.) 6 159.329 ws 26.668 370.82(A box can be constructed either with a list of up to 10 initial glyph components,) 30 412 ws 16 357.08(or an initial size estimate on the number of components. The size is not a) 29 412 ws 16 343.34(maximum, but can avoid growing the list dynamically.) 14 278.993 ws 26.668 328.7(LayoutKit::hbox returns a box that tiles its components in the X) 20 412 ws 16 314.96(dimension left-to-right and aligns the component origins in the Y dimension.) 20 412 ws 16 301.22(LayoutKit::vbox returns a box that tiles top-to-bottom and aligns in the X) 22 412 ws 16 287.48(dimension. LayoutKit::overlay aligns in both the X and Y dimensions, drawing) 21 412 ws 16 273.74(the components in back-to-front order.) 8 201.629 ws 26.668 259.1(LayoutKit::hbox returns a box with its X origin at the left side of the) 26 412 ws 16 245.36(box; LayoutKit::vbox returns a box with its Y origin at the top of the box.) 28 412 ws 16 231.62(Sometimes it is more convenient to have the origin correspond to the origin) 24 412 ws 16 217.88(of the first component. For example, a column of text might want to have) 27 412 ws 16 204.14(its Y origin correspond to the base line of the first line of text. When the) 31 412 ws 16 190.4(aligment should correspond to the first component's alignment, one can use) 20 412 ws 16 176.66(LayoutKit::hbox_first_aligned or LayoutKit::vbox_first_aligned.) 4 328.324 ws 26.668 162.02(A ) 2 40.916 ws 12 /Times-Italic sf 40.916 162.02(deck) 4 62.9 as 12 /Times-Roman sf 62.9 162.02( is a polyglyph similar in some ways to an overlay box. However,) 25 412 ws 16 148.28(instead of overlaying its components, a deck is a polyglyph where only one of the) 28 412 ws 16 134.54(components is visible at any time. Figure 11.2 shows the deck protocol and the) 27 412 ws 16 120.8(LayoutKit operations to create decks.) 8 195.629 ws 26.668 106.16(Deck::flip_to sets which component should currently be visible; Deck::card) 17 412 ws 16 92.42(returns the current top. The natural size of a deck is the maximum size of the) 31 412 ws 16 78.68(natural sizes of its components. A deck can be stretched to be as large as its) 31 412 ws 16 64.94(largest fully-stretched component.) 5 181.805 ws 388.72 36.08(11-) 3 404.716 as 407.716 36.08(1) 1 413.716 as showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 18 /Times-Bold sf 16 245.37(11.2) 4 47.5 as 51 245.37(Glue) 4 88.008 as 12 /Times-Roman sf 16 212.97(Boxes stretch or shrink their components to fit the available space. However,) 23 412 ws 16 199.23(many components are rigid. For example, characters in text typically do not) 23 412 ws 16 185.49(stretch or shrink. Instead, we prefer to stretch or shrink the white space between) 27 412 ws 16 171.75(words. In TeX, this flexible white space is referred to as \252glue\272.) 23 324.089 ws 26.668 157.11(LayoutKit provides the set of operations to create glue object shown in Figure) 24 412 ws 16 143.37(11.3. LayoutKit::glue is the most general operation. It can either be passed a) 26 412 ws 16 129.63(specific dimension, natural size, stretchability, shrinkability, and alignment, or it) 18 412 ws 16 115.89(can be passed a complete requisition.) 10 194.633 ws 26.668 101.25(LayoutKit::hglue and LayoutKit::vglue can create glue that is horizontally or) 18 412 ws 16 87.51(vertically stretchable, respectively. The requirement in the minor dimension is) 19 412 ws 16 73.77(undefined. If no parameters are passed to LayoutKit::hglue or vglue, then a) 23 412 ws 16 60.03(natural size of zero is assumed. If no stretchability is specified, then the glue is) 29 412 ws 388.72 36.08(11-) 3 404.716 as 407.716 36.08(2) 1 413.716 as newpath 17.2 678.94 moveto 17.2 679.94 lineto 413.2 679.94 lineto 413.2 678.94 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.536 662.38(interface Layout {) 4 115.807 ws 46.866 650.86(void request\(GlyphIndex count, const Requisition*, Requisition& result\);) 12 363.106 ws 46.866 639.34(void allocate\() 2 105.776 ws 55.196 627.82(const Allocation& given, GlyphIndex count, const Requisition*,) 12 330.326 ws 55.196 616.3(Allocation* result) 2 129.666 ws 46.866 604.78(\);) 2 52.976 as 38.536 593.26(};) 2 44.656 as 38.536 571.74(PolyGlyph* box\(Layout*, GlyphIndex size = 10\) const;) 12 276.147 ws 38.536 560.22(PolyGlyph* hbox\(GlyphIndex size\) const;) 6 219.717 ws 38.536 548.7(PolyGlyph* hbox\() 2 115.786 ws 46.866 537.18(Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil,) 28 328.937 ws 46.866 525.66(Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil) 28 326.157 ws 38.536 514.14(\) const;) 2 71.3264 ws 38.536 502.62(PolyGlyph* vbox\(GlyphIndex size\) const;) 6 219.157 ws 38.536 491.1(PolyGlyph* vbox\() 2 115.226 ws 46.866 479.58(Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil,) 28 328.937 ws 46.866 468.06(Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil) 28 326.157 ws 38.536 456.54(\) const;) 2 71.3264 ws 38.536 445.02(PolyGlyph* hbox_first_aligned\(GlyphIndex size\) const;) 6 279.186 ws 38.536 433.5(PolyGlyph* hbox_first_aligned\() 2 175.256 ws 46.866 421.98(Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil,) 28 328.937 ws 46.866 410.46(Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil) 28 326.157 ws 38.536 398.94(\) const;) 2 71.3264 ws 38.536 387.42(PolyGlyph* vbox_first_aligned\(GlyphIndex size\) const;) 6 278.626 ws 38.536 375.9(PolyGlyph* vbox_first_aligned\() 2 174.696 ws 46.866 364.38(Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil,) 28 328.937 ws 46.866 352.86(Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil) 28 326.157 ws 38.536 341.34(\) const;) 2 71.3264 ws 38.536 329.82(PolyGlyph* overlay\() 2 126.336 ws 46.866 318.3(Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil,) 28 328.937 ws 46.866 306.78(Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil) 28 326.157 ws 38.536 295.26(\) const;) 2 71.3264 ws 10 /Helvetica sf 87.3559 278.74(Figure 11.1:) 2 140.716 ws 149.046 278.74(Layout protocol and LayoutKit box operations) 10 349.716 ws newpath 17.2 270.57 moveto 17.2 271.57 lineto 413.2 271.57 lineto 413.2 270.57 lineto closepath gsave eofill grestore showpage %%Page: 3 3 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 521.09(assumed to be infinitely stretchable.) 8 188.981 ws 26.668 506.45(LayoutKit::hspace and LayoutKit::vspace create glue with a given size that is) 20 412 ws 16 492.71(rigid. LayoutKit::shape_of returns glue that has the same requisition as another) 21 412 ws 16 478.97(glyph. LayoutKit::shape_of_xy returns glue that takes its X requirement from one) 21 412 ws 16 465.23(glyph and its Y requirement from another glyph.) 14 249.305 ws 26.668 450.59(LayoutKit::spaces returns glue that correspond to a given number of spaces in) 22 412 ws 388.72 36.08(11-) 3 404.716 as 407.716 36.08(3) 1 413.716 as newpath 17.2 680.86 moveto 17.2 681.86 lineto 413.2 681.86 lineto 413.2 680.86 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.536 664.3(interface Deck : PolyGlyph {) 8 162.477 ws 46.866 652.78(GlyphIndex card\(\) const;) 4 155.797 ws 46.866 641.26(void flip_to\(GlyphIndex\);) 2 154.686 ws 38.536 629.74(};) 2 44.656 as 38.536 613.22(Deck* deck\(GlyphIndex size\) const;) 6 196.367 ws 38.536 601.7(Deck* deck\() 2 92.4363 ws 46.866 590.18(Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil,) 28 328.937 ws 46.866 578.66(Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil, Glyph* = nil) 28 326.157 ws 38.536 567.14(\) const;) 2 71.3263 ws 10 /Helvetica sf 100.426 550.62(Figure 11.2:) 2 153.786 ws 162.116 550.62(Deck protocol and LayoutKit operations) 8 336.646 ws newpath 17.2 542.45 moveto 17.2 543.45 lineto 413.2 543.45 lineto 413.2 542.45 lineto closepath gsave eofill grestore newpath 14.32 422.62 moveto 14.32 423.62 lineto 410.32 423.62 lineto 410.32 422.62 lineto closepath gsave eofill grestore 10 /Helvetica sf 35.656 406.06(Glyph* glue\() 2 90.6764 ws 43.986 394.54(DimensionName, Coord natural, Coord stretch, Coord shrink, float alignment) 16 382.436 ws 35.656 383.02(\) const;) 2 68.4464 ws 35.656 371.5(Glyph* glue\(const Requisition&\) const;) 6 206.277 ws 35.656 359.98(Glyph* hglue\(\) const;) 4 129.027 ws 35.656 348.46(Glyph* hglue\(Coord natural\) const;) 6 189.607 ws 35.656 336.94(Glyph* hglue\(Coord natural, Coord stretch, Coord shrink\) const;) 14 317.427 ws 35.656 325.42(Glyph* hglue\(Coord natural, Coord stretch, Coord shrink, float alignment\) const;) 18 388.016 ws 35.656 308.9(Glyph* vglue\(\) const;) 4 128.467 ws 35.656 297.38(Glyph* vglue\(Coord natural\);) 4 162.367 ws 35.656 285.86(Glyph* vglue\(Coord natural, Coord stretch, Coord shrink\) const;) 14 316.867 ws 35.656 274.34(Glyph* vglue\(Coord natural, Coord stretch, Coord shrink, float alignment\) const;) 18 387.456 ws 35.656 257.82(Glyph* hspace\(Coord\) const;) 4 164.037 ws 35.656 246.3(Glyph* vspace\(Coord\) const;) 4 163.477 ws 35.656 234.78(Glyph* shape_of\(Glyph*\) const;) 4 175.716 ws 35.656 223.26(Glyph* shape_of_xy\(Glyph*, Glyph*\) const;) 6 226.847 ws 35.656 206.74(Glyph* spaces\(int count, Coord each, const Font*, const Color*\) const;) 18 347.456 ws 35.656 195.22(Glyph* strut\() 2 91.2264 ws 43.986 183.7(const Font*, Coord natural = 0, Coord stretch = 0, Coord shrink = 0) 26 339.407 ws 35.656 172.18(\) const;) 2 68.4464 ws 35.656 160.66(Glyph* hstrut\() 2 96.7863 ws 43.986 149.14(Coord right_bearing, Coord left_bearing = 0,) 10 239.917 ws 43.986 137.62(Coord natural = 0, Coord stretch = 0, Coord shrink = 0) 22 283.267 ws 35.656 126.1(\) const;) 2 68.4464 ws 35.656 114.58(Glyph* vstrut\() 2 96.2263 ws 43.986 103.06(Coord ascent, Coord descent = 0,) 10 193.787 ws 43.986 91.5401(Coord natural = 0, Coord stretch = 0, Coord shrink = 0) 22 283.267 ws 35.656 80.0201(\) const;) 2 68.4464 ws 10 /Helvetica sf 78.3709 63.5001(Figure 11.3:) 2 131.731 ws 140.061 63.5001(LayoutKit operations for creating spacing glyphs) 10 352.941 ws newpath 14.32 55.33 moveto 14.32 56.33 lineto 410.32 56.33 lineto 410.32 55.33 lineto closepath gsave eofill grestore showpage %%Page: 4 4 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 360.77(the current font. Unlike other glue objects, which despite being generally referred) 23 412 ws 16 347.03(to as \252white space\272 do not actually have an appearance, spaces are drawn in the) 28 412 ws 16 333.29(given color.) 2 73.3244 ws 18 /Times-Bold sf 16 292.01(11.3) 4 47.5 as 51 292.01(Alignment) 9 132 as 12 /Times-Roman sf 16 259.61(In addition to laying out a collection of glyphs, it is often desirable to modify the) 30 412 ws 16 245.87(positioning of a single glyph. LayoutKit provides operations to adjust the layout) 23 412 ws 16 232.13(of a glyph. These operations return a monoglyph.) 15 254.465 ws 26.668 217.49(Figure 11.4 shows the operations that affect the requisition of a glyph.) 22 412 ws 16 203.75(LayoutKit::center , center_dimension, hcenter, and vcenter change the origin of a) 20 412 ws 16 190.01(glyph as it appears in a requisition. When the glyph body is allocated, it is given) 31 412 ws 16 176.27(the origin it requested. Thus, the name \252center\272 is somewhat misleading as these) 25 412 ws 16 162.53(monoglyphs merely return a glyph that asks to be centered at a particular position,) 26 412 ws 16 148.79(they do not actually change the origin themselves.) 14 256.637 ws 26.668 134.15(LayoutKit::fixed, fixed_dimension, hfixed, and vfixed change a glyph to appear) 18 412 ws 16 120.41(rigid even if it is flexible. Fixed monoglyphs are ideal for specifying sizes) 25 412 ws 16 106.67(that are otherwise undefined, such as the initial height of a file chooser. The) 27 412 ws 16 92.9299(inverse functionality\261making a glyph flexible that may be rigid\261is provided by) 20 412 ws 16 79.1899(the LayoutKit::flexible, flexible_dimension, hflexible, and vflexible operations.) 12 412 ws 16 65.4499(The LayoutKit::natural, natural_dimension, hnatural, and vnatural operations are) 14 412 ws 388.72 36.08(11-) 3 404.716 as 407.716 36.08(4) 1 413.716 as newpath 15.28 670.3 moveto 15.28 671.3 lineto 411.28 671.3 lineto 411.28 670.3 lineto closepath gsave eofill grestore 10 /Helvetica sf 36.616 653.74(MonoGlyph* center\(Glyph*, float x = 0.5, float y = 0.5\) const;) 20 303.417 ws 36.616 642.22(MonoGlyph* center_dimension\(Glyph*, DimensionName, float align\) const;) 10 367.286 ws 36.616 630.7(MonoGlyph* hcenter\(Glyph*, float x = 0.5\) const;) 12 251.437 ws 36.616 619.18(MonoGlyph* vcenter\(Glyph*, float y = 0.5\) const;) 12 250.877 ws 36.616 602.66(MonoGlyph* fixed\(Glyph*, Coord x, Coord y\) const;) 12 262.807 ws 36.616 591.14(MonoGlyph* fixed_dimension\(Glyph*, DimensionName, Coord\) const;) 8 345.046 ws 36.616 579.62(MonoGlyph* hfixed\(Glyph*, Coord x\) const;) 8 227.797 ws 36.616 568.1(MonoGlyph* vfixed\(Glyph*, Coord y\) const;) 8 227.237 ws 36.616 556.58(MonoGlyph* flexible\(Glyph*, Coord stretch = fil, Coord shrink = fil\) const;) 20 356.726 ws 36.616 545.06(MonoGlyph* flexible_dimension\() 2 179.996 ws 44.946 533.54(Glyph*, DimensionName, Coord stretch = fil, Coord shrink = fil) 18 319.477 ws 36.616 522.02(\) const;) 2 69.4064 ws 36.616 510.5(MonoGlyph* hflexible\() 2 134.426 ws 44.946 498.98(Glyph*, Coord stretch = fil, Coord shrink = fil) 16 240.017 ws 36.616 487.46(\) const;) 2 69.4064 ws 36.616 475.94(MonoGlyph* vflexible\() 2 133.866 ws 44.946 464.42(Glyph*, Coord stretch = fil, Coord shrink = fil) 16 240.017 ws 36.616 452.9(\) const;) 2 69.4064 ws 36.616 441.38(MonoGlyph* natural\(Glyph*, Coord x, Coord y\) const;) 12 272.257 ws 36.616 429.86(MonoGlyph* natural_dimension\(Glyph*, DimensionName, Coord\) const;) 8 354.496 ws 36.616 418.34(MonoGlyph* hnatural\(Glyph*, Coord\) const;) 6 229.467 ws 36.616 406.82(MonoGlyph* vnatural\(Glyph*, Coord\) const;) 6 228.907 ws 10 /Helvetica sf 92.6658 390.3(Figure 11.4:) 2 146.026 ws 154.356 390.3(LayoutKit operations that adjust alignment) 8 340.566 ws newpath 15.28 382.13 moveto 15.28 383.13 lineto 411.28 383.13 lineto 411.28 382.13 lineto closepath gsave eofill grestore showpage %%Page: 5 5 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 235.21(similar to the fixed operations in that they change the natural size, but they do not) 30 412 ws 16 221.47(affect the flexibility.) 4 114.317 ws 26.668 206.83(LayoutKit also provides a set of operations to put a margin around a glyph.) 26 412 ws 16 193.09(These operations are shown in Figure 11.5. LayoutKit::margin is overloaded to) 21 412 ws 16 179.35(specify a fixed margin around the entire glyph, distinct horizontal and vertical) 22 412 ws 16 165.61(margins, separate left, right, bottom, and top margins, or flexible margins on) 22 412 ws 16 151.87(each side. LayoutKit::hmargin specifies horizontal margins; LayoutKit::vmargin) 13 412 ws 16 138.13(specifies vertical margins. LayoutKit::lmargin, rmargin, bmargin, and tmargin) 15 412 ws 16 124.39(specify left, right, bottom, and top margins, respectively.) 14 288.641 ws 388.72 36.08(11-) 3 404.716 as 407.716 36.08(5) 1 413.716 as newpath 15.28 677.98 moveto 15.28 678.98 lineto 411.28 678.98 lineto 411.28 677.98 lineto closepath gsave eofill grestore 10 /Helvetica sf 36.616 661.42(MonoGlyph* margin\(Glyph*, Coord\) const;) 6 223.897 ws 36.616 649.9(MonoGlyph* margin\(Glyph*, Coord hmargin, Coord vmargin\) const;) 12 333.926 ws 36.616 638.38(MonoGlyph* margin\() 2 128.306 ws 44.946 626.86(Glyph*, Coord lmargin, Coord rmargin, Coord bmargin, Coord tmargin) 16 353.366 ws 36.616 615.34(\) const;) 2 69.4064 ws 36.616 603.82(MonoGlyph* margin\() 2 128.306 ws 44.946 592.3(Glyph*,) 7 77.736 as 44.946 580.78(Coord lmargin, Coord lstretch, Coord lshrink,) 10 242.777 ws 44.946 569.26(Coord rmargin, Coord rstretch, Coord rshrink,) 10 246.107 ws 44.946 557.74(Coord bmargin, Coord bstretch, Coord bshrink,) 10 252.797 ws 44.946 546.22(Coord tmargin, Coord tstretch, Coord tshrink) 10 241.677 ws 36.616 534.7(\) const;) 2 69.4064 ws 36.616 523.18(MonoGlyph* hmargin\(Glyph*, Coord\) const;) 6 229.457 ws 36.616 511.66(MonoGlyph* hmargin\(Glyph*, Coord lmargin, Coord rmargin\) const;) 12 334.476 ws 36.616 500.14(MonoGlyph* hmargin\() 2 133.866 ws 44.946 488.62(Glyph*,) 7 77.736 as 44.946 477.1(Coord lmargin, Coord lstretch, Coord lshrink,) 10 242.777 ws 44.946 465.58(Coord rmargin, Coord rstretch, Coord rshrink) 10 243.327 ws 36.616 454.06(\) const;) 2 69.4064 ws 36.616 442.54(MonoGlyph* vmargin\(Glyph*, Coord\) const;) 6 228.897 ws 36.616 431.02(MonoGlyph* vmargin\(Glyph*, Coord lmargin, Coord rmargin\) const;) 12 333.916 ws 36.616 419.5(MonoGlyph* vmargin\() 2 133.306 ws 44.946 407.98(Glyph*,) 7 77.736 as 44.946 396.46(Coord bmargin, Coord bstretch, Coord bshrink,) 10 252.797 ws 44.946 384.94(Coord tmargin, Coord tstretch, Coord tshrink) 10 241.677 ws 36.616 373.42(\) const;) 2 69.4064 ws 36.616 361.9(MonoGlyph* lmargin\(Glyph*, Coord\) const;) 6 226.117 ws 36.616 350.38(MonoGlyph* lmargin\(Glyph*, Coord nat, Coord stretch, Coord shrink\) const;) 16 370.616 ws 36.616 338.86(MonoGlyph* rmargin\(Glyph*, Coord\) const;) 6 227.227 ws 36.616 327.34(MonoGlyph* rmargin\(Glyph*, Coord nat, Coord stretch, Coord shrink\) const;) 16 371.726 ws 36.616 315.82(MonoGlyph* bmargin\(Glyph*, Coord\) const;) 6 229.457 ws 36.616 304.3(MonoGlyph* bmargin\(Glyph*, Coord nat, Coord stretch, Coord shrink\) const;) 16 373.956 ws 36.616 292.78(MonoGlyph* tmargin\(Glyph*, Coord\) const;) 6 226.677 ws 36.616 281.26(MonoGlyph* tmargin\(Glyph*, Coord nat, Coord stretch, Coord shrink\) const;) 16 371.176 ws 10 /Helvetica sf 123.521 264.74(Figure 11.5:) 2 176.881 ws 185.211 264.74(LayoutKit margin operations) 4 309.711 ws newpath 15.28 256.57 moveto 15.28 257.57 lineto 411.28 257.57 lineto 411.28 256.57 lineto closepath gsave eofill grestore showpage %%Trailer end restore %%Pages: 5 %!PS-Adobe-2.0 %%Creator: ./ch12.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 16 662.72(Chapter 12) 2 131.321 ws 16 625.76(DocumentKit) 11 154.648 as 12 /Times-Roman sf 16 597.44(In Chapter 11, we described the LayoutKit class, which provides operations) 20 412 ws 16 583.7(for creating layout objects. The DocumentKit class will provide operations) 19 412 ws 16 569.96(for creating document objects that use LayoutKit objects to produce formatted) 20 412 ws 16 556.22(documents. The DocumentKit class has not yet been implemented, so for now) 23 412 ws 16 542.48(we describe several objects that can be useful for building document editors in) 24 412 ws 16 528.74(conjunction with the LayoutKit objects.) 8 206.993 ws 26.668 514.1(A ) 2 38.508 ws 12 /Times-Italic sf 38.508 514.1(discretionary) 13 102.504 as 12 /Times-Roman sf 102.504 514.1( can take on one of several appearances depending on whether a) 22 412 ws 16 500.36(break occurs on it. A common use of a discretionary is for white space in a line of) 35 412 ws 16 486.62(text, where the white space becomes zero-width glue if a break occurs on the) 26 412 ws 16 472.88(discretionary. The penalty associated with a discretionary defines the relative cost) 21 412 ws 16 459.14(of breaking. Currently, operations to create discretionaries are defined on the) 21 412 ws 16 445.4(LayoutKit.) 10 68.332 as 26.668 430.76(An ) 2 46.0445 ws 12 /Times-Italic sf 46.0445 430.76(lr-marker) 9 92.7005 as 12 /Times-Roman sf 92.7005 430.76( is a glyph that can mark a region of its body. The marking is) 29 412 ws 16 417.02(done by painting a color under the area or a color on top of the area \(or both\).) 34 412 ws 16 403.28(The region is a shape normally associated with text selections. The LRMarker) 23 412 ws 16 389.54(constructor takes two colors, either of which can be nil if the associated underlay) 26 412 ws 16 375.8(or overlay drawing is not desired. LRMarker::mark paints the given region. If y1) 26 412 ws 16 362.06(and y2 are the same, then the mark region is a single rectangle. Otherwise, the) 29 412 ws 16 348.32(region is defined as starting at \(x1,y1\) and filling a height of h1 to \(x1,right\(\)\),) 28 412 ws 16 334.58(then filling \(left\(\),y1+h1\) to \(right\(\),y2\) and filling a height of h2 from \(left\(\),y2\)) 24 412 ws 16 320.84(to \(x2,y2\). LRMarker::unmark restores the area to its unmarked appearance. An) 22 412 ws 12 /Times-Italic sf 16 307.1(xy-marker) 9 65.308 as 12 /Times-Roman sf 65.308 307.1( is simliar to an lr-marker, but it only paints a rectangular area. While) 27 412 ws 16 293.36(an lr-marker is most useful for selecting text, xy-markers are useful for selecting) 24 412 ws 16 279.62(an item in a list or table. Figure 12.1 shows the LRMarker and XYMarker class) 29 412 ws 16 265.88(interfaces.) 11 65.644 as 18 /Times-Bold sf 16 224.6(12.1) 4 47.5 as 51 224.6(Compositions) 12 156.012 as 12 /Times-Roman sf 16 192.2(A ) 2 30 ws 12 /Times-Italic sf 30 192.2(composition) 11 88.668 as 12 /Times-Roman sf 88.668 192.2( is a glyph that uses a ) 14 210.68 ws 12 /Times-Italic sf 210.68 192.2(compositor) 10 264.68 as 12 /Times-Roman sf 264.68 192.2( to determine suitable breaks) 8 412 ws 16 178.46(between groups of its components. Figure 12.2 shows the class interfaces for the) 25 412 ws 16 164.72(composition and its subclasses. The list of components is broken into sublists) 23 412 ws 16 150.98(that are put into separate composite glyphs and then inserted into the body.) 24 412 ws 16 137.24(The LRComposition subclass uses LayoutKit::hbox_first_aligned to create each) 14 412 ws 16 123.5(sublist, while the TBComposition subclass uses LayoutKit::vbox_first_aligned.) 12 397.348 ws 26.668 108.86(Compositions can be used to break paragraphs into lines, lines into columns,) 22 412 ws 16 95.1201(or columns into pages. A document editor might create an lr-composition for) 23 412 ws 16 81.3801(characters that puts the resulting hboxes for lines into a tb-composition, which in) 24 412 ws 16 67.6401(turn puts the vboxes for columns into an lr-composition, which puts the resulting) 24 412 ws 388.72 36.08(12-) 3 404.716 as 407.716 36.08(1) 1 413.716 as showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 467.29(lr-boxes for pages into a deck.) 10 161.298 ws 26.668 452.65(Compositions also can be used just as easily for arranging buttons in a box,) 26 412 ws 16 438.91(where one wants the buttons to ``wrap-around'' if there are too many to fit) 26 412 ws 16 425.17(horizontally. The code to do this could look as follows:) 19 282.821 ws 10 /Helvetica sf 40.99 399.97(LRComposition* c = new LRComposition\() 8 225.211 ws 49.32 388.45(layout.vbox\(\), new SimpleCompositor, /* no separator */ nil, /* width */ 4*72.0) 22 387.79 ws 40.99 376.93(\);) 2 47.1 as 40.99 365.41(Discretionary* ok = layout.discretionary\(0, nil, nil, nil, nil\);) 14 291.341 ws 40.99 353.89(for \(unsigned int i = 0; i < nbuttons; i++\) {) 20 221.102 ws 49.32 342.37(c->append\(button[i]\);) 21 141.87 as 49.32 330.85(c->append\(ok\);) 14 116.85 as 40.99 319.33(}) 1 44.33 as 40.99 307.81(c->repair\(\);) 12 90.16 as 16 295.33( ) 2 18.7804 ws 12 /Times-Roman sf 26.668 280.69(The composition constructor takes a body in which to insert sublists, a) 22 412 ws 16 266.95(compositor to determine where to break, a separator to be inserted at each break) 26 412 ws 16 253.21(\(unless it is nil\), the dimension to use, the width in which the sublists must fit,) 30 412 ws 16 239.47(and optionally the initial size of the list of components. The initial size is not) 29 412 ws 16 225.73(a maximum, but the list by default starts at a small size and is dynamically) 28 412 ws 16 211.99(reallocated as needed. For large lists, it can be more efficient to specify an) 27 412 ws 16 198.25(estimate of the list size. Composition::repair updates the composition to reflect) 21 412 ws 16 184.51(changes to its structure. Composition::item returns the index of the sublist \(in) 23 412 ws 16 170.77(other words, the component of the body\) containing the component specified by) 22 412 ws 16 157.03(the given index. For example, this function could be used to return the line that) 29 412 ws 16 143.29(contains a particular character. Composition::beginning_of returns the index of) 17 412 ws 16 129.55(the component that starts the sublist specified by the given item. For example,) 25 412 ws 16 115.81(this function could be used to return the character that starts a particular line.) 26 412 ws 16 102.07(Composition::end_of is like beginning_of except it returns the end of the sublist.) 22 412 ws 16 88.33(Composition::margin causes space to be left at the beginning and end of the) 24 412 ws 16 74.59(specified item in the body. For example, this function could be used to put) 27 412 ws 16 60.85(margins on a line of text. Composition::view guarantees that breaks are computed) 22 412 ws 388.72 36.08(12-) 3 404.716 as 407.716 36.08(2) 1 413.716 as newpath 16 679.66 moveto 16 680.66 lineto 412 680.66 lineto 412 679.66 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.336 663.1(interface LRMarker : MonoGlyph {) 8 187.947 ws 45.666 651.58(LRMarker\(Glyph*, Color* overlay, Color* underlay\);) 8 271.826 ws 45.666 640.06(void mark\() 2 92.3363 ws 53.996 628.54(Coord left, Coord right, Coord x1, Coord y1,) 14 247.407 ws 53.996 617.02(Coord h1, Coord x2, Coord y2, Coord h2) 14 234.077 ws 45.666 605.5(\);) 2 51.776 as 45.666 593.98(void unmark\(\);) 2 109.566 ws 37.336 582.46(};) 2 43.456 as 37.336 559.42(interface XYMarker : MonoGlyph {) 8 188.507 ws 45.666 547.9(XYMarker\(Glyph*, Color* overlay, Color* underlay\);) 8 272.386 ws 45.666 536.38(void mark\(Coord left, Coord bottom, Coord right, Coord top\);) 16 312.427 ws 45.666 524.86(void unmark\(\);) 2 109.566 ws 37.336 513.34(}; ) 2 46.2363 ws 10 /Helvetica sf 109.526 496.82(Figure 12.1:) 2 162.886 ws 171.216 496.82(LRMarker and XYMarker protocols) 6 325.146 ws newpath 16 488.65 moveto 16 489.65 lineto 412 489.65 lineto 412 488.65 lineto closepath gsave eofill grestore showpage %%Page: 3 3 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 339.61(for the components between indices ) 10 206.643 ws 12 /Times-Italic sf 206.643 339.61(first) 5 225.987 as 12 /Times-Roman sf 225.987 339.61( and ) 4 255.32 ws 12 /Times-Italic sf 255.32 339.61(last) 4 272.66 as 12 /Times-Roman sf 272.66 339.61( inclusively. By restricting) 7 412 ws 16 325.87(the viewing area, this operation can eliminate the computation of breaks for) 22 412 ws 16 312.13(components that are not visible.) 8 168.989 ws 26.668 297.49(A compositor computes the breaks based on assessing the penalty for a possible) 24 412 ws 16 283.75(breaks. Three subclasses are provided that use different levels of sophistication in) 23 412 ws 16 270.01(determining breaks. An ) 7 143.041 ws 12 /Times-Italic sf 143.041 270.01(array-compositor) 16 227.701 as 12 /Times-Roman sf 227.701 270.01( positions breaks every N elements,) 10 412 ws 16 256.27(where N is specified in the constructor. A ) 17 244.022 ws 12 /Times-Italic sf 244.022 256.27(simple-compositor) 17 333.35 as 12 /Times-Roman sf 333.35 256.27( finds a simple) 6 412 ws 16 242.53(set of breaks quickly. It is analogous to a line-at-a-time text formatter. A) 27 412 ws 12 /Times-Italic sf 16 228.79(TeX-compositor) 14 93.328 as 12 /Times-Roman sf 93.328 228.79( finds breaks using Knuth's TeX algorithm.) 12 302.309 ws 26.668 214.15(Figure 12.3 shows the interfaces to the compositor classes.) 16 412 ws 16 200.41(Compositor::compose uses the natural, stretch, shrink, penalty, and span) 16 412 ws 16 186.67(information for each component as input parameters. The return value is the) 23 412 ws 16 172.93(number of breaks found. The ) 11 168.444 ws 10 /Helvetica sf 168.444 172.93(breaks) 6 198.454 as 12 /Times-Roman sf 198.454 172.93( array contains the positions of the breaks;) 14 412 ws 16 159.19(that is, ) 4 51.0041 ws 10 /Helvetica sf 51.0041 159.19(break[i]) 8 83.7941 as 12 /Times-Roman sf 83.7941 159.19( is the index of the component where the ) 18 282.095 ws 12 /Times-Italic sf 282.095 159.19(i) 1 285.431 as 12 /Times-Roman sf 285.431 159.19(th break occurs.) 4 361.739 ws 388.72 36.08(12-) 3 404.716 as 407.716 36.08(3) 1 413.716 as newpath 15.0399 678.7 moveto 15.0399 679.7 lineto 411.04 679.7 lineto 411.04 678.7 lineto closepath gsave eofill grestore 10 /Helvetica sf 36.3759 662.14(interface Composition : MonoGlyph {) 8 198.667 ws 44.7059 650.62(Composition\() 12 103.606 as 53.0359 639.1(Glyph*, Compositor*, Glyph* separator, DimensionName,) 8 306.446 ws 53.0359 627.58(Coord width, GlyphIndex size) 6 183.087 ws 44.7059 616.06(\);) 2 50.8159 as 44.7059 604.54(void repair\(\);) 2 100.826 ws 44.7059 593.02(GlyphIndex item\(GlyphIndex\);) 2 176.976 ws 44.7059 581.5(lyphIndex beginning_of\(GlyphIndex\);) 2 207.566 ws 44.7059 569.98(GlyphIndex end_of\(GlyphIndex\);) 2 188.666 ws 44.7059 558.46(void margin\(GlyphIndex, Coord begin, Coord end\);) 10 268.687 ws 44.7059 546.94(void view\(GlyphIndex first, GlyphIndex last\);) 8 239.217 ws 36.3759 535.42(};) 2 42.4959 as 36.3759 512.38(interface LRComposition : Composition {) 8 215.887 ws 44.7059 500.86(LRComposition\() 14 116.386 as 53.0359 489.34(Glyph*, Compositor*, Glyph* sep, Coord, GlyphIndex = 10) 14 309.537 ws 44.7059 477.82(\);) 2 50.8159 as 36.3759 466.3(};) 2 42.4959 as 36.3759 443.26(interface TBComposition : Composition {) 8 215.887 ws 44.7059 431.74(TBComposition\() 14 116.386 as 53.0359 420.22(Glyph*, Compositor*, Glyph* sep, Coord, GlyphIndex = 10) 14 309.537 ws 44.7059 408.7(\);) 2 50.8159 as 36.3759 397.18(}; ) 2 45.2763 ws 10 /Helvetica sf 139.686 380.66(Figure 12.2:) 2 193.046 ws 201.376 380.66(Composition classes) 2 293.066 ws 10 /Helvetica sf 393.596 364.14( ) 2 396.376 ws newpath 15.0399 360.97 moveto 15.0399 361.97 lineto 411.04 361.97 lineto 411.04 360.97 lineto closepath gsave eofill grestore showpage %%Page: 4 4 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 387.61(See iv/src/examples/preview.) 2 156.64 ws 388.72 36.08(12-) 3 404.716 as 407.716 36.08(4) 1 413.716 as newpath 14.08 669.1 moveto 14.08 670.1 lineto 410.08 670.1 lineto 410.08 669.1 lineto closepath gsave eofill grestore 10 /Helvetica sf 35.416 652.54(interface Compositor {) 4 133.787 ws 43.746 641.02(virtual int compose\() 4 130.437 ws 52.076 629.5(Coord* natural, Coord* stretch, Coord* shrink,) 10 254.927 ws 52.076 617.98(int* penalties, int component_count,) 6 210.497 ws 52.076 606.46(Coord* spans, int span_count,) 6 186.037 ws 52.076 594.94(int* breaks, int break_count) 6 173.247 ws 43.746 583.42(\);) 2 49.856 as 35.416 571.9(};) 2 41.536 as 35.416 548.86(interface ArrayCompositor : Compositor {) 8 217.137 ws 43.746 537.34(ArrayCompositor\(int N\);) 2 148.756 ws 35.416 525.82(};) 2 41.536 as 35.416 502.78(interface SimpleCompositor : Compositor {) 8 223.807 ws 43.746 491.26(SimpleCompositor\(\);) 19 134.866 as 35.416 479.74(};) 2 41.536 as 35.416 456.7(interface TeXCompositor : Compositor {) 8 211.587 ws 52.076 445.18(TeXCompositor\(int penalty\);) 2 176.556 ws 35.416 433.66(}; ) 2 44.3164 ws 10 /Helvetica sf 140.951 417.14(Figure 12.3:) 2 194.311 ws 202.641 417.14(Compositor classes) 2 289.881 ws newpath 14.08 408.97 moveto 14.08 409.97 lineto 410.08 409.97 lineto 410.08 408.97 lineto closepath gsave eofill grestore showpage %%Trailer end restore %%Pages: 4 %!PS-Adobe-2.0 %%Creator: ./appA.doc %%Pages: atend %%EndComments save 20 dict begin /sf { % scale /fontName => - (set current font) {findfont} stopped {pop /Courier findfont} if exch scalefont setfont } def /ws { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 8#40 4 3 roll widthshow } def /as { 4 index 6 4 roll moveto sub 2 index stringwidth pop sub exch div 0 3 2 roll ashow } def %%EndProlog %%Page: 1 1 90.05 36.94 translate 0 0 0 setrgbcolor 24 /Times-Bold sf 16 662.72(Appendix A) 2 139.361 ws 16 625.76(Operating System Interface) 4 299.945 ws 12 /Times-Roman sf 16 597.44(This appendix describes the classes that abstract operating system services. These) 21 412 ws 16 583.7(classes do not yet cover the entire range of operating system operations, but they) 26 412 ws 16 569.96(offer higher-level abstractions in some cases, relief from name space concerns in) 22 412 ws 16 556.22(other cases, and greater application portability.) 10 240.953 ws 26.668 541.58(The classes are presented below in alphabetical order. A ) 19 323.901 ws 12 /Times-Italic sf 323.901 541.58(directory) 9 367.893 as 12 /Times-Roman sf 367.893 541.58( is a list) 6 412 ws 16 527.84(of files or other directories. A file is a list of bytes. Both directories and) 30 412 ws 16 514.1(files are accessed by a string name. A ) 17 219.437 ws 12 /Times-Italic sf 219.437 514.1(list) 4 234.113 as 12 /Times-Roman sf 234.113 514.1( is an ordered sequence of objects,) 12 412 ws 16 500.36(parameterized by the element type. The math class provides an interface to) 23 412 ws 16 486.62(common mathematical operations on concrete types \(e.g., ints and floats\). The) 21 412 ws 16 472.88(memory class provides operations on variable-length arrays of bytes. A ) 21 364.41 ws 12 /Times-Italic sf 364.41 472.88(string) 6 392.418 as 12 /Times-Roman sf 392.418 472.88( is a) 4 412 ws 16 459.14(variable-length list of characters. A ) 11 190.971 ws 12 /Times-Italic sf 190.971 459.14(table) 5 214.971 as 12 /Times-Roman sf 214.971 459.14( is an associative map from a key type to) 18 412 ws 16 445.4(a data type.) 4 70.9848 ws 26.668 430.76(List and table are generic classes, parameterized by other types. Because) 21 412 ws 16 417.02(few C++ implementations currently support a generic mechanism \(though the) 18 412 ws 16 403.28(language defines a template construct\), it is necessary to define list and table) 24 412 ws 16 389.54(classes using preprocessor macros and must be instantiated explicitly.) 16 350.957 ws 18 /Times-Bold sf 16 348.26(A.1) 3 42.496 as 51 348.26(Directory) 9 124.962 as 12 /Times-Roman sf 16 315.86(Figure A.1 shows the directory class interface. The static member functions) 21 412 ws 16 302.12(Directory::current and Directory::open return a pointer to a Directory.) 16 412 ws 16 288.38(Directory::current looks in the default directory for the application context,) 18 412 ws 16 274.64(Directory::open tries to find the directory with the given name. If the name cannot) 27 412 ws 16 260.9(be found or access is denied to the directory, Director::open returns nil.) 22 358.265 ws 393.84 36.24(A-) 2 406.5 as 409.5 36.24(1) 1 415.5 as newpath 17.2 236.38 moveto 17.2 237.38 lineto 413.2 237.38 lineto 413.2 236.38 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.536 219.82(interface Directory {) 4 125.787 ws 46.866 208.3(static Directory* current\(\);) 4 160.217 ws 46.866 196.78(static Directory* open\(const String&\);) 6 210.807 ws 46.866 185.26(int count\(\) const;) 4 120.787 ws 46.866 173.74(const char* name\(int i\) const;) 8 176.357 ws 46.866 162.22(int index\(const char*\) const;) 6 170.247 ws 46.866 150.7(boolean is_directory\(int index\) const;) 6 209.707 ws 46.866 139.18(void close\(\);) 2 100.766 ws 46.866 127.66(static String* canonical\(const String&\);) 6 216.927 ws 46.866 116.14(static boolean match\(const String& name, const String& pattern\);) 14 334.216 ws 38.536 104.62(};) 2 44.656 as 10 /Helvetica sf 135.181 88.1(Figure A.1:) 2 184.091 ws 192.421 88.1(Directory class interface.) 4 301.891 ws newpath 17.2 79.93 moveto 17.2 80.93 lineto 413.2 80.93 lineto 413.2 79.93 lineto closepath gsave eofill grestore showpage %%Page: 2 2 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 26.668 671.36(Directory::count returns the number of entries \(files and directories\), including) 18 412 ws 16 657.62(any special system entries such as \252.\272 and \252..\272 on Unix. Directory::name returns) 25 412 ws 16 643.88(the name of the specified entry. Directory::index returns the index of the entry) 25 412 ws 16 630.14(that matches the given name or -1 if no match is found. Directory::close discards) 27 412 ws 16 616.4(the information associated with the directory.) 10 233.969 ws 18 /Times-Bold sf 16 575.12(A.2) 3 42.496 as 51 575.12(File) 4 79.998 as 12 /Times-Roman sf 16 542.72(Figure A.2 shows the file class interface and subclasses for input handling. The) 25 412 ws 16 528.98(base class File is abstract and defines no data access functions. Currently, only) 25 412 ws 16 515.24(input files are implemented. File::name returns the string name of the file.) 23 412 ws 16 501.5(File::length returns the number of bytes in the file. File::close releases any) 23 412 ws 16 487.76(information associated with the file.) 8 188.981 ws 26.668 473.12(File::limit sets an upper bound on the size of a buffer to allocate for file storage.) 30 412 ws 16 459.38(By default, a file attempts to allocate contiguous storage for its entire contents.) 24 412 ws 16 445.64(This approach can allow for simpler application code and can be implemented) 22 412 ws 16 431.9(very efficiently on systems with memory-mapped files.) 12 281.633 ws 26.668 417.26(The contents of an input file can be accessed but not modified. InputFile::open) 25 412 ws 16 403.52(returns nil if the named file cannot be found or is not readable. InputFile::read) 27 412 ws 16 389.78(allocates a data area for the file contents, sets the start parameter to the beginning) 28 412 ws 16 376.04(of the area, and returns the length of the area. If no storage limit has been) 31 412 ws 16 362.3(specified and the file is on disk \(as opposed to a terminal or pipe\), then read will) 32 412 ws 16 348.56(return the entire file.) 6 114.641 ws 18 /Times-Bold sf 16 307.28(A.3) 3 42.496 as 51 307.28(List) 4 81.006 as 12 /Times-Roman sf 16 274.88(Figure A.3 shows the list generic class interfaces. The implementation of lists) 23 412 ws 16 261.14(uses a dynamic array with an insertion gap, meaning that large lists are very) 26 412 ws 393.84 36.24(A-) 2 406.5 as 409.5 36.24(2) 1 415.5 as newpath 18.16 234.46 moveto 18.16 235.46 lineto 414.16 235.46 lineto 414.16 234.46 lineto closepath gsave eofill grestore 10 /Helvetica sf 39.496 217.9(interface File {) 4 102.857 ws 47.826 206.38(const char* name\(\) const;) 6 161.757 ws 47.826 194.86(long length\(\) const;) 4 132.867 ws 47.826 183.34(void close\(\);) 2 101.726 ws 47.826 166.82(void limit\(unsigned int buffersize\);) 6 196.207 ws 39.496 155.3(};) 2 45.616 as 39.496 138.78(interface InputFile : File {) 8 149.547 ws 47.826 127.26(static InputFile* open\(const char* name\);) 8 228.457 ws 47.826 115.74(int read\(const char*& start\);) 6 169.537 ws 39.496 104.22(};) 2 45.616 as 10 /Helvetica sf 148.636 87.7(Figure A.2:) 2 197.546 ws 205.876 87.7(InputFile protocols.) 2 290.356 ws newpath 18.16 79.53 moveto 18.16 80.53 lineto 414.16 80.53 lineto 414.16 79.53 lineto closepath gsave eofill grestore showpage %%Page: 3 3 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 265.89(space-efficient. The time efficiency depends on the distribution of insertions\261if) 19 412 ws 16 252.15(the insertion position moves frequently, the list will do excessive copying.) 20 372.653 ws 26.668 237.51(The list constructor takes an optional initial size for the dynamic array. For lists) 27 412 ws 16 223.77(that are known to be large, specifying an initial size avoids the cost of growing the) 30 412 ws 16 210.03(array dynamically. List::count returns the number of elements in the list \(not the) 25 412 ws 16 196.29(size of the array\). List::item returns the indexed item.) 17 273.461 ws 26.668 181.65(List::prepend adds an item at the beginning of the list, List::append at the end,) 26 412 ws 16 167.91(and List::insert before an indexed item. List::remove deletes the item specified by) 23 412 ws 16 154.17(the given index. List::remove_all deletes all the items in the list.) 21 325.493 ws 26.668 139.53(ListItr is a class for iterating through the elements of a list, parameterized) 24 412 ws 16 125.79(explicitly by the list type and implicitly by the element type. The constructor is) 27 412 ws 16 112.05(given the target list. ListItr::more returns true if additional elements are available) 23 412 ws 16 98.3099(in the iteration. ListItr::cur returns the current iteration's item. ListItr::cur_ref) 20 412 ws 16 84.5699(returns a reference to the item. ListItr::remove_cur deletes the current item) 21 412 ws 16 70.8299(from the list. ListItr::next moves the iteration to the next item in the list. No) 30 412 ws 393.84 36.24(A-) 2 406.5 as 409.5 36.24(3) 1 415.5 as newpath 17.2 641.5 moveto 17.2 642.5 lineto 413.2 642.5 lineto 413.2 641.5 lineto closepath gsave eofill grestore 10 /Helvetica sf 38.536 624.94(interface List\(T\) {) 4 114.117 ws 46.866 613.42(List\(T\)\(long initial_size = 0\);) 6 169.397 ws 46.866 596.9(long count\(\) const;) 4 129.127 ws 46.866 585.38(T item\(long index\) const;) 6 156.347 ws 46.866 573.86(T& item_ref\(long index\) const;) 6 180.247 ws 46.866 562.34(void prepend\(const T&\);) 4 153.577 ws 46.866 550.82(void append\(const T&\);) 4 150.247 ws 46.866 539.3(void insert\(long index, const T&\);) 8 192.477 ws 46.866 527.78(void remove\(long index\);) 4 156.347 ws 46.866 516.26(void remove_all\(\);) 2 126.326 ws 38.536 504.74(};) 2 44.656 as 38.536 488.22(interface ListItr\(ListType\) {) 4 154.687 ws 46.866 476.7(ListItr\(ListType\)\)\(const ListType&\);) 2 199.676 ws 46.866 460.18(boolean more\(\) const;) 4 144.127 ws 46.866 448.66(T cur\(\) const;) 4 105.767 ws 46.866 437.14(T& cur_ref\(\) const;) 4 129.667 ws 46.866 425.62(void next\(\);) 2 96.3264 ws 38.536 414.1(};) 2 44.656 as 38.536 397.58(interface ListUpdater\(ListType\) {) 4 181.366 ws 46.866 386.06(ListUpdater\(ListType\)\(ListType&\);) 33 196.346 as 46.866 369.54(boolean more\(\) const;) 4 144.127 ws 46.866 358.02(T cur\(\) const;) 4 105.767 ws 46.866 346.5(T& cur_ref\(\) const;) 4 129.667 ws 46.866 334.98(void remove_cur\(\);) 2 130.216 ws 46.866 323.46(void next\(\);) 2 96.3264 ws 38.536 311.94(};) 2 44.656 as 10 /Helvetica sf 118.221 295.42(Figure A.3:) 2 167.131 ws 175.461 295.42(List and iterator class interfaces.) 8 318.851 ws newpath 17.2 287.25 moveto 17.2 288.25 lineto 413.2 288.25 lineto 413.2 287.25 lineto closepath gsave eofill grestore showpage %%Page: 4 4 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 671.36(modifications should be made to the list during an iteration \(except in the last) 26 412 ws 16 657.62(step\), as this may cause unexpected or erroneous results.) 16 287.273 ws 26.668 642.98(As an example, consider a list of pointers to glyphs. We could declare such a) 29 412 ws 16 629.24(list in a header or source file as follows:) 16 207.966 ws 37.336 609.8(declarePtrList\(GlyphList,Glyph\)) 31 194.32 as 16 590.36(Only one source file may contain the expansion of the implementation:) 20 357.293 ws 37.336 570.92(implementPtrList\(GlyphList,Glyph\)) 33 211.012 as 16 551.48(A loop to iterate over all the glyphs in a list could be written as follows:) 30 360.977 ws 37.336 532.04(for \(ListItr\(GlyphList\) i\(list\); i.more\(\); i.next\(\)\) {) 10 273.401 ws 48.004 518.6(Glyph* g = i.cur\(\);) 6 138.761 ws 48.004 505.16(// do something with g) 8 156.017 ws 37.336 491.72(}) 1 43.096 as 26.668 472.28(A list makes no assumptions about its element type. In particular, destroying a) 25 412 ws 16 458.54(list of pointers will not destroy the objects that are the targets of the pointers.) 28 384.964 ws 18 /Times-Bold sf 16 417.26(A.4) 3 42.496 as 51 417.26(Math) 4 92.994 as 12 /Times-Roman sf 16 384.86(Figure A.4 shows the math class interface. One cannot create a \252math object\272; all) 27 412 ws 16 371.12(the member functions are static. Math::min and Math::max return the minimum) 21 412 ws 16 357.38(and maximum of two or four numbers, respectively. For the sake of brevity only) 27 412 ws 16 343.64(the floating point definitions are shown, but Math::min and Math::max are also) 22 412 ws 16 329.9(defined for ints, longs, unsigned ints, unsigned longs, and doubles.) 18 335.993 ws 26.668 315.26(Math::abs returns the absolute value of a number. Math::round returns the) 21 412 ws 16 301.52(integer nearest to a floating point value. Math::equal compares two floating point) 23 412 ws 16 287.78(numbers and returns whether they are within a given epsilon \(the third parameter\)) 24 412 ws 16 274.04(of each other.) 4 81.6408 ws 18 /Times-Bold sf 16 232.76(A.5) 3 42.496 as 51 232.76(Memory) 6 116.97 as 12 /Times-Roman sf 16 200.36(Figure A.5 shows the memory class interface. Like the math class, the memory) 25 412 ws 16 186.62(class consists solely of static member functions. Memory::copy writes a specified) 21 412 ws 16 172.88(number of bytes from one memory location to another. Memory::compare) 19 412 ws 16 159.14(determines if a specified number of bytes at one memory location is identical to) 26 412 ws 16 145.4(those at another location. If so, Memory::compare returns 0. Otherwise, it returns) 24 412 ws 16 131.66(a non-zero value. Memory::zero sets a specified number of bytes to zero starting) 25 412 ws 16 117.92(at a given memory location.) 8 150.317 ws 26.668 103.28(In certain circumstances, memory operations are faster than a loop over a set) 24 412 ws 16 89.54(of elements. Memory::zero and Memory::copy are useful for implementing a) 19 412 ws 16 75.8(dynamic array, quickly clearing or copying data when the array grows.) 20 355.913 ws 393.84 36.24(A-) 2 406.5 as 409.5 36.24(4) 1 415.5 as showpage %%Page: 5 5 90.05 36.94 translate 0 0 0 setrgbcolor 18 /Times-Bold sf 16 467.33(A.6) 3 42.496 as 51 467.33(String) 6 99.006 as 12 /Times-Roman sf 16 434.93(Figure A.6 shows the string class interface. The purpose of the string class is to) 29 412 ws 16 421.19(provide a convenient set of operations for manipulating variable-length character) 18 412 ws 16 407.45(arrays, ) 2 51.4501 ws 12 /Times-Italic sf 51.4501 407.45(not) 3 66.7861 as 12 /Times-Roman sf 66.7861 407.45( to manage storage. The base class does not allocate or free any storage) 27 412 ws 16 393.71(associated with the characters.) 6 161.957 ws 26.668 379.07(Three string constructors are available. The first, with no arguments, creates an) 23 412 ws 16 365.33(uninitialized string that should be assigned to another string before use. The) 23 412 ws 16 351.59(second, with a character pointer, sets the string's data to the given pointer. The) 27 412 ws 16 337.85(string's length is computed from the pointer under the assumption that the data) 24 412 ws 16 324.11(is null-terminated. The third constructor takes a character pointer and explicit) 21 412 ws 16 310.37(length. It does not assume the data is null-terminated.) 17 274.145 ws 26.668 295.73(String::string returns a pointer to the character data, which may not be) 22 412 ws 16 281.99(null-terminated. String::length returns the number of characters in the string.) 19 412 ws 16 268.25(String::null_terminated returns whether the string is already known to be) 18 412 ws 16 254.51(null-terminated \(it does not attempt to find a null\). String::hash returns a value for) 27 412 ws 16 240.77(the string data suitable for indexing the strings into a hash table.) 22 323.309 ws 26.668 226.13(The string class provides operators for assignment and comparison. The second) 21 412 ws 16 212.39(operand for these operations can be a string or a character pointer. In the latter) 29 412 ws 16 198.65(case, the data is assumed to be null-terminated. String::case_insensitive_equal) 17 412 ws 16 184.91(tests for equality ignoring the case of the characters in the strings.) 22 331.277 ws 393.84 36.24(A-) 2 406.5 as 409.5 36.24(5) 1 415.5 as newpath 16.24 677.02 moveto 16.24 678.02 lineto 412.24 678.02 lineto 412.24 677.02 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.576 660.46(interface Math {) 4 107.057 ws 45.906 648.94(static float min\(float a, float b\);) 10 179.297 ws 45.906 637.42(static float max\(float a, float b\);) 10 182.077 ws 45.906 625.9(static float min\(float a, float b, float c, float d\);) 18 244.337 ws 45.906 614.38(static float max\(float a, float b, float c, float d\);) 18 247.117 ws 45.906 597.86(static int abs\(int\);) 4 121.487 ws 45.906 586.34(static long abs\(long\);) 4 138.167 ws 45.906 574.82(static double abs\(double\);) 4 160.407 ws 45.906 563.3(static int round\(float\);) 4 139.277 ws 45.906 551.78(static int round\(double\);) 4 150.397 ws 45.906 540.26(static boolean equal\(float x, float y, float e\);) 14 236.007 ws 45.906 528.74(static boolean equal\(double x, double y, double e\);) 14 269.367 ws 37.576 517.22(};) 2 43.696 as 10 /Helvetica sf 143.106 500.7(Figure A.4:) 2 192.016 ws 200.346 500.7(Math class interface.) 4 292.046 ws newpath 16.24 492.53 moveto 16.24 493.53 lineto 412.24 493.53 lineto 412.24 492.53 lineto closepath gsave eofill grestore newpath 16.24 155.74 moveto 16.24 156.74 lineto 412.24 156.74 lineto 412.24 155.74 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.576 139.18(interface Memory {) 4 120.937 ws 45.906 127.66(static void copy\(const void*, void* to, unsigned int nbytes\);) 16 303.247 ws 45.906 116.14(static int compare\(const void*, const void*, unsigned int nbytes\);) 16 328.807 ws 45.906 104.62(static void zero\(void*, unsigned int nbytes\);) 10 235.987 ws 37.576 93.1(};) 2 43.696 as 10 /Helvetica sf 136.166 76.58(Figure A.5:) 2 185.076 ws 193.406 76.58(Memory class interface.) 4 298.986 ws newpath 16.24 68.41 moveto 16.24 69.41 lineto 412.24 69.41 lineto 412.24 68.41 lineto closepath gsave eofill grestore showpage %%Page: 6 6 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 26.668 671.36(The subscript operator allows access to individual characters. It is an error to) 25 412 ws 16 657.62(pass a negative index or an index greater than or equal to the length of the string.) 32 412 ws 16 643.88(String::substr returns a new string representing the part of the original string) 22 412 ws 16 630.14(begining at the ) 6 95.3421 ws 12 /Times-Italic sf 95.3421 630.14(start) 5 117.35 as 12 /Times-Roman sf 117.35 630.14( parameter and continuing for ) 10 271.339 ws 12 /Times-Italic sf 271.339 630.14(length) 6 301.339 as 12 /Times-Roman sf 301.339 630.14( characters. If ) 7 377.317 ws 12 /Times-Italic sf 377.317 630.14(start) 5 399.325 as 12 /Times-Roman sf 399.325 630.14( is) 2 412 ws 16 616.4(negative, the beginning position is the end of the string offset by ) 24 330.003 ws 12 /Times-Italic sf 330.003 616.4(start) 5 352.011 as 12 /Times-Roman sf 352.011 616.4(. If ) 5 370.855 ws 12 /Times-Italic sf 370.855 616.4(length) 6 400.855 as 12 /Times-Roman sf 400.855 616.4( is) 2 412 ws 16 602.66(\2611, then the remainder of the string is included. String::substr does not copy the) 27 412 ws 16 588.92(data, it simply creates another string that points into the same data as the original) 28 412 ws 16 575.18(string. String::left and String::right are short-hand for accessing the beginning or) 21 412 ws 16 561.44(end of a string. String::set_to_substr, String::set_to_left, and String::set_to_right) 15 412 ws 16 547.7(are convenience for changing a string to a particular substring instead of creating) 24 412 ws 16 533.96(a new string.) 4 77.6568 ws 26.668 519.32(String::search returns the index of the occurrence of the given character after) 22 412 ws 393.84 36.24(A-) 2 406.5 as 409.5 36.24(6) 1 415.5 as newpath 16.24 498.46 moveto 16.24 499.46 lineto 412.24 499.46 lineto 412.24 498.46 lineto closepath gsave eofill grestore 10 /Helvetica sf 37.576 481.9(interface String {) 4 110.947 ws 45.906 470.38(String\(\);) 9 81.466 as 45.906 458.86(String\(const char*\);) 2 131.486 ws 45.906 447.34(String\(const char*, int length\);) 6 177.627 ws 45.906 430.82(const char* string\(\) const;) 6 159.277 ws 45.906 419.3(int length\(\) const;) 4 122.607 ws 45.906 407.78(boolean null_terminated\(\) const;) 4 188.746 ws 45.906 396.26(unsigned long hash\(\) const;) 6 168.747 ws 45.906 379.74(String& operator =\(const String&\);) 6 196.247 ws 45.906 368.22(boolean operator ==\(const String&\) const;) 8 231.557 ws 45.906 356.7(boolean operator !=\(const String&\) const;) 8 228.497 ws 45.906 345.18(boolean operator >\(const String&\) const;) 8 225.717 ws 45.906 333.66(boolean operator >=\(const String&\) const;) 8 231.557 ws 45.906 322.14(boolean operator <\(const String&\) const;) 8 225.717 ws 45.906 310.62(boolean operator <=\(const String&\) const;) 8 231.557 ws 45.906 299.1(boolean case_insensitive_equal\(const String&\) const;) 6 283.236 ws 45.906 282.58(char operator[]\(int index\) const;) 6 184.297 ws 45.906 271.06(String substr\(int start, int length\) const;) 10 217.087 ws 45.906 259.54(String left\(int length\) const;) 6 164.847 ws 45.906 248.02(String right\(int start\) const;) 6 163.167 ws 45.906 236.5(void set_to_substr\(int start, int length\);) 8 215.427 ws 45.906 224.98(void set_to_left\(int length\);) 4 163.186 ws 45.906 213.46(void set_to_right\(int start\);) 4 161.507 ws 45.906 196.94(int search\(int start, char\) const;) 8 183.177 ws 45.906 185.42(int index\(char\) const;) 4 138.717 ws 45.906 173.9(int rindex\(char\) const;) 4 142.047 ws 45.906 157.38(boolean convert\(int&\) const;) 4 170.406 ws 45.906 145.86(boolean convert\(long&\) const;) 4 178.746 ws 45.906 134.34(boolean convert\(float&\) const;) 4 178.746 ws 45.906 122.82(boolean convert\(double&\) const;) 4 189.866 ws 37.576 111.3(};) 2 43.696 as 10 /Helvetica sf 141.161 94.7802(Figure A.6:) 2 190.071 ws 198.401 94.7802(String class interface.) 4 293.991 ws newpath 16.24 86.6101 moveto 16.24 87.6101 lineto 412.24 87.6101 lineto 412.24 86.6101 lineto closepath gsave eofill grestore showpage %%Page: 7 7 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 16 671.36(the given starting position. If the starting position is negative, it is treated as an) 29 412 ws 16 657.62(offset from the end of the string and the search is made right-to-left. String::index) 27 412 ws 16 643.88(and String::rindex are short-hand for searching from the beginning and end of the) 24 412 ws 16 630.14(string, respectively.) 2 110.32 ws 26.668 615.5(String::convert attempts to interpret the string as a number and sets its) 22 412 ws 16 601.76(parameter to the value. If the conversion is successful, String::convert returns true.) 23 412 ws 26.668 587.12(Three string subclasses of string are provided, all of which have the same) 24 412 ws 16 573.38(constructors and operations as the base class. CopyString is a subclass that) 23 412 ws 16 559.64(copies the string data when constructed and frees the storage when deleted.) 22 412 ws 16 545.9(When the copy is made, a null is appended to ensure the data is null-terminated.) 28 412 ws 16 532.16(NullTerminatedString is a subclass that guarantees its data is null-terminated. If) 21 412 ws 16 518.42(constructed with a normal string, it will copy the data much like a copy-string.) 26 412 ws 16 504.68(However, if the given string is already a copy-string, then no copy is made.) 26 412 ws 16 490.94(NullTerminatedString is useful for passing string data to external C functions,) 20 412 ws 16 477.2(such as printf.) 4 83.6568 ws 26.668 462.56(The third string subclass is UniqueString, which uses a table to map identical) 24 412 ws 16 448.82(strings to the same data. Comparing unique strings for equality is fast because the) 27 412 ws 16 435.08(implementation can compare pointers instead of the string data. Unique strings) 21 412 ws 16 421.34(are not null-terminated.) 4 128.981 ws 18 /Times-Bold sf 16 380.06(A.7) 3 42.496 as 51 380.06(Table) 5 95.01 as 12 /Times-Roman sf 16 347.66(Figure A.7 shows the table class interface. Table is a generic class that is) 27 412 ws 16 333.92(parameterized by a key type and a value type. The constructor is given a size for) 31 412 ws 16 320.18(the hash table implementation. For good access performance, the size should be) 23 412 ws 16 306.44(roughly twice the expected number of keys.) 12 226.289 ws 26.668 291.8(Table::insert stores a pair. Table::find searches an entry with) 19 412 ws 16 278.06(the given key. If such an entry exists, Table::find sets ) 21 298.496 ws 12 /Times-Italic sf 298.496 278.06(value) 5 324.488 as 12 /Times-Roman sf 324.488 278.06( and returns true.) 6 412 ws 16 264.32(Otherwise, it leaves the parameter unmodified and returns false. Table::remove) 19 412 ws 16 250.58(deletes a pair from the table if one exists. Table::find_and_remove) 21 412 ws 16 236.84(combines the find and remove operations in a single call.) 18 289.961 ws 26.668 222.2(If the same key is inserted more than once, Table::find will return the most) 26 412 ws 16 208.46(recently inserted value. Similarly, Table::remove will delete the most recently) 19 412 ws 16 194.72(inserted pair.) 2 78.6524 ws 26.668 180.08(TableIterator allows one to iterate over all the pairs defined in a) 24 412 ws 16 166.34(table. TableIterator is parameterized explicitly by the table type, implicitly by the) 23 412 ws 16 152.6(key and value types. TableIterator::cur_key and TableIterator::cur_value return) 15 412 ws 16 138.86(the current entry information. TableIterator::more tests if additional entries are) 19 412 ws 16 125.12(defined. TableIterator::next moves to the next entry in the table.) 19 324.449 ws 393.84 36.24(A-) 2 406.5 as 409.5 36.24(7) 1 415.5 as showpage %%Page: 8 8 90.05 36.94 translate 0 0 0 setrgbcolor 12 /Times-Roman sf 393.84 36.24(A-) 2 406.5 as 409.5 36.24(8) 1 415.5 as newpath 14.3201 588.7 moveto 14.3201 589.7 lineto 410.32 589.7 lineto 410.32 588.7 lineto closepath gsave eofill grestore 10 /Helvetica sf 35.6561 572.14(unsigned long key_to_hash\(Key\);) 4 184.066 ws 35.6561 555.62(interface Table\(Key,Value\) {) 4 160.157 ws 43.9861 544.1(Table\(Key,Value\)\(int hash_table_size\);) 2 216.276 ws 43.9861 527.58(void insert\(Key, Value\);) 4 147.357 ws 43.9861 516.06(boolean find\(Value&, Key\);) 4 162.937 ws 43.9861 504.54(void remove\(Key\);) 2 125.116 ws 43.9861 493.02(boolean find_and_remove\(Value&, Key\);) 4 224.076 ws 35.6561 481.5(};) 2 41.7761 as 35.6561 464.98(interface TableIterator\(Table\(Key,Value\)\) {) 4 223.506 ws 43.9861 453.46(TableIterator\(Table\(Key,Value\)\)\(Table\(Key,Value\)&\);) 51 277.946 as 43.9861 436.94(Key& cur_key\(\);) 2 115.116 ws 43.9861 425.42(Value& cur_value\(\);) 2 131.796 ws 43.9861 413.9(boolean more\(\);) 2 114.566 ws 43.9861 402.38(boolean next\(\);) 2 110.686 ws 35.6561 390.86(};) 2 41.7761 as 10 /Helvetica sf 139.796 374.34(Figure A.7:) 2 188.706 ws 197.036 374.34(Table class interface.) 4 291.516 ws newpath 14.3201 366.17 moveto 14.3201 367.17 lineto 410.32 367.17 lineto 410.32 366.17 lineto closepath gsave eofill grestore showpage %%Trailer end restore %%Pages: 8 ivtools-1.2.11a1/src/scripts/000077500000000000000000000000001214471147700160035ustar00rootroot00000000000000ivtools-1.2.11a1/src/scripts/chgsuffix.sh000066400000000000000000000003351214471147700203260ustar00rootroot00000000000000#!/bin/sh #set -x if [ "$1" \!= "$2" ]; then # recursively change suffix in $1 for suffix in $2 find . -type f -name "*.$1" -print -o -type d -name TIFF -prune | \ sed "s/^\(.*\)$1/mv \1$1 \1$2" | \ sh fi ivtools-1.2.11a1/src/scripts/cntsrclines.bash000077500000000000000000000011411214471147700211710ustar00rootroot00000000000000#!/bin/bash # # cntsrclines [dir] # # $1 directory in which to recursively count lines of C and C++ source # case "$#" in 0) ;; *) cd $1 ;; esac linecount1=`tmpnam` linecount2=`tmpnam` find . -name \*.c -exec wc -l {} \; >$linecount1 find . -name \*.h -exec wc -l {} \; >>$linecount1 find . -name \*.ci -exec wc -l {} \; >>$linecount1 find . -name \*.cpp -exec wc -l {} \; >>$linecount1 find . -name \*.C -exec wc -l {} \; >>$linecount1 echo "0L +" >$linecount2 sed -e "s/.\/.*/+/" $linecount1 >>$linecount2 echo 0 >>$linecount2 cat $linecount2 | comterp rm $linecount1 $linecount2 ivtools-1.2.11a1/src/scripts/ivcd.cpp000066400000000000000000000003221214471147700174310ustar00rootroot00000000000000XCOMM!/bin/sh XCOMM XCOMM ivcd shell script for ivtools comdraw XCOMM LDLIB_SPEC PATH_SPEC case "$#" in 0) comdraw ;; *) comdraw "$*" ;; esac ivtools-1.2.11a1/src/scripts/ivct.cpp000066400000000000000000000003221214471147700174510ustar00rootroot00000000000000XCOMM!/bin/sh XCOMM XCOMM ivct shell script for ivtools comterp XCOMM LDLIB_SPEC PATH_SPEC case "$#" in 0) comterp ;; *) comterp "$*" ;; esac ivtools-1.2.11a1/src/scripts/ivds.cpp000066400000000000000000000003251214471147700174540ustar00rootroot00000000000000XCOMM!/bin/sh XCOMM XCOMM ivds shell script for ivtools drawserv XCOMM LDLIB_SPEC PATH_SPEC case "$#" in 0) drawserv ;; *) drawserv "$*" ;; esac ivtools-1.2.11a1/src/scripts/ivdt.cpp000066400000000000000000000003251214471147700174550ustar00rootroot00000000000000XCOMM!/bin/sh XCOMM XCOMM ivdt shell script for ivtools drawtool XCOMM LDLIB_SPEC PATH_SPEC case "$#" in 0) drawtool ;; *) drawtool "$*" ;; esac ivtools-1.2.11a1/src/scripts/ivfb.cpp000066400000000000000000000003251214471147700174350ustar00rootroot00000000000000XCOMM!/bin/sh XCOMM XCOMM ivfb shell script for ivtools flipbook XCOMM LDLIB_SPEC PATH_SPEC case "$#" in 0) flipbook ;; *) flipbook "$*" ;; esac ivtools-1.2.11a1/src/scripts/ivgd.cpp000066400000000000000000000003301214471147700174340ustar00rootroot00000000000000XCOMM!/bin/sh XCOMM XCOMM ivgd shell script for ivtools graphdraw XCOMM LDLIB_SPEC PATH_SPEC case "$#" in 0) graphdraw ;; *) graphdraw "$*" ;; esac ivtools-1.2.11a1/src/scripts/ivgetjpg.bash000066400000000000000000000007441214471147700204660ustar00rootroot00000000000000#!/bin/bash # ** requires w3c from w3c.org and djpeg from jpeg.org as well ** # # ivgetjpeg # # bash script to download a jpeg file and import to a local drawing editor # # Parameters: # $1 URL # $2 import port on drawing editor url=$1 importport=$2 echo import $url to port $importport tempfile=`tmpnam` cmapfile=`tmpnam` stdcmapppm >$cmapfile w3c $url >$tempfile; djpeg -map $cmapfile -dither fs -pnm $tempfile | comterp telcat localhost $importport rm $tempfile $cmapfile ivtools-1.2.11a1/src/scripts/ivtiftopnm.bash000066400000000000000000000005031214471147700210370ustar00rootroot00000000000000#!/bin/bash # # ivtiftopnm [file] # # bash script to wrap tifftopnm which can't handle stdin # # Parameters: # $1 optional tiff image filename # case "$#" in 0) tempfile=`tmpnam` cat >$tempfile tifftopnm $tempfile rm $tempfile ;; *) tifftopnm $1 ;; esac ivtools-1.2.11a1/src/scripts/mkdirhier.sh000066400000000000000000000020421214471147700203130ustar00rootroot00000000000000#!/bin/sh # $XConsortium: mkdirhier.sh,v 1.6 91/08/13 18:13:04 rws Exp $ # Courtesy of Paul Eggert newline=' ' IFS=$newline case ${1--} in -*) echo >&2 "mkdirhier: usage: mkdirhier directory ..."; exit 1 esac status= for directory do case $directory in '') echo >&2 "mkdirhier: empty directory name" status=1 continue;; *"$newline"*) echo >&2 "mkdirhier: directory name contains a newline: \`\`$directory''" status=1 continue;; ///*) prefix=/;; # See Posix 2.3 "path". //*) prefix=//;; /*) prefix=/;; -*) prefix=./;; *) prefix= esac IFS=/ set x $directory IFS=$newline shift for filename do if [ "$filename" != "" ]; then path=$prefix$filename fi prefix=$path/ shift test -d "$path" || { paths=$path for filename do if [ "$filename" != "." ]; then path=$path/$filename paths=$paths$newline$path fi done for x in $paths do if [ ! -d $x ]; then mkdir $x || status=$? chmod g+w $x fi done break } done done exit $status ivtools-1.2.11a1/src/scripts/mkgif89a.bash000066400000000000000000000012231214471147700202570ustar00rootroot00000000000000#!/bin/bash # $1 scale # $2 rotation # $3 postscript file echo "** rendering ppmraw images with Ghostscript **" cat $3 | gs -sDEVICE=ppmraw -sOutputFile=$3-%02d.ppm -dNOPAUSE - echo "** converting images from ppmraw to gif **" for x in $3-??.ppm do echo writing `dirname $3`/`basename $x .ppm`.gif pnmscale -xscale $1 -yscale $1 $x | pnmrotate $2 | ppmquant 256 | ppmtogif >`dirname $3`/`basename $x .ppm`.gif done echo "** merging images into multi-frame gif89a **" bash -c "gifmerge -l0 -25 $3-??.gif >$3.gif" echo "** loading multi-frame gif89a into xanim **" xanim $3.gif & echo "** removing intermediate ppmraw and gif images **" rm $3-??.gif $3-??.ppm ivtools-1.2.11a1/src/scripts/mkgif89ac.bash000077500000000000000000000014111214471147700204240ustar00rootroot00000000000000#!/bin/bash # $1 scale # $2 rotation # $3 width of clipping rectangle # $4 height of clipping rectangle # $5 hundreds of a second between frames # $6 postscript file echo "** rendering ppmraw images with Ghostscript **" cat $6 | gs -g$3x$4 -sDEVICE=ppmraw -sOutputFile=$6-%02d.ppm -dNOPAUSE - echo "** converting images from ppmraw to gif **" for x in $6-??.ppm do echo writing `dirname $6`/`basename $x .ppm`.gif pnmscale -xscale $1 -yscale $1 $x | pnmrotate $2 | ppmquant 256 | ppmtogif >`dirname $6`/`basename $x .ppm`.gif done echo "** merging images into multi-frame gif89a **" bash -c "gifmerge -l0 -$5 $6-??.gif >$6.gif" echo "** loading multi-frame gif89a into xanim **" xanim $6.gif & echo "** removing intermediate ppmraw and gif images **" rm $6-??.gif $6-??.ppm ivtools-1.2.11a1/src/scripts/pnmtopgm.sh000066400000000000000000000014521214471147700202020ustar00rootroot00000000000000#!/bin/sh # # pnmtopgm - derived from anytopnm # # Copyright 1998 Vectaport Inc. # Copyright (C) 1991 by Jef Poskanzer. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, provided # that the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. This software is provided "as is" without express or # implied warranty. if [ ! $# = 1 ] ; then echo "usage: $0 " 1>&2 exit 1 fi origfile="$1" file="$origfile" tmpfiles="" filetype=`file "$file"` case "$filetype" in *PBM* ) pnmdepth 255 "$file" exit 0 ;; *PGM* ) cat "$file" exit 0 ;; *PPM* ) ppmtopgm "$file" exit 0 ;; esac exit -1 ivtools-1.2.11a1/src/scripts/tsort-libs000077500000000000000000000014611214471147700200350ustar00rootroot00000000000000#! /bin/sh -f # This lovely little script grovels through Makefile.am to find the # mutual dependencies between the generated libraries. It uses this # information to topologically sort them, and outputs the result in a # form suitable for inclusion in Makefile.am. # # The reason for this is that these must be in dependency order in # Makefile.am to avoid a known but undocumented bug which generates an # install-time link error. egrep 'la_LIBADD[[:blank:]]*=' Makefile.am \ | sed 's/-l[^[:blank:]]*\|_la_LIBADD[[:blank:]]*=\|[.]la\|[$][(][^)]*[)]//g' \ | awk '{for (i=1; i<=NF; i++) print $1, $i}' \ | sed 's/_/-/g' \ | tsort | tac \ | awk '{ if ($1 == "libAceDispatch") print "if HAVE_LIBACE"; print "lib_LTLIBRARIES +=", $1 ".la"; if ($1 == "libAceDispatch") print "endif" }' ivtools-1.2.11a1/src/tests/000077500000000000000000000000001214471147700154565ustar00rootroot00000000000000ivtools-1.2.11a1/src/tests/y2k/000077500000000000000000000000001214471147700161635ustar00rootroot00000000000000ivtools-1.2.11a1/src/tests/y2k/y2ktest.cc000066400000000000000000000032341214471147700201010ustar00rootroot00000000000000/* * Copyright (c) 1999 Vectaport, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of the copyright holders not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. The copyright holders make * no representation about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include