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

File Explorer sample

prolog_main():-

write ( "Welcome to EZY Prolog\n" ),

syspath ( PATH , _ ),

format ( DCL_FILE , "%Ezy_explorer.dcl" , PATH ),

ezy_form_open ( DCL_FILE , WINDOW ),

TREEVIEW_ADDR =[ "ezy_explorer" , "treeview" ],

ezy_get_object ( WINDOW , TREEVIEW_ADDR , TREEVIEW_OBJ ),

ezy_treeview_callback ( TREEVIEW_OBJ , treeview_callback ),

CHECKED = 1 ,

UNCHECKED = 0 ,

DISABLED = 0 ,

ENABLED = 1 ,

SUBMENU =[txt( 10 , "SubmenuMenu1" , 0 , ENABLED , CHECKED ,[]),txt( 11 , "SubmenuMenu2" , 0 , DISABLED , UNCHECKED ,[])],

MENULIST =[txt( 4 , "Add Node" , 0 , ENABLED , UNCHECKED ,[]),txt( 5 , "Delete Node" , 0 , ENABLED , UNCHECKED ,[]),txt( 6 , "Rename Node" , 0 , ENABLED , UNCHECKED ,[]),txt( 1 , "Menu1" , 0 , ENABLED , CHECKED ,[]),txt( 2 , "Menu with Submenu" , 0 , ENABLED , UNCHECKED , SUBMENU ), separator ,txt( 3 , "Menu3 - disabled" , 0 , DISABLED , UNCHECKED ,[])],

MENU =dyn_menu( MENULIST ),

ezy_object_menu ( TREEVIEW_OBJ , MENU ),

string_to_slist ( PATH , "\\" , DIRECTORIES ),

write ( "DIRECTORIES=" , DIRECTORIES ),

nl ,

create_directory_tree( PATH , DIRECTORIES , TREEVIEW ),

ezy_treeview_item ( TREEVIEW_OBJ ,[], TREEVIEW ),

write ( "Sample program initilized succesfully\n" ),

! .

prolog_main():-

dlg_note ( "EZY Prolog" , "EZY Explorer error during initialization" ).

create_directory_tree( PATH ,[ DIR , _ ], TREEVIEW ):-

! ,

directories ( PATH , DIRLIST ),

dirlist_to_treeview( DIRLIST , TREELIST ),

ezy_treeview_icon ( "book_opened" , OPENED_ICON ),

TREEVIEW =bi( 0 , DIR ,node( open , TREELIST ), OPENED_ICON ).

create_directory_tree( PATH ,[ DIR |DIRLIST], TREEVIEW ):-

! ,

create_directory_tree( PATH , DIRLIST , TREEVIEW_CHILD ),

ezy_treeview_icon ( "book_opened" , OPENED_ICON ),

TREEVIEW =bi( 0 , DIR ,node( open ,[ TREEVIEW_CHILD ]), OPENED_ICON ).

dirlist_to_treeview([],[]):-

! .

dirlist_to_treeview([ DIR |DIRLIST], TREELIST ):-

DIR = "." ,

! ,

dirlist_to_treeview( DIRLIST , TREELIST ).

dirlist_to_treeview([ DIR |DIRLIST], TREELIST ):-

DIR = ".." ,

! ,

dirlist_to_treeview( DIRLIST , TREELIST ).

dirlist_to_treeview([ DIR |DIRLIST],[ ITEM |TREELIST]):-

ezy_treeview_icon ( "book_opened" , OPENED_ICON ),

ITEM =bi( 0 , DIR , leaf , OPENED_ICON ),

dirlist_to_treeview( DIRLIST , TREELIST ).

treeview_callback( WINDOW ,node_open( KEY , POSITION )):-

write ( "treeview_callback(node_open(" , KEY , "," , POSITION , "))\n" ),

ezy_treeview_flipnode ( WINDOW , POSITION ),

! .

treeview_callback( WINDOW ,node_close( KEY , POSITION )):-

write ( "treeview_callback(node_close(" , KEY , "," , POSITION , "))\n" ),

ezy_treeview_flipnode ( WINDOW , POSITION ),

! .

treeview_callback( WINDOW ,mouse_dbl( _ , _ , _ )):-

write ( "double click in:\n" , WINDOW , "\n" ),

ezy_treeview_address ( WINDOW , ADDRESS , NODE ),

write ( "NODE=" , NODE , "Address:\n" , ADDRESS , "\n" ),

ezy_treeview_cursor ( WINDOW , CURSOR ),

write ( "Current CURSOR=" , CURSOR , "\n" ),

ezy_treeview_item ( WINDOW , CURSOR , TREE_ITEM ),

write ( "\nSelected node=" , TREE_ITEM , "\n" ),

TREE_ITEM =bi( _ , FOLDER , _ , _ ),

! .

treeview_callback( _WINDOW ,menu_item( NUMBER , _ )):-

write ( "treeview_callback(menu_item(" , NUMBER , ")\n" ),

! .