rem ' BBjFontChooser
if info(3,6)<>"5" and info(3,6)<>"6" then goto skip
rem ' Google Fonts test ("Bungee Spice" selected because it's distinctive)
rem ' https://fonts.google.com/specimen/Bungee+Spice?query=bungee+spice
rem <link rel="preconnect" href="https://fonts.googleapis.com">
rem <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
rem <link href="https://fonts.googleapis.com/css2?family=Bungee+Spice&display=swap" rel="stylesheet">
rem ' Firefox tracking protection can block Google Fonts:
rem ' https://developer.mozilla.org/en-US/docs/Web/Privacy/Firefox_tracking_protection
web! = bbjapi().getWebManager()
web!.setCallback(web!.ON_LINK_LOADED,"event")
web!.setCallback(web!.ON_LINK_FAILED,"event")
bbjapi().getWebManager().injectLinkUrl("https://fonts.googleapis.com",1,"rel=""preconnect""")
bbjapi().getWebManager().injectLinkUrl("https://fonts.gstatic.com",1,"rel=""preconnect""")
url$ = "https://fonts.googleapis.com/css2?family=Bungee+Spice&display=swap"
top = 1
attr$ = "rel=""stylesheet"""
bbjapi().getWebManager().injectLinkUrl(url$,top,attr$)
skip:
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
width = 500, height = 400
title$ = "BBjFontChooser"
window! = sysgui!.addWindow(25,25,width+50,height+100,title$,$00090083$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_RESIZE,"resize")
fontchooser! = window!.addFontChooser(101,25,25,width,height)
fontchooser!.setCallback(fontchooser!.ON_FONTCHOOSER_CHANGE,"change")
fontchooser!.setCallback(fontchooser!.ON_FONTCHOOSER_APPROVE,"approve")
fontchooser!.setCallback(fontchooser!.ON_FONTCHOOSER_CANCEL,"cancel")
rem fontchooser!.setCallback(fontchooser!.ON_GAINED_FOCUS,"event")
rem fontchooser!.setCallback(fontchooser!.ON_LOST_FOCUS,"event")
rem fontchooser!.setCallback(fontchooser!.ON_MOUSE_ENTER,"event")
rem fontchooser!.setCallback(fontchooser!.ON_MOUSE_EXIT,"event")
fontchooser!.setPreviewMessage("The quick brown fox jumps over the lazy dog.")
button! = window!.addButton(1,width+25-120,height+50,120,25,"Random",$$)
button!.setCallback(button!.ON_BUTTON_PUSH,"random")
status! = window!.addStatusBar(99)
families! = fontchooser!.getFontFamilies()
rem i = msgbox(str(families!),0,"getFontFamilies")
sizes! = fontchooser!.getFontSizes()
rem i = msgbox(str(sizes!),0,"getFontSizes")
families! = new BBjVector()
restore families
while 1
dread family$,err=*break
if family$ = "" then break
families!.add(family$)
wend
rem i = msgbox(str(families!),0,"setFontFamilies")
fontchooser!.setFontFamilies(families!)
sizes! = new BBjVector()
restore sizes
while 1
dread size,err=*break
if size = 0 then break
sizes!.add(size)
wend
rem i = msgbox(str(sizes!),0,"setFontSizes")
fontchooser!.setFontSizes(sizes!)
gosub random
rem families! = fontchooser!.getFontFamilies()
rem i = msgbox(str(families!),0,"getFontFamilies")
rem sizes! = fontchooser!.getFontSizes()
rem i = msgbox(str(sizes!),0,"getFontSizes")
dim event$:tmpl(sysgui)
process_events
families:
data "Andale Mono", "Arial", "Bungee Spice", "Comic Sans MS", "Courier New", "Cursive", "Fantasy", "Georgia", "Impact", "Monospace", "Sans-Serif", "Serif", "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana", "Webdings", ""
sizes:
data 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 0
eoj:
release
status:
status!.setText(status$)
print status$
System.err.println(status$)
return
resize:
event! = sysgui!.getLastEvent()
fontchooser!.setSize(event!.getWidth()-50,event!.getHeight()-80)
button!.setLocation(event!.getWidth()-120-25,event!.getHeight()-30)
status$ = event!.getEventName()+" width="+str(event!.getWidth())+",height="+str(event!.getHeight())
gosub status
return
random:
families! = fontchooser!.getFontFamilies()
family$ = families!.get(rnd(families!.size()))
size = sizes!.get(rnd(sizes!.size()))
style = rnd(4)
font! = sysgui!.makeFont(family$,size,style)
status$ = "setSelectedFont "+str(font!)
gosub status
fontchooser!.setSelectedFont(font!)
return
change:
event! = sysgui!.getLastEvent()
event$ = event!.getEventName()
status$ = event$+": "+str(event!.getFont())
gosub status
return
approve:
event! = sysgui!.getLastEvent()
event$ = event!.getEventName()
status$ = event$+": "+str(event!.getFont())
gosub status
return
cancel:
event! = sysgui!.getLastEvent()
event$ = event!.getEventName()
status$ = event$
gosub status
return
event:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
event$ = event.code$+" "+event!.getEventName()
event$ = event$ + " " + event!.getUrl(err=*next)
status$ = event$
gosub status
return
def fnmode$(mode$)
if mode$="0" then return "Fat Client"
if mode$="1" then return "Thin Client"
if mode$="2" then return "Java Applet"
if mode$="3" then return "Java Web Start"
if mode$="4" then return "JavaBBjBridge"
if mode$="5" then return "BUI (Browser)"
if mode$="6" then return "DWC (Browser)"
return mode$
fnend
|