BlitheDictionary


Overview

This class encapsulates the C functionality of Blithe. It not only makes use of some of the features of C++, but also makes life a little easier when getting entries. When you call the Entry method without passing in a buffer, it allocates one for you. It frees it for you the next time you call Entry or when the class is destroyed.


Constructor

BlitheDictionary(int32 dictionary = BL_DEFAULT_LANGUAGE, bool checkForAppDictionary = false);

The constructor takes a language ID dictionary and a boolean checkForAppDictionary.The class uses dictionary as a default language ID whenever zero is passed for a language ID. If checkForAppDictionary is true, it looks for an application dictionary with the language ID dictionary. If the application dictionary is not found, it throws an exception (class BlitheException) with a what of 'NOAP'.


Destructor

~BlitheDictionary(void);

The destructor frees the entry buffer, if there is one.


AppLanguageID

int32 AppLanguageID(void);

This method returns the current application language ID. It does not resolve the language ID if it is the global default language ID.


BlitheBitmap

BBitmap* BlitheBitmap(void);

This method retrieves a BBitmap* of the Blithe image, suitable for framing.


AppLanguageName

char* AppLanguageName(char* inBuffer = NULL, int32 inBuffLength = 0);

This method returns the name associated with the application language ID. If inBuffer is not null, it stores inBuffLength characters of the name in inBuffer and returns it. Otherwise, it allocates a buffer, which must be freed by the caller, and stores the name there.


Entry

char* Entry(int32 id,int32 dictionary = BL_DEFAULT_LANGUAGE, char* inBuffer = NULL, int32 inBuffLength = 0);

This method finds the proper string associated with entry ID id and returns it. It looks only in the dictionaries with language ID dictionary. If inBuffer is not null, it stores inBuffLength characters into inBuffer and returns it. If inBuffer is null, the class will allocate a buffer for you and return the string it. Do free this buffer. It will be freed the next time Entry is called or when the BlitheDictionary is destroyed.


Blob

void* Blob(uint32 type, int32 id, size_t *outBlobSize, int32 dictionary = BL_DEFAULT_LANGUAGE, void* inBuffer = NULL, int32 inBuffLength = 0);

This method acts like Entry, except it returns a pointer to data specified by type_code type (see BResources for this data type) and id. If there is resource in your dictionaries that matches the type and id, it will return null.


LanguageList

int32 LanguageList(char** outList);

This method acts exactly the same as the C function get_language_list. It allocates a character pointer array and character arrays for each element. Each element contains the name of an available language in the common dictionary. It returns the number of items in the array.


LanguageName

char* LanguageName(int32 id, char* inBuffer = NULL, inBuffLength = 0);

This method finds the language name associated with language ID id. If inBuffer is not null, it stores inBuffLength characters in inBuffer and returns it. Otherwise, it allocates a buffer, stores the name there, and returns it.


LanguageID

int32 LanguageID(char* name);

This method returns the language ID associated with the language name name.


LanguagePopupMenu

BPopupMenu* LanguagePopupMenu(void);

This method builds and returns a BPopupMenu with all of the language names of the available common dictionaries. When a menu item is selected from it, it sends a BLITHE_LANGUAGE_CHANGED message to the application with the proper language ID in the message.


SetAppLanguage

void SetAppLanguage(int32 inLangID);

This method sets the application language ID to inLangID.