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
|
:- use_module(library(pce)).
tt :-
new(D, dialog('projet')),
send(D, append, new(LB, list_browser)),
send(LB, size, size(35, 15)),
send(LB, alignment, left),
fill_browser(LB),
send(D, append, new(BTS, dialog_group(buttons, group))),
send(BTS, gap, size(10, 10)),
send(BTS, append, button(ouvrir, message(@prolog, open_trait, LB)),below),
send(BTS, append, button(quitter, message(D, destroy)),below),
send(BTS, layout_dialog),
send(D, layout),
send(LB, bottom_side, BTS?bottom_side),
send(D, open).
open_trait(Browser) :-
get(Browser, selection, DictItem),
( ( DictItem == @nil
; get(DictItem, style, title)
)
-> send(@display, inform, 'First select a demo')
; get(DictItem, key, Name),
( trait(Name, 'Summary', File, Predicate)
-> ( use_module(File)
-> ( Predicate
-> true
; send(@pce, inform, 'Failed to start %s demo', Name)
)
; send(@pce, inform, 'Can''t find demo sourcefile')
)
; send(Browser, report, error, 'No such file : %s', Name)
)
).
fill_browser(LB) :-
forall(trait(Name, Summary, File, Predicate),
send(LB, append, dict_item(Name,
string('%s %s', Name, Summary)))).
trait('chaine',
'traitement par chaine',
chaine,
chaine).
trait('arbre',
'traitement par arbre',
arbre,
arbre).
trait('ruban',
'traitement par rubans',
ruban,
ruban). |
Partager