view glib/windows.h @ 0:5242703e91d3 tip

Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author tomwalters
date Fri, 20 May 2011 15:19:45 +0100
parents
children
line wrap: on
line source
/*
    Copyright (c) Applied Psychology Unit, Medical Research Council. 1988, 1989
    ===========================================================================

    Permission to use, copy, modify, and distribute this software without fee 
    is hereby granted for research purposes, provided that this copyright 
    notice appears in all copies and in all supporting documentation, and that 
    the software is not redistributed for any fee (except for a nominal shipping 
    charge). Anyone wanting to incorporate all or part of this software in a
    commercial product must obtain a license from the Medical Research Council.

    The MRC makes no representations about the suitability of this 
    software for any purpose.  It is provided "as is" without express or implied 
    warranty.
 
    THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 
    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE
    A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 
    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 
    AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/*
    windows.h
    =========

    A rather wave drawing oriented interface to window systems



    Authors : John Holdsworth, Paul Manson.
    Written : 22nd March, 1989.

    Edited  :

    04 April 1989 (Paul Manson) -- Altered the axes entry point to also pass
                                   the WindowObject (it is needed so that the
                                   axes have something to attach to)

    06 July  1989 (Paul Manson) -- Altered the <name> argument of newDisplayWindow()
                                   to refer to the name of the window to be created,
                                   rather than the display to use. 

    01 April 1990 (John Holdsworth) -- function operation changed to more general
				   segment operation to draw part of a wave.
				   The macro Function() preforms as before.

*/

/* allowed extry pointy for a generic window object */

typedef struct _window_entries {
    short (*x       )( /* WindowOjbect info                              */ ) ;
    short (*y       )( /* WindowOjbect info                              */ ) ;
    short (*width   )( /* WindowOjbect info                              */ ) ;
    short (*height  )( /* WindowOjbect info                              */ ) ;
    void  (*draw    )( /* WindowOjbect info, short *xs, *ys, int points  */ ) ;
    void  (*clear   )( /* WindowOjbect info                              */ ) ;
    void  (*close   )( /* WindowOjbect info                              */ ) ;
    int   (*store   )( /* WindowOjbect info                              */ ) ;
    void  (*recall  )( /* WindowOjbect info, int which                   */ ) ;
    void  (*fillRow )( /* WindowOjbect info, int row, pixels[], width    */ ) ;
    void  (*fillCol )( /* WindowOjbect info, int col, pixels[], height   */ ) ;
    void  (*function)( /* WindowOjbect info, short *ys, int segment, skip ;
				double offset, scale ; int start, points */ ) ;
    int   (*read    )( /* WindowObject info, FILE *fptr, int which       */ ) ;
    void  (*write   )( /* WindowObject info, FILE *fptr                  */ ) ;
    char  (*pause   )( /* WindowObject info                              */ ) ;
    void  (*axes    )( /* WindowObject info, char  *title ;
			 double xmin, xmax ; char *xtitle ;
			 double ymin, ymax ; char *ytitle                */ ) ;
    void  (*marker  )( /* WindowObject info, char *text, int start, pts  */ ) ;
    int   (*special )( /* WindowObject info, int code, char *data        */ ) ;
    } windowEntries    /* windowMethods */ ;

typedef struct _window_class {
    struct _window_class *super ;
    windowEntries entries ;
    } windowsClass ;

/* external interface to window object */

typedef struct _window_object {
    windowEntries *entries ;
    char window[4] ; /* Window may be accessed as *( (Window) &window_object->window ) */
    /* struct { user data goes here in sub-class 1st item of which is window } ; */
    } *WindowObject ;


/* best guess at image structure for portable drawing optimisation */

typedef struct _window_image {
   char *data ; int bytes_per_line, height, left_bit, right_bit, start_bit ;
  } *WindowImage ;

extern WindowImage window__current_image( /* WindowObject window */ ) ;

/* #define prototypes to simulate operation as objects and check types */


#define           Width(    _w                         ) \
 ( _w )->entries->width(    _w                         )

#define           Height(   _w                         ) \
 ( _w )->entries->height(   _w                         )


#define           Draw(     _w,            _xs ,            _ys ,         _points  ) \
 ( _w )->entries->draw(     _w, (short *) (_xs), (short *) (_ys), (int)  (_points) )

#define           Plot(     _w,            _xs ,            _ys ,         _points  ) \
 ( _w )->entries->draw(     _w, (short *) (_xs), (short *) (_ys), (int) -(_points) )


#define           Clear(    _w                         ) \
 ( _w )->entries->clear(    _w                         )

#define           Close(    _w                         ) \
 ( _w )->entries->close(    _w                         )


#define           Store(    _w                         ) \
 ( _w )->entries->store(    _w                         )

#define           Recall(   _w,         _which         ) \
 ( _w )->entries->recall(   _w, (int) ( _which )       )


#define           FillRow(  _w,        _row ,            _input ,        _black ,        _white ,          _match ,        _height  ) \
 ( _w )->entries->fillRow(  _w, (int) (_row), (short *) (_input), (int) (_black), (int) (_white), (int *) (_match), (int) (_height) )

#define           FillCol(  _w,        _col ,            _input ,        _black ,        _white ,          _match ,         _height ) \
 ( _w )->entries->fillCol(  _w, (int) (_col), (short *) (_input), (int) (_black), (int) (_white), (int *) (_match), (int) (_height) )


/* function provided for backward compatability */

#define           Function( _w,             _ys  ,              _points    ,         _skip  ,            _offset  ,            _scale                         ) \
 ( _w )->entries->function( _w, (short *) ( _ys ), abs( (int) ( _points ) ), (int) ( _skip ), (double) ( _offset ), (double) ( _scale ), (int)0, (int)_points )

#define            Segment( _w,             _ys  ,         _segment  ,         _skip  ,            _offset  ,            _scale  ,         _start  ,         _points   ) \
 ( _w )->entries->function( _w, (short *) ( _ys ), (int) ( _segment ), (int) ( _skip ), (double) ( _offset ), (double) ( _scale ), (int) ( _start ), (int) ( _points ) )


#define           Read(     _w, _file,        _which   ) \
 ( _w )->entries->read(     _w, _file, (int) (_which)  )

#define           Write(    _w, _file                  ) \
 ( _w )->entries->write(    _w, _file                  )


#define           Pause(    _w                         ) \
 ( _w )->entries->pause(    _w                         )

#define           Axes(     _w,           _title ,           _xmin ,           _xmax ,           _xtitle ,           _ymin,            _ymax ,           _ytitle  ) \
 ( _w )->entries->axes(     _w, (char *) (_title), (double) (_xmin), (double) (_xmax), (char *) (_xtitle), (double) (_ymin), (double) (_ymax), (char *) (_ytitle) )

#define           Marker(   _w,           _label ,       _p,       _points ) \
 ( _w )->entries->marker(   _w, (char *) (_label), (int) _p, (int) _points )

#define           Special(   _w,           _code ,           _data  ) \
 ( _w )->entries->special(   _w, (char *) (_code), (char *) (_data) )


/* standard window object creation routines */

#define NewDisplayWindow( _name, _default_x, _default_y, _default_width, _default_height, _pixels ) \
	newDisplayWindow( _name, _default_x, _default_y, _default_width, _default_height, _pixels )

#define    NewFILEWindow( _name, _default_x, _default_y, _default_width, _default_height, _pixels ) \
	   newFILEWindow( _name, _default_x, _default_y, _default_width, _default_height, _pixels )

#define      NewPSWindow( _name, _default_x, _default_y, _default_width, _default_height, _pixels ) \
	     newPSWindow( _name, _default_x, _default_y, _default_width, _default_height, _pixels )

#define    NewNullWindow( ) \
	   newNullWindow( )

extern WindowObject newDisplayWindow(), newPSWindow(), newPostScriptWindow(), newFILEWindow(), newNullWindow(), NullWindowObject ;

extern windowsClass *initPostScriptClass(), *initDisplayPostScriptClass() ;