% 2014 Ferenc Nagy Budapest, Hungary implement extendedCommonDialogs open core,vpi,vpiDomains,vpiCommonDialogs class facts timeout: positive := max_timeout. % Timeout of dialog in seconds. myTimer : timerId := erroneous. % идентификатор таймера ask_result:integer := 0. default: positive :=0. right: integer:=265. %<== Fact for determination of the necessary width. bottom:integer:=0. %<== Fact for determination of the necessary bottom. % 2016.05.12. constants % Alignment of button titles. alignment :wsflag = wsf_AlignCenter. class facts - height_correction % 2016.04.24. % Height factor. height_factor : real :=1.5. % Fixed additon to text height. height_plus : positive:= 5. % Vertical gap between buttons. vertical_gap : positive := 10. predicates clauses ask(Title,Prompt,ButtonTitlesList,Default) = ask_result :- L=list::length(ButtonTitlesList), bottom:=2, Parent=vpi::getParentWindow(), ParentFont=winGetFont(Parent), fontGetAttrs(ParentFont,_,_)=FontName, Flags=[wsf_Group,wsf_TabStop,alignment ], FlagsD=[wsf_Default|Flags], winGetTextExtent(Parent,"WW",WW,_), Ctl_List= [ CtlI || I=std::fromTo(0,L-1), if I=Default then FlagsI=FlagsD else FLagsI=Flags end if, ButtonTitle=list::nth(convert(positive,I),ButtonTitlesList), % 2016.04.01. These lines determine the necessary with and height of the buttons based on the estimated text extent. winGetTextExtent(Parent,ButtonTitle,WT,H), Right=155+WT+WW, Top=bottom, Bottom=bottom+math::round(H*height_factor)+height_plus, right:=math::max(Right,right), CtlI=ctl( wdef(wc_PushButton,rct(155,Top,Right,Bottom),ButtonTitle,u_DlgBase), I,FlagsI), bottom:=Bottom+vertical_gap ], % 2016.04.24. Equalize control widths. Mod_Ctl_List = [ Mod_Ctl || ctl( wdef(wc_PushButton,rct(Left0,Top0,_Right0,Bottom0),ButtonTitle,u_DlgBase), I,FlagsI) in Ctl_List, Mod_Ctl=ctl( wdef(wc_PushButton,rct(Left0,Top0,right,Bottom0),ButtonTitle,u_DlgBase), I,FlagsI) ], % 2016.04.01. Final stretch of the window rectangle. RCT=rct(50,40,right+60,bottom+40), Static=ctl( wdef(wc_Text,rct(2,2,152,bottom-2), Prompt,u_DlgBase),10001,[alignment]), FontDef=dlgFont( wdef(wd_Modal,RCT,Title,u_DlgBase),FontName,8,[wsf_TitleBar]), default:=math::min(L-1,Default), _ = vpi::winCreateDynDialog(Parent,[FontDef,Static|Mod_Ctl_List], dlg_ask_eh,gui_api::lNull). class predicates dlg_ask_eh : ehandler. clauses dlg_ask_eh(Win,e_Create(_))=gui_api::rNull :- H=winGetCtlHandle(Win,convert(ctlId,default)), % Added on 2016.05.12. if timeout