The Classes
HTMLProject
Derived from: BArchivable
Declared in: HTMLProject.h
The HTMLProject class represents any BeHappy add-on, and includes all what's needed by BeHappy to communicate with it. Inherit from this class to do an add-on.
Some functions in this class are useful only for BeHappy, so you won't need to use them, but if you're curious, I also tell a few things about them. I've just put a warning message underneath their name: You shouldn't need this. I've also marked the virtual functions.
Hook Functions
FindHome()
About()
GiveConfig()
Update()
GiveSupportedAddOns() (not used yet)
Constructor and Destructor
|
|
|
HTMLProject()
|
HTMLProject(BMessage *archive)
| |
The constructor just creates a new project object. The first version creates an empty project (the happyList variable is set to NULL), and the second one rebuilds the happyList from the given archive.
Warning: don't overload the HTMLProject destructor. As it isn't virtual, it would never be called by BeHappy.
Frees all the memory allocated by the project, including the happy list.
Static Functions
see BArchivable::Instantiate().
Member Functions
virtual
Called by BeHappy when the user asks information about the add-on. Should display an 'About' window.
You shouldn't need this
|
|
|
unsigned int AddFile( const char *fname, int guess=-1)
| |
Adds a file name in the project file database. Returns the number of the file in this database. The HTMLLabels store the file number instead of the file name, for some obvious memory economy reasons. If the file is already stored in the database, this method simply returns its number. The search can be sped up with the guess parameter, if you know an approximate value.
You shouldn't need this
|
|
|
unsigned int AddLabel( const HTMLLabel *label)
| |
Adds a label in the project label database, and returns the number of this label. (The number is used in the happylinks)
see BArchivable::Archive()
Empties the happyList. (Called at the beginning of Update().)
You shouldn't need this
This method returns the HTMLFile object associated with the index index.
|
|
|
BPath *GetPath( const char *fname )
| |
Returns the path of the file specified by the relative name fname. See SetHome().
virtual - not used yet
|
|
|
const char **GiveSupportedAddOns()
| |
Unused in this version
virtual
Called by BeHappy to find the home directory for the documentation. (Use the SetHome() function once you've found it). Returns true if the directory if found. If FindHome() returns false, BeHappy will open a window asking the user to enter the path manualy.
If FindHome() returns false but has called SetHome() before, BeHappy will display the given path in its window. The user can modify it, or just confirm it.
virtual
|
|
|
const unsigned int *GiveConfig() const
| |
Returns an array of unsigned int containing the configurations of the different indexes (double or simple lists, 'find' options etc...). The number of integers must be the same as (or at least greater than) the number of indexes. Have a look at the constants to know what defined constants you can use in this function. Each integer is associated with an index.
|
|
|
BString *GiveName( unsigned int index )
| |
Gives the full name of a label indentified by its index number index. A full label name is a string like 'FileName.html#LabelName'.
Returns true if the object initialisation was done correctly, or false if there has been an error.
|
|
|
void NumPrint(unsigned int n)
| |
Tells BeHappy how much Print() calls there will be during the update. Only the Print()s for the second line will be counted.
|
|
|
void Print(const char *line1,const char *line2 = NULL)
| |
Changes the information displayed during the update. If one of the parameters line1 or line2 is NULL, the corresponding line isn't changed. A Print() call with line2 different from NULL also makes the status bar progress. Use the NumPrint() method to tell how much Print() call will be done to fill the status bar. If you only print on the first line (i.e. if line2=NULL), nothing will be done to the status bar.
|
|
|
void SetHome( const BDirectory &dir)
| |
Set the new home directory to dir. All the file names used in the project will be relative to this directory. It should be set in the FindHome() method. If FindHome() returns false, BeHappy will set the home path itself. SetHome() shouldn't be called elsewhere.
You shouldn't use this
|
|
|
void SetInfoMessenger(BMessenger &mess)
| |
Called by BeHappy to give a messenger to the window used to display information about the status of the update. Used by Print().
|
|
|
const char *GetFile( const char *string ) const
| |
This method translates the string given in argument. The language used is the one selected by the user in BeHappy. You should create a .loc file to use this functionnality. You can translate all the strings you want, except the index names, which are automaticly translated by BeHappy. See also "Localisation".
virtual
This method is called when BeHappy wants to do an update of the index. It should empty the index (i.e. call Clean()) and recreate it. For this use the happyList variable, wich must be created here.
The HappyLink* parameter isn't used in this version of BeHappy. Don't use it.
Member Variables
happyList is the head of the tree of HappyLinks. It's created in the Update() method. It should have the name of the add-on, and its children are the indexes used by BeHappy.