|
Copyright ® (1997-2013) EDMGROUP Pty Ltd - EZY Prolog Reference |
/* EZY PROLOG. Copyright (C) 2002 EDMGROUP (Australia)
http://www.ezy-software.com
Code Automatically Generated by EZY Designer
Load EZY form with text editor
Define coloring scheme
Set read-only/read-write mode
Define colored tokens
*/
predicates
prolog_main
my_initialize_gui(WINDOW) - (i)
editor_text_editor_handler: EHANDLER
initialize_text_editor(WINDOW)
my_initialize_buttons(WINDOW)
my_button_ehandler: EHANDLER
clauses
prolog_main():-
syspath(EXEPATH,_),
format(FORMNAME,"%sezy_editor_test.dcl",EXEPATH),
ezy_form_open(FORMNAME,WINDOW),
my_initialize_gui(WINDOW),
!.
my_initialize_gui(WINDOW):-
write("GUI initialization started"),
nl,
initialize_text_editor(WINDOW),
my_initialize_buttons(WINDOW),
write("GUI Initialization completed"),
nl,
!.
my_initialize_gui(_):-
write("GUI initialization failed"),
nl,
!.
my_initialize_buttons(WINDOW):-
SET_READ_ONLY_ADDR=["test_frame","Set Read-only"],
ezy_get_object(WINDOW,SET_READ_ONLY_ADDR,SET_READ_ONLY_WINDOW),
ezy_object_handler(SET_READ_ONLY_WINDOW,my_button_ehandler),
fail.
my_initialize_buttons(WINDOW):-
SET_READ_WRITE_ADDR=["test_frame","Set Read-write"],
ezy_get_object(WINDOW,SET_READ_WRITE_ADDR,SET_READ_WRITE_WINDOW),
ezy_object_handler(SET_READ_WRITE_WINDOW,my_button_ehandler),
fail.
my_initialize_buttons(WINDOW):-
SET_COLORED_TOKENS_ADDR=["test_frame","Set Colored Tokens"],
ezy_get_object(WINDOW,SET_COLORED_TOKENS_ADDR,SET_COLORED_TOKENS_WINDOW),
ezy_object_handler(SET_COLORED_TOKENS_WINDOW,my_button_ehandler),
fail.
my_initialize_buttons(_)
editor_text_editor_handler(WINDOW,EVENT):-
write("[editor_text_editor_handler](",WINDOW,",",EVENT),
nl,
fail.
initialize_text_editor(WINDOW):-
TEXT_EDITOR_ADDR=["test_frame","text editor"],
ezy_get_object(WINDOW,TEXT_EDITOR_ADDR,TEXT_EDITOR_WINDOW),
COLORED_TOKENS=["editor","sample"],
BG_COLOR=65280,
FG_COLOR=16777215,
ezy_editor_colored_tokens(TEXT_EDITOR_WINDOW,BG_COLOR,FG_COLOR,COLORED_TOKENS),
ezy_object_handler(TEXT_EDITOR_WINDOW,editor_text_editor_handler),
write("*** {text editor} Initialized"),
nl,
!.
my_button_ehandler(_,e_control(_,_,CTRLWIN,ACTION)):-
ezy_object_address(CTRLWIN,CTRL_ADDRESS),
CTRL_ADDRESS=["test_frame","Set Read-only"],
TOP_FRAME="test_frame",
ezy_get_parent(CTRLWIN,TOP_FRAME,TOPWIN),
TEXT_EDITOR_ADDR=["test_frame","text editor"],
ezy_get_object(TOPWIN,TEXT_EDITOR_ADDR,TEXT_EDITOR_WINDOW),
READ_ONLY=1,
ezy_editor_flag(TEXT_EDITOR_WINDOW,READ_ONLY),
!.
my_button_ehandler(_,e_control(_,_,CTRLWIN,ACTION)):-
ezy_object_address(CTRLWIN,CTRL_ADDRESS),
CTRL_ADDRESS=["test_frame","Set Read-write"],
TOP_FRAME="test_frame",
ezy_get_parent(CTRLWIN,TOP_FRAME,TOPWIN),
TEXT_EDITOR_ADDR=["test_frame","text editor"],
ezy_get_object(TOPWIN,TEXT_EDITOR_ADDR,TEXT_EDITOR_WINDOW),
READ_ONLY=0,
ezy_editor_flag(TEXT_EDITOR_WINDOW,READ_ONLY),
!.
my_button_ehandler(_,e_control(_,_,CTRLWIN,ACTION)):-
ezy_object_address(CTRLWIN,CTRL_ADDRESS),
CTRL_ADDRESS=["test_frame","Set Colored Tokens"],
TOP_FRAME="test_frame",
ezy_get_parent(CTRLWIN,TOP_FRAME,TOPWIN),
TEXT_EDITOR_ADDR=["test_frame","text editor"],
ezy_get_object(TOPWIN,TEXT_EDITOR_ADDR,TEXT_EDITOR_WINDOW),
ezy_editor_colored_tokens(TEXT_EDITOR_WINDOW,BG_OLD,FG_OLD,OLD_LIST),
write("OLD_LIST=",OLD_LIST),
nl,
slist_to_string(OLD_LIST," ",INIT),
dlg_str("Please list of tokens separated by space",INIT,STRING),
str_toklist(STRING,COLORED_TOKENS),
BG_COLOR=8388672,
FG_COLOR=16777215,
ezy_editor_colored_tokens(TEXT_EDITOR_WINDOW,BG_COLOR,FG_COLOR,COLORED_TOKENS),
!.