home *** CD-ROM | disk | FTP | other *** search
- /* This source file is part of the LynxLib miscellaneous library by
- Robert Fischer, and is Copyright 1990 by Robert Fischer. It costs no
- money, and you may not make money off of it, but you may redistribute
- it. It comes with ABSOLUTELY NO WARRANTY. See the file LYNXLIB.DOC
- for more details.
- To contact the author:
- Robert Fischer \\80 Killdeer Rd \\Hamden, CT 06517 USA
- (203) 288-9599 fischer-robert@cs.yale.edu */
-
- #include <stddef.h>
- #include <nobdefs.h>
- #include <gemdefs.h>
- #include <mygem.h>
- #include <string.h>
- #include <e_osbind.h>
- /* --------------------------------------------------------- */
- gem_ok(s) /* Puts up a GEM OK box */
- char *s;
- {
- char s1[100] = "[0][";
- Cconout(7); /* Bell */
- strcat(s1, s);
- strcat(s1, "][ OK ]");
- form_alert(1, s1);
- }
- /* ------------------------------------------------------ */
- gem_err(s) /* Puts up a GEM error box */
- char *s;
- {
- char s1[100] = "[1][";
- Cconout(7); /* Bell */
- strcat(s1, s);
- strcat(s1, "][ Abort ]");
- form_alert(1, s1);
- }
- /* ------------------------------------------------------ */
- dial_form(d, n) /* Does a form_dial on box d, with mode n */
- register OBJECT *d;
- int n;
- {
- int border;
- border = d->ob_spec.boxchar.thickness;
- if (border > 128) border = 256-border;
- else border = 0;
- if (border < 4) border = 4;
-
- form_dial(n, d->ob_x + (d->ob_width >> 1), d->ob_y + (d->ob_height >> 1),
- 0, 0, d->ob_x - border, d->ob_y - border,
- d->ob_width + (border << 1), d->ob_height + (border << 1));
- }
- /* --------------------------------------------------------- */
- draw_box(d) /* Draws a dialog box */
- OBJECT *d;
- {
- dial_form(d, FMD_START);
- objc_draw(d, 0, 256, 0, 0, 0, 0);
- }
- /* --------------------------------------------------------- */
- /* --------------------------------------------------------- */
- map_obtree(d, this, last, routine)
- /* General object tree walking routine. Applies an operation
- to every node in the tree. This routine was gotton out of
- issue 5 of PROGEM, by Tim Oren. */
-
- OBJECT *d; /* Tree to walk */
- int this; /* Node to start at. */
- int last; /* Node to stop at (This node won't be affected) */
- int (*routine)(); /* Routine to apply to every node of tree */
- /* routine takes the arguments: routine(d, obj)
- OBJECT *d; (* Address of object tree *)
- int obj; (* Object in object tree *)
- If it wants no more walking on the subtree, it returns TRUE.
- Normaly, it should return FALSE. */
- {
- int tmp1;
- tmp1 = this; /* Initialize to impossible value */
- /* TAIL won't point to self! */
- /* Look until final node, or off the end of the tree */
- while (this != last && this != 0) {
- /* Did we 'pop' into this node for the first time? */
- if (tmp1 != d[this].ob_tail) {
- tmp1 = this;
- this = 0;
- /* Apply operation, testing for rejection of sub-tree */
- if ((*routine)(d, tmp1))
- this = d[tmp1].ob_head;
- /* Subtree path not taken, so traverse right */
- if (this == 0) this = d[tmp1].ob_next;
- } else { /* Revisiting parent */
- tmp1 = this;
- this = d[tmp1].ob_next;
- }
- } /* while */
- }
- /* --------------------------------------------------------- */
- map_subtree(d, subtree, routine)
- /* Walks all the children of one node */
- OBJECT *d; /* Tree to walk */
- int subtree; /* Parent of all the children to walk */
- int (*routine)(); /* Routine to apply to every node of tree */
- {
- map_obtree(d, d[subtree].ob_head, d[subtree].ob_tail, routine);
- }
- /* --------------------------------------------------------- */
- /* Another object state */
- #define WAS_ENABLED 0x40
-
- disable_obj(d, obj)
- /* Disables an object, & sets the WAS_ENABLED flag if it was enabled. */
- OBJECT *d;
- int obj;
- {
- if (!(d[obj].ob_state & DISABLED)) /* It was enabled, so disable it. */
- d[obj].ob_state != DISABLED | WAS_ENABLED;
- }
-
- enable_obj(d, obj)
- OBJECT *d;
- int obj;
- /* Undoes the work of disable_obj */
- {
- if (d[obj].ob_state & WAS_ENABLED) /* It was enabled, so enable it again. */
- d[obj].ob_state &= ~DISABLED;
- }
- /* --------------------------------------------------------- */
- set_rchecked(d, obj, box, obox, redraw, checked)
- /* Sets a little box to checked or non-checked, and makes an object
- subtree disappear, according to checked */
- OBJECT *d; /* The object tree to work in */
- int obj; /* Index into the tree */
- int box; /* object to set or unset HIDETREE */
- int obox; /* object to redraw, to see effects on box */
- BOOLEAN redraw; /* Redraw obox? */
- BOOLEAN checked; /* Boolean value representing checkedness of obj when */
- /* flip_checked was called. flip_checked() flips this value. */
- /* TRUE means the box is checked, FALSE means it is unchecked. */
- {
- if (checked) { /* Set obj to checked, box to HIDETREE */
- d[obj].ob_state |= CHECKED;
- d[box].ob_flags |= HIDETREE;
- map_subtree(d, box, &disable_obj);
- } else {
- d[obj].ob_state &= ~CHECKED;
- d[box].ob_flags &= ~HIDETREE;
- map_subtree(d, box, &enable_obj);
- }
- if (redraw) {
- objc_draw(d, obox, 256, 0, 0, 0, 0);
- objc_draw(d, obj, 256, 0, 0, 0, 0);
- }
- }
- /* --------------------------------------------------------- */
- center_form(d)
- OBJECT *d;
- {
- xywh c;
- form_center(d, XYWH_PTR(c));
- }
- /* --------------------------------------------------------- */
- mouse_up()
- /* Waits for the user to lift the mouse */
- {
- int dum;
- evnt_button(1, 1, 0, &dum, &dum, &dum, &dum);
- }
- /* ---------------------------------------------------------------- */
-