module Widget:sig
..end
A library of widgets for building GUIs.
type
widget = {
|
repaint : |
|
handle : |
|
size : |
A widget is an object that provides three services:
Layout widgets are containers for other widgets They route events to the appropriate child widget, translating the events to the child's local coordinate system
val space : Gctx.dimension -> widget
A widget that does nothing but take up space
val border : widget -> widget
Adds a border around another widget
val hpair : widget -> widget -> widget
A pair of horizontally adjacent widgets
val vpair : widget -> widget -> widget
A pair of vertically adjacent widgets
val hlist : widget list -> widget
A horizontal group of widgets
val vlist : widget list -> widget
A vertical group of widgets
type
label_controller = {
|
get_label : |
|
set_label : |
A record of functions that allows us to read and write the string associated with a label.
val label : string -> widget * label_controller
Construct a label widget and its controller.
typeevent_listener =
Gctx.gctx -> Gctx.event -> unit
An event listener processes events as they "flow" through the widget hierarchy.
val mouseclick_listener : (unit -> unit) -> event_listener
Performs an action upon receiving a mouse click.
A notifier widget is a widget "wrapper" that doesn't take up any extra screen space -- it extends an existing widget with the ability to react to events. It maintains a list of of "listeners" that eavesdrop on the events propagated through the notifier widget.
When an event comes in to the notifier, it is passed to each event_listener in turn, and then pass to the child widget.
type
notifier_controller = {
|
add_event_listener : |
A notifier_controller is associated with a notifier widget. It allows the program to add event listeners to the notifier.
val notifier : widget -> widget * notifier_controller
Construct a notifier widget and its controller
string ->
widget * label_controller * notifier_controller
: A button has a string, which can be controlled by the corresponding label_controller, and an event listener, which can be controlled by the notifier_controller to add listeners (e.g. a mouseclick_listener) that will perform an action when the button is pressed.
A widget that allows drawing to a graphics context
val bare_canvas : Gctx.dimension -> (Gctx.gctx -> unit) -> widget
Canvases are just widgets with an associated notifier_controller. The repaint method of a canvas is a parameter of the widget constructor.
val canvas : Gctx.dimension ->
(Gctx.gctx -> unit) -> widget * notifier_controller
A canvas is a bordered widget with a notifier_controller. New event listeners can be added using the notifier_controller. The interior of the canvas will be redrawn by calling a user-specified function, provided as a parameter of the canvas widget constructor.
type 'a
value_controller = {
|
add_change_listener : |
|
get_value : |
|
change_value : |
A controller for a value associated with a widget.
This controller can read and write the value. It also allows change listeners to be registered by the application. These listeners are run whenever this value is set.
val make_controller : 'a -> 'a value_controller
A utility function for creating a value_controller.
val checkbox : bool -> string -> widget * bool value_controller
A checkbox widget.