home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
programs
/
fonts
/
a_q
/
fontpool
/
!Ex-C
/
h
/
FontPool
Wrap
Text File
|
1995-01-10
|
4KB
|
113 lines
/* Copyright (C) Eirik Hansen 1994
Functions to help interact with FontPool v0.12 in C.
(There is no reason this file cannot be set up as a FontPool-library...)
Parameters are mostly passed by means of the FontPool_Struct to prevent
function-calls from growing to long. These parameters all map to parameters
the different FontPool-SWIs require.
*/
/***** #includes.. **********************************************************/
#include "os.h"
/***** #defines.. ***********************************************************/
#define SWIBase 0x8D080
#define FP_Hello SWIBase+0
#define FP_Goodbye SWIBase+1
#define FP_CreateMenu SWIBase+2
#define FP_CreateSubMenu SWIBase+3
#define FP_MenuSelection SWIBase+4
#define FP_Configure SWIBase+5
#ifndef NULL
# define NULL 0 /* null pointer constant. */
#endif
/***** The variables.. ******************************************************/
os_regset r;
os_error *Error;
typedef struct
{ /* Relevant when calling FontPool.. */
unsigned Config; /* _Hello & _Configure */
int x, /* _CreateMenu _CreateSubMenu */
y, /* _CreateMenu _CreateSubMenu */
*RootMenu; /* _Create(Sub)Menu & _MenuSelection */
char *FontName; /* _MenuSelection & _Create(Sub)Menu. */
int *ParentItem; /* Set once after parent-menu is created. */
char *MenuFont; /* _Configure */
int SizeX, /* _Configure */
SizeY, /* _Configure */
ItemHgt; /* _Configure */
} FontPool_Struct;
/***** The functions.. ******************************************************/
/*==== 'Config' holds the same as FontPool_Hello Reg#1 =======================*/
os_error *FontPool_Hello(FontPool_Struct *FP)
{
r.r[1]=FP->Config;
Error=os_swix(FP_Hello, &r);
*FP->ParentItem=r.r[0];
return Error;
}
/*==== No input. Tells FontPool to decrease the number of clients. ===========*/
void FontPool_Goodbye(void)
{
os_swi(FP_Goodbye, &r);
return;
}
/*==== The input conforms with the SWI FontPool_CreateMenu ===================*/
os_error *FontPool_CreateMenu(FontPool_Struct *FP)
{
r.r[1]=(int) FP->FontName;
r.r[2]=FP->x;
r.r[3]=FP->y;
r.r[4]=(int) FP->RootMenu;
Error=os_swix(FP_CreateMenu, &r);
*FP->ParentItem=r.r[0];
return Error;
}
/*==== The input conforms with the SWI FontPool_CreateSubMenu ================*/
os_error *FontPool_CreateSubMenu(FontPool_Struct *FP)
{
r.r[1]=(int) FP->FontName;
r.r[2]=FP->x;
r.r[3]=FP->y;
r.r[4]=0;
Error=os_swix(FP_CreateSubMenu, &r);
*FP->ParentItem=r.r[0];
return Error;
}
/*==== The input conforms with the SWI FontPool_MenuSelection ================*/
/* Returns either a pointer to the font-name or NULL if none selected. */
char *FontPool_MenuSelection(int *Selections, FontPool_Struct *FP)
{
r.r[1]=(int) FP->RootMenu;
r.r[2]=(int) Selections;
r.r[3]=(int) FP->FontName;
os_swi(FP_MenuSelection, &r);
if (r.r[0]) return (char *) r.r[3];
return NULL;
}
/*==== 'Config' holds the same as FontPool_Hello Reg#1 =======================*/
/* 'Build' is either TRUE (build font-menu) or FALSE (don't build) */
os_error *FontPool_Configure(FontPool_Struct *FP, BOOL Build)
{
r.r[1]=FP->Config;
r.r[2]=(int) Build;
r.r[3]=(int) FP->MenuFont;
r.r[4]=FP->SizeX<<24 | FP->SizeY<<8 | FP->ItemHgt;
Error=os_swix(FP_Configure, &r);
*FP->ParentItem=r.r[0];
return Error;
}