|
Copyright ® (1997-2008) EDMGROUP Pty Ltd - EZY Prolog Reference |
|
EZY GUI Concept EZY GUI is a programming paradigm, based upon the following principles:
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):- 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"], The same predicate is used to setup values of GUI element or layout:
% construct prolog term
and pass it to GUI element 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"] 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:
The interaction between programmer and GUI code goes through the built-in tools, which allow to:
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 -
To get values:
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. |