home *** CD-ROM | disk | FTP | other *** search
- There are actually two types of objects (should I have two main object
- classes, inherited from a common root ?):
-
- a) Objects which are visual (labels, lines, rectangles)
- b) Objects which exist semi-independtly from the graph (functions)
-
- Objects of class b are selectable even if the graph is invalid, they have a
- name. Hence, as they can be selected other than by clicking on them, they are
- allowed to be 'invalid' (not displayable). All this is not allowed for
- class a). The name and ok fields serve these purposes, name must be a null
- string and ok true for class a).
-
- The methods will be called as expected: all created objects will be deleted,
- selects will be followed by deselects, the sequence for down/move/up is
-
- down, move, move, ..., up
-
- select will be called if down returns true (the actual sequence is therefore:
- - if down returns FALSE down
- - if down returns TRUE down, select, move, move, ..., up
- )
-
- The graph will be in a valid state (ok, window coords exisiting) when
- down/move/up/draw are called, but not necessarily so for all the other calls.
-
-
- Public fields:
- --------------
-
- node node: used to keep objects in a list
- struct graph *g: the graph in which this object is
- int ok: object in a valid state ?
- int mx, my: These specify an offset to apply to the position of the mouse
- while it is moved around. This allows you to have an object picked up and
- moved around by an arbitray point (the mouse will maintain the same position
- relative to the objects origin thoughout, eg when dragging an object).
-
- methods:
- --------
-
- delete no comment
-
- select you have been selected. You should probbaly highlight yourself.
-
- deselect Deselect yourself (dehighlight ?), return TRUE if the graph
- needs redrawing (eg if you can't unhighlight cleanly).
-
- down Return true if graph's coordinates (in g->s.x,y) are inside you.
- If you answer TRUE, you will be selected (cf select).
-
- move The mouse has moved. Do what you want (resize, drag, nothing).
- Called only if you answered TRUE to down (Coordinates as above).
-
- up The mouse has been released. return TRUE if the graph needs
- redrawing (eg if you moved).
-
- edit Allow the user detailed control over your placement, ... Return
- TRUE if the object changed.
-
- draw Display thyself ! allow_mes is FALSE if called during refresh
- (this mainly means that you can't display error messages).
-
- improve Improve your appearance (for functions mainly). Return TRUE if
- graph needs redrawing.
-
- f2str Provide a concise (one line) textual description of yourself, in
- buf (maximum size: maxlen). Return buf.
-
- var_change Is called for every object whenever a variable changes value. The
- variable that has changed is passed. You should do whatever is
- necessary to make sure that the next time you are displayed, you
- reflect the new value of the variable.
-
- save Save yourself in the file. For the format, see load_<obj> below.
-
- inform Called for every object of a graph when it changes (for the moment,
-
- only when the dots per meter values change). This allows any
- dependent values to be recalculated, any fonts to be loaded, etc
- If this isn't possible (eg no memory left), return FALSE and
- return to your previous state, otherwise return TRUE (but keep
- enough information to return to your previous state without
- needing any resources).
-
- confirm After an inform (to which you retuned TRUE), confirm is called
- (before anything else), with ok being TRUE to confirm the
- changes to the graph (you can now free any old resources), or
- FALSE if the changes failed (return to the old state and free
- any newly allocated resources).
- Note: if you answered FALSE.to inform, this method won't get
- called.
-
- functions
- ---------
- You must also provide two functions to create the objects:
-
- new_<objname> Create a new instance of an object of class objname. Provide
- whatever initial parameters are necessary, or prompt the user.
- The main code will obviously have to be modified to allow
- creation of ant new object type ...
-
- load_<objname> Also creates a new instance, but with ant information loaded
- from disk (The file is one of the parameters). The format, in
- the file must be:
-
- <object tag> a unique short for each type of object
- <any private data>
- <object end tag> another unique short
-
- When load is called, the first tag has been read. load should
- check for data integrity, and the presence of the end_tag.
- NULL should be returned as an error.
-
- The tags are centralised in file.h, to avoid errors.
-
-