OkfPrint, OkfPrintAt,
OkfPrintChar, OkfPrintCharAt,
OkfPrintLong, OkfPrintLongAt

Print data on the current screen.

int OkfPrint( unsigned char *pStr );

int OkfPrintAt( int x, int y, unsigned char *pStr );

int OkfPrintChar( unsigned char ch );

int OkfPrintCharAt( int x, int y, unsigned char ch );

int OkfPrintLong( long number, unsigned char *pFormat );

int OkfPrintLongAt( int x, int y, long number, unsigned char *pFormat );

Routine Required Header
OkfPrint "okf.h"
OkfPrintAt "okf.h"
OkfPrintChar "okf.h"
OkfPrintCharAt "okf.h"
OkfPrintLong "okf.h"
OkfPrintLongAt "okf.h"
 

Libraries

OKLIB.A Oankali's GP32 run-time library
 

Return Value

In case of success these printing functions return 0, otherwise these return -1. Look at okf.lastError for details on what happened.


Parameters

x

An integer value that indicates the horizontal coordinate where to print the data.

y

An integer value that indicates the vertical coordinate where to print the data.

pStr

A pointer to the string to be printed.

ch

The character to be printed.

number

The number to be printed.

pFormat

A pointer to the format string to use to format the number.


Remarks

These functions print the desired data taking into account all the properties settled in okf (font, justification, special effects, character and line separation, clipping area, etc...).
If okf.background.opacity > 0, a background is also painted taking into account the properties of the okf.background structure (see OkfPaintBackground for more details).

OkfPrint, OkfPrintChar and OkfPrintLong uses the current cursor position to print the data. okf.x and okf.y are then automatically updated and point to the next printing position.

OkfPrintAt, OkfPrintCharAt and OkfPrintLongAt uses x and y as starting cursor position to print the data. okf.x and okf.y are then automatically updated and point to the next printing position.

When printing left justified text, there is no limit for the length of the string. For centred or right justified printing, the length of the string to be printed has to be < MAX_LINE.

When using OkfPrintLong or OkfPrintLongAt, the length of the resulting formatted string must be < OKF_MAXNUMBER.

"\n" sequences are interpreted as new line characters like in standard printf C function. Every time a new line character is found, okf.x is initialized to its starting position and okf.y is incremented by the height of the line (GetCurrentFont()->pOkf->defaultHeight + GetCurrentFont()->pOkf->lineSeparation + okf.lineSeparation). Therefore if a new line character is added at the end of a string, okf.x remains unchanged at the end of the function.


Example

#include <gpdef.h>
#include <gpstdlib.h>
#include <gpgraphic.h>
#include "okf.h"
...

GPDRAWSURFACE gtSurface[2];
int giSurface;

static void DisplayMainMenu(void)
{
  // Set properties
  OkfSetToDefaults();
  okf.justify = okfCenter;
  okf.effect.color = 0xF800;     // Red
  okf.effect.intensity = 20;
 
  // Clear screen
  GpRectFill16(NULL, &gtSurface[giSurface], 0, 0,
               GPC_LCD_WIDTH, GPC_LCD_HEIGHT, 0xFFFF); // White

  // Title
  okf.font = 2;
  okf.effect.type = okfOverlay;
  OkfPrintAt(GPC_LCD_WIDTH / 2, 10, "GAME TITLE");
  okf.effect.type = okfNone;

  // Menu options
  OkfPrintAt(GPC_LCD_WIDTH / 2, 35, "START\nHELP\nOPTIONS\nCREDITS\n\nEXIT");

  // Memory available
  okf.font = 1;
  okf.justify = okfJustifyLeft;
  okf.x = 10;
  OkfPrintLong(gm_availablesize(), "Memory: %ld");

  // Flip surfaces
  GpSurfaceFlip(&gtSurface[giSurface]);
  giSurface ^= 0x01;
}

void GpMain(void *arg)
{
  // Init graphics mode and surfaces
  ...

  // Initialize OKF Font Engine
  OkfInitialize(gtSurface, &giSurface);

  // Register fonts
  OkfLoadAndRegister("gp:\\gpmm\\fonts\\big.okf");      // handle: 1
  OkfLoadAndRegister("gp:\\gpmm\\fonts\\normal.okf");   // handle: 2

  // Display main menu
  DisplayMainMenu();
  while (!GpKeyGet());

  // Terminate OKF Font Engine
  OkfTerminate();

  // Exit program
  GpAppExit();
}


See Also

OKF Font Engine Routines, OKF Font Engine Constants, OkfPaintBackground