/* * GRAPH, Version 1.00 - 4 August 1989 * * Copyright 1989, David Gay. All Rights Reserved. * This software is freely redistrubatable. */ /* The object class. All the different objects are subclasses of it */ #ifndef OBJECT_H #define OBJECT_H #include #include "list.h" #include "grph.h" #define FNAMELEN 20 /* Length of object name */ struct object { node node; struct graph *g; /* Which graph this object is in (g->s.x,y contains curren t mouse pos)*/ char name [FNAMELEN]; /* Name (for functions only) "" otherwise */ int ok; /* For functions only: is it displayed */ int mx, my; /* Specify an (optional) displacement for the mouse pointer whe n this is selected */ struct Region *(*delete) (struct object *this); void (*select) (struct object *this); /* You have been selecte d */ struct Region *(*deselect) (struct object *this); /* done. does the screen need refreshing ? */ int (*down) (struct object *this); /* User pressed button. Return TRUE if (x,y) is inside you */ void (*move) (struct object *this); struct Region *(*up) (struct object *this); /* Redraw necessary ? */ int (*edit) (struct object *this, struct Region **ref); /* Returns true if graph changed */ void (*draw) (struct object *this, int allow_mes); struct Region *(*improve) (struct object *this); char *(*f2str) (struct object *this, char *buf, int maxlen); void (*var_change)(struct object *this, char *name); /* Change in variable "name" */ int (*save) (struct object *this, FILE *f); int (*inform) (struct object *this); /* Inform of changes to g */ void (*confirm) (struct object *this, int ok); /* Confirm previ ous changes */ }; /* A special object, used for selecting points on screen (cross hair mode) */ /* The fields are public. Only new, down, move, up and deselect are implemented */ struct pos { struct object o; int cross : 1; int rect : 1; double x0, y0, x1, y1; }; struct pos *new_pos(struct graph *g); /* A label on the graph */ struct label *new_label(struct graph *g, double x, double y); struct label *load_label(struct graph *g, FILE *f); /* A function (ie f(x), r(theta), etc */ struct function *new_function(struct graph *g); struct function *load_function(struct graph *g, FILE *f); #endif