/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 27319 - (show annotations)
Fri Aug 31 15:55:19 2001 UTC (18 years, 4 months ago) by etienne
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/case_tool/bon/cluster_figure.e
File size: 10891 byte(s)
Fix problem with cluster resizing (when moving its content in particular).

1 indexing
2 description:
3 "Graphical representations of clusters without%N%
4 %commitment to any notation."
5 date: "$Date$"
6 revision: "$Revision$"
7
8 deferred class
9 CLUSTER_FIGURE
10
11 inherit
12 LINKABLE_FIGURE
13 undefine
14 position_on_figure
15 redefine
16 set_origin,
17 world,
18 cluster_figure
19 end
20
21 LINKABLE_FIGURE_GROUP
22 rename
23 cluster_figures as subclusters,
24 class_figures as classes
25 undefine
26 default_create,
27 is_equal
28 end
29
30 feature {NONE} -- Initialization
31
32 make_with_cluster (lace_cluster: CLUSTER_I) is
33 -- Initialize `Current' with lace_cluster.
34 require
35 lace_cluster_not_void: lace_cluster /= Void
36 do
37 default_create
38 create layout
39 create subclusters.make
40 create classes.make
41 create saved_subclusters.make
42 create saved_classes.make
43 cluster_i := lace_cluster
44 set_name (cluster_i.name_in_upper)
45 initialize
46 create {CLUSTER_FIGURE_STONE} pebble.make (Current)
47 set_accept_cursor (Cursors.cur_Cluster)
48 build_figure
49 end
50
51 initialize is
52 deferred
53 end
54
55 feature -- Access
56
57 parent: LINKABLE_FIGURE_GROUP
58 -- Figure group containing `Current'.
59
60 world: CLUSTER_DIAGRAM is
61 -- World `Current' belongs to.
62 do
63 Result ?= Precursor
64 end
65
66 cluster_i: CLUSTER_I
67 -- Cluster this figure is a representation of.
68
69 resizer_bottom_right: EV_MOVE_HANDLE is
70 -- Mover of `Current'.
71 deferred
72 end
73
74 resizer_top_left: EV_MOVE_HANDLE is
75 -- Mover of `Current'.
76 deferred
77 end
78
79 resizer_top_right: EV_MOVE_HANDLE is
80 -- Mover of `Current'.
81 deferred
82 end
83
84 resizer_bottom_left: EV_MOVE_HANDLE is
85 -- Mover of `Current'.
86 deferred
87 end
88
89 name_mover: EV_MOVE_HANDLE is
90 -- Mover of `Current' name.
91 deferred
92 end
93
94 center_point: EV_RELATIVE_POINT is
95 -- Point at the center of `body', origin of `name_mover'.
96 deferred
97 end
98
99 cluster_figure: CLUSTER_FIGURE is
100 -- Cluster figure `Current' is in directly.
101 -- Void if none or more than one.
102 do
103 Result ?= parent
104 end
105
106 feature -- Element change
107
108 add_class (a_class: CLASS_FIGURE) is
109 -- Add `a_class' to `classes'.
110 require
111 a_class_not_void: a_class /= Void
112 do
113 classes.extend (a_class)
114 a_class.set_cluster (Current)
115 a_class.set_origin (point)
116 ensure
117 a_class_added: classes.has (a_class)
118 end
119
120 remove_class (a_class: CLASS_FIGURE) is
121 -- Remove `a_class' from `classes'.
122 require
123 a_class_not_void: a_class /= Void
124 do
125 classes.prune_all (a_class)
126 ensure
127 a_class_removed: not classes.has (a_class)
128 end
129
130 add_all_classes is
131 -- Add class figures representing all items
132 -- in `cluster_i'.
133 do
134 world.include_classes_of_cluster (Current, True)
135 end
136
137 add_subcluster (a_cluster: CLUSTER_FIGURE) is
138 -- Add `a_cluster' to `subclusters'.
139 require
140 a_cluster_not_void: a_cluster /= Void
141 do
142 if not subclusters.has (a_cluster) then
143 subclusters.extend (a_cluster)
144 a_cluster.set_parent (Current)
145 -- EA: a_cluster.point.set_origin (point)
146 a_cluster.point.change_origin (point)
147 end
148 ensure
149 a_cluster_added: subclusters.has (a_cluster)
150 end
151
152 remove_subcluster (a_cluster: CLUSTER_FIGURE) is
153 -- Remove `a_cluster' from `subclusters'.
154 require
155 a_cluster_not_void: a_cluster /= Void
156 do
157 subclusters.prune_all (a_cluster)
158 a_cluster.set_parent (Void)
159 ensure
160 a_cluster_removed: not subclusters.has (a_cluster)
161 end
162
163 set_parent (p: LINKABLE_FIGURE_GROUP) is
164 -- Assign `p' to `parent'.
165 -- `p' can be Void if `Current' is a top-level cluster in diagram.
166 do
167 parent := p
168 if p = Void and then world /= Void then
169 point.set_origin (world.point)
170 end
171 ensure
172 parent_assigned: parent = p
173 end
174
175 remove_from_diagram (exclude_needed: BOOLEAN) is
176 -- Remove `Current' from its diagram, exclude it if `exclude_needed'.
177 local
178 d: CLUSTER_DIAGRAM
179 saved_cursor: CURSOR
180 cf: CLASS_FIGURE
181 do
182 d := world
183 if d.center_cluster /= Current then
184 saved_subclusters.wipe_out
185 saved_classes.wipe_out
186
187 from
188 classes.start
189 until
190 classes.after
191 loop
192 cf := classes.item
193 classes.forth
194 saved_cursor := classes.cursor
195 saved_classes.extend (cf)
196 cf.remove_from_diagram (exclude_needed)
197 classes.go_to (saved_cursor)
198 end
199
200 if exclude_needed then
201 d.exclude_cluster (cluster_i)
202 else
203 d.remove_cluster (cluster_i)
204 end
205 end
206 end
207
208 recursive_remove_from_diagram (exclude_needed: BOOLEAN) is
209 -- Remove `Current' from its diagram, exclude it if `exclude_needed',
210 -- and remove subclusters as well.
211 local
212 d: CLUSTER_DIAGRAM
213 saved_cursor: CURSOR
214 cf: CLASS_FIGURE
215 clf: CLUSTER_FIGURE
216 do
217 d := world
218 if d.center_cluster /= Current then
219 saved_subclusters.wipe_out
220 saved_classes.wipe_out
221
222 from
223 subclusters.start
224 until
225 subclusters.after
226 loop
227 clf := subclusters.item
228 subclusters.forth
229 saved_cursor := subclusters.cursor
230 saved_subclusters.extend (clf)
231 clf.recursive_remove_from_diagram (exclude_needed)
232 subclusters.go_to (saved_cursor)
233 end
234
235 from
236 classes.start
237 until
238 classes.after
239 loop
240 cf := classes.item
241 classes.forth
242 saved_cursor := classes.cursor
243 saved_classes.extend (cf)
244 cf.remove_from_diagram (exclude_needed)
245 classes.go_to (saved_cursor)
246 end
247
248 if exclude_needed then
249 d.exclude_cluster (cluster_i)
250 else
251 d.remove_cluster (cluster_i)
252 end
253 end
254 end
255
256 put_back_on_diagram (d: CONTEXT_DIAGRAM) is
257 -- Put `Current' back on `d'.
258 local
259 cd: CLUSTER_DIAGRAM
260 do
261 cd ?= d
262 if cd /= Void then
263 cd.add_cluster_figure (Current, False)
264
265 from
266 saved_subclusters.start
267 until
268 saved_subclusters.after
269 loop
270 saved_subclusters.item.put_back_on_diagram (d)
271 saved_subclusters.forth
272 end
273
274 from
275 saved_classes.start
276 until
277 saved_classes.after
278 loop
279 saved_classes.item.put_back_on_diagram (d)
280 saved_classes.forth
281 end
282 end
283 end
284
285 change_origin (new_origin: EV_RELATIVE_POINT) is
286 -- Set the point this figure is relative to.
287 -- Do not change absolute coordinates.
288 do
289 point.change_origin (new_origin)
290 end
291
292 feature -- Status report
293
294 iconified: BOOLEAN
295 -- Is `Current' iconified?
296
297 is_subcluster_of (other: CLUSTER_FIGURE): BOOLEAN is
298 -- Is Current a subcluster of `other' (directly or not)?
299 require
300 other_not_void: other /= Void
301 local
302 tmp: CLUSTER_FIGURE
303 do
304 Result := other = Current
305 from
306 tmp := cluster_figure
307 until
308 Result = True or tmp = Void
309 loop
310 if other = tmp then
311 Result := True
312 end
313 tmp := tmp.cluster_figure
314 end
315 end
316
317 recursive_has_class (a_class: CLASS_FIGURE): BOOLEAN is
318 -- Does `a_class' belong to `Current' or to one of its subclusters?
319 require
320 a_class_not_void: a_class /= Void
321 do
322 Result := classes.has (a_class)
323 from
324 subclusters.start
325 until
326 Result or else subclusters.after
327 loop
328 Result := subclusters.item.recursive_has_class (a_class)
329 subclusters.forth
330 end
331 end
332
333 position_strictly_on_figure (x, y: INTEGER): BOOLEAN is
334 -- Is the point on (`x', `y') on this figure?
335 -- (excluding its subclusters).
336 deferred
337 end
338
339 feature -- Status setting
340
341 set_origin (a_point: EV_RELATIVE_POINT) is
342 -- Assign `a_point' to the origin of all
343 -- figures related to `Current'.
344 do
345 point.change_origin (a_point)
346 end
347
348 update is
349 -- `Current' has just been moved/resized.
350 do
351 from
352 subclusters.start
353 until
354 subclusters.after
355 loop
356 subclusters.item.update
357 subclusters.item.move_to_front
358 subclusters.forth
359 end
360 from
361 classes.start
362 until
363 classes.after
364 loop
365 classes.item.update
366 classes.forth
367 end
368 end
369
370 set_size (a_width, a_height: INTEGER) is
371 -- Resize `Current' to `a_width', `a_height'.
372 require
373 a_width_non_negative: a_width >= 0
374 a_height_non_negative: a_height >= 0
375 deferred
376 end
377
378 set_minimum_bounds (a_left, a_top, a_right, a_bottom: INTEGER) is
379 -- Assign minimum bounds.
380 deferred
381 end
382
383 update_minimum_size is
384 -- Figures have been added/removed in `Current',
385 -- minimum size should change.
386 deferred
387 end
388
389 set_bounds (a_left, a_top, a_right, a_bottom: INTEGER) is
390 -- Assign bounds.
391 deferred
392 end
393
394 set_relative_position_and_size (a_x, a_y, a_width, a_height: INTEGER) is
395 -- Assign bounds.
396 deferred
397 end
398
399 iconify is
400 -- Iconify `Current'.
401 deferred
402 ensure
403 is_iconified: iconified
404 end
405
406 deiconify is
407 -- Deiconify `Current'.
408 deferred
409 ensure
410 is_not_iconified: not iconified
411 end
412
413 mask is
414 -- `Current' no longer needs to be displayed.
415 deferred
416 end
417
418 unmask is
419 -- `Current' needs to be displayed again.
420 deferred
421 end
422
423 feature {CLUSTER_FIGURE} -- Events
424
425 move_to_front is
426 -- Make `Current' appear in front of its peers.
427 deferred
428 end
429
430 feature {NONE} -- Implementation
431
432 external_client_links: LINKED_LIST [CLIENT_SUPPLIER_FIGURE] is
433 -- Client figures which `supplier' is a figure inside `Current',
434 -- and `client' is a figure outside `Current'.
435 local
436 class_client_links: LINKED_LIST [CLIENT_SUPPLIER_FIGURE]
437 do
438 from
439 classes.start
440 until
441 classes.after
442 loop
443 class_client_links := classes.item.client_figures
444 from
445 class_client_links.start
446 until
447 class_client_links.after
448 loop
449 if class_client_links.item.client.cluster_figure /= Current then
450 Result.extend (class_client_links.item)
451 end
452 class_client_links.forth
453 end
454 classes.forth
455 end
456 --| FIXME: take subclusters into account as well.
457 end
458
459 external_supplier_links: LINKED_LIST [CLIENT_SUPPLIER_FIGURE] is
460 -- Client figures which `client' is a figure inside `Current',
461 -- and `supplier' is a figure outside `Current'.
462 local
463 class_supplier_links: LINKED_LIST [CLIENT_SUPPLIER_FIGURE]
464 do
465 from
466 classes.start
467 until
468 classes.after
469 loop
470 class_supplier_links := classes.item.supplier_figures
471 from
472 class_supplier_links.start
473 until
474 class_supplier_links.after
475 loop
476 if class_supplier_links.item.supplier.cluster_figure /= Current then
477 Result.extend (class_supplier_links.item)
478 end
479 class_supplier_links.forth
480 end
481 classes.forth
482 end
483 --| FIXME: take subclusters into account as well.
484 end
485
486 saved_subclusters: LINKED_LIST [CLUSTER_FIGURE]
487 -- Subclusters backup to undo delete command.
488
489 saved_classes: LINKED_LIST [CLASS_FIGURE]
490 -- Classes backup to undo delete command.
491
492 on_pebble_request: ANY is
493 -- New CLUSTER_STONE with `Current' as source.
494 do
495 create {CLUSTER_FIGURE_STONE} Result.make (Current)
496 end
497
498 old_width: INTEGER is
499 -- Backup of `width' for iconifying.
500 deferred
501 end
502
503 old_height: INTEGER is
504 -- Backup of `height' for iconifying.
505 deferred
506 end
507
508 minimum_width: INTEGER is
509 --
510 deferred
511 end
512
513 end -- class CLUSTER_FIGURE
514
515
516
517

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23