-
-
Save fushnisoft/da53fe79e297e979f621 to your computer and use it in GitHub Desktop.
Clarion - AdjustFontSizeByHeight
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! Code by MarkG on the skype cw-chat | |
AdjustFontSizeByHeight PROCEDURE(LONG xDesiredHInPixels, UNSIGNED xFEQ) | |
holdPixels LONG | |
CODE | |
holdPixels = 0{PROP:Pixels} | |
0{PROP:Pixels} = TRUE | |
IF xFEQ{PROP:Height} < xDesiredHInPixels | |
DO SearchByIncreasing | |
ELSIF xFEQ{PROP:Height} > xDesiredHInPixels | |
DO SearchByDecreasing | |
END | |
0{PROP:Pixels} = HoldPixels | |
SearchByIncreasing ROUTINE | |
LOOP | |
IF xFEQ{PROP:Height} = xDesiredHInPixels | |
BREAK | |
ELSIF xFEQ{PROP:Height} > xDesiredHInPixels | |
xFEQ{PROP:FontSize} = xFEQ{PROP:FontSize} - 1 | |
BREAK | |
ELSE | |
xFEQ{PROP:FontSize} = xFEQ{PROP:FontSize} + 1 | |
END | |
END | |
SearchByDecreasing ROUTINE | |
LOOP | |
IF xFEQ{PROP:Height} = xDesiredHInPixels | |
BREAK | |
ELSIF xFEQ{PROP:Height} < xDesiredHInPixels | |
xFEQ{PROP:FontSize} = xFEQ{PROP:FontSize} + 1 | |
BREAK | |
ELSE | |
xFEQ{PROP:FontSize} = xFEQ{PROP:FontSize} - 1 | |
END | |
END | |
!------------------------ | |
! Additional comments and things to change | |
Omit('***demo***') | |
AlterFontSizeToFit PROCEDURE(LONG xProp, LONG xDesired, UNSIGNED xFEQ) | |
CODE | |
IF xFEQ{xProp} < xDesired THEN DO SearchByIncreasing | |
ELSIF xFEQ{xProp} > xDesired THEN DO SearchByDecreasing | |
END | |
SearchByIncreasing ROUTINE | |
LOOP | |
IF xFEQ{xProp} = xDesired THEN BREAK | |
ELSIF xFEQ{xProp} > xDesired THEN xFEQ{PROP:FontSize} = xFEQ{PROP:FontSize} - 1; BREAK | |
ELSE xFEQ{PROP:FontSize} = xFEQ{PROP:FontSize} + 1 | |
END | |
END | |
SearchByDecreasing ROUTINE | |
LOOP | |
IF xFEQ{xProp} = xDesired THEN BREAK | |
ELSIF xFEQ{xProp} < xDesired THEN xFEQ{PROP:FontSize} = xFEQ{PROP:FontSize} + 1; BREAK | |
ELSE xFEQ{PROP:FontSize} = xFEQ{PROP:FontSize} - 1 | |
END | |
END[4:37 PM] Mark.Goldberg: | |
<<< AlterFontSizeToFitHeight PROCEDURE(LONG xDesired, UNSINGED xFEQ) | |
CODE | |
SELF.AlterFontSizeToFit( PROP:Height, xDesired, xFEQ) | |
AlterFontSizeToFitWidth PROCEDURE(LONG xDesired, UNSINGED xFEQ) | |
CODE | |
SELF.AlterFontSizeToFit( PROP:Width, xDesired, xFEQ) | |
***demo*** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment