# $RCSfile: help.itcl,v $ -- # # This file contains the routines for managing the display of # the help for a given GUI-module. This help is accessed by pressing # the "Help" button of a given ****help megawidget. # # Copyright (c) 2003--2004 Anton Kokalj Email: tone.kokalj@ijs.si # # # This file is distributed under the terms of the GNU General Public # License. See the file `COPYING' in the root directory of the present # distribution, or http://www.gnu.org/copyleft/gpl.txt . # # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # ANTON KOKALJ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # # $Id: help.itcl,v 1.3 2008-05-08 18:44:37 kokalj Exp $ # # # NOTE: the documentation of this file is yet to be build # # ------------------------------------------------------------------------ # DISPLAYHELP # ------------------------------------------------------------------------ #****f* widgets/displayhelp # NAME # ::guib::widgets::displayhelp -- displayhelp megawidget # USAGE # displayhelp varName helpFmt helpText # DESCRIPTION # Displayhelp megawidget display a help associated with a given # input variable defined in module definition file. # ARGUMENTS # varName -- the GUIB input variable's identifier # helpFmt -- the format of the help-text, (html|txt2html|txt) # helpText -- the help-text to be displayed # RETURN VALUE # Returns the path of the displayhelp's toplevel widget. #******** # ------------------------------------------------------------------------ proc ::guib::widgets::displayhelp {varName varType helpFmt helpText} { set t [::guib::widgets::toplevel [::tku::widgetName] -title "Help console: $varName"] #set labelText "Description of the variable: $varName" set labelText "" set HELP_FMT [string toupper $helpFmt] switch -- $HELP_FMT { "HELPDOC" { # this is for html generated by helpdoc utility set labelText "" set html_head "\n
\n
}
if { $varType != "" } {
set html_vartype " Variable's type: $varType
"
} else {
set html_vartype ""
}
set html_tail {
}
if { $HELP_FMT == "TXT2HTML" } {
set helpText [format %s%s%s%s%s%s \
[subst $html_head] [subst $html_vartype] \
"
\n" $helpText "" \ [subst $html_tail]] } else { set helpText [format %s%s%s%s \ [subst $html_head] [subst $html_vartype] \ $helpText \ [subst $html_tail]] } set wid [::iwidgets::scrolledhtml $t.html \ -labeltext $labelText \ -linkcommand [list $t.html import -link] \ -wrap word -vscrollmode static \ -hscrollmode static] $wid render $helpText } "TXT" { # format == TXT (in the FUTURE also add the support for LaTex) set wid [::iwidgets::scrolledtext $t.text \ -labeltext $labelText \ -vscrollmode static \ -hscrollmode static \ -wrap none] set txt_head { Variable: $varName Variable's type: $varType } $wid insert end [format %s%s [subst $txt_head] $helpText] } default { ::tclu::ERROR "unknown help format $helpFMT, must be html, txt2html, or txt" } } #$wid configure -width 700 -height 300 set bb [::iwidgets::buttonbox $t.bb] $bb add Close -text "Close" -command "destroy $t" $bb default Close pack $bb -side top -fill x -expand 0 pack $wid -before $bb -side top -fill both -expand 1 ::tku::centerWindow $t return $t }