rem ' msgbox & prompt sysgui = unt open (sysgui)"X0" bbjapi! = bbjapi() sysgui! = bbjapi!.getSysGui() window! = sysgui!.addWindow(10,10,730,525,"MSGBOX & PROMPT",$00090083$) window!.setCallback(window!.ON_CLOSE,"eoj") LocaleBox! = window!.addListBox(100,10,10,350,340,$$,$$) x$ = "", y$ = "", w$ = $$, h$ = $$, html = 0 window!.addStaticText(101,0,365,25,25,"&X:",$8000$) x! = window!.addEditBox(102,30,360,50,25,"",$$) x!.setToolTipText("X location of dialog") x!.setCallback(x!.ON_EDIT_MODIFY,"x") window!.addStaticText(103,90,365,25,25,"&Y:",$8000$) y! = window!.addEditBox(104,120,360,50,25,"",$$) y!.setToolTipText("Y location of dialog") y!.setCallback(y!.ON_EDIT_MODIFY,"y") window!.addStaticText(105,180,365,25,25,"&W:",$8000$) w! = window!.addEditBox(106,210,360,50,25,"",$$) w!.setToolTipText("Maximum width of content") w!.setCallback(w!.ON_EDIT_MODIFY,"w") window!.addStaticText(107,270,365,25,25,"&H:",$8000$) h! = window!.addEditBox(108,300,360,50,25,"",$$) h!.setToolTipText("Maximum height of content") h!.setCallback(h!.ON_EDIT_MODIFY,"h") window!.addStaticText(109,360,365,75,25,"Extra &rows:",$8000$) rows! = window!.addInputNSpinner(110,440,360,75,25,0,5000) rows!.setCallback(rows!.ON_SPIN,"rows") rows!.setToolTipText("Extra rows of content") rows!.setCallback(rows!.ON_EDIT_MODIFY,"rows") rows = 0 window!.addStaticText(111,525,365,75,25,"Extra &cols:",$8000$) cols! = window!.addInputNSpinner(112,605,360,75,25,0,2000) cols!.setCallback(cols!.ON_SPIN,"cols") cols!.setToolTipText("Extra columns of content") cols!.setCallback(cols!.ON_EDIT_MODIFY,"cols") cols = 0 rem ' config.bbx: SET !OPTIONS=NATIVE_BROWSER_MSGBOX=TRUE native_dialog$ = stbl("!OPTIONS","NATIVE_BROWSER_MSGBOX") native_dialog = sgn(pos("TRUE"=native_dialog$)) flags$ = iff(native_dialog,$0004$,$0000$) native_dialog! = window!.addCheckBox(113,10,400,110,25,"&Native dialog",flags$) native_dialog!.setToolTipText("BUI: Use native browser dialog for OK and OK/Cancel") native_dialog!.setCallback(native_dialog!.ON_CHECK_ON,"native_dialog_true") native_dialog!.setCallback(native_dialog!.ON_CHECK_OFF,"native_dialog_false") use_html! = window!.addCheckBox(114,120,400,120,25,"HTML content",$0000$) use_html!.setToolTipText("Always set MSGBOX content using html") use_html!.setCallback(use_html!.ON_CHECK_ON,"use_html_true") use_html!.setCallback(use_html!.ON_CHECK_OFF,"use_html_false") window!.addStaticText(115,245,405,60,25,"&Timeout:",$8000$) timeout! = window!.addInputNSpinner(116,310,400,50,25,0,10) timeout!.setCallback(timeout!.ON_SPIN,"timeout") timeout!.setCallback(timeout!.ON_EDIT_MODIFY,"timeout") timeout!.setToolTipText("MSGBOX timeout (seconds)") timeout = 0 disable_html! = window!.addCheckBox(117,120,435,120,25,"&Disable HTML",$0000$) disable_html!.setToolTipText("Render HTML content as raw text") disable_html!.setCallback(disable_html!.ON_CHECK_ON,"disable_html_true") disable_html!.setCallback(disable_html!.ON_CHECK_OFF,"disable_html_false") window!.addStaticText(118,245,440,60,25,"&Modes:",$8000$) modes$ = "theme=primary" mode! = window!.addEditBox(119,310,430,410,25,modes$,$$) mode!.setToolTipText("Add comma-separated modes/attributes here.") window!.addGroupBox(200,380,10,130,190,"Icon",$$) Icon0! = window!.addRadioButton(201,390,40,110,25,"No Icon",$0004$) Icon16! = window!.addRadioButton(202,390,70,110,25,"Stop Sign",$$) Icon32! = window!.addRadioButton(203,390,100,110,25,"Question",$$) Icon48! = window!.addRadioButton(204,390,130,110,25,"Exclamation",$$) Icon64! = window!.addRadioButton(205,390,160,110,25,"Information",$$) IconGroup! = window!.addRadioGroup() IconGroup!.add(Icon0!) IconGroup!.add(Icon16!) IconGroup!.add(Icon32!) IconGroup!.add(Icon48!) IconGroup!.add(Icon64!) window!.addGroupBox(300,380,220,130,130,"Default Button",$$) Default0! = window!.addRadioButton(301,390,250,110,25,"First",$0004$) Default256! = window!.addRadioButton(302,390,280,110,25,"Second",$$) Default512! = window!.addRadioButton(303,390,310,110,25,"Third",$$) DefaultGroup! = window!.addRadioGroup() DefaultGroup!.add(Default0!) DefaultGroup!.add(Default256!) DefaultGroup!.add(Default512!) window!.addGroupBox(400,530,10,190,340,"Buttons",$$) Buttons0! = window!.addRadioButton(401,540,40,160,25,"OK",$0004$) Buttons1! = window!.addRadioButton(402,540,70,160,25,"OK/Cancel",$$) Buttons2! = window!.addRadioButton(403,540,100,160,25,"Abort/Retry/Ignore",$$) Buttons3! = window!.addRadioButton(404,540,130,160,25,"Yes/No/Cancel",$$) Buttons4! = window!.addRadioButton(405,540,160,160,25,"Yes/No",$$) Buttons5! = window!.addRadioButton(406,540,190,160,25,"Retry/Cancel",$$) Buttons7! = window!.addRadioButton(407,540,220,160,25,"Custom",$$) ButtonsGroup! = window!.addRadioGroup() ButtonsGroup!.add(Buttons0!) ButtonsGroup!.add(Buttons1!) ButtonsGroup!.add(Buttons2!) ButtonsGroup!.add(Buttons3!) ButtonsGroup!.add(Buttons4!) ButtonsGroup!.add(Buttons5!) ButtonsGroup!.add(Buttons7!) Custom1! = window!.addEditBox(501,540,250,170,25,"&1",$$) Custom2! = window!.addEditBox(502,540,280,170,25,"&2",$$) Custom3! = window!.addEditBox(503,540,310,170,25,"&3",$$) Close! = window!.addButton(2,380,400,100,25,"Close") Close!.setCallback(Close!.ON_BUTTON_PUSH,"eoj") Msgbox! = window!.addButton(1,490,400,110,25,"MSGBOX()") Msgbox!.setCallback(Msgbox!.ON_BUTTON_PUSH,"msgbox") Prompt! = window!.addButton(3,610,400,110,25,"PROMPT()") Prompt!.setCallback(Prompt!.ON_BUTTON_PUSH,"prompt") imagefile! = window!.addButton(120,10,470,120,25,"Image File",$$) imagefile!.setCallback(imagefile!.ON_BUTTON_PUSH,"imagefile") iconwidth! = window!.addEditBox(121,140,470,50,25,"",$$) iconwidth!.setToolTipText("Scaled icon width") iconheight! = window!.addEditBox(122,200,470,50,25,"",$$) iconheight!.setToolTipText("Scaled icon height") window!.addStaticText(128,250,470,50,25,"Icon:",$8000$) icon$ = "" icon! = window!.addEditBox(129,310,470,410,25,icon$,$$) icon!.setToolTipText("Specify a custom icon here.") status! = window!.addStatusBar(99) gosub init process_events eoj: release native_dialog_true: native_dialog$="TRUE" native_dialog$ = stbl("!OPTIONS","NATIVE_BROWSER_MSGBOX="+native_dialog$) return native_dialog_false: native_dialog$="FALSE" native_dialog$ = stbl("!OPTIONS","NATIVE_BROWSER_MSGBOX="+native_dialog$) return use_html_true: html = 1 return use_html_false: html = 0 return disable_html_true: disable_html = 1 return disable_html_false: disable_html = 0 return msgbox: Locale = LocaleBox!.getSelectedIndex() if Locale<0 then Locale$ = stbl("!LOCALE",Locale.getDefault().toString()) Locale! = Locale.getDefault() Message! = Locale!.getDisplayName(Locale!) Title! = Locale!.getDisplayName() else Locale$ = stbl("!LOCALE",Locales!.get(Locale)) Locale! = LocaleList!.get(Locale) Message! = localNameList!.get(Locale) Title! = defaultNameList!.get(Locale) endif Title$ = fnhtml$(Title!,html) if rows then for i = 1 to rows extra$ = fill(cols,"row"+str(i)+",") Message! = Message!.concat($0a$).concat(extra$) next i endif Message$ = fnhtml$(Message!,html) expr = 0, custom = 0 switch ButtonsGroup!.getSelected().getID() case Buttons0!.getID(); break case Buttons1!.getID(); expr=1; break case Buttons2!.getID(); expr=2; break case Buttons3!.getID(); expr=3; break case Buttons4!.getID(); expr=4; break case Buttons5!.getID(); expr=5; break case Buttons7!.getID(); expr=7,custom=1; break case default; escape swend switch IconGroup!.getSelected().getID() case Icon0!.getID(); break case Icon16!.getID(); expr=expr+16; break case Icon32!.getID(); expr=expr+32; break case Icon48!.getID(); expr=expr+48; break case Icon64!.getID(); expr=expr+64; break case default; escape swend switch DefaultGroup!.getSelected().getID() case Default0!.getID(); break case Default256!.getID(); expr=expr+256; break case Default512!.getID(); expr=expr+512; break case default; escape swend if disable_html then expr=expr+32768 mode$ = "x="+x$+",y="+y$+",w="+w$+",h="+h$ if len(mode!.getText().trim()) then mode$ = mode$ + "," +mode!.getText().trim() iconwidth$ = iconwidth!.getText().trim() if len(iconwidth$) then mode$ = mode$ + ",iconwidth=" + iconwidth$ iconheight$ = iconheight!.getText().trim() if len(iconheight$) then mode$ = mode$ + ",iconheight=" + iconheight$ icon$ = icon!.getText().trim() if pos(","=icon$) then icon$ = """" + icon$ + """" if len(icon$) then mode$ = mode$ + ",icon=" + icon$ print mode$ if custom then Button1! = Custom1!.getText().trim(),Button1$=fnhtml$(Button1!,html) Button2! = Custom2!.getText().trim(),Button2$=fnhtml$(Button2!,html) Button3! = Custom3!.getText().trim(),Button3$=fnhtml$(Button3!,html) if Button3!.length() then result = msgbox(Message$,expr,Title$,Button1$,Button2$,Button3$,tim=timeout,mode=mode$,err=oops) else if Button2!.length() then result = msgbox(Message$,expr,Title$,Button1$,Button2$,tim=timeout,mode=mode$,err=oops) else if Button1!.length() then result = msgbox(Message$,expr,Title$,Button1$,tim=timeout,mode=mode$,err=oops) else result = msgbox(Message$,expr,Title$,tim=timeout,mode=mode$,err=oops) endif endif endif switch result case -1; result$ = "Timeout"; break case 0; result$ = "None"; break case 1; result$ = Button1$; break case 2; result$ = Button2$; break case 3; result$ = Button3$; break case default; result$ = "Undefined" swend else result = msgbox(Message$,expr,Title$,tim=timeout,mode=mode$,err=oops) switch result case -1; result$ = "Timeout"; break case 0; result$ = "None"; break case 1; result$ = "OK"; break case 2; result$ = "Cancel"; break case 3; result$ = "Abort"; break case 4; result$ = "Retry"; break case 5; result$ = "Ignore"; break case 6; result$ = "Yes"; break case 7; result$ = "No"; break case default; result$ = "Undefined" swend endif result$ = "MSGBOX result = " + result$ + " ("+str(result)+")" status!.setText(result$) return oops: result = msgbox(errmes(-1),48,"*** ERROR ***") return prompt: Locale = LocaleBox!.getSelectedIndex() if Locale<0 then Locale$ = stbl("!LOCALE",Locale.getDefault().toString()) Locale! = Locale.getDefault() Message! = Locale!.getDisplayName(Locale!) Title! = Locale!.getDisplayName() else Locale$ = stbl("!LOCALE",Locales!.get(Locale)) Locale! = LocaleList!.get(Locale) Message! = localNameList!.get(Locale) Title! = defaultNameList!.get(Locale) endif Title$ = fnhtml$(Title!,html) Default$ = Title$ if rows then for i = 1 to rows extra$ = fill(cols,"row"+str(i)+",") Message! = Message!.concat($0a$).concat(extra$) next i endif Message$ = fnhtml$(Message!,html) expr = 0 switch IconGroup!.getSelected().getID() case Icon0!.getID(); break case Icon16!.getID(); expr=expr+16; break case Icon32!.getID(); expr=expr+32; break case Icon48!.getID(); expr=expr+48; break case Icon64!.getID(); expr=expr+64; break case default; escape swend mode$ = "x="+x$+",y="+y$+",w="+w$+",h="+h$ if len(mode!.getText().trim()) then mode$ = mode$ + "," +mode!.getText().trim() iconwidth$ = iconwidth!.getText().trim() if len(iconwidth$) then mode$ = mode$ + ",iconwidth=" + iconwidth$ iconheight$ = iconheight!.getText().trim() if len(iconheight$) then mode$ = mode$ + ",iconheight=" + iconheight$ icon$ = icon!.getText().trim() if pos(","=icon$) then icon$ = """" + icon$ + """" if len(icon$) then mode$ = mode$ + ",icon=" + icon$ print mode$ result$ = prompt(Message$,Default$,Title$,expr,tim=timeout,mode=mode$,err=oops) result$ = "PROMPT result = " + result$ status!.setText(result$) return use java.util.Arrays use java.util.ArrayList use java.util.Locale init: default$ = Locale.getDefault().toString() default! = default$ vector! = bbjapi().makeVector() list! = stbl("!LOCALES") Locales! = Arrays.asList(list!.split($0a$)) java.util.Collections.sort(Locales!) localeList! = new ArrayList() localNameList! = new ArrayList() defaultNameList! = new ArrayList() for i=0 to Locales!.size()-1 temp! = Arrays.asList(Locales!.get(i).split("_",3)) switch temp!.size() case 3; Locale! = new Locale(temp!.get(0),temp!.get(1),temp!.get(2)); break case 2; Locale! = new Locale(temp!.get(0),temp!.get(1)); break case 1; Locale! = new Locale(temp!.get(0)); break case default; Locale! = Locale.getDefault(); break swend localeList!.add(Locale!) language$ = Locale!.getLanguage() localName! = new String(Locale!.getDisplayName(Locale!).getBytes("UTF-8"),"UTF-8") defaultName! = new String(Locale!.getDisplayName().getBytes("UTF-8"),"UTF-8") unicode! = localName!.concat(" - ").concat(defaultName!) vector!.add(unicode!) localNameList!.add(localName!) defaultNameList!.add(defaultName!) if Locales!.get(i).equals(default$) then default!=unicode! next i LocaleBox!.insertItems(-1,vector!) default = vector!.indexOf(default!) LocaleBox!.selectIndex(default) return def fnhtml$(string!,_html) html! = new StringBuffer("") if string!.length() then for i=0 to string!.length()-1 c = string!.codePointAt(i) if c<128 then html!.append(chr(c)) else html!.append("&#").append(str(c)).append(";"); _html=1 next i if _html then html!.insert(0,"

>") endif endif print string!," = ",html! if _html then return html!.toString().replaceAll($0a$,"
") return html!.toString() fnend timeout: event! = sysgui!.getLastEvent() timeout = num(event!.getText()) return rows: event! = sysgui!.getLastEvent() rows = num(event!.getText()) return cols: event! = sysgui!.getLastEvent() cols = num(event!.getText()) return x: event! = sysgui!.getLastEvent() x$ = event!.getText() return y: event! = sysgui!.getLastEvent() y$ = event!.getText() return w: event! = sysgui!.getLastEvent() w$ = event!.getText() return h: event! = sysgui!.getLastEvent() h$ = event!.getText() return imagefile: filter$ = "Images"+$0a$+"*.png;*.jpg;*.jpeg;*.gif;*.tif;*.tiff" filter$ = filter$ + $0a$ + "All Files (*.*)"+$0a$+"*.*" clientfile$ = fileopen("Image File","","","",filter$,mode="client,style=style") if pos("::"=clientfile$) then icon!.setText(""); return tc! = bbjapi().getThinClient() fs! = tc!.getClientFileSystem() cf! = fs!.getClientFile(clientfile$) rem ' The Java Swing GUI client doesn't understand data urls if info(3,6)="5" or info(3,6)="6" then bytes! = cf!.getContents() base64$=java.util.Base64.getMimeEncoder().encode(bytes!) url$ = "data:image/png;base64,"+base64$ icon!.setText(url$) else imagefile$ = cf!.copyFromClient() icon!.setText(imagefile$) endif return