BBjMDI::enableMDIWindowMenu

Description

In BBj 3.0 and higher, this method enables the BBjMDI window menu. This menu is not under program control. There are two selections on the BBjMDI window menu. The first menu item allows the user to arrange (Cascade, Tile, Horizontal, Vertical) all windows within the BBjMDI window. The second menu item presents the user with a list of all Windows that are currently visible within the BBjMDI window. By choosing a window from the list, the user is able to bring that window to the front of the BBjMDI display.

Syntax

Return Value

Method

void

enableMDIWindowMenu()

void

enableMDIWindowMenu(string windowLabel, string arrangeLabel, string cascadeLabel, string tileLabel, string horizontalLabel, string verticalLabel, string listLabel, string noVisibleFrameLabel)

Parameters

Variable

Description

windowLabel

Specifies the label to appear on the BBjMDI window menu.

arrangeLabel

Specifies the label of the first popup item displayed when the BBjMDI window menu is selected.

cascadeLabel

Specifies the label of the menu item causing all windows within the BBjMDI window to be cascaded.

tileLabel

Specifies the label of the menu item causing all windows within the BBjMDI window to be tiled.

horizontalLabel

Specifies the label of the menu item causing all windows within the BBjMDI window to be arranged stacked.

verticalLabel

Specifies the label of the menu item causing all windows within the BBjMDI window to be arranged side-by-side.

listLabel

Specifies the label of the menu item causing a listing of all windows within the BBjMDI window to be displayed.

noVisibleFramesLabel

Specifies the label displayed when the listing of all windows within the BBjMDI is empty.

Return Value

None.

Remarks

The BBjMDI::enableMDIWindowMenu() method is equivalent to BBjMDI::enableMDIWindowMenu("Window", "Arrange", "Cascade", "Tile", "Show windows stacked", "Show windows side by side", "List", "no visible frames") and will result in a menu having the label "Window". The popup menu will contain two menu items with the labels "Arrange" and "List". Choosing the "Arrange" menu item will display a second-level popup having the labels "Cascade", "Tile", "Show windows stacked", and "Show windows side by side".

Example

BBjMDI_enableWindowMenu_Example.bbj

rem ' BBjMDI::enableMDIWindowMenu
if len(cvs(argv(1,err=*next),8)) then goto client
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
mdi! = bbjapi().getMDI()
lf$ = str(javax.swing.UIManager@.getLookAndFeel())
title$ = "mdidock: "+info(0,0)+" "+info(0,1)+" "+info(1,0)+" "+info(1,1)+" "+lf$
print 'title'(title$)
mdi!.createMDIWindow(50,50,800,600,title$,$0000088f$)
menubar! = mdi!.addMenuBar()
font = msgbox("Set MDI menubar font?",4+32+256)=6
font! = sysgui!.makeFont("Courier New",16,2)
if font then menubar!.setFont(font!)
menu! = menubar!.addMenu(99,"File")
if font then menu!.setFont(font!)
menuitem! = menu!.addMenuItem(100,"Exit")
if font then menuitem!.setFont(font!)
menuitem!.setCallback(menuitem!.ON_MENU_ITEM_SELECT,"closeAll")
mdi!.enableMDIWindowMenu()
mdi!.setArrangeModal(1)
status! = mdi!.addStatusBar(); status!.setText("MDI Status Bar")
status!.setForeColor(BBjColor.YELLOW)
status!.setBackColor(BBjColor.RED)
mdi!.setCallback(mdi!.ON_CLOSE,"closeAll")
mdi!.setCallback(mdi!.ON_RESIZE,"resize")
mdi!.setCallback(mdi!.ON_WINDOW_MOVE,"move")
mdi!.setCallback(mdi!.ON_SCREEN_RESIZE,"screen")
mdi!.setBackColor(sysgui!.makeColor(255,255,0))
imagemanager! = sysgui!.getImageManager()
image$ = "com/basis/utilities/launchdock/icons/bbj.png"
image! = imagemanager!.loadImageFromServerJar(image$)
mdi!.setBackgroundImage(0,image!)
mdi!.setDefaultMDIMode("MDI")
rem invoke = scall("bbj "+pgm(-1)+" - f &")
invoke = scall("bbj "+pgm(-1)+" - n &")
rem invoke = scall("bbj "+pgm(-1)+" - f &")
gosub toolbar
rem invoke = scall("bbj "+pgm(-1)+" - f &")
invoke = scall("bbj "+pgm(-1)+" - w &")
rem invoke = scall("bbj "+pgm(-1)+" - f &")
invoke = scall("bbj "+pgm(-1)+" - e &")
rem invoke = scall("bbj "+pgm(-1)+" - f &")
rem invoke = scall("bbj "+pgm(-1)+" - f &")
invoke = scall("bbj "+pgm(-1)+" - s &")
invoke = scall("bbj "+pgm(-1)+" - f1 &")
invoke = scall("bbj "+pgm(-1)+" - f2 &")
invoke = scall("bbj "+pgm(-1)+" - f3 &")
invoke = scall("bbj "+pgm(-1)+" - f4 &")
invoke = scall("bbj "+pgm(-1)+" - f5 &")
mode = 0; rem msgbox("Select MDI mode",7+32+256,"MDI Mode","MDI","SDI","DETACHED")
mode$ = "MDI"
switch mode
   case 0; mode$ = "MDI"; break
   case 1; mode$ = "MDI"; break 
   case 2; mode$ = "SDI"; break
   case 3; mode$ = "DETACHED"; break
swend
mdi!.setDefaultMDIMode(mode$)
rem invoke = scall("bbj "+pgm(-1)+" - x "+mode$+" &")
gosub getSize
gosub getDesktopSize
gosub getClientSize
gosub getClientLocation
mdi!.setVisible(1)
gosub getSize
gosub getDesktopSize
gosub getClientSize
gosub getClientLocation
mdi!.setSize(850,600)
process_events
toolbar:
  tb! = mdi!.addToolButton(mdi!.getAvailableControlID(),0,0,50,50,"1",$4000$)
  print tb!.getID()
  tb!.setCallback(tb!.ON_TOOL_BUTTON_PUSH,"tb")
  mb! = mdi!.addMenuButton(mdi!.getAvailableControlID(),0,0,50,50,"2",$4000$)
  print mb!.getID()
  mb!.setCallback(mb!.ON_BUTTON_PUSH,"mb")
  lb$ = "cascade"+$0a$+"tile"+$0a$+"vertical"+$0a$+"horizontal"+$0a$
  lb! = mdi!.addListButton(mdi!.getAvailableControlID(),0,0,100,200,lb$,$4000$)
  print lb!.getID()
  lb!.setCallback(tb!.ON_LIST_SELECT,"lb")
return
tb:
  gosub getClientSize
  rem event! = sysgui!.getLastEvent()
  rem tb! = event!.getControl()
  rem tb = msgbox(tb!.getText(),0,event!.getEventName())
  info! = bbjapi().getCurrentSessionInfo()
  sessionid = info!.getSessionID()
  groupid = info!.getGroupID()
  infos! = bbjapi().getSessionInfos()
  all! = new java.util.LinkedHashSet()
  group! = new java.util.LinkedHashSet()
  for i = 0 to infos!.size() - 1
    info! = infos!.get(i)
    id = info!.getSessionID()
    group = info!.getGroupID()
    all!.add(id)
    if group=groupid then group!.add(id)
  next i
  info$ = "All Processes: "+str(all!)+$0a$+"Group Processes: "+str(group!)
  title$ = "MDI Process: "+str(sessionid)+" Group ID: "+str(groupid)
  i = msgbox(info$,0,title$)
return
mb:
  image! = mdi!.getWindowImage()
  image$ = image!.getBytes("png")
  image = unt
  open (image,mode="O_CREATE,O_TRUNC")"./mdidock.png"
  writerecord (image)image$
  close (image)
  event! = sysgui!.getLastEvent()
  mb! = event!.getControl()
  mb = msgbox(mb!.getText(),0,event!.getEventName())
return
lb:
  event! = sysgui!.getLastEvent()
  event$ = event!.getEventName()
  item$ = event!.getSelectedItem()
  index = event!.getSelectedIndex()
  switch index
    case 0; mdi!.cascade(); break
    case 1; mdi!.tile(); break
    case 2; mdi!.arrangeVertical(); break
    case 3; mdi!.arrangeHorizontal(); break
  swend
  lb = msgbox(item$,0,event$)
return
getSize:
  width = mdi!.getWidth()
  height = mdi!.getHeight()
  print "getSize",width,height
return
getDesktopSize:
  width = mdi!.getDesktopWidth()
  height = mdi!.getDesktopHeight()
  print "getDesktopSize",width,height
return
getClientSize:
  width = mdi!.getClientWidth()
  height = mdi!.getClientHeight()
  print "getClientSize",width,height
  System.out.println("BBjMDI::getClientSize = "+str(width)+","+str(height))
return
getClientLocation:
  x = mdi!.getClientX()
  y = mdi!.getClientY()
  print "getClientLocation",x,y
return
rem ' client windows
client:
if bbjapi().isInMDI() then
   bbjapi().getMDI().registerMDIClosingCallback("veto")
   _w = bbjapi().getMDI().getClientWidth()
   _h = bbjapi().getMDI().getClientHeight()
   System.out.println("bbjapi().getMDI().getClientSize '"+title$+"' = "+str(_w)+","+str(_h))
endif
print 'hide',
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
title$ = cvs(argv(1),8)
print 'title'(title$)
if pos("f"=title$) then w=120,h=100 else w=50,h=50
window! = sysgui!.addWindow(rnd(250),rnd(250),w,h,title$,$00090883$,$00090083$)
rem window!.setMinimumSize(75,75)
window!.setTrack(1)
window!.setBackColor(sysgui!.makeColor(rnd(255),rnd(255),rnd(255)))
print title$," getBackColor ",window!.getBackColor()
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_RESIZE,"resize")
window!.setCallback(window!.ON_SCREEN_RESIZE,"screen")
window!.setCallback(window!.ON_WINDOW_MOVE,"move")
button! = window!.addMenuButton(1,0,0,25,25,title$,$$)
button!.setCallback(button!.ON_BUTTON_PUSH,"size")
checkbox! = window!.addCheckBox(2,25,0,25,25,title$,$0004$)
checkbox!.setCallback(checkbox!.ON_CHECK_ON,"resizable")
checkbox!.setCallback(checkbox!.ON_CHECK_OFF,"resizable")
status! = window!.addStatusBar(99,$$)
status!.setForeColor(sysgui!.makeColor(255,255,255))
status!.setBackColor(sysgui!.makeColor(0,0,255))
status!.setText("Status Bar")
if title$="n" then
   bbjapi().getMDI().getNorthBorder().setWindow(window!)
endif
if title$="s" then
   bbjapi().getMDI().getSouthBorder().setWindow(window!)
endif
if title$="w" then
   bbjapi().getMDI().getWestBorder().setWindow(window!)
endif
if title$="e" then
   bbjapi().getMDI().getEastBorder().setWindow(window!)
endif
message$ = "Initial window bounds: x="+str(window!.getX())+",y="+str(window!.getY())+",width="+str(window!.getWidth())+",height="+str(window!.getHeight())
window!.setToolTipText(message$)
print message$
if title$="x" then escape
process_events
veto:
  bbjapi().getMDI().approveMDIClose()
  release
closeAll:
  bbjapi().getMDI().closeAll(10)
eoj:
  release
size:
  message$ = "Window bounds: x="+str(window!.getX())+",y="+str(window!.getY())+",width="+str(window!.getWidth())+",height="+str(window!.getHeight())
  window!.setToolTipText(message$)
  print message$
  if bbjapi().isInMDI() then
     bbjapi().getMDI().registerMDIClosingCallback("veto")
     _h = bbjapi().getMDI().getClientHeight()
     _w = bbjapi().getMDI().getClientWidth()
     System.out.println("bbjapi().getMDI().getClientSize "+title$+" = "+str(_w)+","+str(_h))
  endif
  i = msgbox(message$,0,title$)
return
resizable:
  window!.setResizable(checkbox!.isSelected())
return
screen:
  event! = sysgui!.getLastEvent()
  win! = event!.getControl()
  message$ = "ON_SCREEN_RESIZE: width="+str(event!.getWidth())+",height="+str(event!.getHeight())
  win!.setToolTipText(message$)
  print message$
return
resize:
  event! = sysgui!.getLastEvent()
  win! = event!.getControl()
  message$ = "ON_RESIZE: width="+str(event!.getWidth())+",height="+str(event!.getHeight())+",adjusting="+Boolean.toString(event!.isAdjusting())
  message$ = message$ + ".  Window reports: x="+str(win!.getX())+",y="+str(win!.getY())+",width="+str(win!.getWidth())+",height="+str(win!.getHeight())
  win!.setToolTipText(message$)
  print message$
return
move:
  event! = sysgui!.getLastEvent()
  win! = event!.getControl()
  message$ = "ON_WINDOW_MOVE: x="+str(event!.getX())+",y="+str(event!.getY())
  message$ = message$ + ".  Window reports: x="+str(win!.getX())+",y="+str(win!.getY())+",width="+str(win!.getWidth())+",height="+str(win!.getHeight())
  win!.setToolTipText(message$)
  print message$
return

See Also

BBjAPI

BBjMDI

Object Variables

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.