Script Writing The GUI
Domain Specific Dialecting. Doctors express their ideas in medical terms, stockbrokers in trade terms, and quarterbacks in football terms. Why? Because it's more efficient and productive. That's the benefit of dialecting. Dialecting is the ability to create sub-languages that provide you with extra leverage and productivity by expressing your solutions in terms that are best suited to your purpose.
VID is Rebol's Visual Interface Dialect. A dialect is an extension of the Rebol language that makes it easier to express or describe information, actions, or interfaces. VID is a dialect that provides a powerful method of describing user interfaces. |
GUI's are created by specifying a series of faces and their attributes. The script to the right illustrates the general syntax of a face written with the VID dialect: |
''variable: face inline-options'' OPTIONS ''options'' '' actions'' |
|
|
The full syntax is not always required. A variable name does not always have to be specified for example. |
|
"field" is an inbuilt face, (field is it's style) "Enter Data", the field text as an inline option "[area-color:]", field color as an options block "submit main-url" is the action "Customer-Address" is the face variable variable, face, inline option, options block |
Note: The images shown here with a temporary, prototype skin designed for development purposes only.
Just to provide a simple starting point, here's a GUI that consists of two buttons:
<TD WIDTH=50%>
<TD WIDTH=50%>
Rebol []
- load-gui
- view [
- button]
</td> <TD align=center valign=MIDDLE>
|
Rebol scripts must have the header Rebol [].
If using the R3 alpha version, load-gui must also be included in the script to ensure the latest version will be downloaded and used. |
To run a script, copy and paste the examples into a text file headed with Rebol [], include the load-gui function, and save this file with a ".r" extension. Then either from the console type: do %example.r, or drag the script file icon onto the Rebol file icon. |
|
It should be noted that the view function is one of several ways to construct GUIs. In addition to view, R3 will also allow you to evaluate GUI code directly, similar to an HTML page. Therefore, to make this document simpler, we could just write the contents of the panel. For example, |
|
For the sake of illustration, let's toss in a few more faces and their styles to the example:
</td> <TD align=center valign=MIDDLE>[[images/Gui-basics-survey2.jpg|216px 221px]]
|
<TD align=center valign=MIDDLE>[[images/Gui-basics-test-panel2.jpg|298px 393px]]
Rebol []
load-gui
view [
|
Here is another example that we use for the R3 GUI test program. It tests the features of a scroll-bar, both on input from the user as well as from other GUI objects. It shows that a small amount of GUI code can make a useful panel. |