rem ' BBjHtmlEdit::getState
client = 0
if (info(3,6)<>"5" and info(3,6)<>"6") then
client = msgbox("BBjHtmlEdit Client",7+32+512,"BBjHtmlEdit","Swing","JavaFX","Chromium")
switch client
case 1; rem ' Swing
print stbl("!OPTIONS","CHROMIUM_HTMLEDIT=FALSE",ERR=*NEXT)
print stbl("!OPTIONS","JAVAFX_HTMLEDIT=FALSE",ERR=*NEXT)
break
case 2; rem ' JavaFX
print stbl("!OPTIONS","CHROMIUM_HTMLEDIT=FALSE",ERR=*NEXT)
print stbl("!OPTIONS","JAVAFX_HTMLEDIT=TRUE",ERR=*NEXT)
break
case 3; rem ' Chromium
print stbl("!OPTIONS","CHROMIUM_HTMLEDIT=TRUE",ERR=*NEXT)
print stbl("!OPTIONS","JAVAFX_HTMLEDIT=TRUE",ERR=*NEXT)
break
swend
endif
basic = msgbox("Basic toolbar?",4+32+256) = 6
minimized = 0
minimized = msgbox("Initially minimized toolbar?",4+32+256) = 6
title$ = iff(info(3,6)="5","BUI","GUI") + " " + info(1,4)
text$ = "<html><head><style>p{margin:0;padding:0;}</style><title>BASIS</title></head><body>"
img$ = "https://www.basis.cloud/images/BusJGBetter.jpg"
text$ = text$ + "<img src="""+img$+""">"
url$ = "https://documentation.basis.cloud/BASISHelp/WebHelp/bbjobjects/Window/bbjhtmledit/BBjHtmlEdit.htm"
text$ = text$ + "<p>This is a <a href="""+url$+""">BBjHtmlEdit</a>."
text$ = text$ + "</body></html>"
text = unt
open (text,err=oops)"htmledit.html"
bytes = dec(fin(text)(1,4))
readrecord (text,siz=bytes)text$
close (unt)
oops:
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(0,25,25,850,550,title$,$00090093$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_RESIZE,"resize")
rem ' $0001$ = disabled, $0010$ = invisible
rem ' $0002$ = minimized toolbar, $0004$ = basic toolbar
flags$ = $0000$
if minimized then flags$ = ior(flags$,$0002$)
if basic then flags$ = ior(flags$,$0004$)
htmledit! = window!.addHtmlEdit(101,25,75,800,450,text$,flags$)
rem 'htmledit!.setLocale("de_DE")
print "getClientType: ",htmledit!.getClientType(err=*next)
print "getClientVersion: ",htmledit!.getClientVersion(err=*next)
title$ = window!.getTitle() + " " + htmledit!.getClientType(err=*next) + " " + htmledit!.getClientVersion(err=*next)
window!.setTitle(title$)
htmledit!.setCallback(htmledit!.ON_PAGE_LOADED,"page")
htmledit!.setCallback(htmledit!.ON_GAINED_FOCUS,"event")
htmledit!.setCallback(htmledit!.ON_LOST_FOCUS,"event")
htmledit!.setCallback(htmledit!.ON_MOUSE_ENTER,"event")
htmledit!.setCallback(htmledit!.ON_MOUSE_EXIT,"event")
htmledit!.setCallback(htmledit!.ON_POPUP_REQUEST,"event")
htmledit!.setCallback(htmledit!.ON_RIGHT_MOUSE_DOWN,"event")
htmledit!.setCallback(htmledit!.ON_EDIT_MODIFY,"event")
htmledit!.setCallback(htmledit!.ON_STATE_CHANGE,"state")
flags$ = iff(htmledit!.isEnabled(),$0004$,$0000$)
enabled! = window!.addCheckBox(1,25,25,95,25,"Enabled",flags$)
enabled!.setCallback(enabled!.ON_CHECK_ON,"enable")
enabled!.setCallback(enabled!.ON_CHECK_OFF,"disable")
flags$ = iff(htmledit!.isVisible(),$0004$,$0000$)
visible! = window!.addCheckBox(2,125,25,95,25,"Visible",flags$)
visible!.setCallback(visible!.ON_CHECK_ON,"show")
visible!.setCallback(visible!.ON_CHECK_OFF,"hide")
flags$ = iff(htmledit!.isFocusable(),$0004$,$0000$)
focusable! = window!.addCheckBox(3,225,25,95,25,"Focusable",flags$)
focusable!.setCallback(focusable!.ON_CHECK_ON,"focusable_on")
focusable!.setCallback(focusable!.ON_CHECK_OFF,"focusable_off")
flags$ = iff(htmledit!.isTabTraversable(),$0004$,$0000$)
traversable! = window!.addCheckBox(4,325,25,95,25,"Traversable",flags$)
traversable!.setCallback(traversable!.ON_CHECK_ON,"traversable_on")
traversable!.setCallback(traversable!.ON_CHECK_OFF,"traversable_off")
flags$ = iff(htmledit!.getBasicToolbar(),$0004$,$0000$)
basic! = window!.addCheckBox(5,425,25,120,25,"Basic Toolbar",flags$)
basic!.setCallback(traversable!.ON_CHECK_ON,"basic_toolbar_on")
basic!.setCallback(traversable!.ON_CHECK_OFF,"basic_toolbar_off")
focus! = window!.addToolButton(6,550,25,100,25,"Focus",$$)
focus!.setCallback(focus!.ON_TOOL_BUTTON_PUSH,"focus")
showToolbarStyles! = window!.addToolButton(7,655,25,175,25,"setBasicToolbarStyles",$$)
showToolbarStyles!.setCallback(showToolbarStyles!.ON_TOOL_BUTTON_PUSH,"showToolbarStyles")
states! = htmledit!.getAvailableStates()
java.util.Collections.sort(states!)
states$ = ""
if (states!.size() > 0) then
for i = 0 to states!.size() - 1
states$ = states$ + states!.get(i) + $0a$
next i
endif
state! = window!.addListButton(8,25,50,175,175,states$,$$)
state!.selectIndex(0)
values$ = "toggle" + $0a$ + "false" + $0a$ + "true" +$0a$
stateValue! = window!.addListButton(9,225,50,175,175,values$,$$)
stateValue!.selectIndex(0)
setState! = window!.addButton(10,425,50,175,25,"setState",$$)
setState!.setCallback(setState!.ON_BUTTON_PUSH,"setState")
getAvailableStates! = window!.addToolButton(11,655,50,175,25,"getAvailableStates",$$)
getAvailableStates!.setCallback(getAvailableStates!.ON_TOOL_BUTTON_PUSH,"getAvailableStates")
window!.setVisible(1)
x = window!.getX() + window!.getWidth()
y = window!.getY()
w = 500
h = window!.getHeight()
styles! = sysgui!.addWindow(1,x,y,w,h,"toolbarStyles",$00090093$)
styles!.setCallback(styles!.ON_CLOSE,"hideToolbarStyles")
allStyles! = htmledit!.getAllToolbarStyles()
java.util.Collections.sort(allStyles!)
basicStyles! = new java.util.HashSet(htmledit!.getBasicToolbarStyles())
x = 25
y = 25
w = 175
h = 25
styles = allStyles!.size()
if (styles) then
for style = 0 to styles - 1
style$ = allStyles!.get(style)
flags$ = iff(basicStyles!.contains(style$),$0004$,$0000$)
style! = styles!.addCheckBox(style+100,x,y,w,h,style$,flags$)
style!.setCallback(style!.ON_CHECK_ON,"addBasicStyle")
style!.setCallback(style!.ON_CHECK_OFF,"removeBasicStyle")
y = y + h
if y > 500 then y = 25, x = x + w
next style
endif
process_events
eoj:
release
page:
gosub event
rem 'print event!.getControl().getText()
return
resize:
gosub event
width = event!.getWidth()
height = event!.getHeight()
htmledit!.setSize(width-50,height-100)
print width,height
return
state:
event! = sysgui!.getLastEvent()
msg$ = event!.getState()+" = "+Boolean.toString(event!.getValue())
gosub event
i = msgbox(msg$,0,event!.getEventName())
return
event:
event! = sysgui!.getLastEvent()
control! = event!.getControl()
event$ = event!.getEventName()+" "+str(control!)
print event$
System.err.println(event$)
return
enable:
htmledit!.setEnabled(1)
return
disable:
htmledit!.setEnabled(0)
return
show:
htmledit!.setVisible(1)
return
hide:
htmledit!.setVisible(0)
return
focusable_on:
htmledit!.setFocusable(1)
return
focusable_off:
htmledit!.setFocusable(0)
return
traversable_on:
htmledit!.setTabTraversable(1)
return
traversable_off:
htmledit!.setTabTraversable(0)
return
basic_toolbar_on:
htmledit!.setBasicToolbar(1)
return
basic_toolbar_off:
htmledit!.setBasicToolbar(0)
return
focus:
htmledit!.focus()
return
showToolbarStyles:
styles!.setVisible(1)
styles!.focus()
return
hideToolbarStyles:
styles!.setVisible(0)
window!.focus()
return
getAvailableStates:
states! = htmledit!.getAvailableStates()
java.util.Collections.sort(states!)
states$ = ""
if (states!.size() > 0) then
for i = 0 to states!.size() - 1
state$ = states!.get(i)
states$ = states$ + state$ + " = " + Boolean.toString(htmledit!.getState(state$)) + $0a$
next i
endif
i = msgbox(states$,0,"getAvailableStates")
return
setState:
state$ = state!.getText()
value$ = stateValue!.getText().toLowerCase()
value! = null()
switch value$
case "toggle"; value! = null(); break
case "true"; value! = Boolean.TRUE; break
case "false"; value! = Boolean.FALSE; break
case default; escape
swend
print state$," = ",stateValue!.getText()," = ",value!
System.err.println(state$+" = "+stateValue!.getText()+" = "+str(value!))
if len(state$) htmledit!.setState(state$,value!)
return
addBasicStyle:
style$ = sysgui!.getLastEvent().getControl().getText()
rem 'print "addBasicStyle ",style$
basicStyles!.add(style$)
gosub setBasicToolbarStyles
return
removeBasicStyle:
style$ = sysgui!.getLastEvent().getControl().getText()
rem 'print "removeBasicStyle ",style$
basicStyles!.remove(style$)
gosub setBasicToolbarStyles
return
setBasicToolbarStyles:
vector! = bbjapi().makeVector()
iter! = basicStyles!.iterator()
while iter!.hasNext()
vector!.add(iter!.next())
wend
print "htmledit!.setBasicToolbarStyles(",vector!,")"
htmledit!.setBasicToolbarStyles(vector!)
return
|