2
* FIG : Facility for Interactive Generation of figures
3
* Copyright (c) 1985-1988 by Supoj Sutanthavibul
4
* Parts Copyright (c) 1989-2000 by Brian V. Smith
5
* Parts Copyright (c) 1991 by Paul King
6
* Parts Copyright (c) 1994 by Bill Taylor
7
* "Enter Compound" written by Bill Taylor (bill@mainstream.com) 1994
9
* Any party obtaining a copy of these files is granted, free of charge, a
10
* full and unrestricted irrevocable, world-wide, paid up, royalty-free,
11
* nonexclusive right and license to deal in this software and
12
* documentation files (the "Software"), including without limitation the
13
* rights to use, copy, modify, merge, publish, distribute, sublicense,
14
* and/or sell copies of the Software, and to permit persons who receive
15
* copies from any such party to do so, with the only requirement being
16
* that this copyright notice remain intact.
21
* open_compound lets the user select a compound with the left button,
22
* then replaces the current drawing with that compound alone so that the
23
* user can edit the insides of that compound without taking it apart.
25
* close_compound pops out one compound; close_all_compounds pops all the way out.
31
#include "resources.h"
42
Widget close_compound_popup;
43
Boolean close_popup_isup = False;
44
void open_this_compound();
47
init_open_compound(c, type, x, y, px, py, loc_tag)
54
if (type != O_COMPOUND)
56
open_this_compound(c);
65
mask_toggle_compoundmarker(c);
67
c->parent = d = create_compound();
68
*d = objects; /* Preserve the parent, it points to c */
70
objects.GABPtr = c; /* Where original compound came from */
71
if (!close_popup_isup)
72
popup_close_compound();
79
/* prepatory functions done for mode operations by sel_mode_but */
80
update_markers((int)M_COMPOUND);
82
set_mousefun("open compound", "", "", LOC_OBJ, LOC_OBJ, LOC_OBJ);
83
canvas_kbd_proc = null_proc;
84
canvas_locmove_proc = null_proc;
85
init_searchproc_left(init_open_compound);
86
canvas_leftbut_proc = object_search_left;
87
canvas_middlebut_proc = null_proc;
88
canvas_rightbut_proc = null_proc;
89
set_cursor(pick15_cursor);
96
F_compound *d; /* Destination */
98
/* if trying to close compound while drawing an object, don't allow it */
99
if (check_action_on())
101
if (c = (F_compound *)objects.parent) {
102
objects.parent = NULL;
103
d = (F_compound *)objects.GABPtr; /* Where this compound was */
104
objects.GABPtr = NULL;
105
/* compute new bounding box if changed */
106
compound_bound(&objects, &objects.nwcorner.x, &objects.nwcorner.y,
107
&objects.secorner.x, &objects.secorner.y);
108
*d = objects; /* Put in any changes */
109
objects = *c; /* Restore compound above */
110
/* user may have deleted all objects inside the compound */
111
if (object_count(d)==0) {
112
list_delete_compound(&objects.compounds, d);
115
/* popdown close panel if this is the last one */
116
if ((F_compound *)objects.parent == NULL) {
117
XtPopdown(close_compound_popup);
118
XtDestroyWidget(close_compound_popup);
119
close_popup_isup = False;
122
/* re-select open compound mode */
123
change_mode(&open_comp_ic);
128
close_all_compounds()
131
F_compound *d; /* Destination */
133
/* if trying to close compound while drawing an object, don't allow it */
134
if (check_action_on())
136
if (objects.parent) {
137
while (c = (F_compound *)objects.parent) {
138
objects.parent = NULL;
139
d = (F_compound *)objects.GABPtr; /* Where this compound was */
140
objects.GABPtr = NULL;
141
/* compute new bounding box if changed */
142
compound_bound(&objects, &objects.nwcorner.x, &objects.nwcorner.y,
143
&objects.secorner.x, &objects.secorner.y);
144
*d = objects; /* Put in any changes */
146
/* user may have deleted all objects inside the compound */
147
if (object_count(d)==0) {
148
list_delete_compound(&objects.compounds, d);
152
/* popdown close panel */
153
XtPopdown(close_compound_popup);
154
XtDestroyWidget(close_compound_popup);
155
close_popup_isup = False;
157
/* re-select open compound mode */
158
change_mode(&open_comp_ic);
162
popup_close_compound()
164
Widget close_compound_form;
165
Widget close_compoundw, close_compound_allw;
166
Position xposn, yposn;
168
XtWidgetGeometry xtgeom,comp;
169
int llx, lly, urx, ury, dum;
173
/* position the popup above the compound we're opening */
174
compound_bound(&objects, &llx, &lly, &urx, &ury);
176
/* translate object coords to screen coords relative to the canvas */
180
/* translate those to absolute screen coords */
181
XtTranslateCoords(canvas_sw, llx, lly, &xposn, &yposn);
183
FirstArg(XtNallowShellResize, True);
184
NextArg(XtNx, xposn-40);
185
NextArg(XtNy, yposn-65);
186
NextArg(XtNtitle, "Xfig: Close Compound");
187
NextArg(XtNcolormap, tool_cm);
188
close_compound_popup = XtCreatePopupShell("close_compound_popup", transientShellWidgetClass,
189
tool, Args, ArgCount);
190
close_compound_form = XtCreateManagedWidget("close_compound_form", formWidgetClass,
191
close_compound_popup, (XtPointer) NULL, 0);
193
FirstArg(XtNlabel, "Close This Compound")
194
close_compoundw = XtCreateManagedWidget("close_compound", commandWidgetClass,
195
close_compound_form, Args, ArgCount);
196
XtAddEventHandler(close_compoundw, ButtonReleaseMask, (Boolean) 0,
197
(XtEventHandler)close_compound, (XtPointer) NULL);
199
FirstArg(XtNlabel, "Close All Compounds");
200
NextArg(XtNfromHoriz, close_compoundw);
201
close_compound_allw = XtCreateManagedWidget("close_all_compounds", commandWidgetClass,
202
close_compound_form, Args, ArgCount);
203
XtAddEventHandler(close_compound_allw, ButtonReleaseMask, (Boolean) 0,
204
(XtEventHandler)close_all_compounds, (XtPointer) NULL);
207
XtPopup(close_compound_popup, XtGrabNone);
209
/* insure that the most recent colormap is installed */
210
set_cmap(XtWindow(close_compound_popup));
211
(void) XSetWMProtocols(tool_d, XtWindow(close_compound_popup),
212
&wm_delete_window, 1);
213
XDefineCursor(tool_d, XtWindow(close_compound_popup), arrow_cursor);
214
close_popup_isup = True;