This section describes Some of the predicates available from the XPCE/Prolog library.
The predicates in this section used to be XPCE principal predicates. Changes to XPCE, the interface and our current understanding about programming the XPCE/Prolog environment have made these predicates less important.
send_list([], _) :- !.
send_list(_, []) :- !.
send_list([Object|Objects], Selectors) :- !,
send_list(Object, Selectors),
send_list(Objects, Selectors).
send_list(Object, [Selector|Selectors]) :- !,
send_list(Object, Selector),
send_list(Object, Selectors).
send_list(Object, Selector) :-
send(Object, Selector).
|
Note that, since send/2
accepts Selector(Arg...) the following is now valid code:
...,
send_list(Box,
[ colour(red),
fill_pattern(colour(greed))
]),
|
topmost_graphical(Pict, Pos, Gr) :-
get(Pict, graphicals, Grs0),
chain_list(Grs0, Grs1),
topmost(Grs1, Pos, @nil, Gr),
Gr \== @nil.
topmost([], _, Gr, Gr).
topmost([H|T], Pos, _, Gr) :-
send(H, overlap, Pos), !,
topmost(T, Pos, H, Gr).
topmost([_|T], Pos, Gr0, Gr) :-
topmost(T, Pos, Gr0, Gr).
|
Or, using XPCE's list processing:
topmost_graphical(Dev, Pos, Gr) :-
get(Dev, graphicals, Grs),
get(Grs, find_all,
message(@arg1, overlap, Pos), O),
get(O, tail, Gr),
send(O, done).
|
The second implementation is not only shorter, it also requires far less data conversions between Prolog and XPCE and is therefore much faster.
get_chain(Receiver, Selector, List) :-
get(Receiver, Selector, Chain),
chain_list(Chain, List).
|
See comments with chain_list/2.
The predicates in this section provide shorthands for common commands for debugging XPCE programs. See section 12 for more information on debugging XPCE/Prolog programs.
->), get- (<-) method or
variable (-) and cause invocations thereof to be printed on
the console.
Syntax note: (->) is a standard Prolog operator with
priority > 1000. Therefore many Prolog systems require
additional brackets:
1 ?- tracepce((graphical ->selected)). |
In SWI-Prolog this is not necessary. To be able to trace get-methods
with this predicate (<-) must be declared as an infix
operator.
->_check'
on them. This performs various consistency checks on the objects and
prints diagnostic messages if something is wrong. `object->_check'
checks all objects it can (recursively) find through slot-references,
chains, vectors and hash-tables and deals properly with loops in the
data-structure.
1 ?- new(@move_gesture, move_gesture).
2 ?- show_slots(@move_gesture).
@move_gesture/move_gesture
active @on/bool
button middle
modifier @810918/modifier
condition @nil/constant
status inactive
cursor @default/constant
offset @548249/point
|
A graphical tool for inspecting instance variables is described in section 12.5.
1 ?- manpce(box). 2 ?- manpce((view->caret)). |