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

 EZY Graphics

 

EZY Designing

EZY Prolog basics

EZY GUI and Visual Prolog

EZY Debugger

EZY Code Generator

EZY DLL

EZY Read/Write

EZY Lists

EZY Dialogs

EZY Menu

EZY GUI

EZY Programming

EZY Samples

EZY_XML

EZY ODBC

EZY Tree and XTree

EZY Regular expressions

EZY DDE (Dynamic Data Exchange)

Data type checking/conversion

Execution control

Term unification

Operators

File system

Operating system

Date/Time functions

String operations

Built-in WEB Browser

Internal Databases

Debugging

HTML support

EZY Prolog Domains

EZY Prolog Functions

EZY Prolog versions

Graphics programming subsystem provides programmer with set of language calls which allows direct draw of graphical primitives.

 

 

Click here for Graphics subsystem language calls:

 

 

Program text:

predicates

    % SYSTEM ENTRY POINT
    initialize_gui: EZY_INITIALIZE_GUI
    % EVENT HANDLERS CODE
    initialize_event_handlers(WINDOW)
    frame_ehandler: EHANDLER
    handler_ok: EHANDLER
    handler_cancel: EHANDLER
    listbox_ehandler: EHANDLER
% USER CODE

    process_selection(WINDOW,STRING SELECTED) - (i,i)

clauses



% START OF GUI INITIALIZE

% EZY PROLOG PASSES CONTROL TO THIS CLAUSE WHEN FORM LOADED

initialize_gui(WINDOW):-
    write("GUI initialization started"),nl,
    initialize_event_handlers(WINDOW),
% END OF GUI INITIALIZE

    write("GUI Initialization completed"),nl,
    !.

initialize_gui(_):-
    write("GUI initialization failed"),nl,
    !.

% EVENT HANDLERS INITIALIZE START

initialize_event_handlers(WINDOW):-
    TOP_FRAME_ADDR = ["TOP_FRAME"],
    ezy_object_get(WINDOW,TOP_FRAME_ADDR,TOP_FRAME_WINDOW),
    ezy_object_handler(TOP_FRAME_WINDOW,frame_ehandler),
    fail.
initialize_event_handlers(WINDOW):-
    BUTTONS_ADDR = ["TOP_FRAME","buttons"],
    ezy_object_get(WINDOW,BUTTONS_ADDR,BUTTONS_WINDOW),
    ezy_object_handler(BUTTONS_WINDOW,frame_ehandler),
    fail.
initialize_event_handlers(WINDOW):-
    CANVAS_ADDR = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,CANVAS_ADDR,CANVAS_WINDOW),
    ezy_object_handler(CANVAS_WINDOW,frame_ehandler),
    fail.
initialize_event_handlers(WINDOW):-
    LIST_ADDR = ["TOP_FRAME","list"],
    ezy_object_get(WINDOW,LIST_ADDR,LIST_WINDOW),
    ezy_object_handler(LIST_WINDOW,listbox_ehandler),
    fail.
initialize_event_handlers(_):-
    write("*** {EVENT HANDLERS Initialised}"),nl,
    !.
/* EVENT HANDLERS INITIALIZE END*/


% Frame Default Event Handler

frame_ehandler(_,_,_):-
    fail.
% OK EVENT HANDLER

handler_ok(_,e_control(_,_,CTRLWIN,activated),0):-
    ezy_object_address(CTRLWINCTRL_ADDRESS),
    write("Button(",CTRL_ADDRESS,") activated"),nl,
    dlg_note("handler_ok Button Pressed","Button:[TOP_FRAME.buttons.Ok]"),
    % Use GUI Designer menu {Control to Clipboard/Reply code} to insert reply code here
    % Change address of top frame if it has different name
    TOP_FRAME_ADDRESS = ["TOP_FRAME"],
    ezy_object_data(CTRLWIN,TOP_FRAME_ADDRESS,VALUE_TOP_FRAME),
    % Destroy dialog and return Values
    ezy_dialog_destroy([VALUE_TOP_FRAME]),
    !.
% CANCEL EVENT HANDLER

handler_cancel(_,e_control(_,_,_,activated),0):-
    ezy_dialog_destroy([]),
    !.
% LISTBOX - EVENT HANDLER


listbox_ehandler(_,e_control(_,_,LISTBOX_WINDOW,selchanged),0):-
    ezy_lbox_selected_get(LISTBOX_WINDOW,SELECTED_LIST,_),
    SELECTED_LIST = [SELECTED],
    process_selection(LISTBOX_WINDOW,SELECTED),
    !.
listbox_ehandler(_,e_control(_,_,LISTBOX_WINDOW,CONTROL_INFO),0):-
    ezy_object_address(LISTBOX_WINDOW,ADDRESS),
    ezy_lbox_selected_get(LISTBOX_WINDOW,SELECTED,_),
    write("Listbox ",ADDRESS,", event=",CONTROL_INFO,", Selected=",SELECTED),nl,
    !.
process_selection(WINDOW,"Line"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    FROM  = pnt(10,10)TO = pnt(100,100),
    draw_line(OBJECT_WINDOW,FROM ,TO),
    !.
process_selection(WINDOW,"Arc"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    BoundRect = rct(10,10,100,100),
    StartX = 10StartY = 10,
    StopX = 100StopY = 100,
    draw_arc(OBJECT_WINDOW,BoundRect,StartX,StartY,StopX,StopY),
    !.
process_selection(WINDOW,"Ellipse"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    BoundRect = rct(10,100,100,200),
    draw_ellipse(OBJECT_WINDOW,BoundRect),
    !.
process_selection(WINDOW,"Pie"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    BoundRect = rct(10,10,100,100),
    StartX = 10StartY = 10,
    StopX = 100StopY = 100,
    draw_pie(OBJECT_WINDOW,BoundRect,StartX,StartY,StopX,StopY),
    !.
process_selection(WINDOW,"Pixel"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    PNT = pnt(55,50),
    COLOR = 255,
    draw_pixel(OBJECT_WINDOW,PNT,COLOR),
    !.
process_selection(WINDOW,"Rect"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    RCT = rct(50,50,100,100),
    draw_rect(OBJECT_WINDOWRCT),
    !.
process_selection(WINDOW,"RoundRect"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    RCT = rct(50,50,150,150),
    EllipseWidth = 20,
    EllipseHeight = 20,
    draw_roundrect(OBJECT_WINDOW,RCT,EllipseWidth,EllipseHeight),
    !.
process_selection(WINDOW,"Polyline"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    PNT1 = pnt(10,10),
    PNT2 = pnt(100,50),
    PNT3 = pnt(50,100),
    PNT4 = pnt(10,50),
    Vertices = [PNT1,PNT2,PNT3,PNT4],
    draw_polyline(OBJECT_WINDOW,Vertices),
    !.
process_selection(WINDOW,"Polygon"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    PNT1 = pnt(10,10),
    PNT2 = pnt(100,50),
    PNT3 = pnt(50,100),
    PNT4 = pnt(10,50),
    Vertices = [PNT1,PNT2,PNT3,PNT4],
    draw_polygon(OBJECT_WINDOW,Vertices),
    !.

process_selection(WINDOW,"Floodfill"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    PNT = pnt(70,50),
    COLOR = 255,
    dlg_choosecolor(COLOR,RESULT),
    draw_floodfill(OBJECT_WINDOW,PNT,RESULT),
    !.
process_selection(WINDOW,"Set Fore Color"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    COLOR = 255,
    dlg_choosecolor(COLOR,RESULT),
    win_setforecolor(OBJECT_WINDOW,RESULT),
    !.
process_selection(WINDOW,"Set Back Color"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    COLOR = 255,
    dlg_choosecolor(COLOR,RESULT),
    win_setbackcolor(OBJECT_WINDOW,RESULT),
    !.
process_selection(WINDOW,"Set Pen Size"):-
    ADDRESS = ["TOP_FRAME","canvas"],
    ezy_object_get(WINDOW,ADDRESS,OBJECT_WINDOW),
    PENWIDTH = 5,
    PENSTYLE = ps_solid,
    COLOR = 255,
    PEN    =    pen(PENWIDTHPENSTYLECOLOR),
    win_setpen(OBJECT_WINDOW,PEN),
    !.

process_selection(_,SELECTED):-
    write("Failed ",SELECTED),nl,
    !.
goal

    true.

 .Copyright 1997-2013 EDMGROUP (Australia)