This chapter describes how to provide context-sensitive help in your application:
To create help text to be read by the Photon Helpviewer, you'll need two types of files:
The help files are written in HTML, and have .html as an extension. The Helpviewer supports the following tags (with attributes):
Element | Tags | Attributes |
---|---|---|
Comment | <!-- comment --> | |
Document | <html>...</html> | |
Head | <head>...</head> | |
Title | <title>...</title> | |
Link | <link> | href=url, rel=string |
Body | <body>...</body> | |
Heading 1 | <h1>...</h1> | id=string, align={left,center,right} |
Heading 2 | <h2>...</h2> | id=string, align={left,center,right} |
Heading 3 | <h3>...</h3> | id=string, align={left,center,right} |
Heading 4 | <h4>...</h4> | id=string, align={left,center,right} |
Heading 5 | <h5>...</h5> | id=string, align={left,center,right} |
Heading 6 | <h6>...</h6> | id=string, align={left,center,right} |
Rule | <hr> | id=string |
Paragraph | <p>...[</p>] | id=string |
Linebreak | <br> | id=string |
Image | <img> | src=url, align={top,middle,bottom}, alt=string, id=string (See note below) |
Anchor | <a>...</a> | href=url, name=string, id=string |
Preformatted | <pre>...</pre> | id=string |
Blockquote | <blockquote>...</blockquote> | id=string |
Address | <address>...</address> | id=string |
Note | <note>...</note> | src=url, id=string |
Definition list | <dl>...</dl> | compact, id=string |
Term | <dt>...[</dt>] | id=string |
Description | <dd>...[</dd>] | id=string |
Ordered list | <ol>...</ol> | id=string |
Unordered list | <ul>...</ul> | id=string |
List item | <li>...[</li>] | id=string |
Emphasis | <em>...</em> | id=string |
Strong | <strong>...</strong> | id=string |
Code | <code>...</code> | id=string |
Sample | <samp>...</samp> | id=string |
Keyboard | <kbd>...</kbd> | id=string |
Variable | <var>...</var> | id=string |
Definition | <dfn>...</dfn> | id=string |
Citation | <cite>...</cite> | id=string |
Teletype | <tt>...</tt> | id=string |
Bold | <b>...</b> | id=string |
Italic | <i>...</i> | id=string |
Underlined | <u>...</u> | id=string |
Table | <table>...</table> | border, align={left,center,right}, id=string |
Table heading | <th>...[</th>] | align={left,center,right}, id=string |
Table data | <td>...[</td>] | align={left,center,right}, id=string |
Table row | <tr>...[</tr>] | id=string |
The Helpviewer supports only GIF and BMP images. |
The Helpviewer also supports the standard HTML1/ISO entities for characters, plus:
Entity: | Meaning: | Rendered as: |
---|---|---|
| Nonbreaking space | Space |
  | Em-space | Space |
  | En-space | Space |
— | Em-dash | Dash (-) |
– | En-dash | Dash (-) |
“ | Left double quote | " |
” | Right double quote | " |
‘ | Left single quote | ' |
’ | Right single quote | ' |
™ | Trademark | TM |
Table-of-contents (TOC) files define the list of products that have help information, and the hierarchy of topics for each product. They have .toc as a file extension.
All these have to be under the /usr/help/product directory. Each product has a level-1 TOC file, and a directory with everything else. For example, Photon help includes:
photon.toc photon/
The photon.toc file consists of the following line:
1|Photon microGUI|./photon/bookset.html
where:
Don't use the vertical bar (|) in topic titles, because it's used as a delimiter in the TOC files. |
The photon directory contains a TOC file and a directory for each book. For example, it includes:
prog_guide.toc prog_guide/
The prog_guide.toc file is similar to photon.toc:
2|Programmer's Guide|./prog_guide/about.html
The prog_guide directory contains the HTML files, and a book.toc file that identifies the topic titles in the HTML files:
3|About This Guide|about.html#ABOUTTHISGUIDE 4|Assumptions|#id3 4|Changes and corrections|#ChangesAndCorrections 3|Introduction|intro.html#id1 4|Photon Application Builder - PhAB|#PhABApplications 6|Get immediate results|#id3 ...
The part of the URL following the # is an anchor defined in the HTML.
The Helpviewer understands two distinct ways of specifying the location of the HTML help text to be displayed:
/usr/help/product/photon/run_inst/pdm.html
URLs are case-sensitive. These URLs are restricted in scope to the help files; they can't be used to access the web. |
/Photon microGUI/Installation & Configuration/pdm
For the Helpviewer, the topic path is case-insensitive (unlike other HTML browsers) and may contain the wildcard characters * or ?, where * matches a string and ? matches a character. The first matching topic is selected.
A topic tree used by the Helpviewer must have at least three hierarchical levels: the top level is known as the bookshelf, the second level as the book set, and the third level as the book. A book may contain further levels of chapters and sections.
Entries in a bookshelf or book set should not contain any HTML, only .toc entries for the next level; help text should only be found in books.
You can display help information for a widget in the Helpviewer or in a help balloon. You can even use both methods in an application. For example, you could use a balloon for short explanations and the Helpviewer for more detailed help.
No matter which method you choose, you need to do the following in each of your application's windows:
If using the ? icon isn't suitable for your application, see "Help without the ? icon" later in this chapter.
For more information, see the Window Management chapter.
To use the Helpviewer to display help information for a widget, do the following:
Use a topic path, not a URL. |
The topic root should start with a slash (/), and should be the top of all topics for the window, usually taken from a TOC file in the /usr/help/product directory. For example:
/Photon microGUI/User's Guide
Introduction
When the user clicks on the ? icon and selects the widget, the help information is displayed in the Helpviewer.
If you get an error message about a bad link when you ask for help for a widget, make sure that the topic path is correct. |
To use a balloon to display help information for a widget:
When the user clicks on the ? icon, and selects the widget, the help information appears in a balloon.
In many applications the ? icon in the window frame isn't suitable. However, you may still want to use the Photon Helpviewer for displaying help. For example:
To get the mouse pointer to change to the Help pointer, forward the Ph_WM_HELP event to the window manager. The following code would be in a callback attached to a PtButton widget labeled Help:
int help_cb( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) { PhWindowEvent_t winev; memset( &winev, 0, sizeof(winev) ); winev.event_f = Ph_WM_HELP; winev.rid = PtWidgetRid( window ); PtForwardWindowEvent( &winev ); return( Pt_CONTINUE ); }
The window must have Ph_WM_HELP set in the Managed Flags (Pt_ARG_WINDOW_MANAGED_FLAGS) resource. You must also fill in the Help Topic (Pt_ARG_HELP_TOPIC) resource for the widgets that have help, as outlined above. |
Use the following functions (described in the Photon Library Reference) to access help from your application's code-you don't need them if you're using the method described in "Connecting help to widgets":
PxHelpUrlRoot() and PxHelpTopicRoot() don't save the passed string, so don't free it until you're finished using the help root. |