routine CONTENTS.CTL given FIELD.ID, FORM yielding STATUS
''
''    AUTHOR: Steve Bailey
''    CREATED: 9-6-94
''    DESCRIPTION:
''      Control routine called when the currently displayed information
''      heading is changed.
''

    define FIELD.ID as a text variable
    define FORM as a pointer variable
    define STATUS as an integer variable
    define TEXT.PTR, LISTBOX.PTR, EXAMPLE.FORM as a pointer variable
    define ITEMS as 1-dim text arrays
    define PICKED as a text variable
    define FAMILY, PATH, FILE as a text saved variable
    define SIZE, WEIGHT, SLANT, CURSOR as saved integer variables
    define SUCCESS as an integer variable

    let TEXT.PTR = DFIELD.F("TEXT", HELP.FORM)
    let LISTBOX.PTR = DFIELD.F("TABLE", FORM)
    let ITEMS(*) = DARY.A(LISTBOX.PTR)

    select case FIELD.ID
      case "TABLE"
          '' find the line number of the selected topic
        select case ITEMS(DDVAL.A(LISTBOX.PTR))
          case .DEFAULT.BUTTON.DESC     
            call SET.LISTBOX.TOP.R(TEXT.PTR, .DEFAULT.BUTTON.LINE)
            show EXAMPLE.FORM with "defaultbutton.frm"
            let PICKED = ACCEPT.F(EXAMPLE.FORM, 0)

          case .DIALOG.POSITIONING.DESC 
            call SET.LISTBOX.TOP.R(TEXT.PTR, .DIALOG.POSITIONING.LINE)
            show EXAMPLE.FORM with "dialogpositioning.frm"
            let PICKED = ACCEPT.F(EXAMPLE.FORM, 0)
            call MESSAGEBOX.R(CONCAT.F("This dialog is at (", 
              ITOT.F(LOCATION.X(CONTENTS.FORM)), ", ", 
              ITOT.F(LOCATION.Y(CONTENTS.FORM)), ")"), "")


          case .FILE.DIALOG.DESC
            call SET.LISTBOX.TOP.R(TEXT.PTR, .FILE.DIALOG.LINE)
            call FILEBOX.R("*.sim", "Select a `sim' file!") yielding PATH, FILE
            call MESSAGEBOX.R(CONCAT.F("The path & file selected was ",
                 PATH, FILE), "Notification")

          case .FONT.DIALOG.DESC        
            call SET.LISTBOX.TOP.R(TEXT.PTR, .FONT.DIALOG.LINE)
            call FONTBOX.R("Select a font!") 
              yielding FAMILY, SIZE, WEIGHT, SLANT
            call DRAW.TEXT(FAMILY, SIZE, WEIGHT, SLANT)

          case .LISTBOX.TOP.DESC        
            call SET.LISTBOX.TOP.R(TEXT.PTR, .LISTBOX.TOP.LINE)
            show EXAMPLE.FORM with "listboxtop.frm"
            let PICKED = ACCEPT.F(EXAMPLE.FORM, 0)

          case .SYSTEM.CURSOR.DESC      
            call SET.LISTBOX.TOP.R(TEXT.PTR, .SYSTEM.CURSOR.LINE)
            let CURSOR = 1 - CURSOR
            call SETCURSOR.R(CURSOR)

          case .SYSTEM.TEXT.DESC        
            call SET.LISTBOX.TOP.R(TEXT.PTR, .SYSTEM.TEXT.LINE)
            call FONTBOX.R("Select a font!") 
              yielding FAMILY, SIZE, WEIGHT, SLANT
            call DRAW.TEXT(FAMILY, SIZE, WEIGHT, SLANT)

          case .PRINT.WINDOW.DESC
            call SET.LISTBOX.TOP.R(TEXT.PTR, .PRINT.WINDOW.LINE)
            call PRINTWINDOW.R(WIN, 1) yielding SUCCESS
  
        endselect

      case "QUIT"
        let STATUS = 1

      default
    endselect
end
