use java.util.Arrays use java.util.ArrayList use java.util.Locale sysgui = unt open (sysgui)"X0" bbjapi! = bbjapi() sysgui! = bbjapi!.getSysGui() window! = sysgui!.addWindow(100,100,730,400,"MSGBOX",$00010003$) LocaleBox! = window!.addListBox(101,10,10,350,380,$$,$$) window!.addGroupBox(200,380,10,130,190,"Icon",$$) Icon0! = window!.addRadioButton(201,400,40,100,25,"No Icon",$0004$) Icon16! = window!.addRadioButton(202,400,70,100,25,"Stop Sign",$$) Icon32! = window!.addRadioButton(203,400,100,100,25,"Question",$$) Icon48! = window!.addRadioButton(204,400,130,100,25,"Exclamation",$$) Icon64! = window!.addRadioButton(205,400,160,100,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,400,250,100,25,"First",$0004$) Default256! = window!.addRadioButton(302,400,280,100,25,"Second",$$) Default512! = window!.addRadioButton(303,400,310,100,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,550,40,150,25,"OK",$0004$) Buttons1! = window!.addRadioButton(402,550,70,150,25,"OK/Cancel",$$) Buttons2! = window!.addRadioButton(403,550,100,150,25,"Abort/Retry/Ignore",$$) Buttons3! = window!.addRadioButton(404,550,130,150,25,"Yes/No/Cancel",$$) Buttons4! = window!.addRadioButton(405,550,160,150,25,"Yes/No",$$) Buttons5! = window!.addRadioButton(406,550,190,150,25,"Retry/Cancel",$$) Buttons7! = window!.addRadioButton(407,550,220,150,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,570,250,130,25,"",$$) Custom2! = window!.addEditBox(502,570,280,130,25,"",$$) Custom3! = window!.addEditBox(503,570,310,130,25,"",$$) Close! = window!.addButton(2,380,360,100,25,"Close") OK! = window!.addButton(1,490,360,100,25,"MSGBOX") Result! = window!.addStaticText(3,600,360,120,25,"") Result!.setBackColor(sysgui!.makeColor(255,255,0)) gosub init window!.setCallback(window!.ON_CLOSE,"eoj") Close!.setCallback(Close!.ON_BUTTON_PUSH,"eoj") OK!.setCallback(OK!.ON_BUTTON_PUSH,"msgbox") process_events eoj: release 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!) Message$ = fnhtml$(Message!) 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 custom then Button1! = Custom1!.getText().trim(),Button1$=fnhtml$(Button1!) Button2! = Custom2!.getText().trim(),Button2$=fnhtml$(Button2!) Button3! = Custom3!.getText().trim(),Button3$=fnhtml$(Button3!) if Button3!.length() then result = msgbox(Message$,expr,Title$,Button1$,Button2$,Button3$) else if Button2!.length() then result = msgbox(Message$,expr,Title$,Button1$,Button2$) else if Button1!.length() then result = msgbox(Message$,expr,Title$,Button1$) else result = msgbox(Message$,expr,Title$) endif endif endif switch result case 0; result$ = "None"; break case 1; result$ = Button1$+"(1)"; break case 2; result$ = Button2$+"(2)"; break case 3; result$ = Button3$+"(3)"; break case default; result$ = "Undefined "+str(result) swend else result = msgbox(Message$,expr,Title$) switch result 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: "+str(result) swend endif Result!.setText(result$) return init: default$ = Locale.getDefault().toString() default = 0 vector! = bbjapi().makeVector() list! = stbl("!LOCALES") Locales! = Arrays.asList(list!.split($0a$)) localeList! = new ArrayList() localNameList! = new ArrayList() defaultNameList! = new ArrayList() for i=0 to Locales!.size()-1 if Locales!.get(i).equals(default$) then default=i 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!) next i LocaleBox!.insertItems(-1,vector!) LocaleBox!.selectIndex(default) return def fnhtml$(string!) html! = new StringBuffer(""), html = 0 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 return html!.toString() fnend