home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / HELPDEV.PRG < prev    next >
Encoding:
Text File  |  1991-09-02  |  22.8 KB  |  690 lines

  1. /*
  2.    Program: HELPDEV.PRG
  3.    System: GRUMPFISH LIBRARY
  4.    Author: Greg Lief
  5.    Copyright (c) 1988-90, Greg Lief
  6.    Clipper 5.01 Version
  7.    Compile instructions: clipper helpdev /n/a
  8.  
  9.    Procs & Fncts: HELPDEV()
  10.                 : HELPSCREEN()
  11.                 : PICKACOLOR()
  12.                 : DRAW_FTHD()
  13.                 : EDITHELP()
  14.                 : HELPHEAD()
  15.    Creates/displays user-defined help screens
  16. */
  17.  
  18. //───── begin preprocessor directives
  19.  
  20. #include "grump.ch"
  21. #include "inkey.ch"
  22. #include "achoice.ch"
  23.  
  24. //───── end preprocessor directives
  25.  
  26. //───── begin global declarations
  27.  
  28. static buffer                           // saved entry screen
  29. static palette := []                    // color palette
  30. static helptext                         // help text
  31. static helpdefs_ := { 0,   ;            // top row of help window
  32.                       0,   ;            // left column of help window
  33.                       20,  ;            // bottom row of help window
  34.                       79,  ;            // right column of help window
  35.                       2,   ;            // box outline type (single)
  36.                       7,   ;            // color for box outline (W/N)
  37.                       112, ;            // color for title (N/W)
  38.                       112, ;            // color for footer (N/W)
  39.                       15,  ;            // color for help text (+W/N)
  40.                       "Help Screen", ;  // default title
  41.         "  Alt-P print  Esc exit", ;  // default footer
  42.                       "help" }          // default filename (HELP.DBF)
  43.  
  44. //───── manifest constants for the contents of the HELPDEV array
  45. #define TopRow        helpdefs_[1]
  46. #define LeftColumn    helpdefs_[2]
  47. #define BottomRow     helpdefs_[3]
  48. #define RightColumn   helpdefs_[4]
  49. #define BoxType       helpdefs_[5]
  50. #define BoxColor      helpdefs_[6]
  51. #define TitleColor    helpdefs_[7]
  52. #define FooterColor   helpdefs_[8]
  53. #define TextColor     helpdefs_[9]
  54. #define Title         helpdefs_[10]
  55. #define Footer        helpdefs_[11]
  56. #define HelpFile      helpdefs_[12]
  57.  
  58. //───── end global declarations
  59.  
  60. function helpdev(mproc, mline, mvar)
  61. local hotkey := 0, wk_area := select(), oldinsert, mid, ;
  62.       oldscore := set(_SET_SCOREBOARD, .F.), oldblock
  63. memvar helpcode   // would be declared in the calling program if it exists
  64.  
  65. /*
  66.    usually if HELPDEV() was called from anything other than GINKEY(),
  67.    MPROC will be a null string.  We would then have to use the procedure
  68.    name three levels deep.  However, in the event that the procedure
  69.    name passed to HELPDEV() is an internal Clipper function (beginning
  70.    with double underscore "__"), then we must use the procedure name
  71.    four levels deep.
  72. */
  73. if empty(mproc)
  74.    mproc := procname(3)
  75. elseif left(mproc, 2) = '__'
  76.    mproc := procname(4)
  77. endif
  78. oldblock := setkey(hotkey := lastkey(), NIL)
  79. GFSaveEnv(, 0)                      // turn off cursor
  80. if ! file(HelpFile + '.dbf')
  81.    waiton('initializing help database... please wait')
  82.    dbcreate(HelpFile + ".dbf", { {"THEPROC", "C", 10, 0} , ;
  83.                                  {"VAR",     "C", 10, 0} , ;
  84.                                  {"TEXT",    "M", 10, 0} , ;
  85.                                  {"TOPROW",  "N",  2, 0} , ;
  86.                                  {"BOTROW",  "N",  2, 0} , ;
  87.                                  {"LT_COL",  "N",  2, 0} , ;
  88.                                  {"RT_COL",  "N",  2, 0} , ;
  89.                                  {"BOXCOLOR","N",  3, 0} , ;
  90.                                  {"TITCOLOR","N",  3, 0} , ;
  91.                                  {"TXTCOLOR","N",  3, 0} , ;
  92.                                  {"BOXNO",   "N",  1, 0} , ;
  93.                                  {"TITLE",   "C", 30, 0} , ;
  94.                                  {"FTCOLOR", "N",  3, 0} , ;
  95.                                  {"FOOTER",  "C", 30, 0} } )
  96.    use (HelpFile) new exclusive
  97.    index on _field->theproc + _field->var to (HelpFile)
  98.    waitoff()
  99. else
  100.    use (HelpFile) new
  101. endif
  102. buffer := savescreen(0, 0, maxrow(), maxcol())
  103. if ! file(HelpFile + '.ntx')     && must rebuild help index file
  104.    if flock()
  105.       waiton("Indexing help database")
  106.       index on _field->theproc + _field->var to (HelpFile)
  107.       unlock
  108.    else
  109.       waiton("Database is being reindexed... please wait or press Esc to abort")
  110.       do while ! flock() .and. inkey() != K_ESC
  111.       enddo
  112.    endif
  113.    waitoff()
  114. else
  115.    set index to (HelpFile)
  116. endif
  117.  
  118. //───── seek on helpcode first if such a variable is defined
  119. seek if(type('helpcode') == "U", padr(mproc, 10) + padr(mvar, 10), ;
  120.         padr(helpcode, 20))
  121. if found()
  122.    setcolor(Color_N2S((HelpFile)->boxcolor))
  123.    shadowbox((HelpFile)->toprow, (HelpFile)->lt_col, (HelpFile)->botrow, ;
  124.              (HelpFile)->rt_col, (HelpFile)->boxno)
  125.    mid := (HelpFile)->lt_col + (int((HelpFile)->rt_col - (HelpFile)->lt_col) / 2)
  126.    @ (HelpFile)->toprow, mid - int(len(trim((HelpFile)->title))/2) ;
  127.             ssay trim((HelpFile)->title) color Color_N2S((HelpFile)->titcolor)
  128.    @ (HelpFile)->botrow, mid - int(len(trim((HelpFile)->footer))/2) ;
  129.             ssay trim((HelpFile)->footer) color Color_N2S((HelpFile)->ftcolor)
  130.    setcolor(Color_N2S((HelpFile)->txtcolor))
  131.    memoedit((HelpFile)->text, (HelpFile)->toprow + 1, (HelpFile)->lt_col + 1, ;
  132.             (HelpFile)->botrow - 1, (HelpFile)->rt_col - 1, .f., 'EditHelp')
  133. else
  134.    setcolor('+w/n')
  135.    SINGLEBOX(0, 0, 20, 79)
  136.    SCRNCENTER(0, '<< help screen >>')
  137.    SCRNCENTER(10, 'no help text defined...')
  138.    SCRNCENTER(12, 'Press F2 to create, any other key to go back')
  139.    if ginkey(0) == K_F2
  140.       restscreen(0, 0, maxrow(), maxcol(), buffer)
  141.       oldinsert := readinsert(.T.)    // toggle insert mode on, save status
  142.       setcolor(BoxColor)
  143.       shadowbox(TopRow, LeftColumn, BottomRow, RightColumn, BoxType)
  144.       mid := LeftColumn + (int(RightColumn - LeftColumn) / 2)
  145.       @ BottomRow, mid - 12 ssay ' Ctrl-W save   Esc quit '
  146.       setcursor(2)
  147.       helptext := memoedit([], TopRow + 1, LeftColumn + 1, ;
  148.                            BottomRow - 1, RightColumn - 1, .t.)
  149.       readinsert(oldinsert)
  150.       setcursor(0)
  151.       if ! empty(helptext)
  152.          append blank
  153.          if ! neterr()
  154.             replace (HelpFile)->theproc with if(type('helpcode') == "U", ;
  155.                                     mproc, substr(helpcode, 1, 10)), ;
  156.                     (HelpFile)->var with if(type('helpcode') == "U", ;
  157.                                     mvar, substr(helpcode, 11, 10)), ;
  158.                     (HelpFile)->text with helptext
  159.             //───── redraw bottom row of box, clearing out Save/Quit msg
  160.             @ BottomRow, mid - 12 ssay ;
  161.                   replicate(substr(BOXFRAMES[BoxType], 6, 1), 24)
  162.             HelpScreen("A")
  163.          else
  164.             Err_Msg(NETERR_MSG)
  165.          endif
  166.       endif
  167.    endif
  168. endif
  169.  
  170. //───── restore hot-key
  171. setkey( hotkey, oldblock )
  172. restscreen(0, 0, maxrow(), maxcol(), buffer)
  173. use
  174. select(wk_area)
  175. set(_SET_SCOREBOARD, oldscore)    // in case you were keeping SCORE
  176. GFRestEnv()
  177. return NIL
  178.  
  179. * end of function HelpDev()
  180. *--------------------------------------------------------------------
  181.  
  182.  
  183. /*
  184.    Function: HelpScreen()
  185.    allow user to select box coordinates, box type, title,
  186.    and colors for this help screen
  187. */
  188. static function HelpScreen(mode)     // A = adding new, E = editing existing
  189. local xx, yy, key, buffer2, buffer3, firstloop, redraw, palettetop
  190. local getlist := {}
  191. local mainloop := .t.
  192. static boxtypes := {}
  193. if len(boxtypes) == 0
  194.    for xx = 1 to 5
  195.       aadd(boxtypes, substr(BOXFRAMES[xx], 1, 8))
  196.    next
  197.    aadd(boxtypes, 'no border')
  198. endif
  199.  
  200. if mode == 'E'
  201.    TopRow      := (HelpFile)->toprow
  202.    LeftColumn  := (HelpFile)->lt_col
  203.    BottomRow   := (HelpFile)->botrow
  204.    RightColumn := (HelpFile)->rt_col
  205.    BoxType     := (HelpFile)->boxno
  206.    BoxColor    := (HelpFile)->boxcolor
  207.    TitleColor  := (HelpFile)->titcolor
  208.    FooterColor := (HelpFile)->ftcolor
  209.    TextColor   := (HelpFile)->txtcolor
  210.    Title       := (HelpFile)->title
  211.    Footer      := (HelpFile)->footer
  212. endif
  213.  
  214. do while mainloop
  215.    ColorSet(C_MESSAGE)
  216.    buffer2 := ShadowBox(maxrow()-3, 11, maxrow(), 68, 2)
  217.    SCRNCENTER(maxrow()-2, 'use arrow keys to drag top left corner of help box')
  218.    SCRNCENTER(maxrow()-1, 'press Enter when finished')
  219.  
  220.    //───── get top left coordinate for help box
  221.    firstloop := .t.
  222.    key := 0
  223.    do while key != K_ENTER
  224.       redraw := .t.
  225.       key := inkey(0)
  226.       if firstloop
  227.          ByeByeBox(buffer2)
  228.          firstloop := .f.
  229.       endif
  230.       dispbegin()
  231.       do case
  232.  
  233.          case key == K_DOWN .and. TopRow < maxrow()-4 .and. ;
  234.                                  TopRow < BottomRow - 4
  235.             restscreen(0, 0, maxrow(), maxcol(), buffer)
  236.             TopRow++
  237.  
  238.          case key == K_UP .and. TopRow > 0
  239.             TopRow--
  240.  
  241.          case key == K_RIGHT .and. LeftColumn < maxcol()-9 .and. ;
  242.                                   LeftColumn < RightColumn - 11
  243.             restscreen(0, 0, maxrow(), maxcol(), buffer)
  244.             LeftColumn++
  245.  
  246.          case key == K_TAB .and. LeftColumn < maxcol()-14 .and. ;
  247.                                 LeftColumn < RightColumn - 16
  248.             restscreen(0, 0, maxrow(), maxcol(), buffer)
  249.             LeftColumn += 5
  250.  
  251.          case key == K_SH_TAB .and. LeftColumn > 5
  252.             restscreen(0, 0, maxrow(), maxcol(), buffer)
  253.             LeftColumn -= 5
  254.  
  255.          case key == K_LEFT .and. LeftColumn > 0
  256.             restscreen(0, 0, maxrow(), maxcol(), buffer)
  257.             LeftColumn--
  258.  
  259.          case key == K_CTRL_LEFT .and. LeftColumn > 0
  260.             restscreen(0, 0, maxrow(), maxcol(), buffer)
  261.             LeftColumn := 0
  262.  
  263.          case key == K_HOME           // reposition at top left corner
  264.             LeftColumn := TopRow := 0
  265.  
  266.          otherwise
  267.             redraw := .f.
  268.       endcase
  269.       if redraw
  270.          @ TopRow,LeftColumn,BottomRow,RightColumn box BOXFRAMES[BoxType] ;
  271.                   color Color_N2S(BoxColor)
  272.          setcolor(Color_N2S(TextColor))
  273.          memoedit(helptext, TopRow+1, LeftColumn+1, BottomRow-1, ;
  274.                   RightColumn-1, .f., .f.)
  275.       endif
  276.       dispend()
  277.    enddo
  278.  
  279.    //───── get bottom right coordinate of help box
  280.    ColorSet(C_MESSAGE)
  281.    buffer2 := ShadowBox(maxrow()-3, 11, maxrow(), 68, 2)
  282.    SCRNCENTER(maxrow() - 2, ;
  283.               'Use arrow keys to drag bottom right corner of help box')
  284.    SCRNCENTER(maxrow() - 1, 'Press Enter when finished')
  285.    firstloop := .t.
  286.    key := 0
  287.    do while key != K_ENTER
  288.       redraw := .t.
  289.       key := inkey(0)
  290.       if firstloop
  291.          ByeByeBox(buffer2)
  292.          firstloop := .f.
  293.       endif
  294.       dispbegin()
  295.       do case
  296.  
  297.          case key == K_DOWN .and. BottomRow < maxrow()
  298.             BottomRow++
  299.  
  300.          case key == K_UP .and. BottomRow > 6 .and. BottomRow > TopRow + 4
  301.             restscreen(0, 0, maxrow(), maxcol(), buffer)
  302.             BottomRow--
  303.  
  304.          case key == K_RIGHT .and. RightColumn < maxcol()
  305.             RightColumn++
  306.  
  307.          case key == K_LEFT .and. RightColumn > 11 .and. ;
  308.                                  RightColumn > LeftColumn + 11
  309.             restscreen(0, 0, maxrow(), maxcol(), buffer)
  310.             RightColumn--
  311.  
  312.          case key == K_END           // reposition at bottom right corner
  313.             RightColumn := maxcol()
  314.             BottomRow := maxrow()
  315.  
  316.          case key == K_TAB .and. RightColumn < maxcol() - 5
  317.             RightColumn += 5
  318.  
  319.          case key == K_SH_TAB .and. RightColumn > 16 .and. ;
  320.                                  RightColumn > LeftColumn + 16
  321.             restscreen(0, 0, maxrow(), maxcol(), buffer)
  322.             RightColumn -= 5
  323.  
  324.          case key == K_CTRL_RIGHT .and. RightColumn < maxcol()
  325.             RightColumn := maxcol()
  326.  
  327.          otherwise
  328.             redraw := .f.
  329.       endcase
  330.       if redraw
  331.          @ TopRow, LeftColumn, BottomRow, RightColumn box BOXFRAMES[BoxType] ;
  332.                    color Color_N2S(BoxColor)
  333.          setcolor(Color_N2S(TextColor))
  334.          memoedit(helptext, TopRow + 1, LeftColumn + 1, BottomRow - 1, ;
  335.                   RightColumn - 1, .f., .f.)
  336.       endif
  337.       dispend()
  338.    enddo
  339.  
  340.    //───── drag box around
  341.    ColorSet(C_MESSAGE)
  342.    buffer2 := ShadowBox(maxrow()-3, 14, maxrow(), 65, 2)
  343.    SCRNCENTER(maxrow() - 2, 'Use arrow keys to drag box to desired location')
  344.    SCRNCENTER(maxrow() - 1, 'Press Enter when finished')
  345.    firstloop := .t.
  346.    key := 0
  347.    do while key != K_ENTER
  348.       redraw := .t.
  349.       key := inkey(0)
  350.       if firstloop
  351.          ByeByeBox(buffer2)
  352.          buffer2 := savescreen(TopRow, LeftColumn, BottomRow, RightColumn)
  353.          firstloop := .f.
  354.       endif
  355.       dispbegin()
  356.       do case
  357.  
  358.          case key == K_HOME
  359.             BottomRow -= TopRow
  360.             RightColumn -= LeftColumn
  361.             TopRow := LeftColumn := 0
  362.  
  363.          case key == K_PGUP
  364.             BottomRow -= TopRow
  365.             TopRow := 0
  366.  
  367.          case key == K_END
  368.             TopRow += maxrow()- BottomRow
  369.             LeftColumn += maxcol() - RightColumn
  370.             BottomRow := maxrow()
  371.             RightColumn := maxcol()
  372.  
  373.          case key == K_PGDN
  374.             TopRow += maxrow() - BottomRow
  375.             BottomRow := maxrow()
  376.  
  377.          case key == K_UP .and. TopRow > 0
  378.             TopRow--
  379.             BottomRow--
  380.  
  381.          case key == K_DOWN .and. BottomRow < maxrow()
  382.             TopRow++
  383.             BottomRow++
  384.  
  385.          case key == K_LEFT .and. LeftColumn > 0
  386.             LeftColumn--
  387.             RightColumn--
  388.  
  389.          case key == K_RIGHT .and. RightColumn < maxcol()
  390.             LeftColumn++
  391.             RightColumn++
  392.  
  393.          case key == K_CTRL_LEFT .and. LeftColumn > 0
  394.             RightColumn -= LeftColumn
  395.             LeftColumn := 0
  396.  
  397.          case key == K_CTRL_RIGHT .and. RightColumn < maxcol()
  398.             LeftColumn += maxcol() - RightColumn
  399.             RightColumn := maxcol()
  400.  
  401.          otherwise
  402.             redraw = .f.
  403.       endcase
  404.       if redraw
  405.          restscreen(0, 0, maxrow(), maxcol(), buffer)
  406.          restscreen(TopRow, LeftColumn, BottomRow, RightColumn, buffer2)
  407.       endif
  408.       dispend()
  409.    enddo
  410.  
  411.    //───── redraw header and footer if we are editing an existing screen
  412.    if mode == "E"
  413.       Draw_FtHd()
  414.    endif
  415.  
  416.    //───── select box outline
  417.    ColorSet(C_MESSAGE)
  418.    buffer2 := ShadowBox(maxrow()-3, 18, maxrow(), 61, 2)
  419.    SCRNCENTER(maxrow()-2, 'Use arrow keys to select help box outline')
  420.    SCRNCENTER(maxrow()-1, 'Press Enter when finished')
  421.    buffer3 := shadowbox(10, 35, 17, 44, 2)
  422.    BoxType := max(achoice(11, 36, 17, 43, boxtypes, '', 'PickABox', ;
  423.                  BoxType, BoxType), 1)
  424.    ByeByebox(buffer3)
  425.    @ TopRow, LeftColumn, BottomRow, RightColumn ;
  426.                 box substr(BOXFRAMES[BoxType], 1, 8) color Color_N2S(BoxColor)
  427.    Draw_FtHd()
  428.    ByeByeBox(buffer2)
  429.  
  430.    //───── header and footer
  431.    ColorSet(C_MESSAGE)
  432.    Title := padr(Title, 30)
  433.    Footer := padr(Footer, 30)
  434.    buffer2 := ShadowBox(maxrow()-3, 10, maxrow(), 69, 2)
  435.    @ 22, 12 ssay 'Enter help screen header:'
  436.    @ 23, 12 ssay 'Enter help screen footer:'
  437.    @ 22, 38 get Title
  438.    @ 23, 38 get Footer
  439.    setcursor(2)
  440.    read
  441.    setcursor(0)
  442.    ByeByeBox(buffer2)
  443.    @ TopRow, LeftColumn, BottomRow, RightColumn ;
  444.              box substr(BOXFRAMES[BoxType], 1, 8) color Color_N2S(BoxColor)
  445.    Draw_FtHd()
  446.  
  447.    //───── draw color palette based upon location of help window
  448.    palettetop := if(TopRow > 8, 0, 14)
  449.    if empty(palette)
  450.       for xx = 0 to 127
  451.          palette += " " + chr(xx) + chr(4) + chr(xx) + " " + chr(xx)
  452.       next
  453.    endif
  454.    restscreen(palettetop, 16, palettetop + 7, 63, palette)
  455.    setcolor('w/n')
  456.    scroll(palettetop + 8, 16, palettetop + 8, 63, 0)
  457.  
  458.    BoxColor    := PickAColor('box',    BoxColor,    palettetop)
  459.    TitleColor  := PickAColor('title',  TitleColor,  palettetop)
  460.    FooterColor := PickAColor('footer', FooterColor, palettetop)
  461.    TextColor   := PickAColor('text',   TextColor,   palettetop)
  462.  
  463.    //───── okay, show 'em the beast and ask for confirmation
  464.    restscreen(0, 0, maxrow(), maxcol(), buffer)
  465.    setcolor(Color_N2S(BoxColor))
  466.    shadowbox(TopRow, LeftColumn, BottomRow, RightColumn, BoxType)
  467.    Draw_FtHd()
  468.    setcolor(Color_N2S(TextColor))
  469.    memoedit(helptext, TopRow+1, LeftColumn+1, BottomRow-1, RightColumn-1, .f., .f.)
  470.    mainloop := ! yes_no('Is this satisfactory')
  471. enddo
  472. if rlock()
  473.    replace (HelpFile)->toprow with TopRow, ;
  474.            (HelpFile)->botrow with BottomRow, ;
  475.            (HelpFile)->lt_col with LeftColumn, ;
  476.            (HelpFile)->rt_col with RightColumn, ;
  477.            (HelpFile)->title with Title, ;
  478.            (HelpFile)->footer with Footer,   ;
  479.            (HelpFile)->boxcolor with BoxColor, ;
  480.            (HelpFile)->titcolor with TitleColor, ;
  481.            (HelpFile)->ftcolor with FooterColor, ;
  482.            (HelpFile)->txtcolor with TextColor, ;
  483.            (HelpFile)->boxno with BoxType
  484.    unlock
  485. else
  486.    err_msg(NETERR_MSG)
  487. endif
  488. return NIL
  489.  
  490. * end function HelpScreen()
  491. *--------------------------------------------------------------------*
  492.  
  493.  
  494. /*
  495.    Function: PickAColor()
  496.    allow user to select box coordinates, box type, title,
  497.    and colors for this help screen
  498. */
  499. static function PickAColor(msg, colortype, ntop)
  500. local mrow := ntop + int(colortype / 16), firstloop := .t., ;
  501.       mcol := 17 + colortype % 16 * 3, key := 0, buffer
  502. ColorSet(C_MESSAGE)
  503. buffer := ShadowBox(maxrow()-2, 6, maxrow(), 73, 2)
  504. @ maxrow()-1, 8 ssay padr('Use arrow keys to change ' + msg + ' color ' + ;
  505.                          '- press Enter when finished', 64)
  506. do while key != K_ENTER
  507.    @ mrow, mcol ssay chr(4) color '*' + Color_N2S(colortype)
  508.    key := inkey(0)
  509.    if firstloop
  510.       ByeByeBox(buffer)
  511.       firstloop := .f.
  512.    endif
  513.    do case
  514.  
  515.       case key == K_DOWN .and. mrow < ntop + 7
  516.          mrow++
  517.          colortype += 16
  518.  
  519.       case key == K_UP .and. mrow > ntop
  520.          mrow--
  521.          colortype -= 16
  522.  
  523.       case key == K_RIGHT .and. mcol < 62
  524.          colortype++
  525.          mcol += 3
  526.  
  527.       case key == K_LEFT .and. mcol > 17
  528.          colortype--
  529.          mcol -= 3
  530.  
  531.    endcase
  532.    do case
  533.  
  534.       case msg == 'box'         // adjusting the box color
  535.          @ TopRow, LeftColumn, BottomRow, RightColumn ;
  536.            box substr(BOXFRAMES[BoxType], 1, 8) color Color_N2S(colortype)
  537.          Draw_FtHd()
  538.  
  539.       case msg == 'title'       // adjusting the title color
  540.          @ TopRow, LeftColumn + (int(RightColumn - LeftColumn) / 2) - ;
  541.            int(len(trim(Title))/2) ssay trim(Title) color Color_N2S(colortype)
  542.  
  543.       case msg == 'footer'      // adjusting the footer color
  544.          @ BottomRow, LeftColumn + (int(RightColumn - LeftColumn) / 2) - ;
  545.            int(len(trim(Footer))/2) ssay trim(Footer) color Color_N2S(colortype)
  546.  
  547.       case msg == 'text'        // adjusting the text color
  548.          setcolor(Color_N2S(colortype))
  549.          memoedit(helptext, TopRow+1, LeftColumn+1, BottomRow-1, ;
  550.                   RightColumn-1, .f., .f.)
  551.    endcase
  552.    restscreen(ntop, 16, ntop + 7, 63, palette)
  553. enddo
  554. return colortype
  555.  
  556. * end static function PickAColor()
  557. *--------------------------------------------------------------------*
  558.  
  559.  
  560. /*
  561.      function: PickABox()
  562. */
  563. function PickABox(stat, curr_elem, rel_row)
  564. local ret_val := 2, mrow := row(), mcol := col(), key := lastkey(), buffer
  565. do case
  566.    case stat == AC_IDLE                  // arrow key - redraw box
  567.       dispbegin()
  568.       buffer := savescreen(10, 35, 18, 46)
  569.       @ TopRow, LeftColumn, BottomRow, RightColumn box ;
  570.                 substr(BOXFRAMES[curr_elem], 1, 8) color Color_N2S(BoxColor)
  571.       Draw_FtHd()
  572.       restscreen(10, 35, 18, 46, buffer)
  573.       dispend()
  574.  
  575.    case stat == AC_EXCEPT
  576.  
  577.       if key == K_ESC
  578.          ret_val := AC_ABORT
  579.       elseif key == K_ENTER
  580.          ret_val := AC_SELECT
  581.       endif
  582.  
  583. endcase
  584. setpos(mrow, mcol)           // restore proper screen coordinates
  585. return ret_val
  586.  
  587. * end function PickABox()
  588. *--------------------------------------------------------------------*
  589.  
  590.  
  591. /*
  592.  
  593.      function: Draw_FfHd() -- redraw header and footer
  594.  
  595. */
  596. static function draw_fthd
  597. local mid := LeftColumn + (int(RightColumn - LeftColumn) / 2)
  598. @ TopRow, mid - int(len(trim(Title)) / 2) ssay trim(Title) ;
  599.           color Color_N2S(TitleColor)
  600. @ BottomRow, mid - int(len(trim(Footer)) / 2) ssay trim(Footer) ;
  601.           color Color_N2S(FooterColor)
  602. return nil
  603.  
  604. * end static function Draw_FtHd()
  605. *--------------------------------------------------------------------*
  606.  
  607.  
  608. /*
  609.  
  610.     function: EditHelp() -- UDF for MEMOEDIT() above
  611.  
  612. */
  613. function EditHelp(mstat, mline, mcol)
  614. local mtext, mproc, key := lastkey(), linewidth, lines, currline
  615. if key = K_ALT_E      // edit existing help text
  616.    setcursor(2)
  617.    if rlock()
  618.       (HelpFile)->text := helptext := ;
  619.             memoedit((HelpFile)->text, (HelpFile)->toprow + 1, ;
  620.                      (HelpFile)->lt_col + 1, (HelpFile)->botrow - 1, ;
  621.                      (HelpFile)->rt_col - 1, .t.)
  622.       setcursor(0)
  623.       HelpScreen("E")  // edit the rest of the screen
  624.       unlock
  625.    else
  626.       err_msg(NETERR_MSG)
  627.    endif
  628. elseif key = K_ALT_P    // print this help screen
  629.    if PrintOK()
  630.       waiton('Now printing help text, press Esc to abort')
  631.       set device to printer
  632.       currline := 1
  633.       linewidth := (HelpFile)->rt_col - (HelpFile)->lt_col + 1
  634.       lines := mlcount((HelpFile)->text, linewidth)
  635.       HelpHead()
  636.       do while currline <= lines .and. inkey() != K_ESC
  637.          @ prow()+1, (HelpFile)->lt_col say ;
  638.                      trim(memoline((HelpFile)->text, linewidth, currline++))
  639.          if prow() >= 59
  640.             HelpHead()
  641.          endif
  642.       enddo
  643.       eject
  644.       set device to screen
  645.       waitoff()
  646.    endif
  647. endif
  648. return 0
  649.  
  650. * end function EditHelp()
  651. *--------------------------------------------------------------------*
  652.  
  653.  
  654. /*
  655.     function: HelpHead() -- heading when printing help text
  656. */
  657. static function HelpHead
  658. static page := 1
  659. devpos(0, 0)
  660. @ 1, 1 say upper((HelpFile)->title)
  661. @ 1,72 say 'Page ' + ltrim(str(page++))      // increment page counter
  662. devpos(3, 0)
  663. return NIL
  664.  
  665. * end static function HelpHead()
  666. *--------------------------------------------------------------------*
  667.  
  668.  
  669. /*
  670.     Function: HelpDevSet()
  671.     Purpose:  Allows developer to change any of the help defaults
  672.     Notes:    See manifest constants contained in GRUMPH.CH
  673.     Returns:  Previous setting
  674.     Examples:
  675.  
  676.      #include "grumph.ch"
  677.  
  678.      helpdevset(_HELP_FILENAME, "custhelp")  // use CUSTHELP.DBF, not HELP.DBF
  679.      helpdevset(_HELP_TOP, 10)               // use 10 as top row for window
  680. */
  681. function HelpdevSet(nsetting, value)
  682. local ret_val := helpdefs_[nsetting]
  683. helpdefs_[nsetting] := value
  684. return ret_val
  685.  
  686. * end function HelpDevSet()
  687. *--------------------------------------------------------------------*
  688.  
  689. * eof helpdev.prg
  690.