Here is my solution for ask dialog with more than 3 buttons

Discussions related to Visual Prolog
User avatar
Ferenc Nagy
VIP Member
Posts: 343
Joined: 24 Apr 2007 12:26

Here is my solution for ask dialog with more than 3 buttons

Unread post by Ferenc Nagy » 22 Oct 2014 12:24

Here is my solution.
It works well as long as the ButtonTitles fit in the rectangles.
C:\Users\nagy\Documents\Visual Prolog Projects\Colorful Reports\Extended_Dialog\ExtendedCommonDialogs.cl

Code: Select all

% 2014 Ferenc Nagy Budapest, Hungary % 2014.10.21. Extended common dialogs class extendedCommonDialogs     open core   predicates     % Ask with more than 3 answers.     ask : (string Title, string Prompt, string* ButtonTitlesList, integer Default) -> integer Answer.   end class extendedCommonDialogs
C:\Users\nagy\Documents\Visual Prolog Projects\Colorful Reports\Extended_Dialog\ExtendedCommonDialogs.pro

Code: Select all

% 2014 Ferenc Nagy Budapest, Hungary   implement extendedCommonDialogs     open core,vpiDomains,vpiCommonDialogs   class facts     ask_result:integer := 0.   clauses     ask(Title, Prompt, ButtonTitlesList,Default) = ask_result :-         L=list::length(ButtonTitlesList),         Rct=rct(50,40,265,40+20*L),         FontDef=dlgFont(             wdef(wd_Modal,RCT,Title,u_DlgBase),"Arial",8,[wsf_TitleBar]),         Static=ctl(             wdef(wc_Text,rct(2,2,152,20*list::length(ButtonTitlesList)),                 Prompt,u_DlgBase),10001,[wsf_AlignLeft]),         Flags=[wsf_Group,wsf_TabStop],         FlagsD=[wsf_Default|Flags],         Ctl_List=             [             CtlI             ||             I=std::fromTo(0,L-1),             if I=Default then FLagsI=Flags else FLagsI=FlagsD end if,             ButtonTitle=list::nth(convert(positive,I),ButtonTitlesList),             CtlI=ctl(                     wdef(wc_PushButton,rct(155,5+20*I,210,17+20*I),ButtonTitle,u_DlgBase),                     I,FlagsI)             ],         Parent=vpi::getParentWindow(),         _ = vpi::winCreateDynDialog(Parent,[FontDef,Static|Ctl_List],             dlg_ask_eh,gui_api::lNull).   class predicates     dlg_ask_eh : ehandler. clauses     dlg_ask_eh(Win,e_Control(I,_,_,_CtrlInfo)) = gui_api::rNull:-         ask_result := I,         vpi::winDestroy(Win).   end implement extendedCommonDialogs
Attachments
Ask4.GIF
Here is the dialog.
Ask4.GIF (20.17 KiB) Viewed 2176 times
TIA, Regards,
Frank Nagy

Post Reply