OkfSetToDefaults
Set all
properties of the okf global variable to their default values.
int OkfSetToDefaults( void
);
Routine |
Required
Header |
OkfSetToDefaults |
"okf.h" |
Libraries
OKLIB.A |
Oankali's GP32
run-time library |
Return
Value
OkfSetToDefaults always
returns 0.
Parameters
None.
Remarks
The OkfSetToDefaults function
set all
properties of the okf global variable to their default values:
- Current font is set to the
first font in the list if the list is not empty, otherwise it is set to 0.
- Cursor position is set to
0,0.
- Justification is set to okfJustifyLeft.
- Character and line
separations are set to 0.
- Opacity of font and shadow
are set to 31.
- Shadow position is set to
0,0.
- Special effects of font and
shadow are set to okfNone, intensity
31, color 0.
- Clipping are is set to the
whole screen.
- Masks are used when
rendering fonts.
- Background position and
indents are set to 0,0.
- Background color and opacity
are set to 0.
- Background call back
function is set to NULL.
Use OkfSetToDefaults
when you start a new process to be sure of the current state of OKF Font Engine.
Then set the properties you need for the following printing functions.
It's a good practice, to make a
function independent from the others, to save the current state of the OKF Font Engine
in a temporal variable before using OkfSetToDefaults or before setting a
property. At the end of the function the state of the font engine can then be
restored with the temporal variable (see example). That way you are sure not to
interfere with the calling function.
Example
// Prints a message on the screen taking care
// of saving and restoring font engine state
// Note: surface flipping to be done by calling function
void PrintMessage(unsigned char *pMessage, int width)
{
OKFENGINE oldState;
unsigned char pMemoText[256];
int height;
// Save current state of the OKF Font Engine
oldState = okf;
// Set properties
OkfSetToDefaults();
okf.font = 1;
okf.justify = okfCenter;
// Prepare message
OkfSplitLines(pMessage, width, pMemoText);
height = OkfGetTextHeight(pMemoText);
// Print message centered on the screen
okf.x = GPC_LCD_WIDTH / 2;
okf.y = (GPC_LCD_HEIGHT - height) / 2;
OkfPrint(pMemoText);
// Restore state
okf = oldState;
}
|
See Also
OKF
Font Engine Routines, OKF Font Engine Constants,
OkfSplitLines