Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fushnisoft
Created July 31, 2012 13:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fushnisoft/da53fe79e297e979f621 to your computer and use it in GitHub Desktop.
Save fushnisoft/da53fe79e297e979f621 to your computer and use it in GitHub Desktop.
Clarion - AdjustFontSizeByHeight
! 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