File: menu.pl

package info (click to toggle)
swi-prolog 9.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 82,408 kB
  • sloc: ansic: 387,503; perl: 359,326; cpp: 6,613; lisp: 6,247; java: 5,540; sh: 3,147; javascript: 2,668; python: 1,900; ruby: 1,594; yacc: 845; makefile: 428; xml: 317; sed: 12; sql: 6
file content (591 lines) | stat: -rw-r--r-- 21,273 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
/*  Part of XPCE --- The SWI-Prolog GUI toolkit

    Author:        Jan Wielemaker and Anjo Anjewierden
    E-mail:        jan@swi.psy.uva.nl
    WWW:           http://www.swi.psy.uva.nl/projects/xpce/
    Copyright (c)  1985-2002, University of Amsterdam
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:

    1. Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.

    2. Redistributions in binary form must reproduce the above copyright
       notice, this list of conditions and the following disclaimer in
       the documentation and/or other materials provided with the
       distribution.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    POSSIBILITY OF SUCH DAMAGE.
*/

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This module defines the  mode-selection  menu at  the left-side of the
canvas.  It consists of two classes: draw_menu, which is a subclass of
picture  and which  is responsible for  communication, load/save, etc.
and draw_icon, which defines the combination of a mode, a cursor and a
prototype.

There are two reasonable primitives  for implementing this menu.   The
first   is to use a  dialog  window and  a choice  menu, of which  the
menu_items have image labels.  The  second  is  the approach taken  in
this file, to use a picture with a 1-column  format attached to it and
images for the options.  Which of them is to be preferred is difficult
to   tell.    Both  approaches   require   about  the  same  amount of
programming.   I've  chosen  for  the  latter   approach,  partly  for
`historical'  reasons and partly to  illustrate how non-standard menus
can be created using ordinary graphicals.

As the  user can modify  the   menu by adding/deleting prototypes  and
changing prototype attributes, the contents of  this menu can be saved
to file.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

:- module(draw_menu, []).

:- use_module(library(pce)).
:- require([ default/3
           , memberchk/2
           ]).


                /********************************
                *          ICON MENU            *
                ********************************/

:- pce_begin_class(draw_menu, dialog).

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Variables to keep track of load/save.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

variable(file,          file*,  both,
         "File for storing prototypes").
variable(modified,      bool,   get,
         "Menu has been modified").

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The menu of with the modes and  prototypes   is  a  dialog window with a
displayed menu. This is one  of   the  many possibilities. When updating
this documentation, it would have been a   more  natural choice to use a
dialog window with an attached format and buttons using an `image' label
for the modes.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

initialise(M) :->
    send(M, send_super, initialise, 'Icons'),
    send(M, gap, size(0,0)),
    send(M, ver_shrink, 100),
    send(M, ver_stretch, 100),
    send(M, display,
         new(P, menu(proto, choice, message(@arg1, activate)))),
    send(P, layout, vertical),
    send(P, show_label, @off),
    send(M, resize_message, message(M, new_size, @arg2)),
    send(M, modified, @off).


new_size(M, Size:size) :->
    get(M, member, proto, Menu),
    get(Size, width, W),
    Cols is max(1, W // 48),
    send(Menu, columns, Cols).


modified(M, Value:[bool]) :->
    default(Value, @on, Val),
    send(M, slot, modified, Val).


/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Attach   a new prototype.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

proto(M, Proto:proto='graphical|link*', Mode:'mode=name',
      Cursor:cursor=cursor, Icon:icon=[image], Tag:tag=[name],
      UserProto:user_proto=[bool]) :->
    "Attach a new prototype"::
    default(UserProto, @off, UProto),
    get(M, member, proto, Menu),
    send(Menu, append, new(I, draw_icon(Proto, Mode, Cursor, Icon))),
    (   Tag \== @default,
        send(I, has_send_method, help_message) % help message package
    ->  send(I, help_message, tag, Tag)        % loaded
    ;   true
    ),
    send(I, user_proto, UProto),
    send(M, adjust),
    send(M, modified, @on).


adjust(M) :->
    "Make it wide enough to display all items"::
    (   get(M, displayed, @on)
    ->  get(M?visible, height, H),
        get(M, member, proto, Menu),
        get(Menu?members, size, S),
        get(Menu, border, B),
        Rows is max(1, H//(32+2*B)),
        Cols is (S+Rows-1)//Rows,
        (   get(Menu, columns, Cols)
        ->  true
        ;   send(Menu, columns, Cols),
            send(M, ideal_width, Menu?width),
            send(M?frame, resize)
        )
    ;   true
    ).


current(M, Icon:draw_icon) :<-
    "Find current icon"::
    get(M, member, proto, Menu),
    get(Menu, selection, Icon).


find_icon(M, Cond:code, Icon:draw_icon) :<-
    "Find icon from condition"::
    get(M, member, proto, Menu),
    get(Menu?members, map, @arg1?value, Icons),
    get(Icons, find, Cond, Icon).


activate_select(M) :->
    "Activate icon that does select"::
    get(M, member, proto, Menu),
    get(Menu?members, find, @arg1?(mode) == select, Item),
    send(Item, activate).

                 /*******************************
                 *           STYLE              *
                 *******************************/

columns(M, Cols:'0..') :->
    "Set # columns in menu"::
    get(M, member, proto, TheMenu),
    send(TheMenu, columns, Cols).


                /********************************
                *            CREATE             *
                ********************************/

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Create a prototype from a  chain of graphicals (usually the selection;
in the future this might  also come from  a prototype editor).  If the
chain has one element, no compound is needed.

NOTE:   Due to the improper functioning of <-clone with regards to
        connections to the outside world, all connections should be
        internal to the chain of graphicals.  We won't try to program
        around this problem here, but improve PCE's kloning schema
        later.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

create_proto(M, Graphicals:chain, How:{as_is,virgin}) :->
    "Create a prototype from a chain of graphicals"::
    get(Graphicals, size, Size),
    (   Size == 0
    ->  send(M, report, error, 'No selection')
    ;   Size == 1
    ->  get(Graphicals, head, Sel1),
        clone_proto(How, Sel1, Proto),
        send(Proto, selected, @off)
    ;   new(Proto, draw_compound),
        get(Graphicals, clone, Members),
        send(Members, for_all,
             and(message(Proto, display, @arg1),
                 message(@arg1, selected, @off))),
        send(Proto, reference, @default),
        send(Proto, string, '')
    ),
    mode_and_cursor_from_proto(How, Proto, Mode, Cursor),
    send(M, proto, Proto, Mode, Cursor, user_proto := @on).

clone_proto(_, Connection, Clone) :-
    send(Connection, instance_of, connection),
    !,
    get(Connection, link, Link),
    get(Link, clone, Clone),
    send(Clone, copy, Connection).
clone_proto(virgin, Path, Clone) :-
    send(Path, instance_of, path),
    get(Path, clone, Clone),
    send(Clone, clear).
clone_proto(_, Graphical, Clone) :-
    get(Graphical, clone, Clone).


mode_and_cursor(text,           draw_text,    xterm).
mode_and_cursor(box,            draw_resize,  crosshair).
mode_and_cursor(ellipse,        draw_resize,  crosshair).
mode_and_cursor(line,           draw_line,    crosshair).
mode_and_cursor(path,           draw_path,    cross).
mode_and_cursor(link,           draw_connect, plus).

mode_and_cursor_from_proto(as_is, _Proto, draw_proto, dotbox) :- !.
mode_and_cursor_from_proto(virgin, Proto, Mode, Cursor) :-
    mode_and_cursor(Class, Mode, Cursor),
    send(Proto, instance_of, Class).

                /********************************
                *            DELETE             *
                ********************************/

can_delete(M) :->
    "Test if current prototype may be deleted"::
    get(M, current, Icon),
    send(Icon, can_delete).


delete(M, Icon0:[draw_icon]) :->
    "Delete current prototype"::
    (   Icon0 == @default
    ->  get(M, current, Icon),
        (   send(Icon, can_delete)
        ->  send(M, activate_select)
        ;   send(@display, inform, 'Can''t delete this prototype'),
            fail
        )
    ;   Icon = Icon0
    ),
    send(Icon, free),
    send(M, modified, @on).

clear(M) :->
    "Remove all prototypes"::
    get(M, member, proto, TheMenu),
    send(TheMenu, clear).


                /********************************
                *           SAVE/LOAD           *
                ********************************/

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Saving/loading is very similar to the corresponding code in canvas.pl.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

save_as(M) :->
    "Save in user-requested file"::
    get(@finder, file, @off, '.proto', File),
    send(M, save, File).


save(M, File:[file]) :->
    "Save prototypes to named file"::
    (   File == @default
    ->  get(M, file, SaveFile),
        SaveFile \== @nil
    ;   send(M, file, File),
        SaveFile = File
    ),
    get(M, proto_sheet, Sheet),
    send(Sheet, save_in_file, SaveFile),
    send(M, report, status,
         'Prototypes saved in %s', SaveFile?absolute_path),
    send(M, modified, @off).

proto_sheet(M, Sheet:sheet) :<-
    "Fetch description of user prototypes in a sheet"::
    new(Sheet, sheet(attribute(pcedraw_prototype_version, 1),
                     attribute(protos, new(Protos, chain)))),
    get(M, member, proto, Menu),
    send(Menu?members, for_all,
         message(M, append_proto_sheet, Protos, @arg1)).


append_proto_sheet(_M, Protos:chain, Icon:draw_icon) :->
    "Append a single proto to Protos"::
    (   get(Icon, user_proto, @on)
    ->  get(Icon, mode_cursor, CursorName),
        get(Icon, mode, Mode),
        get(Icon, slot, proto, Proto), % also @nil !
        send(Protos, append,
             sheet(attribute(cursor, CursorName),
                   attribute(mode, Mode),
                   attribute(proto, Proto)))
    ;   true
    ).


proto_sheet(M, Sheet:sheet, Clear:[bool]) :->
    "Load prototype definitions from sheet"::
    get(M, member, proto, Menu),
    (   Clear == @on
    ->  send(Menu, clear),
        send(M?frame, fill_menu)
    ;   true
    ),
    get(Sheet, protos, Chain),
    send(Chain, for_all,
         message(M, proto,
                 @arg1?proto, @arg1?mode, @arg1?cursor,
                 user_proto := @on)).


load_from(M) :->
    "Load from user-requested file"::
    get(@finder, file, @on, '.proto', File),
    send(M, load, File).


load(M, File:[file]) :->
    "Load prototypes from named file"::
    (   File == @default
    ->  get(M, file, LoadFile),
        LoadFile \== @nil
    ;   send(M, file, File),
        LoadFile = File
    ),
    get(LoadFile, object, ProtoSheet),
    (   send(ProtoSheet, instance_of, sheet),
        get(ProtoSheet, pcedraw_prototype_version, 1)
    ->  send(M, proto_sheet, ProtoSheet, @on),
        send(M, activate_select),
        send(M, adjust),
        send(M, modified, @off)
    ;   send(M, report, error,
             'File contains old or no PceDraw prototypes')
    ).

:- pce_end_class.


                /********************************
                *             ICONS             *
                ********************************/

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
We have chosen  to specialise class   `bitmap' to represent the  icon.
Each icon represents a prototype, a mode and a cursor that is  used by
the canvas to indicate the mode.  The visual representation of an icon
is  an outline that indicates  the mode  and  a  small  version of the
prototype to indicate what is drawn.

There are two   reasonable choices  for this job.   One is   to use  a
subclass of device and display the outline  and a resized clone of the
prototype.  The other is to use class bitmap and  draw  a clone of the
prototype in it.  It is difficult to say which of the two is better. I
finally decided that just a bitmap is cheaper to save (considering the
fact  that  the device  case holds a  bitmap  of the  same  size too).
Another criterium is how difficult it is to  change an argument of the
prototype.  For a device this is slightly simpler  as we just pass the
message to change the argument to the prototype  and the clone  of the
prototype displayed in the icon.  Using a bitmap, we have to recompute
the contents of the bitmap.  This however is not very hard.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

:- pce_begin_class(draw_icon, menu_item).

variable(proto,         'graphical|link*', none,
         "Prototype represented").
variable(mode,          name,           both,
         "Mode initiated by the icon").
variable(mode_cursor,   name,           both,
         "Associated cursor-name").
variable(user_proto,    bool := @off,   both,
         "Prototype was created by the user").

item_size(48,32).

initialise(I, Proto:'graphical|link*', Mode:name,
           Cursor:cursor, Image:[image]) :->
    "Create an icon for a specific mode"::
    send(I, send_super, initialise, @nil),
    send(I, slot, value, I),        % hack, needs to be fixed!
    send(I, mode, Mode),
    send(I, proto, Proto, Image),
    send(I, slot, mode_cursor, Cursor?name).

proto(I, Proto:'graphical|link') :<-
    get(I, slot, proto, Proto),
    Proto \== @nil.


can_delete(I) :->
    "Can I delete this icon?"::
    get(I, user_proto, @on).


                /********************************
                *           PROTOTYPES          *
                ********************************/

proto(I, Proto:'graphical|link*', Image:[image]) :->
    "Set the prototype"::
    send(I, slot, proto, Proto),
    (   Image == @default
    ->  send(I, paint_proto)
    ;   send(I, label, Image)
    ).


/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Create the image of  the  icon.  First,   we  will  paint  the  outline,
indicating the mode. Next, we make a   copy of the prototype (because we
have to modify it and we  should   not  change  the original prototype),
modify the text to `T' and the size to fit in the icon. Finally, we draw
the prototype in the icon  and  send   `Object  ->done'  to the clone to
inform PCE we have done with it.

The general case uses an  intermediate  device   to  ensure  that if the
prototype creates additional graphicals, these are displayed correctly.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

paint_proto(MI) :->
    "Paint a small version of the prototype"::
    get(MI, slot, proto, Proto),
    item_size(IW, IH),
    send(MI, label, new(I, image(@nil, IW, IH))),
    send(MI, paint_outline),
    (   Proto == @nil
    ->  true
    ;   send(Proto, instance_of, link)
    ->  new(Dev, device),                   % links (connection)
        send(Dev, display, new(B1, box(0,0)), point(11, 10)),
        send(Dev, display, new(B2, box(0,0)), point(27, 20)),
        send(B1, handle, handle(0, 0, Proto?from)),
        send(B2, handle, handle(0, 0, Proto?to)),
        (   get(Proto, attribute, draw_connection_class, Class)
        ->  true
        ;   Class = draw_connection
        ),
        Term =.. [Class, B1, B2, Proto],
        new(Connection, Term),
        (   send(Connection, has_send_method, menu_text)
        ->  send(Connection, menu_text)
        ;   true
        ),
        send(I, draw_in, Dev),
        send(Dev, destroy)
    ;   send(Proto, instance_of, path),     % Path case
        send(Proto?points, empty)
    ->  get(Proto, clone, Clone),
        send(Clone, clear),
        send(Clone, append, point(10,10)),
        send(Clone, append, point(20,7)),
        send(Clone, append, point(30,15)),
        send(Clone, append, point(15,21)),
        send(I, draw_in, Clone)
    ;   send(Proto, instance_of, bezier_curve)      % Bezier curves
    ->  get(Proto, clone, Clone),
        send(Clone, start, point(5,23)),
        send(Clone, end, point(35,23)),
        send(Clone, control1, point(15,0)),
        send(Clone, control2, point(48,0)),
        send(I, draw_in, Clone)
    ;   new(D, device),             % general case
        get(Proto, clone, Clone),
        (   send(Clone, has_send_method, menu_text)
        ->  send(Clone, menu_text)
        ;   true
        ),
        (   get(MI, mode, draw_proto)
        ->  get(Clone, size, size(PW, PH)),
            (   (PW/30) > (PH/20)
            ->  DW = 30, DH is integer(30 * PH/PW)
            ;   DH = 20, DW is integer(20 * PW/PH)
            )
        ;   DW = 30,
            DH = 14
        ),
        send(Clone, size, size(DW, DH)),
        send(D, display, Clone),
        send(D, center, point(22, 14)),
        send(I, draw_in, D)
    ),
    send(MI, label, I).


/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Paint the outline in the bitmap.  For each of the outlines, there is a
bitmap file named `Mode.bm' in PCE's bitmap search-path.  We copy this
image in the bitmap.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

paint_outline(MI) :->
    "Paint the mode indicating bitmap"::
    get(MI, label, I),
    get(MI, mode, Mode),
    outline_image(Mode, ImageFile),
    send(I, copy, image(resource(ImageFile))).

outline_image(select,        'select.bm').
outline_image(draw_text,     'draw_text.bm').
outline_image(draw_resize,   'draw_resize.bm').
outline_image(draw_line,     'draw_line.bm').
outline_image(draw_bezier,   'draw_line.bm').
outline_image(draw_path,     'draw_path.bm').
outline_image(draw_connect,  'draw_connect.bm').
outline_image(draw_cconnect, 'draw_cconnect.bm').
outline_image(draw_proto,    'draw_proto.bm').

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Hook to find the resource.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

resource(Name, image, image(Name)) :-
    outline_image(_, Name).


                /********************************
                *           ATTRIBUTES          *
                ********************************/

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
These two methods from the  interface to  the attribute editor.    See
also the files `attribute.pl' and `shape.pl'.  Note that prototypes do
not have a position and  therefore  the `x'  and  `y'  should  not  be
regarded arguments.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

has_attribute(I, Att:name) :->
    "Test if prototype has named attribute"::
    \+ memberchk(Att, [x, y]),
    send(I?proto, has_attribute, Att).


draw_attribute(I, Att:name, Val:any) :->
    "Set attribute of prototype"::
    send(I?proto, draw_attribute, Att, Val),
    send(I, repaint_proto),
    send(I?window, modified, @on).


                /********************************
                *          ACTIVATION           *
                ********************************/

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Activate an icon.   First it sets `Graphical   ->inverted' to @on  for
only this icon in  the menu.  Note  the  use of `Device ->for_all' and
`if'.   This is the  most efficient way to  reach our  goals,  both in
terms  of the  amount of   code we  have  to  write   as in  terms  of
performance.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

activate(I) :->
    "Select the icon; set mode and proto"::
    get(I, menu, Menu),
    send(Menu, selection, I),
    send(Menu?frame, mode, I?mode, I?mode_cursor),
    (   get(I, proto, Proto)
    ->  send(Menu?frame, proto, Proto)
    ;   send(Menu?frame, proto, @nil)
    ).

:- pce_end_class.