BBjMDI::arrangeVertical

Description

In BBj 3.00 and higher, this method equally arranges all BBjMDI client windows vertically to fit the size of the BBjTopLevelWindow. This method orders the client windows from left to right, with the window most recently interacted with on the left.

Syntax

Return Value

Method

void

arrangeVertical()

Parameters

None.

Return Value

None.

Remarks

Unless another action is taken, changing the size and/or position of the BBjTopLevelWindow will not change the arrangement of the client windows.

Example

rem ' BBjMDI
if info(3,6)="1" then
   UIDefaults! = javax.swing.UIManager@.getDefaults() 
   print "InternalFrame.closeSound=",UIDefaults!.get("InternalFrame.closeSound") 
   UIDefaults!.put("InternalFrame.closeSound","") 
endif
message = 0
argv$ = cvs(argv(1,err=*next),11)
if len(argv$) and pos(argv$(1,1)="nsewf") then goto client
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
mdi! = bbjapi().getMDI()
lf$ = str(javax.swing.UIManager@.getLookAndFeel())
title$ = "MDI: "+info(0,0)+" "+info(0,1)+" "+info(1,0)+" "+info(1,1)+" "+lf$
print 'title'(title$)
x = 25
y = 25
width = 800
height = 600
float = 5
f = 0
mdi!.createMDIWindow(x,y,width,height,title$,$0009009f$)
mdi!.setOutlineDrag(0)
mdi!.setDefaultForwardMenuAccelerators(1)
rem mdi!.setVisible(1)
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))
gosub toolbar
gosub sizes
mdi!.setName("MDIWindow")
mdi!.setArrangeModal(1)
status! = mdi!.addStatusBar(); status!.setText("MDI Status Bar")
status!.setForeColor(BBjColor.YELLOW)
status!.setBackColor(BBjColor.RED)
imagemanager! = sysgui!.getImageManager()
image$ = "com/basis/utilities/launchdock/icons/bbj.png"
image! = imagemanager!.loadImageFromServerJar(image$)
mdi!.setBackgroundImage(0,image!)

if 0 and msgbox("Set desktop background image?",4+32+256)=6 then
   url$ = "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/Shiprock.snodgrass3.jpg/1280px-Shiprock.snodgrass3.jpg"
   image! = javax.imageio.ImageIO.read(new java.net.URL(url$))
   os! = new java.io.ByteArrayOutputStream()
   javax.imageio.ImageIO.write(image!,"png",os!)
   bytes! = os!.toByteArray()
   imagemanager! = sysgui!.getImageManager()
   image! = imagemanager!.loadImageFromBytes(bytes!)
   mdi!.setBackgroundImage(BBjMDI.FILL,image!)
endif

mdi!.setDefaultMDIMode("MDI")
invoke = scall("bbj "+pgm(-1)+" - n &")
invoke = scall("bbj "+pgm(-1)+" - w &")
invoke = scall("bbj "+pgm(-1)+" - e &")
invoke = scall("bbj "+pgm(-1)+" - s &")
if float then
   for f=1 to float
       invoke = scall("bbj "+pgm(-1)+" - f"+str(f)+" &")
   next f
endif
rem invoke = scall("bbj "+pgm(-1)+" - x &")
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$)
mdi!.setVisible(1)
gosub menubar
gosub getSize
gosub getDesktopSize
gosub getClientSize
gosub getClientLocation
skip:
process_events
menubar:
  menubar! = mdi!.addMenuBar()
  font = 0 and 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")
  menuitem!.setAccelerator($4058$); rem ' Alt+X
  if font then menuitem!.setFont(font!)
  menuitem!.setCallback(menuitem!.ON_MENU_ITEM_SELECT,"closeAll")
  mdi!.enableMDIWindowMenu()
return
sizes:
  context = sysgui!.getActiveContext()
  sysgui!.setContext(sysgui!.getAvailableContext())
  sizes! = sysgui!.addWindow(100,100,300,275,"Sizes",$00090093$)
  sizes!.setCallback(sizes!.ON_CLOSE,"hide")
  sizes!.addStaticText(101,5,25,85,25,"Width:",$8000$)
  width! = sizes!.addInputN(102,100,25,100,25)
  sizes!.addStaticText(103,5,75,85,25,"Height:",$8000$)
  height! = sizes!.addInputN(104,100,75,100,25)
  sizes!.addStaticText(105,5,125,85,25,"Client:",$8000$)
  client! = sizes!.addEditBox(106,100,125,175,25,$0200$)
  sizes!.addStaticText(107,5,175,85,25,"Desktop:",$8000$)
  desktop! = sizes!.addEditBox(108,100,175,175,25,$0200$)
  set! = sizes!.addButton(1,100,225,75,25,"Set",$$)
  set!.setCallback(set!.ON_BUTTON_PUSH,"set")
  get! = sizes!.addButton(2,200,225,75 ,25,"Get",$$)
  get!.setCallback(get!.ON_BUTTON_PUSH,"get")
  sysgui!.setContext(context)
return
hide:
  sizes!.setVisible(0)
return
show:
  gosub get
  sizes!.setVisible(1)
return
set:
  width = width!.getValue()
  height = height!.getValue()
  mdi!.setSize(width,height)
return
get:
  width = mdi!.getWidth()
  height = mdi!.getHeight()
  width!.setValue(width)
  height!.setValue(height)
  x = mdi!.getClientX()
  y = mdi!.getClientY()
  width = mdi!.getClientWidth()
  height = mdi!.getClientHeight()
  client$ = str(x)+","+str(y)+","+str(width)+","+str(height)
  client!.setText(client$)
  width = mdi!.getDesktopWidth()
  height = mdi!.getDesktopHeight()
  desktop$ = str(width)+","+str(height)
  desktop!.setText(desktop$)
return
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")
  show! = mdi!.addToolButton(mdi!.getAvailableControlID(),0,0,50,50,"Sizes",$$)
  show!.setCallback(show!.ON_TOOL_BUTTON_PUSH,"show")
  float! = mdi!.addToolButton(mdi!.getAvailableControlID(),0,0,50,50,"Float",$$)
  float!.setCallback(float!.ON_TOOL_BUTTON_PUSH,"float")
  modal! = mdi!.addToolButton(mdi!.getAvailableControlID(),0,0,50,50,"Modal",$$)
  modal!.setCallback(float!.ON_TOOL_BUTTON_PUSH,"modal")
return
float:
  invoke = scall("bbj "+pgm(-1)+" - f"+str(f)+" &")
  f = f + 1
return
modal:
  invoke = scall("bbj "+pgm(-1)+" - F"+str(f)+" &")
  f = f + 1
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
  Desktop$ = System@.getProperty("user.home") + "/Desktop/"
  open (image,mode="O_CREATE,O_TRUNC")Desktop$ + "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: return
  width = mdi!.getWidth()
  height = mdi!.getHeight()
  print "getSize "+str(width)+","+str(height)
return
getDesktopSize: return
  width = mdi!.getDesktopWidth()
  height = mdi!.getDesktopHeight()
  print "getDesktopSize "+str(width)+","+str(height)
return
getClientSize: return
  width = mdi!.getClientWidth()
  height = mdi!.getClientHeight()
  print "getClientSize "+str(width)+","+str(height)
return
getClientLocation: return
  x = mdi!.getClientX()
  y = mdi!.getClientY()
  print "getClientLocation "+str(x)+","+str(y)
return
rem ' client windows
client:
if bbjapi().isInMDI() then
   _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$ = argv(1)
print 'title'(title$)
docked = pos("f"=cvs(title$,8))<>1
if docked then w=50,h=50,flags$=$02090083$ else w=120,h=100,flags$=$00090083$
if pos("F"=title$)=1 then flags$ = $020b0083$
window! = sysgui!.addWindow(rnd(250),rnd(250),w,h,title$,flags$,$$)
window!.setTrack(1)
window!.setBackColor(sysgui!.makeColor(rnd(255),rnd(255),rnd(255)))
window!.setName("Client Window "+title$)
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,"toggle"); rem destroy
checkbox! = window!.addCheckBox(2,25,0,25,25,title$,$0004$)
checkbox!.setCallback(checkbox!.ON_CHECK_ON,"toggle")
checkbox!.setCallback(checkbox!.ON_CHECK_OFF,"toggle")
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
if message then
   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$
endif
process_events
approve:
  event! = sysgui!.getLastEvent()
  title$ = bbjapi().getSysGui().getWindow(0).getText()
  bbjapi().getMDI().approveMDIClose()
  release
closeAll:
  bbjapi().getMDI().closeAllClients(0)
eoj:
  title$ = bbjapi().getSysGui().getWindow(0).getText()
  release
toggle:
  i = msgbox("toggle isDesktopModal="+Boolean.toString(window!.isDesktopModal()))
  border! = null()
  if title$="n" then
     border! = bbjapi().getMDI().getNorthBorder()
  endif
  if title$="s" then
     border! = bbjapi().getMDI().getSouthBorder()
  endif
  if title$="w" then
     border! = bbjapi().getMDI().getWestBorder()
  endif
  if title$="e" then
     border! = bbjapi().getMDI().getEastBorder()
  endif
  if border!<>null()
     if docked then
        border!.removeWindow()
        window!.setSize(100,100)
        window!.setLocation(rnd(250),rnd(250))
     else
        window!.setSize(50,50)
        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
     endif
  endif
  docked = !docked
  return
destroy:
  release
  if title$="n" then
     bbjapi().getMDI().getNorthBorder().removeWindow()
  endif
  if title$="s" then
     bbjapi().getMDI().getSouthBorder().removeWindow()
  endif
  if title$="w" then
     bbjapi().getMDI().getWestBorder().removeWindow()
  endif
  if title$="e" then
     bbjapi().getMDI().getEastBorder().removeWindow()
  endif
  window!.destroy()
  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
     _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:
  if message then
     event! = sysgui!.getLastEvent()
     win! = event!.getControl()
     message$ = "ON_SCREEN_RESIZE: width="+str(event!.getWidth())+",height="+str(event!.getHeight())
     win!.setToolTipText(message$)
     print message$
  endif
return
resize:
  if message then
     event! = sysgui!.getLastEvent()
     win! = event!.getControl()
     message$ = "ON_RESIZE "+win!.getName()+": 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$
  endif
return
move:
  if message then
     event! = sysgui!.getLastEvent()
     win! = event!.getControl()
     message$ = "ON_WINDOW_MOVE "+win!.getName()+": 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$
  endif
return

Figure 1 shows a screenshot of the example code above. This example code demonstrates various ways to arrange BBjMDI client windows.

Figure 1. BBjMDI Client Windows Arranged by BBjMDI::arrangeVertical

See Also

BBjAPI

BBjMDI

BBjMDI::arrangeHorizontal

BBjMDI::cascade

BBjMDI::tile

Object Variables

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