home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Global Amiga Experience
/
globalamigaexperience.iso
/
text_dtp
/
editor
/
turbotext
/
rexx
/
organizewindows.ttx
< prev
next >
Wrap
Text File
|
1995-07-10
|
6KB
|
274 lines
/** $VER: OrganizeWindows.ttx 2.0 (5.3.94)
**
** Organize all document windows on the same screen as the current document
** windows. The argument specifies how the windows are to be organized:
**
** STACK
** Puts the windows in horizontal slices, stacked vertically on the screen
**
** CASCADE
** Puts the windows in a cascade, one top of the other. All title bars
** then become visible.
**
** TILE
** Puts all windows in a 2D tile pattern.
**
** ICONIFY
** Iconifies all windows, and aligns them on the left side of the screen.
**/
OPTIONS RESULTS
OPTIONS FAILAT 11
PARSE ARG style
IF style = "" THEN
style = ICONIFY
ELSE
style = UPPER(style)
GetScreenInfo
PARSE VAR RESULT dummy dummy screenWidth screenHeight dummy '"' screenName '"' .
IF (RC ~= 0) THEN DO
RETURN
END
GetDocuments
docs = RESULT
GetPort
originalPort = RESULT
numIcons = 0
numWindows = 0
iconHeight = 0
DO WHILE docs ~= ''
PARSE VAR docs '"' names.numWindows '" ' ports.numWindows docs
ADDRESS VALUE ports.numWindows
GetWindowInfo
IF RC = 0 THEN DO
windowInfo = RESULT
GetScreenInfo
IF screenName = Strip(Word(RESULT,8),B,'"') THEN DO
icons.numWindows = FALSE
IF Word(windowInfo,1) = ON THEN DO
icons.numWindows = TRUE;
numIcons = numIcons + 1
iconHeight = Word(windowInfo,5)
END
numWindows = numWindows + 1
END
END
END
availHeight = (screenHeight - (numIcons * iconHeight))
numFull = numWindows - numIcons
yPos = 0
/* look ma, a bubble sort... */
swap = TRUE
DO WHILE swap = TRUE
i = 0
swap = FALSE
DO WHILE i < numWindows - 1
j = i + 1
IF names.i > names.j THEN DO
swap = TRUE
nswap = names.i
pswap = ports.i
iswap = icons.i
names.i = names.j
ports.i = ports.j
icons.i = icons.j
names.j = nswap
ports.j = pswap
icons.j = iswap
END
i = j
END
END
IF numFull = 0 THEN DO
style = ICONIFY
END
IF style = STACK THEN DO
wHeight = availHeight % numFull
winCnt = 0
ADDRESS VALUE originalPort
GetWindowInfo
IF Word(RESULT,1) = OFF THEN DO
MoveSizeWindow 0 0 screenWidth wHeight
Window2Front
yPos = wHeight
winCnt = 1
END
DO i = 0 TO numWindows-1
IF ports.i ~= originalPort THEN DO
IF icons.i = FALSE THEN DO
winCnt = winCnt + 1
IF (winCnt = numFull) THEN DO
wHeight = wHeight + (availHeight // numFull)
END
ADDRESS VALUE ports.i
MoveSizeWindow 0 yPos screenWidth wHeight
Window2Front
yPos = yPos+wHeight
END
END
END
END
IF style = CASCADE THEN DO
wHeight = availHeight
yPos = 0
IF iconHeight = 0 THEN DO
iconHeight = 15
END
DO i = 0 TO numWindows-1
IF ports.i ~= originalPort THEN DO
ADDRESS VALUE ports.i
IF icons.i = FALSE THEN DO
MoveSizeWindow 0 yPos screenWidth wHeight
Window2Front
wHeight = wHeight - iconHeight
yPos = yPos + iconHeight
END
END
END
ADDRESS VALUE originalPort
GetWindowInfo
IF Word(RESULT,1) = OFF THEN DO
MoveSizeWindow 0 yPos screenWidth wHeight
Window2Front
wHeight = wHeight - iconHeight
yPos = yPos + iconHeight
END
yPos = availHeight
END
IF style = TILE THEN DO
/* cheezy way of doing a square root... */
DO i = 2 TO 100
IF i*i > numFull THEN DO
i = i - 1
LEAVE
END
END
numW = i
numH = i
extras = numFull - (i*i)
IF extras > numH THEN DO
numH = numH + 1
extras = extras - numW
END
extras = - (numH - extras)
winCnt = 0
winInRow = numW + (extras >= 0)
wWidth = screenWidth % winInRow
wHeight = availHeight % numH
xPos = 0;
yPos = 0
rowCnt = 0;
ADDRESS VALUE originalPort
GetWindowInfo
IF Word(RESULT,1) = OFF THEN DO
winCnt = winCnt + 1
rowCnt = rowCnt + 1
IF rowCnt // winInRow = 0 THEN DO
MoveSizeWindow xPos yPos (screenWidth-xPos) wHeight
xPos = 0
yPos = yPos + wHeight
extras = extras + 1
winInRow = numW + (extras >= 0)
wWidth = screenWidth % winInRow
rowCnt = 0
IF winCnt + winInRow = numFull THEN DO
wHeight = availHeight - yPos
END
END; ELSE DO
MoveSizeWindow xPos yPos wWidth wHeight
xPos = xPos + wWidth;
END;
Window2Front
END
DO i = 0 TO numWindows-1
IF ports.i ~= originalPort THEN DO
IF icons.i = FALSE THEN DO
ADDRESS VALUE ports.i
winCnt = winCnt + 1
rowCnt = rowCnt + 1
IF rowCnt // winInRow = 0 THEN DO
MoveSizeWindow xPos yPos (screenWidth-xPos) wHeight
xPos = 0
yPos = yPos + wHeight
extras = extras + 1
winInRow = numW + (extras >= 0)
wWidth = screenWidth % winInRow
rowCnt = 0
IF winCnt + winInRow = numFull THEN DO
wHeight = availHeight - yPos
END
END; ELSE DO
MoveSizeWindow xPos yPos wWidth wHeight
xPos = xPos + wWidth;
END;
Window2Front
END
END
END
END
IF style = ICONIFY THEN DO
DO i = 0 TO numWindows-1
ADDRESS VALUE ports.i
IconifyWindow ON
GetWindowInfo
height = Word(RESULT,5)
yPos = yPos + height + 1
MoveSizeWindow 0 yPos
END
END; ELSE DO
DO i = 0 TO numWindows-1
IF icons.i = TRUE THEN DO
ADDRESS VALUE ports.i
MoveSizeWindow 0 yPos
Window2Front
yPos = yPos + iconHeight
END
END
END