rem 'BBjMenuButton setBorderPainted
rem 'Open the SysGui device
SYSGUI = UNT
OPEN (SYSGUI)"X0"
DIM EVENT$:TMPL(SYSGUI)
rem 'Create BBjWindow
sysgui! = BBjAPI().getSysGui()
window! = sysgui!.addWindow(200,200,430,160,"MenuButton::setBorderPainted")
rem ' Custom backcolor?
color! = sysgui!.makeColor(207,231,250)
color! = sysgui!.makeColor(239,239,239)
color! = sysgui!.makeColor(200,200,200)
color! = window!.getBackColor()
rem 'window!.setBackColor(color!)
rem 'Create Toolbar-style BBjMenuButtons
window!.addGroupBox(100,10,10,410,60,"Toolbar MenuButtons paint their border on rollover")
toolbarMenuButton1! = window!.addMenuButton(101,20,30,90,25,"Button&1",$0000$)
toolbarMenuButton2! = window!.addMenuButton(102,120,30,90,25,"Button&2",$0000$)
toolbarMenuButton3! = window!.addMenuButton(103,220,30,90,25,"Button&3",$0000$)
toolbarMenuButton4! = window!.addMenuButton(104,320,30,90,25,"Button&4",$0000$)
rem 'Add images
ImageManager! = sysgui!.getImageManager()
printImage! = ImageManager!.loadImageFromFile("save.png",err=*next)
toolbarMenuButton1!.setImage(printImage!)
saveImage! = ImageManager!.loadImageFromFile("print.png",err=*next)
toolbarMenuButton2!.setImage(saveImage!)
nadaImage! = ImageManager!.loadImageFromFile("nada.png",err=*next)
toolbarMenuButton3!.setImage(nadaImage!)
rem 'Create Standalone BBjMenuButtons
window!.addGroupBox(105,10,90,410,60,"Standalone MenuButtons always paint their border")
standaloneMenuButton1! = window!.addMenuButton(106,20,110,90,25,"Button&5",$4000$)
standaloneMenuButton2! = window!.addMenuButton(107,120,110,90,25,"Button&6",$4000$)
standaloneMenuButton3! = window!.addMenuButton(108,220,110,90,25,"Button&7",$0000$)
standaloneMenuButton3!.setBorderPainted(1)
standaloneMenuButton4! = window!.addMenuButton(109,320,110,90,25,"Button&8",$0000$)
standaloneMenuButton4!.setBorderPainted(1)
rem 'Add images
ImageManager! = sysgui!.getImageManager()
printImage! = ImageManager!.loadImageFromFile("save.png",err=*next)
standaloneMenuButton1!.setImage(printImage!)
saveImage! = ImageManager!.loadImageFromFile("print.png",err=*next)
standaloneMenuButton2!.setImage(saveImage!)
nadaImage! = ImageManager!.loadImageFromFile("nada.png",err=*next)
standaloneMenuButton3!.setImage(nadaImage!)
rem 'Create dropdown menu(s)
dropdownMenu! = sysgui!.addPopupMenu()
dropdownItem1! = dropdownMenu!.addMenuItem(-201,"Dropdown Item 1")
dropdownItem2! = dropdownMenu!.addMenuItem(-202,"Dropdown Item 2")
rem 'Associate dropdown menu(s) with the buttons
toolbarMenuButton1!.setDropdownMenu(dropdownMenu!)
toolbarMenuButton2!.setDropdownMenu(dropdownMenu!)
toolbarMenuButton3!.setDropdownMenu(dropdownMenu!)
toolbarMenuButton4!.setDropdownMenu(dropdownMenu!)
standaloneMenuButton1!.setDropdownMenu(dropdownMenu!)
standaloneMenuButton2!.setDropdownMenu(dropdownMenu!)
standaloneMenuButton3!.setDropdownMenu(dropdownMenu!)
standaloneMenuButton4!.setDropdownMenu(dropdownMenu!)
rem 'Create popup menu(s)
popupMenu! = sysgui!.addPopupMenu()
popupItem1! = popupMenu!.addMenuItem(-301,"Popup Item 1")
popupItem2! = popupMenu!.addMenuItem(-302,"Popup Item 2")
rem 'Associate popup menu(s) with the buttons
toolbarMenuButton1!.setPopupMenu(popupMenu!)
toolbarMenuButton2!.setPopupMenu(popupMenu!)
toolbarMenuButton3!.setPopupMenu(popupMenu!)
toolbarMenuButton4!.setPopupMenu(popupMenu!)
standaloneMenuButton1!.setPopupMenu(popupMenu!)
standaloneMenuButton2!.setPopupMenu(popupMenu!)
standaloneMenuButton3!.setPopupMenu(popupMenu!)
standaloneMenuButton4!.setPopupMenu(popupMenu!)
rem 'Register the CALLBACK routines
CALLBACK(ON_BUTTON_PUSH,ToolbarMenuButton1,sysgui!.getContext(),ToolbarMenuButton1!.getID())
CALLBACK(ON_BUTTON_PUSH,ToolbarMenuButton2,sysgui!.getContext(),ToolbarMenuButton2!.getID())
CALLBACK(ON_BUTTON_PUSH,ToolbarMenuButton3,sysgui!.getContext(),ToolbarMenuButton3!.getID())
CALLBACK(ON_BUTTON_PUSH,ToolbarMenuButton4,sysgui!.getContext(),ToolbarMenuButton4!.getID())
CALLBACK(ON_BUTTON_PUSH,StandaloneMenuButton1,sysgui!.getContext(),StandaloneMenuButton1!.getID())
CALLBACK(ON_BUTTON_PUSH,StandaloneMenuButton2,sysgui!.getContext(),StandaloneMenuButton2!.getID())
CALLBACK(ON_BUTTON_PUSH,StandaloneMenuButton3,sysgui!.getContext(),StandaloneMenuButton3!.getID())
CALLBACK(ON_BUTTON_PUSH,StandaloneMenuButton4,sysgui!.getContext(),StandaloneMenuButton4!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,DropdownItem1,dropdownMenu!.getID(),dropdownItem1!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,DropdownItem2,dropdownMenu!.getID(),dropdownItem2!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,PopupItem1,popupMenu!.getID(),popupItem1!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,PopupItem2,popupMenu!.getID(),popupItem2!.getID())
CALLBACK(ON_CLOSE,APP_CLOSE,sysgui!.getContext())
rem 'Process Events
process_events
rem 'Callback routine invoked when the user clicks the button
ToolbarMenuButton1:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
i = msgbox("ToolbarMenuButton1 was clicked")
return
rem 'Callback routine invoked when the user clicks the button
ToolbarMenuButton2:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
i = msgbox("ToolbarMenuButton2 was clicked")
return
rem 'Callback routine invoked when the user clicks the button
ToolbarMenuButton3:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
i = msgbox("ToolbarMenuButton3 was clicked")
return
rem 'Callback routine invoked when the user clicks the button
ToolbarMenuButton4:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
i = msgbox("ToolbarMenuButton4 was clicked")
return
rem 'Callback routine invoked when the user clicks the button
StandaloneMenuButton1:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
i = msgbox("StandaloneMenuButton1 was clicked")
return
rem 'Callback routine invoked when the user clicks the button
StandaloneMenuButton2:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
i = msgbox("StandaloneMenuButton2 was clicked")
return
rem 'Callback routine invoked when the user clicks the button
StandaloneMenuButton3:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
i = msgbox("StandaloneMenuButton3 was clicked")
return
rem 'Callback routine invoked when the user clicks the button
StandaloneMenuButton4:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
i = msgbox("StandaloneMenuButton4 was clicked")
return
rem 'Callback routine invoked when the user selects the first dropdown item
DropdownItem1:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
i = msgbox("Dropdown Item 1 was selected on "+event!.getControl().getText())
return
rem 'Callback routine invoked when the user selects the second dropdown item
DropdownItem2:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
i = msgbox("Dropdown Item 2 was selected on "+event!.getControl().getText())
return
rem 'Callback routine invoked when the user selects the first popup item
PopupItem1:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
i = msgbox("Popup Item 1 was selected on "+event!.getControl().getText())
return
rem 'Callback routine invoked when the user selects the second popup item
PopupItem2:
event! = sysgui!.getLastEvent()
event$ = sysgui!.getLastEventString()
i = msgbox("Popup Item 2 was selected on "+event!.getControl().getText())
return
rem 'Callback routine called when the user closes the application window
APP_CLOSE:
release
|