Scripting
HappyCommander
Derived from: none
Declared in: HappyCommander.h
HappyCommander is an example class to show how to command BeHappy from an application,
to use it to display the documentation and help files.
The source is free, you can modify it as you want, and include it in your application.
This is just an example, you'll probably have to change a few things.
Constructor and Destructor
|
|
|
HappyCommander(const char *addOnName, const char *addOnFileName, const char *htmlIndex)
| |
The constructor does nothing. It just copies the different names.
- addOnName is the name of the
add-on to use, as seen in BeHappy's 'Book' menu.
- addOnFileName is the file name of
the add-on. It doesn't have to be the same as
addOnName.
- htmlIndex is the file name of the
file to open if BeHappy isn't found.
Destroys the HappyCommander.
Member Functions
Checks if the add-on is installed in BeHappy's add-on folder. If it isn't, an alert
box will open, asking if the user wants the add-on automaticaly installed. If he
says yes, the add-on is installed. For this function to work, the add-on must be
at first in the application's folder. Its name must be
addOnFileName, as given to the HappyCommander()
constructor. If the user wants it to be installed, it will simply be moved in
BeHappy's add-on folder.
It can return one of the following values:
- HappyCommander::HC_OK if the add-on was correctly installed
- HappyCommander::HC_ALREADY_INSTALLED if it was already installed
- HappyCommander::HC_REFUSED if the user didn't want it to be installed
- HappyCommander::HC_NO_MORE_ASKING if the user didn't want it to be installed,
and didn't want to be asked anymore (you should save this with your preferences, to
avoid calling InstallAddOn() the next time your application
is launched).
- HappyCommander::HC_NO_ADDON if the add-on couldn't be found in the application's
folder.
- HappyCommander::HC_NO_BEHAPPY if BeHappy couldn't be found
- HappyCommander::HC_INSTALL_ERROR if another error occured
This function should be called when your application starts. (In BApplication::ReadyToRun(),
as an example). This function doesn't launch BeHappy.
|
|
|
int Show(const
char *index
= NULL, const char *
topic = NULL)
|
int Show(const
char *index, const char * fathertopic, const char * childtopic)
| |
Select a particular index and/or topic to show in BeHappy. The following actions
are performed:
If BeHappy isn't running, launch it
If BeHappy hasn't any window opened, open one
If the BeHappy window used by previous calls to Show() is
still there, select it. And if it isn't there anymore, open a new one
Sets the selected BeHappy window to the correct book (
addOnName, as given to the HappyCommander()
constructor).
Sets the window to the correct index
(if index isn't NULL)
Sets the window to the correct topic
(if topic isn't NULL)
The second version can be used with indexes that have two lists. You can select the topic in the upper list with fathertopic and the one in the lower list with childtopic.
It can return one of the following values:
- HappyCommander::HC_OK if the change was successfull
- HappyCommander::HC_NO_BEHAPPY if BeHappy wasn't found. In that case, the
file htmlIndex, as given to the
HappyCommander() constructor, is opened instead.
- HappyCommander::HC_OLD_BEHAPPY if the Behappy installed is a version
< 1.02, which doesn't understands scripting. That means the BeHappy window may not
be at the correct book, index and/or topic.
- HappyCommander::HC_NO_INDEX if the index wasn't found.
- HappyCommander::HC_NO_TOPIC if the topic wasn't found
- HappyCommander::HC_ERROR if another error occured (if the add-on has
disapeared, as an example)
Open the file htmlIndex,
as given to the HappyCommander() constructor. This
function is called by Show() when BeHappy isn't found.