rem ' BBjDrawPanel::getDrawPanelImage
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
x = 50, y = 50, w = 400, h = 250
title$ = "BBjDrawPanel::getDrawPanelImage"
window! = sysgui!.addWindow(x,y,w,h,title$,$00090883$,$$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setTrack(0)
window!.setScribble(1)
menu! = window!.addMenuBar()
file! = menu!.addMenu(100,"&File")
wipe! = file!.addMenuItem(101,"&New")
wipe!.setCallback(wipe!.ON_MENU_ITEM_SELECT,"wipe")
save! = file!.addMenuItem(102,"Save &As...")
save!.setCallback(wipe!.ON_MENU_ITEM_SELECT,"save")
exit! = file!.addMenuItem(199,"E&xit")
exit!.setCallback(exit!.ON_MENU_ITEM_SELECT,"eoj")
drawpanel! = window!.getDrawPanel()
color! = sysgui!.makeColor(255,255,240)
drawpanel!.clearDrawing(color!)
drawpanel!.setPenColor(BBjColor.BLUE)
drawpanel!.setPenWidth(3)
format$ = "png"
process_events
eoj:
release
wipe:
drawpanel!.clearDrawing()
return
save:
file$ = "Signature."+format$
file$ = filesave("Save Signature",dsk("")+dir(""),file$,"")
if pos("::"=file$) then return
file! = new java.io.File(file$)
file$ = file!.getCanonicalPath()
path! = file!.getCanonicalPath().toLowerCase()
if path!.endsWith(".gif") then format$ = "gif"
if path!.endsWith(".png") then format$ = "png"
if path!.endsWith(".jpg") then format$ = "jpg"
if path!.endsWith(".jpeg") then format$ = "jpeg"
image! = window!.getDrawPanelImage()
image$ = image!.getBytes(format$,err = failed)
image = unt
open (image,mode="O_CREATE,O_TRUNC")file$
writerecord (image)image$
close (image)
i = msgbox(file$,0,"Signature image file created")
return
failed:
i = msgbox(errmes(-1),16,"Signature image file failed")
return
|