/* rename window - sept 97 - by Sylvain Huet
   renaming interface
*/

/* renaming structure */
struct Rename=
 [chRename:Chn,winRename:ObjWin,txtRename:ObjText,endRename:fun[S] I]
 mkRename;;

typeof Font=ObjFont;;

fun _paintE(x,b)=
 _TXTout b.winRename Font 45 5 TD_TOP+TD_RIGHT 0 "old :";
 _TXTout b.winRename Font 45 30 TD_TOP+TD_RIGHT 0 "new :";;

fun _ok(x,b)=
 let _GETtext b.txtRename -> s in
 (_DSwindow b.winRename;
  exec b.endRename with [s])
;;

fun _cancel(x,b)=
 _DSwindow b.winRename;
 exec b.endRename with [nil]
;;

fun _destroyE(x,b)=
 exec b.endRename with [nil];;


fun iniRename(ch,father,x,y,title,end,old)=
 set Font= if Font!=nil then Font else _CRfont ch 14 0 0 "arial";
 let _CRwindow ch father x y 300 80 WN_MENU+WN_MINBOX title -> win in
 let _CRtext ch win 50 5 245 20 ET_BORDER old -> oldtext in
 let _CReditLine ch win 50 30 245 20 ET_DOWN+ET_AHSCROLL old -> text in
 let _CRbutton ch win 5 55 70 20 0 "Ok"-> ok in
 let _CRbutton ch win 80 55 70 20 0 "Cancel"-> cancel in
 let mkRename [ch win text end]-> b in
 (_CBwinDestroy win @_destroyE b;
  _CBwinPaint win @_paintE b;
  _AFFfontButton _CBbutton ok @_ok b Font;
  _AFFfontButton _CBbutton cancel @_cancel b Font;
  _AFFfontText oldtext Font;
  _AFFfontText text Font;
  _paintE nil b;
  b)
;;


fun mydest(i)=_fooS i;_closemachine;;

fun main()=
 iniRename _channel nil 150 200 "rename window" @mydest "abc" ;;