############################################################################
# Copyright (C) 1982-2005 ESL Syndetic Limited #
# All Rights Reserved. #
# #
# NOTICE #
# PROPRIETARY AND CONFIDENTIAL #
# #
# This computer program is and contains trade secret and confidential and #
# proprietary information of ESL Syndetic Limited. All use, disclosure, #
# and/or reproduction not specifically authorized in writing by #
# ESL Syndetic Limited is prohibited. This program may also be protected #
# under the copyright and trade secrets laws of countries other than the #
# U.S.A. #
# #
# #
############################################################################
screen size dialog units
string Region
action bar Menu is
pulldown File_PD text "~File"
choice Tile_MC text "~Tile"
separator
choice Exit_MC text "~Exit"
end pulldown
end action bar
primary graphical region Primary_GR
size 300 300 at 25 32
in desktop
size border
title bar "Primary"
system menu
action bar Menu
# no scale
minimize button
maximize button
graphical region Child1_GR
size 142 81 at 7 199
in Primary_GR
size border
title bar "First"
# no scale
system menu
minimize button
maximize button
graphical region Child2_GR
size 132 83 at 156 195
in Primary_GR
size border
title bar "Second"
system menu
# no scale
minimize button
maximize button
graphical region Child3_GR
size 135 94 at 11 81
in Primary_GR
size border
title bar "Third"
system menu
# no scale
minimize button
maximize button
graphical region Child4_GR
size 127 94 at 160 79
in Primary_GR
size border
title bar "Fourth"
# no scale
system menu
minimize button
maximize button
###########################################################################################
# #
# This sample code tiles child of graphical region into two levels in the region. If the #
# region contains an even number of children, both levels of the region contain the same #
# number of children. If the region contains an odd number of children, the first child #
# is twice the size of the other children and occupies the upper and lower levels of the #
# side of the region. The routine ignores invisible, minimized and maximized children, as #
# a result, if the parent contains a maximized child, any other children will be tiled #
# behined, which is become visible after the maximized children is minimized, made #
# invisible or one of the tiled children is activated. #
# #
###########################################################################################
subroutine TileChildren(string: ParentRegion) is
string Visible_Children # list containing all Children to be tiled
Children # list of Children to be processed
Child # Child being processed
integer Child_Counter # How many visible children in the region?
Odd_or_Even_Counter # Odd or even-numbered occurence of object?
Upper_Level_Loop # How many windows in the upper screen?
Lower_Level_Loop # How many windows in the lower screen?
Parent_XSize # Size of parents viewport (Width)
Parent_YSize # Size of parents viewport (Height)
Title_Height # Height of the Titlebar
# Ignore calls if parent is not a graphical region
if (type of ParentRegion = "graphical region") then
# Calculate the true size of the parent' viewport and titlebar of the children
copy ((xsize of ParentRegion) - ((2 * (window xsize of desktop)) / (xsize of desktop))) to Parent_XSize
copy ((ysize of ParentRegion) - ((4 * (window ysize of desktop)) / (ysize of desktop))) to Parent_YSize
copy ((26 * (window ysize of desktop)) / (ysize of desktop)) to Title_Height
# Dynamically build a list of visible children and determine value of counter variable Child_Counter.
for each child Child of ParentRegion loop
if ((visibility of Child) and
(Child is restored)) then
append " " Child to Visible_Children
copy (Child_Counter + 1) to Child_Counter
end if
end loop
# Move all child to the same position
copy Visible_Children to Children
while (Children != "") loop
extract from Children
take word Child
take to last Children
change Child position to 0 (Parent_YSize / 2)
# Change child size relative to size of primary region
if (Child_Counter mod 2 != 0) then
change Child size to (Parent_XSize / ((Child_Counter + 1) / 2))
((Parent_YSize / 2) - Title_Height)
else
change Child size to (Parent_XSize / (Child_Counter / 2))
((Parent_YSize / 2) - Title_Height)
end if
end loop
# Process all the children to position them correctly
copy Visible_Children to Children
while (Children != "") loop
extract from Children
take word Child
take to last Children
copy (Odd_or_Even_Counter + 1) to Odd_or_Even_Counter
# Odd or even number of objects?
if (Child_Counter mod 2 != 0) then # Odd Count
# Make the first child in an odd count double the height
if (Odd_or_Even_Counter = 1) then
change Child size by 0 (Parent_YSize / 2)
change Child position by 0 (0-(Parent_YSize / 2))
copy 1 to Upper_Level_Loop
copy 1 to Lower_Level_Loop
else
if ((Odd_or_Even_Counter mod 2) != 0) then
change Child position by (xsize of Child * Upper_Level_Loop) 0
copy (Upper_Level_Loop + 1) to Upper_Level_Loop
else
if (Odd_or_Even_Counter = 2) then
change Child position by (xsize of Child * Lower_Level_Loop)
(0 - (Parent_YSize / 2))
copy (Lower_Level_Loop + 1) to Lower_Level_Loop
else
if ((Odd_or_Even_Counter mod 2 = 0) and (Odd_or_Even_Counter != 2)) then
change Child position by (xsize of Child * Lower_Level_Loop)
(0 - (Parent_YSize / 2))
copy (Lower_Level_Loop + 1) to Lower_Level_Loop
end if
end if
end if
end if
else # Even Count
if (Odd_or_Even_Counter = 1) then
copy 1 to Upper_Level_Loop
else
if ((Odd_or_Even_Counter mod 2 != 0) and (Odd_or_Even_Counter != 1)) then
change Child position by (xsize of Child * Upper_Level_Loop) 0
copy (Upper_Level_Loop + 1) to Upper_Level_Loop
else
if (Odd_or_Even_Counter = 2) then
change Child position by 0 (0 - (Parent_YSize / 2))
copy (Lower_Level_Loop + 1) to Lower_Level_Loop
else
if ((Odd_or_Even_Counter mod 2 = 0) and (Odd_or_Even_Counter != 2)) then
change Child position by (xsize of Child * Lower_Level_Loop)
(0 - (Parent_YSize / 2))
copy (Lower_Level_Loop + 1) to Lower_Level_Loop
end if
end if
end if
end if
end if
end loop
end if
############################################################################
subroutine Resize(string: ParentRegion) is
string Title
Child
integer Parent_XSize
Parent_YSize
copy ((xsize of ParentRegion) - ((2 * (window xsize of desktop)) / (xsize of desktop))) to Parent_XSize
copy ((ysize of ParentRegion) - ((4 * (window ysize of desktop)) / (ysize of desktop))) to Parent_YSize
copy "Size is " Parent_XSize " by " Parent_YSize to Title
change ParentRegion text to Title
for each child Child of ParentRegion loop
if (type of Child = "graphical region") then
call Resize(Child)
end if
end loop
############################################################################
response to graphical region
on resize
copy object to Region
call Resize(Region)
############################################################################
response to item Tile_MC
copy ancestry to Region
call TileChildren(Region)
############################################################################
response to item Exit_MC
exit