rem ' CSS sampler
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(50,50,325,500,"CSS Sampler",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
text$ = "The quick brown fox jumps over the lazy dog."
edit! = window!.addEditBox(100,25,25,275,50,text$,$$)
edit!.setName("MyEditBox")
print edit!.getName()
popupMenu! = edit!.addPopupMenu()
popupMenu!.setName("MyPopupMenu")
print popupMenu!.getName()
popupMenu!.setAttribute("property","value")
print popupMenu!.getAttribute("property")
popupMenu!.putClientProperty("property","value")
print popupMenu!.getClientProperty("property")
item1! = popupMenu!.addMenuItem(-1,"Popup Item 1",1,0)
item1!.setCallback(item1!.ON_POPUP_ITEM_SELECT,"popup")
item2! = popupMenu!.addMenuItem(-1,"Popup Item 2",1,1)
item2!.setCallback(item2!.ON_POPUP_ITEM_SELECT,"popup")
item3! = popupMenu!.addMenuItem(-1,"Popup Item 3",1,0)
item3!.setCallback(item3!.ON_POPUP_ITEM_SELECT,"popup")
border! = window!.addCheckBox(101,25,100,275,25,"borderStyle",$$)
border!.setCallback(border!.ON_CHECK_ON,"addStyle")
border!.setCallback(border!.ON_CHECK_OFF,"removeStyle")
shadow! = window!.addCheckBox(102,25,125,275,25,"shadowStyle",$$)
shadow!.setCallback(shadow!.ON_CHECK_ON,"addStyle")
shadow!.setCallback(shadow!.ON_CHECK_OFF,"removeStyle")
background! = window!.addCheckBox(103,25,150,275,25,"backgroundStyle",$$)
background!.setCallback(background!.ON_CHECK_ON,"addStyle")
background!.setCallback(background!.ON_CHECK_OFF,"removeStyle")
popupStyle1! = window!.addCheckBox(104,25,175,275,25,"popupStyle1",$$)
popupStyle1!.setCallback(popupStyle1!.ON_CHECK_ON,"addPopupStyle")
popupStyle1!.setCallback(popupStyle1!.ON_CHECK_OFF,"removePopupStyle")
popupStyle2! = window!.addCheckBox(105,25,200,275,25,"popupStyle2",$$)
popupStyle2!.setCallback(popupStyle2!.ON_CHECK_ON,"addPopupStyle")
popupStyle2!.setCallback(popupStyle2!.ON_CHECK_OFF,"removePopupStyle")
windowStyle! = window!.addCheckBox(106,25,225,275,25,"windowStyle",$$)
windowStyle!.setCallback(windowStyle!.ON_CHECK_ON,"addWindowStyle")
windowStyle!.setCallback(windowStyle!.ON_CHECK_OFF,"removeWindowStyle")
titlebarStyle! = window!.addCheckBox(107,25,250,275,25,"titleStyle",$$)
titlebarStyle!.setCallback(titlebarStyle!.ON_CHECK_ON,"addTitleBarStyle")
titlebarStyle!.setCallback(titlebarStyle!.ON_CHECK_OFF,"removeTitleBarStyle")
getStyles! = window!.addButton(1,25,300,125,25,"getStyles",$$)
getStyles!.setCallback(getStyles!.ON_BUTTON_PUSH,"getStyles")
clearStyles! = window!.addButton(2,175,300,125,25,"clearStyles",$$)
clearStyles!.setCallback(clearStyles!.ON_BUTTON_PUSH,"clearStyles")
window!.addStaticText(108,5,355,50,25,"Style:",$8000$)
style! = window!.addEditBox(109,60,350,240,25,"",$$)
window!.addStaticText(110,5,405,50,25,"Value:",$8000$)
value! = window!.addEditBox(111,60,400,240,25,"",$$)
getStyle! = window!.addButton(3,5,450,80,25,"Get Style",$$)
getStyle!.setCallback(getStyle!.ON_BUTTON_PUSH,"getStyle")
getComputedStyle! = window!.addButton(4,90,450,145,25,"Get Computed Style",$$)
getComputedStyle!.setCallback(getComputedStyle!.ON_BUTTON_PUSH,"getComputedStyle")
setStyle! = window!.addButton(5,240,450,80,25,"Set Style",$$)
setStyle!.setCallback(setStyle!.ON_BUTTON_PUSH,"setStyle")
process_events
eoj:
release
getStyles:
i = msgbox(edit!.getStyles().toString(),0,"getStyles")
return
clearStyles:
border!.setSelected(0)
shadow!.setSelected(0)
background!.setSelected(0)
popup!.setSelected(0)
important!.setSelected(0)
windowStyle!.setSelected(0)
titlebarStyle!.setSelected(0)
edit!.clearStyles()
popupMenu!.clearStyles()
item1!.clearStyles()
item2!.clearStyles()
item3!.clearStyles()
window!.clearStyles()
window!.clearTitleBarStyles()
return
addStyle:
event! = sysgui!.getLastEvent()
control! = event!.getControl()
style$ = control!.getText()
edit!.addStyle(style$)
print edit!.getStyles()
return
removeStyle:
event! = sysgui!.getLastEvent()
control! = event!.getControl()
style$ = control!.getText()
edit!.removeStyle(style$)
print edit!.getStyles()
return
addPopupStyle:
event! = sysgui!.getLastEvent()
control! = event!.getControl()
style$ = control!.getText()
popupMenu!.addStyle(style$)
item1!.addStyle(style$)
item2!.addStyle(style$)
item3!.addStyle(style$)
print popupMenu!.getStyles()
return
removePopupStyle:
event! = sysgui!.getLastEvent()
control! = event!.getControl()
style$ = control!.getText()
popupMenu!.removeStyle(style$)
item1!.removeStyle(style$)
item2!.removeStyle(style$)
item3!.removeStyle(style$)
print popupMenu!.getStyles()
return
addWindowStyle:
event! = sysgui!.getLastEvent()
control! = event!.getControl()
style$ = control!.getText()
window!.addStyle(style$)
print window!.getStyles()
return
removeWindowStyle:
event! = sysgui!.getLastEvent()
control! = event!.getControl()
style$ = control!.getText()
window!.removeStyle(style$)
print window!.getStyles()
return
addTitleBarStyle:
event! = sysgui!.getLastEvent()
control! = event!.getControl()
style$ = control!.getText()
window!.addTitleBarStyle(style$)
print window!.getTitleBarStyles()
return
removeTitleBarStyle:
event! = sysgui!.getLastEvent()
control! = event!.getControl()
style$ = control!.getText()
window!.removeTitleBarStyle(style$)
print window!.getTitleBarStyles()
return
getStyle:
value!.setText(popupMenu!.getStyle(style!.getText()))
return
getComputedStyle:
rem ' getComputedStyle only works with visible components
popupMenu!.show(edit!,0,0)
value!.setText(popupMenu!.getComputedStyle(style!.getText()))
popupMenu!.hide()
return
setStyle:
edit!.setStyle(style!.getText(),value!.getText())
popupMenu!.setStyle(style!.getText(),value!.getText())
return
popup:
event! = sysgui!.getLastEvent()
print event!.getEventName()," ",event!.getMenuItem().getText()
return
}
|