REM getFontsScaled
REM Obtain the instance of the BBjAPI object LET myAPI!=BBjAPI()
REM Open the SysGui device SYSGUI=UNT OPEN (SYSGUI)"X0"
REM Obtain the instance of the BBjSysGui object LET mySysGui!=myAPI!.getSysGui()
REM Set addWindow param values X=100 Y=100 WIDTH=400 HEIGHT=300 TITLE$="BBjFontChooser"
REM Create a window myWindow! = mySysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$,$00010003$)
REM Add a "fonts scaled?" checkbox myCheckBox! = myWindow!.addCheckBox(100,10,10,100,20,"Fonts scaled?")
REM Add a font chooser on the window myFontChooser! = myWindow!.addFontChooser(101,0,30,WIDTH,HEIGHT-30)
REM Initialize the Fonts Scaled value gosub fonts_scaled
REM Register the CALLBACK routines CALLBACK(ON_CHECK_ON,FONTS_SCALED,mySysGui!.getContext(),myCheckBox!.getID()) CALLBACK(ON_CHECK_OFF,FONTS_SCALED,mySysGui!.getContext(),myCheckBox!.getID()) CALLBACK(ON_FONTCHOOSER_APPROVE,APPROVE,mySysGui!.getContext(),myFontChooser!.getID()) CALLBACK(ON_FONTCHOOSER_CANCEL,CANCEL,mySysGui!.getContext(),myFontChooser!.getID()) CALLBACK(ON_RESIZE,RESIZE,mySysGui!.getContext()) CALLBACK(ON_CLOSE,CANCEL,mySysGui!.getContext())
REM Process Events PROCESS_EVENTS
FONTS_SCALED: myFontChooser!.setFontsScaled(myCheckBox!.isSelected()) print "Fonts scaled?",myFontChooser!.getFontsScaled() RETURN
RESIZE: myFontChooser!.setSize(myWindow!.getWidth(),myWindow!.getHeight()-30) RETURN
REM Callback routine called when the fontchooser's OK button is pressed APPROVE: REM Display a message with the approprate font gosub FontInfo message$="<html><head><style type='text/css'>p{font:"+html$+"}</style></head><body><p>"+info$+"</p></body></html>" LET X=MSGBOX(MESSAGE$,0,"Selected Font") RELEASE
FontInfo: Font!=myFontChooser!.getSelectedFont() name$=Font!.getName() style=Font!.getStyle() size=Font!.getSize() if style=0 then style$="Plain" html$=str(size)+"px "+name$ else style$="" if fnIsBitSet(style,Font!.FONT_BOLD) then style$=style$+"Bold " endif if fnIsBitSet(style,Font!.FONT_ITALIC) then style$=style$+"Italic " endif style$=cvs(style$,3) html$=cvs(style$,8)+" "+str(size)+"px "+name$ endif info$=name$+" "+style$+" "+str(size) return
def fnIsBitSet(value,bit) return sgn(dec(and(bin(value,4),bin(bit,4)))) fnend
REM Callback routine called when the fontchooser's Cancel button is REM pressed or the window is closed without selecting a font CANCEL: RELEASE
|