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:

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