Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clarion - Collapse Controls
qtFEQs QUEUE,TYPE
FEQ SIGNED
END
gtXYWH GROUP,TYPE
X LONG
Y LONG
W LONG
H LONG
END
MAX:FEQ EQUATE(2147483647) !equivalent of CLEAR(Long,1) = 2^31 - 1
MAP
GetFEQs (qtFEQs outQ, <*WINDOW xWin>, SIGNED xLowFEQ=-MAX:FEQ, SIGNED xHiFEQ=MAX:FEQ)
CollapseControl (SIGNED FeqToCollapse)
MoveControls (qtFEQs FEQs, LONG MoveByX, LONG MoveByY)
MoveControl (SIGNED inFEQ, LONG MoveByX, LONG MoveByY)
END
!---------------------------------------------------------------
GetFEQs PROCEDURE(qtFEQs outQ, <*WINDOW xWin>, SIGNED xLowFEQ=-MAX:FEQ, SIGNED xHiFEQ=MAX:FEQ)
PARAM:xWin EQUATE(2)
CurrFEQ LONG !no ,AUTO
CODE
FREE(outQ)
LOOP
CurrFEQ = xWin{PROP:NextField, CurrFEQ}
IF ~CurrFEQ
BREAK
END
IF INRANGE( CurrFEQ, xLowFEQ, xHiFEQ)
outQ.FEQ = CurrFEQ
ADD(outQ)
END
END
SORT(outQ, outQ.FEQ)
!---------------------------------------------------------------
CollapseControl PROCEDURE(SIGNED FeqToCollapse)
OrigHeight LONG,AUTO
FEQs QUEUE(qtFEQs)
END
CODE
OrigHeight = FeqToCollapse{PROP:Height}
FeqToCollapse{PROP:Height} = 0
GetFEQs(FEQs, ,1, ) ! 1 is the lowest FEQ we wish to include, this effectively excludes the window, menu and toolbar FEQs
DO CollapseControl:FilterControls
MoveControls(FEQs, 0, -OrigHeight)
CollapseControl:FilterControls ROUTINE
DATA
QPtr LONG,AUTO
CODE
! TO TEST: What should happen when FeqToCollapse{PROP:Parent} <> 0
! guessing should only include controls with the same parent.
LOOP QPtr = RECORDS(FEQs) TO 1 BY -1 !we are deleting, so go backwards
GET(FEQs, QPtr)
IF FEQs.FEQ{PROP:YPos } < FeqToCollapse{PROP:YPos} |
OR FEQs.FEQ{PROP:Parent} <> FeqToCollapse{PROP:Parent} | !Orig was filtering on Prop:Parent <> 0
OR FEQs.FEQ = FeqToCollapse |
THEN
DELETE(FEQs)
END
END
!---------------------------------------------------------------
MoveControls PROCEDURE(qtFEQs FEQs, LONG MoveByX, LONG MoveByY)
QPtr LONG,AUTO
CODE
SYSTEM{PROP:DeferMove} = RECORDS(FEQs)
LOOP QPtr = 1 TO RECORDS(FEQs)
GET(FEQs, QPtr)
MoveControl( FEQs.FEQ, MoveByX, MoveByY)
END
!---------------------------------------------------------------
MoveControl PROCEDURE(SIGNED inFEQ, LONG MoveByX, LONG MoveByY)
ControlPosition LIKE(gtXYWH)
CODE
GETPOSITION(inFEQ, ControlPosition.X, ControlPosition.Y, ControlPosition.W, ControlPosition.H)
ControlPosition.X += MoveByX
ControlPosition.Y += MoveByY
SETPOSITION(inFEQ, ControlPosition.X, ControlPosition.Y, ControlPosition.W, ControlPosition.H)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.