tomwalters@0: /* tomwalters@0: Copyright (c) Applied Psychology Unit, Medical Research Council. 1988, 1989 tomwalters@0: =========================================================================== tomwalters@0: tomwalters@0: Permission to use, copy, modify, and distribute this software without fee tomwalters@0: is hereby granted for research purposes, provided that this copyright tomwalters@0: notice appears in all copies and in all supporting documentation, and that tomwalters@0: the software is not redistributed for any fee (except for a nominal shipping tomwalters@0: charge). Anyone wanting to incorporate all or part of this software in a tomwalters@0: commercial product must obtain a license from the Medical Research Council. tomwalters@0: tomwalters@0: The MRC makes no representations about the suitability of this tomwalters@0: software for any purpose. It is provided "as is" without express or implied tomwalters@0: warranty. tomwalters@0: tomwalters@0: THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING tomwalters@0: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE tomwalters@0: A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY tomwalters@0: DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN tomwalters@0: AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF tomwalters@0: OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. tomwalters@0: */ tomwalters@0: tomwalters@0: /* tomwalters@0: windows.h tomwalters@0: ========= tomwalters@0: tomwalters@0: A rather wave drawing oriented interface to window systems tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: Authors : John Holdsworth, Paul Manson. tomwalters@0: Written : 22nd March, 1989. tomwalters@0: tomwalters@0: Edited : tomwalters@0: tomwalters@0: 04 April 1989 (Paul Manson) -- Altered the axes entry point to also pass tomwalters@0: the WindowObject (it is needed so that the tomwalters@0: axes have something to attach to) tomwalters@0: tomwalters@0: 06 July 1989 (Paul Manson) -- Altered the argument of newDisplayWindow() tomwalters@0: to refer to the name of the window to be created, tomwalters@0: rather than the display to use. tomwalters@0: tomwalters@0: 01 April 1990 (John Holdsworth) -- function operation changed to more general tomwalters@0: segment operation to draw part of a wave. tomwalters@0: The macro Function() preforms as before. tomwalters@0: tomwalters@0: */ tomwalters@0: tomwalters@0: /* allowed extry pointy for a generic window object */ tomwalters@0: tomwalters@0: typedef struct _window_entries { tomwalters@0: short (*x )( /* WindowOjbect info */ ) ; tomwalters@0: short (*y )( /* WindowOjbect info */ ) ; tomwalters@0: short (*width )( /* WindowOjbect info */ ) ; tomwalters@0: short (*height )( /* WindowOjbect info */ ) ; tomwalters@0: void (*draw )( /* WindowOjbect info, short *xs, *ys, int points */ ) ; tomwalters@0: void (*clear )( /* WindowOjbect info */ ) ; tomwalters@0: void (*close )( /* WindowOjbect info */ ) ; tomwalters@0: int (*store )( /* WindowOjbect info */ ) ; tomwalters@0: void (*recall )( /* WindowOjbect info, int which */ ) ; tomwalters@0: void (*fillRow )( /* WindowOjbect info, int row, pixels[], width */ ) ; tomwalters@0: void (*fillCol )( /* WindowOjbect info, int col, pixels[], height */ ) ; tomwalters@0: void (*function)( /* WindowOjbect info, short *ys, int segment, skip ; tomwalters@0: double offset, scale ; int start, points */ ) ; tomwalters@0: int (*read )( /* WindowObject info, FILE *fptr, int which */ ) ; tomwalters@0: void (*write )( /* WindowObject info, FILE *fptr */ ) ; tomwalters@0: char (*pause )( /* WindowObject info */ ) ; tomwalters@0: void (*axes )( /* WindowObject info, char *title ; tomwalters@0: double xmin, xmax ; char *xtitle ; tomwalters@0: double ymin, ymax ; char *ytitle */ ) ; tomwalters@0: void (*marker )( /* WindowObject info, char *text, int start, pts */ ) ; tomwalters@0: int (*special )( /* WindowObject info, int code, char *data */ ) ; tomwalters@0: } windowEntries /* windowMethods */ ; tomwalters@0: tomwalters@0: typedef struct _window_class { tomwalters@0: struct _window_class *super ; tomwalters@0: windowEntries entries ; tomwalters@0: } windowsClass ; tomwalters@0: tomwalters@0: /* external interface to window object */ tomwalters@0: tomwalters@0: typedef struct _window_object { tomwalters@0: windowEntries *entries ; tomwalters@0: char window[4] ; /* Window may be accessed as *( (Window) &window_object->window ) */ tomwalters@0: /* struct { user data goes here in sub-class 1st item of which is window } ; */ tomwalters@0: } *WindowObject ; tomwalters@0: tomwalters@0: tomwalters@0: /* best guess at image structure for portable drawing optimisation */ tomwalters@0: tomwalters@0: typedef struct _window_image { tomwalters@0: char *data ; int bytes_per_line, height, left_bit, right_bit, start_bit ; tomwalters@0: } *WindowImage ; tomwalters@0: tomwalters@0: extern WindowImage window__current_image( /* WindowObject window */ ) ; tomwalters@0: tomwalters@0: /* #define prototypes to simulate operation as objects and check types */ tomwalters@0: tomwalters@0: tomwalters@0: #define Width( _w ) \ tomwalters@0: ( _w )->entries->width( _w ) tomwalters@0: tomwalters@0: #define Height( _w ) \ tomwalters@0: ( _w )->entries->height( _w ) tomwalters@0: tomwalters@0: tomwalters@0: #define Draw( _w, _xs , _ys , _points ) \ tomwalters@0: ( _w )->entries->draw( _w, (short *) (_xs), (short *) (_ys), (int) (_points) ) tomwalters@0: tomwalters@0: #define Plot( _w, _xs , _ys , _points ) \ tomwalters@0: ( _w )->entries->draw( _w, (short *) (_xs), (short *) (_ys), (int) -(_points) ) tomwalters@0: tomwalters@0: tomwalters@0: #define Clear( _w ) \ tomwalters@0: ( _w )->entries->clear( _w ) tomwalters@0: tomwalters@0: #define Close( _w ) \ tomwalters@0: ( _w )->entries->close( _w ) tomwalters@0: tomwalters@0: tomwalters@0: #define Store( _w ) \ tomwalters@0: ( _w )->entries->store( _w ) tomwalters@0: tomwalters@0: #define Recall( _w, _which ) \ tomwalters@0: ( _w )->entries->recall( _w, (int) ( _which ) ) tomwalters@0: tomwalters@0: tomwalters@0: #define FillRow( _w, _row , _input , _black , _white , _match , _height ) \ tomwalters@0: ( _w )->entries->fillRow( _w, (int) (_row), (short *) (_input), (int) (_black), (int) (_white), (int *) (_match), (int) (_height) ) tomwalters@0: tomwalters@0: #define FillCol( _w, _col , _input , _black , _white , _match , _height ) \ tomwalters@0: ( _w )->entries->fillCol( _w, (int) (_col), (short *) (_input), (int) (_black), (int) (_white), (int *) (_match), (int) (_height) ) tomwalters@0: tomwalters@0: tomwalters@0: /* function provided for backward compatability */ tomwalters@0: tomwalters@0: #define Function( _w, _ys , _points , _skip , _offset , _scale ) \ tomwalters@0: ( _w )->entries->function( _w, (short *) ( _ys ), abs( (int) ( _points ) ), (int) ( _skip ), (double) ( _offset ), (double) ( _scale ), (int)0, (int)_points ) tomwalters@0: tomwalters@0: #define Segment( _w, _ys , _segment , _skip , _offset , _scale , _start , _points ) \ tomwalters@0: ( _w )->entries->function( _w, (short *) ( _ys ), (int) ( _segment ), (int) ( _skip ), (double) ( _offset ), (double) ( _scale ), (int) ( _start ), (int) ( _points ) ) tomwalters@0: tomwalters@0: tomwalters@0: #define Read( _w, _file, _which ) \ tomwalters@0: ( _w )->entries->read( _w, _file, (int) (_which) ) tomwalters@0: tomwalters@0: #define Write( _w, _file ) \ tomwalters@0: ( _w )->entries->write( _w, _file ) tomwalters@0: tomwalters@0: tomwalters@0: #define Pause( _w ) \ tomwalters@0: ( _w )->entries->pause( _w ) tomwalters@0: tomwalters@0: #define Axes( _w, _title , _xmin , _xmax , _xtitle , _ymin, _ymax , _ytitle ) \ tomwalters@0: ( _w )->entries->axes( _w, (char *) (_title), (double) (_xmin), (double) (_xmax), (char *) (_xtitle), (double) (_ymin), (double) (_ymax), (char *) (_ytitle) ) tomwalters@0: tomwalters@0: #define Marker( _w, _label , _p, _points ) \ tomwalters@0: ( _w )->entries->marker( _w, (char *) (_label), (int) _p, (int) _points ) tomwalters@0: tomwalters@0: #define Special( _w, _code , _data ) \ tomwalters@0: ( _w )->entries->special( _w, (char *) (_code), (char *) (_data) ) tomwalters@0: tomwalters@0: tomwalters@0: /* standard window object creation routines */ tomwalters@0: tomwalters@0: #define NewDisplayWindow( _name, _default_x, _default_y, _default_width, _default_height, _pixels ) \ tomwalters@0: newDisplayWindow( _name, _default_x, _default_y, _default_width, _default_height, _pixels ) tomwalters@0: tomwalters@0: #define NewFILEWindow( _name, _default_x, _default_y, _default_width, _default_height, _pixels ) \ tomwalters@0: newFILEWindow( _name, _default_x, _default_y, _default_width, _default_height, _pixels ) tomwalters@0: tomwalters@0: #define NewPSWindow( _name, _default_x, _default_y, _default_width, _default_height, _pixels ) \ tomwalters@0: newPSWindow( _name, _default_x, _default_y, _default_width, _default_height, _pixels ) tomwalters@0: tomwalters@0: #define NewNullWindow( ) \ tomwalters@0: newNullWindow( ) tomwalters@0: tomwalters@0: extern WindowObject newDisplayWindow(), newPSWindow(), newPostScriptWindow(), newFILEWindow(), newNullWindow(), NullWindowObject ; tomwalters@0: tomwalters@0: extern windowsClass *initPostScriptClass(), *initDisplayPostScriptClass() ;