Copyright (1997-2013) EDMGROUP Pty Ltd - EZY Prolog Reference

 

EZY GUI Concept

EZY GUI is a programming paradigm, based upon the following principles:

  • Symbolic addressing of GUI elements

  • GUI elements can be nested.

  • Every GUI element can be expressed in Prolog term.

  • EZY FORM - GUI declarations stored together with code in one container

So, what is new and where is difference in EZY GUI in comparison with Visual Prolog?

Symbolic addressing of GUI elements

Every GUI element has name in form of STRING. Programmer can use any names, convenient for him, which makes programs more readable and clear.

Under Windows every GUI element has it's ID, which is number. Compiler or interpreter can use symbolic names declared as constants. It helps programming, but when it comes to testing and debugging programmer has to consult constants definitions to resolve what does particular ID mean.

Windows ID doesn't describe full address of GUI elements. So, to obtain GUI handler programmer have to know handler of the parent GUI element. In practice this leads to extra confusion on design stage and, in case of change management, errors at run-time.

Passing data between GUI elements requires knowledge of their ID's and parents. It is not hard for simple GUI layouts, but becomes quite difficult for complex GUI layouts.

EZY GUI address is a list of names of it's parents. System supports absolute and relative addressing.

The difference between traditional addressing and EZY GUI addressing is that there is no need to know the parent of the GUI element to access it's handler. System locates GUI element by it's address and reference to any GUI element. Once GUI object handler is known - it can be used in EZY Prolog functional calls to access properties and performing actions (see, for instance, Object handling calls).

Sample code - initialize GUI event handler:

initialize_event_handlers(WINDOW):-
    CHECK_BOX_ADDR = ["TOP_FRAME","Check Box"],
    ezy_object_get(WINDOW,CHECK_BOX_ADDR,CHECK_BOX_WINDOW),
    % now access GUI element via it's WINDOW reference
% setup event handler

    ezy_object_handler(CHECK_BOX_WINDOW,check_box_handler),
    fail.

The Code Expert  allows insertion of the GUI element address from GUI tree directly into program code.

Nesting of GUI elements

EZY GUI allows to group elements inside EZY FRAME.

The FRAME is graphical area with some properties (text or picture) and can include any other GUI element as child. Nesting allows to consider GUI layout as a tree of elements. It is possible to operate with individual GUI elements as well as the whole GUI tree, such as get/set values and various parameters.

EZY Prolog run-time engine uses GUI tree to provide addressing of GUI elements and access to their properties.

Prolog terms for GUI elements

The major idea in EZY GUI is that each EZY GUI element has correspondent prolog term, which describes it's properties. Term representation allows to use the power of unification mechanism and avoid conversion between GUI data and prolog terms.

So, to get values of GUI element (or the whole layout) programmer gets a prolog term for this GUI element and uses term unification to access individual elements (or properties) of the GUI element.

To setup values of GUI element programmer constructs prolog term and passes it via EZY GUI language call.

EZY GUI has basic set of elements

This allows programmer to rely upon Prolog unification mechanism to get/set parameters of GUI elements.

GUI Expert (EZY Prolog VDE) allows to generate prolog term template for any element of the GUI tree (including the whole tree). So, there is no need to remember the structure of Prolog terms, necessary to get/set values of GUI element.

This allows programmer to rely upon Prolog unification mechanism to get/set parameters of GUI elements.

There is only one language call to Get values of any GUI element or layout:

    FRAME_ADDRESS = ["TOP_FRAME"],
    ezy_object_data(CTRLWIN,FRAME_ADDRESS,VALUE_FRAME),
% now use unification to get individual values of the GUI element

VALUE_FRAME
 = ....prolog_term.....

The same predicate is used to setup values of GUI element or layout:

    % construct prolog term and pass it to GUI element
VALUE_FRAME
 = ....prolog_term.....
    FRAME_ADDRESS = ["TOP_FRAME"],
    ezy_object_data(CTRLWIN,FRAME_ADDRESS,VALUE_FRAME),

While prolog terms for GUI elements or layouts can be very complex, there is no need to consult documentation to have correct term for selected GUI element or layout. The Code Expert provides tools for generation Prolog code for selected GUI element or layout.

So, programmer does not need to know the syntax of the prolog declarations and the system will provide correct template for prolog term which describes selected GUI element.

As result, there is no need to remember the structure of GUI layout and how to get/set it's values - the "GUI" button will generate necessary code for selected GUI element or layout.

This is sample code how to get value of the check box using EZY GUI. Note the use of term unification to access properties.

(Code generated by EZY GUI VDE)

    ADDRESS_CHECK_BOX = ["TOP_FRAME","Check Box"]
    ezy_object_data(WINDOW,ADDRESS_CHECK_BOX,RESULT_Check_Box)
    RESULT_Check_Box =
     ezy_reply(["TOP_FRAME","Check Box"]/*ADDRESS*/
                EZY_ITEM/* EZY_ITEM*/
    ) /* end of the ezy_reply */,
    EZY_ITEM = ezy_integer(CHECK_BOX_VALLUE),

So, the goal of the programer is to fill in variable names into the prolog term, which represents selected GUI element or layout.

Prolog template comes with symbolic addresses and comments, which help to identify individual elements of the complex GUI layouts..

EZY FORM - storage for GUI and code

System considers GUI and associated code as one resource and stores it in container (EZY Form). EZY Prolog run-time engine creates an isolated instance of Prolog Virtual Machine for GUI declarations and associated prolog code.

What is important, that EZY FORM can be included into another form as external reference. System creates instance of Prolog Virtual Machine for each EZY FORM which prevents re-declaration of prolog rules from different objects.

Every EZY FORM has it's own facts and rules, which are completely isolated from other EZY FORM rules. EZY GUI language calls allow to get/set values of entire form

EZY FORM can be initialized statically (at design stage in GUI Expert) or dynamically. So, the same GUI layout can be reused with different parameters inside one GUI layout.

EZY GUI support tools

The goal of EZY GUI paradigm is to create conditions, where programmer does not need to know and learn, how to do GUI programming.

Basic steps in GUI programming are:

  • Drawing of the GUI using components (GUI Expert)

  • Generation of code, which supports drawn GUI (GUI Expert)

  • Getting/Setting values of GUI elements inside code (Code Expert)

The interaction between programmer and GUI code goes through the built-in tools, which allow to:

  • get address of GUI elements

  • generate code for Get/Set values of GUI elements

EZY GUI paradigm provides unified way of getting/setting values of GUI elements and layouts. Regardless of complexity of the GUI layout, programmer uses the same way of programming.

To set values -

  • generate GUI term for selected element or layout

  • fill in variable names into generated term

  • send term to GUI element

To get values:

  • generate GUI term for selected element or layout

  • fill in variable names into generated term (for unification)

In case of changes in GUI layout there is no need to review the whole program. Use the same steps to get/set values of GUI elements and EZY Prolog VDE will provide automated assistance to generate correct working code, which will reflect changes.

 

Copyright 1997-2013 EDMGROUP (Australia)