UniTest is a simple application to show you how to use the Unicode-GLib library. It reads a Memo record
that starts with UniTest\n and is followed by Unicode characters written as four digit hex values.
It then lets you scroll the screen to see all the text you entered.
Take a look at the following pieces of code once you have UniTest downloaded:
Important includes and declarations
#define kUniD 'UniD'
#define kCMAP 'CMAP'
#define kNbrPaths 4
Declare these important global variables:
//UniBucketType holds the initialization data for using Unicode-GLib
UniBucketPtr uniBucketPtr = &uniBucket;
//Database Flags - these flags tell us whether we found important databases
Boolean foundUniCharDB = false;
Boolean foundMappingDB = false;
UInt8 foundVFS = false; //foundVFS means we can try to find databases on memory cards
UInt32 vfsMgrVersion = 0;
WinHandle bufferWinH = NULL; //Declare a buffer window that UniText will use
UniTextPtr textData; //pointer to the UniText gadget data
UInt16 textLength = 0; //length of our Unicode text in UInt16
MemHandle textH; //handle to our Unicode text
UniChar* textP; //pointer to our Unicode text
Look at these functions, which work to set up / clean up the Unicode library:
- StartApplication - sets up variables, calls OpenUnicode
- OpenUnicode - sets UniBucket variables, calls UniBucketOpenUnicode which opens font databases and initializes important font and unicode structures.
- StopApplication - deallocates memory, calls UniBucketCloseUnicode which closes all the fonts and databases we opened with UniBucketOpenUnicode
Look at these functions, which work to set up, clean up, and (re)display the UniText gadget:
- MainFormHandleEvent - handles form open/close, UniText scrolling, calls InitializeUniText, UninitializeUniText
- InitializeUniText - helper function to create UniText gadget data
- UninitializeUniText - helper function to clean up UniText gadget data