rem ' BBjTabCtrl print stbl("!COMPAT","PRESERVE_TABCTRL_SIZE=FALSE") precision 16 sysgui = unt open (sysgui)"X0" sysgui! = bbjapi().getSysGui() mgr! = sysgui!.getImageManager() modal = 1; rem msgbox("Modal dialog?",4+32,"Modal")=6 flags$ = iff(modal,$00090083$,$00010083$) window! = sysgui!.addWindow(50,50,800,450,"BBjTabControl",flags$) window!.setCallback(window!.ON_CLOSE,"eoj") window!.setCallback(window!.ON_RESIZE,"resize") setCloseableAt! = window!.addCheckBox(101,25,200,150,25,"setCloseableAt",$$) setCloseableAt!.setCallback(setCloseableAt!.ON_CHECK_ON,"setCloseableAt1") setCloseableAt!.setCallback(setCloseableAt!.ON_CHECK_OFF,"setCloseableAt0") setEnabledAt! = window!.addCheckBox(102,200,200,200,25,"setEnabledAt",$$) setEnabledAt!.setCallback(setEnabledAt!.ON_CHECK_ON,"setEnabledAt1") setEnabledAt!.setCallback(setEnabledAt!.ON_CHECK_OFF,"setEnabledAt0") clearImageSizeAt! = window!.addToolButton(103,25,250,300,25,"clearImageSizeAt",$$) clearImageSizeAt!.setCallback(clearImageSizeAt!.ON_TOOL_BUTTON_PUSH,"clearImageSizeAt") setSelectedIndex! = window!.addToolButton(104,350,250,150,25,"setSelectedIndex",$$) setSelectedIndex!.setCallback(setSelectedIndex!.ON_TOOL_BUTTON_PUSH,"setSelectedIndex") imageWidth! = window!.addHorizontalSlider(105,25,300,window!.getWidth()-50,50,$$) imageWidth!.setPaintLabels(1) imageWidth!.setToolTipText("Image Width") imageWidth!.setCallback(imageWidth!.ON_CONTROL_SCROLL,"imageWidth") imageHeight! = window!.addHorizontalSlider(106,25,350,window!.getWidth()-50,50,$$) imageHeight!.setPaintLabels(1) imageHeight!.setToolTipText("Image Height") imageHeight!.setCallback(imageHeight!.ON_CONTROL_SCROLL,"imageHeight") width = window!.getWidth() - 50 height = window!.getHeight() - 300 tabctrl! = window!.addTabCtrl(100,25,25,width,height,$0000$); rem ' $0002$ = closeable tabctrl!.setFont(sysgui!.makeFont("Arial",8,0)) tabctrl!.setCallback(tabctrl!.ON_TAB_SELECT,"tabSelect") tabctrl!.setCallback(tabctrl!.ON_TAB_CLOSE,"tabClose") tabPopup! = sysgui!.addPopupMenu() newTab! = tabPopup!.addMenuItem(-1,"New Tab") newTab!.setCallback(newTab!.ON_POPUP_ITEM_SELECT,"newTab") closeTab! = tabPopup!.addMenuItem(-2,"Close Tab") closeTab!.setCallback(closeTab!.ON_POPUP_ITEM_SELECT,"closeTab") closeOtherTabs! = tabPopup!.addMenuItem(-3,"Close Other Tabs") closeOtherTabs!.setCallback(closeOtherTabs!.ON_POPUP_ITEM_SELECT,"closeOtherTabs") closeTabsToRight! = tabPopup!.addMenuItem(-4,"Close Tabs to the Right") closeTabsToRight!.setCallback(closeTabsToRight!.ON_POPUP_ITEM_SELECT,"closeTabsToRight") tabctrl!.setCallback(tabctrl!.ON_TAB_POPUP,"tabPopup") rem tabctrl!.setCallback(tabctrl!.ON_POPUP_REQUEST,"popup") rem tabctrl!.setPopupMenu(tabPopup!) tabPopup = -1 tab = 0 width! = bbjapi().makeVector() height! = bbjapi().makeVector() while 1 dread image$,end=*break image! = mgr!.loadImageFromServerJar(image$) flags$ = $80008810$ rem ' $80000000$ = Draw Panel 'TRACK'(0) rem ' $00008000$ = DWC Simple Child Window rem ' $00001000$ = DWC Fieldset Child Window rem ' $00000800$ = No border rem ' $00000010$ = Initially invisible rem *** initially invisible DWC simple child window doesn't remove the display:none when added to the tab flags$ = $80000810$; rem ' omit DWC simple child window flag flags$ = $80008800$; rem ' omit initially invisible flag flags$ = $80000810$ child! = window!.addChildWindow(200+tab,250,250,1024,1024,"",flags$,200+tab,$$) child!.setSize(350,75) child!.setCallback(child!.ON_RESIZE,"resize_child"); rem ' BBj 22+ child!.setBackColor(sysgui!.makeColor(127+rnd(128),127+rnd(128),127+rnd(128))) text! = child!.addMenuButton(300,tab,tab,300,25,image$) text!.setText(image$+" "+text!.getClientObjectID()) text!.setBackColor(BBjColor.YELLOW) tabctrl!.addTab(fntitle$(tab),child!) width = image!.getWidth() width!.add(width) height = image!.getHeight() height!.add(height) tabctrl!.setToolTipTextAt(tab,"Tab #"+str(tab)+": "+image$+" ("+str(width)+","+str(height)+")") max = 10 if height>max then scale = max/height print tab,width,height,scale, width = round(width*scale,2) height = round(height* scale,2) print width,height tabctrl!.setImageSizeAt(tab,width,height) endif tabctrl!.setImageAt(tab,image!) if mod(tab,2) then tabctrl!.setCloseableAt(tab,1) print tabctrl!.getToolTipTextAt(tab) tab = tab + 1 wend tabctrl!.setVisible(0) rem tabctrl!.setSelectedIndex(tab-1) tabctrl!.setVisible(1) tabctrl!.focus() rem tabctrl!.setSelectedIndex(1) rem tabctrl!.setEnabledAt(1,0); rem ' disable tab 1 rem tabctrl!.setEnabledAt(2,0); rem ' disable tab 2 rem ' BBjTabCtrl::setTabAt(int,BBjControl) rem ' BBjTabCtrl::setTabAt(int,String,BBjControl) if info(3,6)="6" then dwc_icon! = window!.addWebComponent("dwc-icon") dwc_icon!.setAttribute("name","bell") tabctrl!.setSlotAt(0,"prefix",dwc_icon!) endif process_events eoj: release resize: event! = sysgui!.getLastEvent() control! = event!.getControl() width = event!.getWidth() height = event!.getHeight() print event!.getEventName()," ",control!,control!.getID(),width,height tabctrl!.setSize(width - 50,height - 300) setCloseableAt!.setLocation(25,height - 300 + 50) setEnabledAt!.setLocation(200,height - 300 + 50) clearImageSizeAt!.setLocation(25,height - 300 + 100) setSelectedIndex!.setLocation(350,height - 300 + 100) imageWidth!.setLocation(25,height - 300 + 150) imageWidth!.setSize(width - 50, 50) imageHeight!.setLocation(25,height - 300 + 200) imageHeight!.setSize(width - 50, 50) return resize_child: event! = sysgui!.getLastEvent() control! = event!.getControl() width = event!.getWidth() height = event!.getHeight() info$ = event!.getEventName()+" "+str(control!.getID())+" "+str(width)+","+str(height) print info$ control!.getDrawPanel().clearDrawing(control!.getBackColor()) control!.getDrawPanel().drawText(50,50,info$) return popup: event! = sysgui!.getLastEvent() x = event!.getX() y = event!.getY() print event!," ",x,y return tabPopup: event! = sysgui!.getLastEvent() tabPopup = event!.getIndex() print event!.getEventName(),tabPopup x = event!.getX() y = event!.getY() tabPopup!.show(tabctrl!,x,y) title$ = event!.getTitle() print event!," ",title$,tabPopup,x,y,event! print " ctrl=",event!.isControlDown(), print " alt=",event!.isAltDown(), print " shift=",event!.isShiftDown(), print " cmd=",event!.isCmdDown(), print "" dim event$:tmpl(sysgui),generic$:noticetpl(0,0) event$=sysgui!.getLastEventString() generic$ = notice(sysgui,event.x) dim notice$:noticetpl(generic.objtype,event.flags) notice$ = generic$ fields = pos($0a$=fattr(notice$,""),1,0) dim field$:"name["+str(fields)+"]:c(1*)" let field$=fattr(notice$,"") for field=1 to fields name$ = field.name$[field] info$ = fattr(notice$,name$,$$) print " ",name$,"=", if asc(info$)=1 then print field(notice$,name$), else print str(nfield(notice$,name$)), next field print "" return newTab: event! = sysgui!.getLastEvent() tabPopup$ = event!.getMenuItem().getText() print tabPopup$,tabPopup tab = tabPopup + 1 image$ = "com/basis/bbj/images/basis-b.gif" image$ = "com/basis/bbj/images/red-ball.gif" image! = mgr!.loadImageFromServerJar(image$) child = window!.getAvailableControlID() context = sysgui!.getAvailableContext() child! = window!.addChildWindow(child,0,25,340,100,"",$00000810$,context,$$) text! = child!.addMenuButton(300,tab,tab,200,50,image$) tabctrl!.insertTab(tab,"New Tab",child!) width = image!.getWidth() width!.add(width) height = image!.getHeight() height!.add(height) tabctrl!.setToolTipTextAt(tab,"Tab #"+str(tab)+": "+image$+" ("+str(width)+","+str(height)+")") max = 10 if height>max then scale = max/height print tab,width,height,scale, width = round(width*scale,2) height = round(height* scale,2) print width,height tabctrl!.setImageSizeAt(tab,width,height) endif tabctrl!.setImageAt(tab,image!) tabctrl!.setCloseableAt(tab,1) print tabctrl!.getToolTipTextAt(tab) return closeTab: event! = sysgui!.getLastEvent() tabPopup$ = event!.getMenuItem().getText() print tabPopup$,tabPopup title$ = tabctrl!.getTitleAt(tabPopup) if msgbox("Close tab #"+str(tabPopup)+" ("""+title$+""")?",4+32+256,"ON_TAB_POPUP")=6 then tabctrl!.removeTab(tabPopup) endif return closeOtherTabs: event! = sysgui!.getLastEvent() tabPopup$ = event!.getMenuItem().getText() print tabPopup$,tabPopup title$ = tabctrl!.getTitleAt(tabPopup) if msgbox("Tab #"+str(tabPopup)+" ("""+title$+"""); Close Other Tabs?",4+32+256,"ON_TAB_POPUP")=6 then last = tabctrl!.getNumTabs() - 1 if last > tabPopup then for index = last to tabPopup + 1 step -1 tabctrl!.removeTab(index) next index endif if tabPopup > 0 then for index = 0 to tabPopup - 1 tabctrl!.removeTab(0) next index endif endif return closeTabsToRight: event! = sysgui!.getLastEvent() tabPopup$ = event!.getMenuItem().getText() print tabPopup$,tabPopup title$ = tabctrl!.getTitleAt(tabPopup) if msgbox("Tab #"+str(tabPopup)+" ("""+title$+"""); Close Tabs to the Right?",4+32+256,"ON_TAB_POPUP")=6 then last = tabctrl!.getNumTabs() - 1 if last > tabPopup then for index = last to tabPopup + 1 step -1 tabctrl!.removeTab(index) next index endif endif return tabClose: event! = sysgui!.getLastEvent() index = event!.getIndex() print event!.getEventName(),index title$ = event!.getTitle() if msgbox("Close tab #"+str(index)+" ("""+title$+""")?",4+32+256,"ON_TAB_CLOSE")=6 then tabctrl!.removeTab(index) endif return tabSelect: event! = sysgui!.getLastEvent() index = event!.getIndex() print event!.getEventName(),index rem i = msgbox(event!.getEventName(),0,str(index)) setCloseableAt!.setText("setCloseableAt "+str(index)) setCloseableAt!.setSelected(tabctrl!.isCloseableAt(index)) setEnabledAt!.setText("setEnabledAt "+str(index)) setEnabledAt!.setSelected(tabctrl!.isEnabledAt(index)) clearImageSizeAt!.setText("clearImageSizeAt "+str(index)) gosub update control! = tabctrl!.getControlAt(index) print "BBjTabCtrl::getControlAt",index," = ",control!, size$ = "Index "+str(index)+" size = "+str(control!.getWidth())+","+str(control!.getHeight()) print size$ System.err.println(size$) dim rect$:"x:i(2),y:i(2),w:u(2),h:u(2)" id = tabctrl!.getID() context = tabctrl!.getContextID() rem ' Get Bounding Rectangle - TABCTRL SENDMSG() Function 21 rem ' https://documentation.basis.cloud/BASISHelp/WebHelp/sendmsg/tabctrl/get_bounding_rectangle_tabsendfun_21.htm rem ' GetTabBoundsMessage.js let rect$=sendmsg(sysgui,id,21,index,$$,context,err=*return) bounds$ = "Tab "+str(index)+" bounds: " + str(rect.x)+","+str(rect.y)+","+str(rect.w)+","+str(rect.h) print (sysgui)'title'(0,bounds$) print bounds$ System.err.println(bounds$) return setCloseableAt0: tabctrl!.setCloseableAt(tabctrl!.getSelectedIndex(),0) return setCloseableAt1: tabctrl!.setCloseableAt(tabctrl!.getSelectedIndex(),1) return setEnabledAt0: tabctrl!.setEnabledAt(tabctrl!.getSelectedIndex(),0) return setEnabledAt1: tabctrl!.setEnabledAt(tabctrl!.getSelectedIndex(),1) return clearImageSizeAt: index = tabctrl!.getSelectedIndex() if index<0 then return tabctrl!.clearImageSizeAt(index) gosub update return setSelectedIndex: index = rnd(tabctrl!.getNumTabs()) print "setSelectedIndex",index System.err.println("setSelectedIndex "+str(index)) tabctrl!.setSelectedIndex(index) return imageWidth: event! = sysgui!.getLastEvent() width = event!.getPosition() height = imageHeight!.getValue() index = tabctrl!.getSelectedIndex() print "imageSize",index,width,height tabctrl!.setImageSizeAt(index,width,height) return imageHeight: event! = sysgui!.getLastEvent() width = imageWidth!.getValue() height = event!.getPosition() index = tabctrl!.getSelectedIndex() print "imageSize",index,width,height tabctrl!.setImageSizeAt(index,width,height) return update: width = width!.get(index) imageWidth!.setMajorTickSpacing(10^ept(width/10)) imageWidth!.setMaximum(width) imageWidth!.setValue(tabctrl!.getImageWidthAt(index)) imageWidth!.setPaintTicks(width<100) height = height!.get(index) imageHeight!.setMajorTickSpacing(10^ept(height/10)) imageHeight!.setMaximum(height) imageHeight!.setValue(tabctrl!.getImageHeightAt(index)) imageHeight!.setPaintTicks(height<100) return def fntitle$(n) switch n case 0; return "zero" case 1; return "one" case 2; return "two" case 3; return "three" case 4; return "four" case 5; return "five" case 6; return "six" case 7; return "seven" case 8; return "eight" case 9; return "nine" case 10; return "ten" case 11; return "eleven" case 12; return "twelve" case 13; return "thirteen" case 14; return "fourteen" case 15; return "fifteen" case 16; return "sixteen" case 17; return "seventeen" case 18; return "eighteen" case 19; return "nineteen" case 20; return "twenty" case default; return str(n) swend fnend rem data "com/basis/bbj/images/splash.jpg" data "com/basis/bbj/images/BBjIDE.gif" rem data "com/basis/bbj/images/IndexPropClosed.gif" rem data "com/basis/bbj/images/IndexPropClosedAni.gif" rem data "com/basis/bbj/images/IndexPropOpened.gif" rem data "com/basis/bbj/images/IndexPropOpenedAni.gif" rem data "com/basis/bbj/images/NavigatorFirst.gif" rem data "com/basis/bbj/images/NavigatorLast.gif" rem data "com/basis/bbj/images/NavigatorNext.gif" rem data "com/basis/bbj/images/NavigatorPrevious.gif" rem data "com/basis/bbj/images/basis-b.gif" rem data "com/basis/bbj/images/basis-b16.gif" data "com/basis/bbj/images/bbjclient.gif" data "com/basis/bbj/images/bbjserver.gif" data "com/basis/bbj/images/broken.png" data "com/basis/bbj/images/browser.gif" data "com/basis/bbj/images/busyrow.gif" data "com/basis/bbj/images/close.gif" data "com/basis/bbj/images/copy.gif" data "com/basis/bbj/images/cuidemo.gif" data "com/basis/bbj/images/cursor_c_1616.gif" data "com/basis/bbj/images/cursor_c_3232.gif" data "com/basis/bbj/images/cut.gif" data "com/basis/bbj/images/datadmin.gif" data "com/basis/bbj/images/deleterow.gif" data "com/basis/bbj/images/demoicons.gif" data "com/basis/bbj/images/fieldtest.jpg" data "com/basis/bbj/images/first.gif" data "com/basis/bbj/images/fitheight.gif" data "com/basis/bbj/images/fitwidth.gif" data "com/basis/bbj/images/griddemo.gif" data "com/basis/bbj/images/guicontrols.gif" data "com/basis/bbj/images/helpbook.gif" data "com/basis/bbj/images/insertrow.gif" data "com/basis/bbj/images/jdbcdemo.gif" data "com/basis/bbj/images/last.gif" data "com/basis/bbj/images/leftarrow.gif" data "com/basis/bbj/images/new.gif" data "com/basis/bbj/images/next.gif" data "com/basis/bbj/images/no-breakpoint.gif" data "com/basis/bbj/images/open.gif" data "com/basis/bbj/images/pagedown.gif" data "com/basis/bbj/images/pageup.gif" data "com/basis/bbj/images/paste.gif" data "com/basis/bbj/images/prev.gif" data "com/basis/bbj/images/print.gif" data "com/basis/bbj/images/resconverter.gif" data "com/basis/bbj/images/rightarrow.gif" data "com/basis/bbj/images/save.gif" data "com/basis/bbj/images/selBord.gif" data "com/basis/bbj/images/sidebyside.gif" data "com/basis/bbj/images/sqldemo.gif"