Two new Common Graphics Widgets in Allegro CL 8.0

Allegro CL 8.0 has two new Common Graphics widgets for use in applications that use Common Graphics. (Common Graphics is only supported on Windows and Linux in release 8.0.) The widgets are the lamp widget, which is a labeled colored shape which displays different colors as it is on or off; and an HTML widget, with an associated HTML browser dialog, which allows an in-Lisp browser. In this note, we show examples using each widget and point to additional documentation.

The Lamp widget

The lamp control is a colored shape (a circle, rectangle, triangle, or diamond) which can be on or off, or can blink between on and off. The on and off colors may be any colors, and may be changed at any time. A single lamp widget can optionally display an entire rectangular array of lamp images, which may individually be on or off or blinking. This picture shows several lamp controls, illustrating different shapes and on and off color choices. Lamp controls have a title, which we use here to describe the particular lamp.

The lamp can also be blinking with a specified blink interval (we felt it was better not to show that in this article but set the value slot to :blinking and specify values for blink-off-milliseconds and blink-on-milliseconds and away you go).

If the value slot of a lamp control is a 2x2 array whose values are t, nil, or :blinking, then an array of lamps will be displayed, as in the second illustration (on color is green, off color is red, and the I in HI is blinking though we have caught it when the lamps are on). Note there is no title when the lamp value is an array:

The description of the lamp class in the documentation has more information and has links to all lamp functionality.

The HTML widget and dialog

The html-widget is a control that renders HTML and handles clicking on links and similar browser actions. It can be used as the main pane of a web browser. The control is implemented on Windows on the WebBrowser OCX control. It is implemented on Linux on the Mozilla GTK widget. (On Windows, Allegro CL offers the ability to create other Common Graphics widgets from OCX controls -- see def-cg-ocx-control. This will be the subject of a future Tech Corner article.)

The function html-browser displays a browser dialog containing an html-widget. Here is what one looks like (displaying the invaluable internet movie database site

The browser has most of the standard buttons. (Unfortunately the Search button is missing: that does not seem to be part of the MS control and we are working on a way to provide a search facility.) If you want an HTML widget in your own dialog, just add it as you would any widget when designing a dialog using a form. Here is a rather rudimentary dialog with an HTML widget, an editable-text widget for entering a URL and a Go button:

Again, we try "" and press Go and the display changes to that website:

The code for doing that is to have the on-click event handler of the Go button do the following (assuming *hw* is the HTML widget and *et* is the editable-text widget):

(defun form1-button1-on-click (dialog widget)
   (declare (ignore-if-unused dialog widget))
   (setf (value *hw*) (value *et*))
   (invalidate (window *hw*))
   (update-window (window *hw*))

Calling invalidate and update-window ensure the change takes place immediately.

See the pages for HTML widget and HTML browser for more information and links to additional documentation. The section Release Notes for Common Graphics and the IDE in the Release Notes for more information on new features and changes in Common Graphics in Allegro CL 8.0. General documentation for Common Graphics and the IDE is described in About Common Graphics and IDE documentation in cgide.htm.

Copyright © 2019 Franz Inc., All Rights Reserved | Privacy Statement Twitter Google+