This appendix provides a complete overview of all built-in classes of XPCE. For each class, it presents the name, arguments needed to create an instance, place in the inheritance and delegation hierarchies as well as a summary description. For many classes we added a small illustrative example of typical usage of the class.
The summaries stress on describing what the class is commonly used for and what other classes are designed to cooperate with the class.
The classes are presented in alphabetical order. Some classes that
are closely related and have symbol-names (>, +
) are
combined into one description, sometimes violating the alphabetical
order.
..., send(Editor, style, sensitive, style(underline := @on, colour := dark_green)), ..., |
?- new(UDC, chain), send(@classes, for_all, if(@arg2?creator \== built_in, message(UDC, append, @arg1))). |
..., send(Dialog, append, new(TI, text_item(name))), send(Dialog, append, button(ok, message(Dialog, return, TI?selection))), |
<pcehome>/Defaults
. The following example
from Defaults
creates the objects @_dialog_bg
and @_win_pen depending on whether
or not the display is monochrome or colour.
display.initialise: \ and(_dialog_bg @= when(@colour_display, \ grey80, white), \ _win_pen @= when(@colour_display, \ 0, 1)) |
..., get(Dialog, frame, Frame), send(Dialog, append, new(Function, text_item(function))), send(Dialog, append, button(switch_to, and(message(Frame, switch_to, Function?selection), message(Function, clear)))), ..., |
?- new(A, arc(100, 20, 50)), send(A, close, pie_slice). |
..., get(Box, area, area(X, Y, W, H)), ..., |
->
arrows'. arrow
can be used directory to create fancy arrows.
?- new(L, line(0, 0, 100, 50, second)) |
and(assign(new(C, var), @arg1?controller), message(C, ...), message(C, ...), ...) |
<->
attribute'.
send(Frame, attribute, visualises, bicycle24) |
<-
width <
5 or <-
height < 5.
..., get(Device?graphicals, find_all, or(@arg1?width < 5, @arg1?height < 5), SmallGraphicals), ..., |
... send(Box, height, Text?height + 10), ... |
?- new(I, image('pce.bm')), new(B, bitmap(I)). |
?- send(block(new(A, var), new(B, var), message(@pce, write_ln, A, B)), forward, hello, world). hello world |
..., send(Image, transparent, @on) ... |
?- new(B, box(100, 50)), send(B, radius, 10). |
?- new(B, browser), send_list(B, append, [gnu, gnat]). |
?- new(B, button(hello, message(@pce, write_ln, hello))). |
?- pce_predicate_reference(gnat:gnu(_,_), X). X = @1190997/c_pointer |
<-
graphicals'
returns a chain holding the graphicals displayed on the device. The
example changes the font of all objects of class text
to `bold'.
..., send(Device?graphicals, for_all, if(message(@arg1, instance_of, text), message(@arg1, font, bold))), ... |
library(hyper)
and section
10.11.
insert_bold_text(Editor, Text:char_array) :-> "Insert text with fragment of bold text":: get(Editor, caret, Start), send(Editor, insert, Text), get(Editor, caret, End), Len is End-Start, new(_, fragment(Editor, Start, Len, bold)). |
<-
width
and <-
height. Not used frequently.
?- get(@pce, convert, box, class, ClassBox), get(ClassBox, super_class, X). X = @graphical_class/class. |
A class_variable
provides can be used to describe class properties as well as to provide
access to the XPCE
Defaults
database. Typically, class-variables are defined
similar to instance-variables in the XPCE/Prolog
class definition:
:- pce_begin_class(title_text, text). class_variable(font, font, huge, "Default font for titles"). ... |
..., send(Bitmap, recogniser, click_gesture(left, double, message(Bitmap, open))), ... |
->
forward:
any ...' pushes the var objects @arg1,
... and then executes the code object. Code objects are often associated
with controllers to describe the action the controller should perform.
They also serve the role of lambda
functions. See also section 10.2.
?- send(message(@prolog, format, 'Hello ~w.', @arg1), forward, world). Hello world. |
<-
kind'.
In the latter case, the system will automatically choose the
`best-looking' handle.
?- new(@uninitialised, constant(uninitialised, 'Not yet initialised slot')). |
<-
relation'
is a description of the relation maintained by the constrained. The
system defines the relations identity
(both objects have an attribute that has same value) and spatial
(general purpose geometry-relation between two (graphical) objects. It
is possible to define new relation
classes. Constraints are getting out of fashion as XPCE
lacks a good mechanism to detect when an object has been changed and
therefore evaluates the relation far too often. User-defined classes,
possibly combined with hyper
objects form an attractive alternative. The following keeps a text
centered in a box.
..., new(_, constraint(Box, Text, identity(center))), ... |
->
for_all'
has to create objects. The following code generates dict_items
from all send_methods of
the specified class and displays them to a browser.
send_methods_of_class(ClassName) :- new(B, browser(ClassName)), get(@pce, convert, ClassName, class, Class), get(Class, send_methods, SendMethods), send(SendMethods, for_all, message(B, append, create(dict_item, @arg1?name, @default, @arg1))), send(B, open). |
Cursors can be associated with graphicals and windows using the ->
cursor
method. They are also associated to gestures,
where they define the cursor that is visible while the gesture is active
(i.e. while the mouse-button that activated the gesture is down).
Type-conversion converts names into cursor objects. Explicit creation of cursors is rarely used.
..., send(Box, cursor, gobbler), ... |
?- send(@pce, format, 'It is now "%s"\n', new(date)?string). It is now "Tue Jan 30 14:07:05 1996" |
make_icon(Icon, Image, Label) :- new(Icon, device), send(Icon, display, new(BM, bitmap(Image))), send(Icon, display, new(T, text(Label, center))), send(T, y, BM?bottom_side), send(T, center_x, BM?center_x). |
->
appending
a number of controllers to a dialog window. The frame-
and dialog-layout services take
care of proper window sizes and layout of the controllers. Dialog
windows are also involved in forwarding ->
report
messages (see section 10.7) and keyboard
accelerators, handling the default button.
:- pce_autoload(file_item, library(file_item)). edit_file_dialog :- new(D, dialog('Edit File')), send(D, append, file_item(edit_file, '')), send(D, append, button(edit, message(@prolog, emacs, @arg1))), send(D, append, button(cancel, message(D, destroy))), send(D, open). |
<->
object'
slot.
A name is translated to a
dict_item using the name as key, default label and @nil
object. `dict_item<->
style'
can be used to give an item special attributes (colour, font, etc.).
?- get(directory(.), files, Files). |
<-
size, showing modal message
boxes using ->
inform and ->
confirm,
etc.
?- get(@display. size, size(W, H)). W = 1024, H = 786 |
library(pce_editable_text)
.
An editor is a compound object and a subclass of device. The other components are a text_image to form the actual display, a text_buffer to provide the storage for the text, elementary operations on the text and undo, a text_cursor to indicate the location of the caret, and optionally a text_margin to visualise the presence of annotations.
A single text_buffer can be associated with multiple editor objects, providing shared editing.
Editors can handle sensitive regions, different fonts, colours and attributes using fragment objects. All text windows in XPCE's demo programs (PceEmacs, cards from the online help, application help, etc.) either use class view or class editor to display the text.
Most controllers handle elevations. The only general purpose graphical supporting an elevation is figure.
->
error:
id, context ...' to the object that trapped the error. If this method is
not redefined, the system will report the error using the `object->
report'
mechanism described in section 10.7. Errors
can be prevented from being reported using pce_catch_error/2.
The
Error Browser of the online manual shows all defined
errors.
The development system will report errors that are considered `programming errors' (undefined methods, type violations, invalid object references, etc.) to the terminal and start the tracer. See also section 12.
->
post'.
Graphical objects and windows can redefine their event handling using
two mechanisms: by redefining the ->
event method
or by associating a recogniser
object using `graphical->
recogniser'.
Normally, XPCE will read and dispatch events
when `there is nothing else to do'. For processing events during
computation, see `graphical
->
synchronise' and `display->
dispatch'.
->
is_a'.
event(Dev, Ev:event) :-> "Forward all keyboard events to the text":: ( send(Ev, is_a, keyboard) -> get(Dev, member, text, Text), send(Ev, post, Text) ; send(Dev, send_super, event, Ev) ). |
->
status'.
An example of the usage of figures are the `object cards' of the Inspector
tool.
?- get(file('summary.doc', size, Size). Size = 30762 |
..., send(Text, font, bold), ... |
->
format' actually realises the format.
->
style'.
..., send(Editor, style, title, style(font := huge)), new(_, fragment(Editor, Start, Len, title)), ... |
..., new(F, frame('My application')), send(F, append, new(B, browser)), send(new(P, picture), right, B), ... send(F, open). |
->
initiate,
->
drag and ->
terminate
methods that are redefined in its subclasses. This class is often
sub-classed.
->
get_method'
or with an individual object using `object
->
get_method'. Normally specified through the
preprocessor layer defined in chapter 7.
left
or
right
alignment, grbox
can also be used to have text floating around graphical illustrations.
See section 11.10.
:- pce_global(@north_handle, new(handle(w/2, 0, link, north))). :- pce_global(@south_handle, new(handle(w/2, h, link, south))). :- pce_global(@east_handle, new(handle(0, h/2, link, east))). :- pce_global(@west_handle, new(handle(w, h/2, link, west))). |
->
event'
method, it is now rarely used.
..., send(Graphical, recogniser, handler(area_enter, message(Graphical, report, 'Hi, I''m %s', Graphical?name))), ... |
:- pce_global(@move_resize_gesture, new(handler_group(new(resize_gesture), new(move_gesture)))). |
?- new(@ht, hash_table), send(@ht, append, gnu, image('gnu.img')). ?- get(@ht, member, gnu, Image). |
?- send(@prolog, write, hello). hello |
prolog
.
Details are discussed in the interface definition in section
6.2.
new(_, constraint(Slider, Box, identity(selection, width))) |
->
for_all':
..., send(Device?graphicals, for_all, if(message(@arg1, instance_of, device), ...)), ... |
<->
accelerator'
is generally more suitable for this purpose.
->
report
messages. See section 10.7. The code below is
the typical way to associate a label that will catch report messages for
all windows of the frame in which
the
dialog is enclosed.
..., send(Dialog, append, label(reporter)), ... |
A layout_manager may be attached to a graphical device (including a window) to manage the layout of graphicals displayed on the device, as well as painting the background of the device. See table for a typical example.
:- pce_global(@in_handle, new(handle(0, h/2, in, in))). :- pce_global(@out_handle, new(handle(w, h/2, out, out))). :- pce_global(@inout_link, new(link(out, in, line(arrows := second)))). :- pce_global(@link_in_out_gesture, new(connect_gesture(left, '', @inout_link))). make_shape(S) :- new(S, box(50,50)), send_list(S, handle, [@in_handle, @out_handle]), send(S, recogniser, @link_in_out_gesture). |
show_source_files :- new(D, dialog('Prolog Source Files')), send(D, append, new(B, list_browser)), forall(source_file(X), send(B, append, X)), send(B, open_message, message(@prolog, emacs, @arg1?key)), send(D, append, button(consult, message(@prolog, consult, B?selection?key))), send(D, open). |
->
multiple_selection') and defines a `look'. The `menu->
kind'
set the various attributes to often-used combinations. The other
`look-and-feel' attributes may be used to fine-tune the result
afterwards.
Menu-items can have a textual or image label. Labels can be coloured and specify a different font.
..., new(M, menu(gender, choice)), send_list(M, append, [male, female]), send(M, layout, horizontal), ..., |
:- pce_begin_class(my_application, frame). initialise(F) :-> send(F, send_super, initialise, 'My Application'), send(F, append, new(MBD, dialog)), new(V, view), send(new(B, browser, left, V)), send(B, below, MBD), send(MBD, append, new(MB, menu_bar)), send(MB, append, new(F, popup(file))), send(MB, append, new(E, popup(edit))), send_list(F, append, [ menu_item(load, message(F, load)), ... |
<-
value, <-
message @default
and a <-
label created by `capitalising' the
value.
->
execute or ->
forward, a
message is sent to the receiver. Message are the most popular code
objects. See section 10.2 and many
examples in this chapter.
s
, c
and m
into a modifier that
requires the shift, control and/or meta-key to be down an the other
modifier keys to be up. The example specifies a `shift-click'
gesture.
..., click_gesture(left, 's', single, message(...)), ... |
..., send(Box, gesture, new(move_gesture)), ... |
..., new(T, tree(new(Root, node(text(shapes))))), send(Root, son, node(circle(50))), send(Root, son, node(box(50, 50))), ... |
primitives(Device, Primitives) :- get(Device?graphicals, find_all, not(message(@arg1, instance_of, device)), Primitives). |
widest_graphical(Device, Width) :- new(N, number(0)), send(Device, for_all, message(N, maximum, @arg1?width)), get(N, value, Width), send(N, done). |
draw_sine :- send(new(Pict, picture), open), send(Pict, display, new(P, path)), ( between(0, 360, X), Y is sin((X * 6.283185)/360) * 100, send(P, append, point(X, Y)), fail ; true ). |
?- get(@pce, user, User). User = jan |
->
initialise
method is specialised for handling colour images.
... get(Box, center, Point), get(Point, mirror, Mirrored), send(Box, center, Mirrored), ... |
Popups are ->
appended to menu_bars. Various
classes define the method
->
popup to associate popup menus. Finally, class popup_gesture
provides a gesture that operates popup menus.
A popup consists of menu_items, each of which normally defines a message to be executed if the corresponding item is activated. Pull-right sub-menus are realised by appending a popup to a popup.
..., new(P, popup(options)), send(P, append, new(L, popup(layout, message(Tree, layout, @arg1)))), send_list(L, append, [horizontal, vertical, list]), send(P, append, menu_item(quit, message(Tree, destroy))), ... |
:- pce_global(@graph_node_gesture, make_graph_node_gesture). make_graph_node_gesture(G) :- new(P, popup), send_list(P, append, [...]), new(G, handler_group(connect_gesture(...), move_gesture(middle), popup_gesture(P))). |
In the example, ChainOfChains is a chain holding chains as
its elements. The task is to sort each of the member chains, using the
function ?(@arg1,
compare, @arg2) for sorting. If
not enclosed in a quote_function,
the message will try to evaluate the function. Now it passes the
quote_function unchanged. The `chain->
sort'
method requires a code argument
and therefore the function will be extracted from the quote_function.
..., send(ChainOfChains, for_all, message(@arg1, sort, quote_function(?(@arg1, compare, @arg2)))), ... |
?- new(S, string('Hello World')), new(R, regex('Hello\s +\(\w+\)')), send(R, match, S), get(R, register_value, S, 1, name, W). W = 'World' |
..., send(Box, recogniser, new(resize_gesture)), ... |
A resource is data associated with the application. It is most commonly used to get access to image-data. Example:
resource(splash, image, image('splash.gif')). show_splash_screen :- new(W, window), send(W, kind, popup), % don't show border new(I, image(resource(splash))), get(I, size, size(W, H)), send(W, size, size(W, H)), send(W, display, bitmap(I)), send(W, open_centered), send(timer(2), delay), send(W, destroy). |
..., send(Window, scrollbars, vertical), ... |
<->
attribute' and user-defined classes have
made sheets obsolete.
<-
width and <-
height
used to communicate with graphical objects about dimension. See also point
and area.
..., new(Done, slider(done, 0, 100, 0)), send(Done, show_label, @off), send(Done, show_value, @off), ... send(Done, selection, N), send(Done, synchronise), ... |
library(pce_server)
provides a good starting point for
defining server sockets. The support executable xpce-client
may be used to communicate with XPCE server
sockets. See also PceEmacs server mode as defined in library('emacs/server')
.
new(_, constraint(Gr1, Gr2, spatial(xref=x+w/2, yref=y+h, xref=x+w/w, yref=y+h, w2=w+2, h2=h+2))) |
Strings are commonly used to hold descriptions, text entered by the user, etc.
make_browser(B) :- new(B, browser), send(B, style, file, style(font := normal)), send(B, style, directory, style(font := bold)), send(B, open). append_file(B, Name) :- send(B, append, dict_item(Name, style := file)). append_dir(B, Name) :- send(B, append, dict_item(Name, style := directory)). |
library(emacs_extend)
.
new(D, dialog(settings)), send(D, append, new(TS, tab_stack)), send(TS, append, new(G, tab(global))), send(TS, append, new(U, tab(user))), ..., <fill G and U> ..., send(D, append, button(ok)), send(D, append, button(cancel)). |
simple_table :- new(P, picture), send(P, layout_manager, new(T, table)), send(T, border, 1), send(T, frame, box), send(T, append, text('row1/col1')), send(T, append, text('row1/col2')), send(T, next_row), send(T, append, new(C, table_cell(text(spanned, font := bold)))), send(C, col_span, 2), send(C, halign, center), send(P, open). |
Provides the layout_interface to a table. Table cells are automatically created if a graphical is appended to a table. Explicit creation can be used to manipulate spanning, background and other parameters of the cell.
These classes are used for storing row- and column information in table objects. They are normally created implicitly by the table. References to these objects can be used to change attributes or delete rows or columns from the table. Example:
..., get(Table, column, 2, @on, Column), send(Column, halign, center), ... |
library(pce_editable_text)
exploits these methods to arrive at a flexible editable text object.
See class editor for an overview of the other objects involved in editing text.
..., send(Editor?text_cursor, displayed, @off), ... |
<-
value_set',
the item will perform completion, which
is by default bound to the space-bar. If a type is specified, the typed
value will be converted to the type and an error will be raised if this
fails. The following text-item is suitable for entering integers:
..., new(T, text_item(height, 0)), send(T, type, int), send(T, length, 8), ... |
->
margin_width' >
0. If the text_buffer
defines fragments, and the style
objects define `style<-
icon',
the margin will show an icon near the start of the fragment. After the
introduction of multiple fonts, attributes and colour this mechanism has
become obsolete.
..., new(T, timer(0.5, message(Gr, inverted, Gr?inverted?negate))), ... |
?- get(type(int), check, '42', X). X = 42 |
->
forward'
and the execution of a block.
The system predefines a number of var objects providing context for messages, methods, etc: @arg1, ... @arg10 for argument forwarding, @event for the current event, @receiver for the receiver of an event or message and @class for the class under construction are the most popular ones. Class block and and give examples of using these objects.
<-
contains'
and `visual<-
contained_in'
methods that define the visual consists-of hierarchy as shown by the
Visual Hierarchy. Class visual itself plays a role in
the
->
report mechanism as described in section
10.7 and defines
`visual->
destroy'
to ensure destruction of a sub-tree of the visual consists-of hierarchy.
editor.selection_style: \ when(@colour_display, \ style(background := yellow), \ style(highlight := @on)) |
->
for_all, ->
for_some, <-
find
and <-
find_all methods defines on most collection
classes.
Class window can be used as a graphics window if no scrollbars are needed.