A dialog is a window that is designed to be used for creating dialog boxes. A dialog performs automatic layout over its contents, thus largely simplifying the definition of simple dialog windows and the automatic generation of dialog windows.
Dialog windows normally only display instances of subclasses of class dialog_item.
These are added to the dialog using the dialog->append
method rather than device->display. dialog->append
places the item relative to the other items in the dialog. When the
frame in which the dialog resides is created, the final positions are
automatically calculated by dialog->layout.
Dialog windows may be operated in two modes: each change to an item
in the dialog immediately sends a message or pressing an apply
button will apply all modifications made to the dialog. The example
below illustrates a dialog of the latter type for editing some window
attributes:
dialog(W) :-
new(D, dialog('Edit Window Attributes')),
send(D, append, label(reporter)),
send(D, append,
text_item(frame_label,
W?frame?label,
message(W?frame, label, @arg1))),
send(D, append,
slider(width, 50, 500, W?visible?width,
message(W, width, @arg1))),
send(D, append,
slider(height, 50, 500, W?visible?height,
message(W, height, @arg1))),
send(D, append, button(apply)),
send(D, append, button(restore)),
send(D, append, button(quit, message(D, destroy))),
send(D, default_button, apply),
send(D, open).
?- new(@w, window),
send(@w, open),
dialog(@w).
This dialog may be converted into an immediate changing
dialog by deleting the apply button. See dialog->apply, dialog->modified_item
and dialog->restore
for details.
<-gap,
the distance between items.->layout->size, dialog->width
and dialog->height.
Used by dialog->_compute_desired_size
to determine the dimensions that should not be altered. Values:
->_compute_desired_size
sets graphical<-width and graphical<-height.
->_compute_desired_size
only sets graphical<-width
->_compute_desired_size
only sets graphical<-height
->_compute_desired_size
does not modify dimensions.
->fit.
It invokes the automatic dialog->layout,
assigns the dialog->caret
to the first text_item and (depending on -size_given) computes the
desired dimensions of the dialog window.
<-activerelative_to_last:
below below the last one right right of the last one next_row below the left-most item of previous row
If relative_to_last is omitted, the following defaults apply: if the
last item and this item are instances of class button,
the item is placed right. Otherwise the item is placed
next_row.
<-message
for each of the dialog_item's in
device<-graphicals.
If always equals @on
the message will be invoked regardless whether the user has modified the
item or not. If always equals @off
or @default
the message will only be invoked if
dialog_item<-modified
yields @on. If
the dialog has a
device<-default_button,
execute graphical->active.
See also dialog->restore.
<-graphicals,
computes a set of accelerators to use for them and finally uses
dialog_item->accelerator
to assign them.
See also menu->assign_accelerators and dialog->assign_accelerators.
->advance
and
text_item<-advance.<-default_button->display,
but invokes
`dialog_item ->auto_align: @off`
To inform dialog->layout
not to move this object.
->append.->_compute_desired_size
when then dialog's frame is created. See also frame->fit.
The layout process consists of the following stages:
<-auto_align
in a two-dimensional grid.
<-auto_label_align,
dialog_item<-label_width, dialog_item<-auto_value_align
and dialog_item<-value_width
<-alignment not
column, but one of left, center
or right are not horizontally with items above or below
them, but combined with items to their left and right into sequences of
items with the same alignment. At the end of the layout process aligned
such sequences are aligned in the available space. Notably button
objects have
dialog_item<-alignment,
so a row of buttons is normally centered in the dialog window.
<-reference
in the two-dimensional grid.
<-default_button,
this button will be activated using graphical->active.
Otherwise, this method fails. Dialog-items will send their dialog_item<-message
immediately if this message fails. Otherwise they assume the default
button will activate dialog->apply.
See also dialog_item->modified, dialog->apply
and dialog->restore.
->restore to all device<-graphicals.
If the dialog has a device<-default_button,
this is send graphical->active.
See also graphical->restore, dialog_item<-default
and
dialog_item->modified, graphical->apply
and dialog->apply.
->size
and sets -size_given to both to avoid overruling of the given size by
the automatic layout system invoked by dialog->_compute_desired_size.
See also
dialog->width
and dialog->height->_compute_desired_size
computes the size on the basis of the dialog's contents, the
graphical<-width will not be changed after
this message. Sets -size_given to width or both.
See also dialog->height
and dialog->size.
<->sensitive.
Both for consistency with class dialog_item
and for backward compatibility.<-slot
-border is not @default
return it, else return
dialog<-gap.->modified_item
and dialog->apply.|frame<-member dialog_item
called reporter, this item is returned. Otherwise visual<-report_to
is invoked.
This method is normally exploited by displaying a label
object with name reporter on the dialog
object. This label will then display all error messages raised from
operating the dialog item. See
visual->report, object->report
and class error.