home *** CD-ROM | disk | FTP | other *** search
- STATIC entry_scr := '', graph_col := 0, graph_row := 0, ;
- graph_set := 0, graph_on, graphics[11], pointer := 1
-
- ****************************************************************
- FUNCTION GRAPHCHAR
- ****************************************************************
- *
- * Allows entry of graphics characters during a read or memoedit
- *
- * Copyright(c) 1991 - James Occhiogrosso
-
- #include "dl_keys.ch"
- #include "set.ch"
- #include "inkey.ch"
- #include "setcurs.ch"
-
- * Last graphic set defined
- # define LASTGRSET 7
-
- LOCAL init_row, init_col, init_scr, keypress, old_color, ;
- old_score, old_cursor
-
- * Save entry conditions
- old_color = SETCOLOR(colwindow)
- old_score = SET(_SET_SCOREBOARD, .F.)
- old_cursor = SET(_SET_CURSOR, SC_NONE)
- init_row = ROW() ; init_col = COL()
-
- * Test for array initialization
- IF graph_on = NIL
- * Load graphics array
- graph_on = .T.
- LOADARRAY()
- ELSE
- * Otherwise, toggle it
- graph_on = !graph_on
- ENDIF
-
-
- IF graph_on
-
- * This is first time, set default graphic box position
-
- IF init_row < INT(MAXROW()/2) .AND. init_col < INT(MAXCOL()/2)
- graph_row = INT(MAXROW()-8)
- graph_col = INT(MAXCOL()-12)
- ELSEIF init_row < INT(MAXROW()/2) .AND. init_col >= INT(MAXCOL()/2)
- graph_row = INT(MAXROW()-8)
- graph_col = 0
- ELSEIF init_row >= INT(MAXROW()/2) .AND. init_col < INT(MAXCOL()/2)
- graph_row = 0
- graph_col = INT(MAXCOL()-12)
- ELSEIF init_row >= INT(MAXROW()/2) .AND. init_col >= INT(MAXCOL()/2)
- graph_row = 0
- graph_col = 0
- ENDIF
-
- * Save the screen area we are going to use
- entry_scr = SCRNSAVE(graph_row, graph_col, ;
- graph_row + 8, graph_col + 12)
-
- * Let operator move box
- MOVEBLOCK()
-
- * When box is positioned, turn on the key definitions
-
- SET KEY K_PLUS TO PROCESSKEY
- SET KEY K_MINUS TO PROCESSKEY
- SET KEY K_ZERO TO PROCESSKEY
- SET KEY K_ONE TO PROCESSKEY
- SET KEY K_TWO TO PROCESSKEY
- SET KEY K_THREE TO PROCESSKEY
- SET KEY K_FOUR TO PROCESSKEY
- SET KEY K_FIVE TO PROCESSKEY
- SET KEY K_SIX TO PROCESSKEY
- SET KEY K_SEVEN TO PROCESSKEY
- SET KEY K_EIGHT TO PROCESSKEY
- SET KEY K_NINE TO PROCESSKEY
- SET KEY K_PERIOD TO PROCESSKEY
-
- * Display graphics key set
- SHOWBLOCK()
-
- ELSE
- * Restore entry screen
- SCRNREST(entry_scr)
-
- * Turn off all key definitions
-
- SET KEY K_PLUS TO
- SET KEY K_MINUS TO
- SET KEY K_ZERO TO
- SET KEY K_ONE TO
- SET KEY K_TWO TO
- SET KEY K_THREE TO
- SET KEY K_FOUR TO
- SET KEY K_FIVE TO
- SET KEY K_SIX TO
- SET KEY K_SEVEN TO
- SET KEY K_EIGHT TO
- SET KEY K_NINE TO
- SET KEY K_PERIOD TO
-
- ENDIF
-
- * Restore to entry conditions and return
- SETCOLOR(old_color)
- SET SCOREBOARD (old_score)
- SETCURSOR(old_cursor)
- @ init_row, init_col SAY ''
-
- RETURN NIL
-
-
- *****************************************************************
- STATIC FUNCTION PROCESSKEY
- *****************************************************************
-
- * Process keystrokes
-
-
- LOCAL init_row, init_col, keypress, old_color
-
- init_row = ROW()
- init_col = COL()
- old_color = SETCOLOR(colwindow)
- keypress = LASTKEY()
-
- IF keypress = K_PLUS .OR. keypress = K_MINUS
-
- * Change graphics character set
-
- IF graph_set < LASTGRSET .AND. keypress = K_PLUS
- graph_set++
- ELSEIF graph_set > 0 .AND. keypress = K_MINUS
- graph_set--
- ELSEIF graph_set = 0 .AND. keypress = K_MINUS
- graph_set = LASTGRSET
- ELSE
- graph_set = 0
- ENDIF
-
- * Load new graphics set
- LOADARRAY()
-
- * Display new graphics set
- SHOWBLOCK()
- ELSE
- * Generate pointer to graphics array element
-
- IF keypress >= K_ONE .AND. keypress <= K_NINE
- * Subtract 48 from ACSII value of Keys 1 through 9
- pointer = keypress - 48
- ELSEIF keypress = K_ZERO
- * Zero key is 10th element
- pointer = 10
- ELSEIF keypress = K_PERIOD
- * Period key is 11th element
- pointer = 11
- ENDIF
-
- * Stuff selected character in keyboard buffer
- KEYBOARD graphics[pointer]
- ENDIF
-
- * Restore color and cursor position and return
- SETCOLOR(old_color)
-
- @ init_row, init_col SAY ''
-
- RETURN NIL
-
-
- ****************************************************************
- STATIC FUNCTION LOADARRAY
- ****************************************************************
-
- * Load graphics array
-
- IF graph_set = 0
- graphics[1] = CHR(200) &&
- graphics[2] = CHR(202) && Double line
- graphics[3] = CHR(188) && ┌───┬───┬───┐
- graphics[4] = CHR(204) && │ ╔ │ ╦ │ ╗ │
- graphics[5] = CHR(206) && ├───┼───┼───┤
- graphics[6] = CHR(185) && │ ╠ │ ╬ │ ╣ │
- graphics[7] = CHR(201) && ├───┼───┼───┤
- graphics[8] = CHR(203) && │ ╚ │ ╩ │ ╝ │
- graphics[9] = CHR(187) && ├───┴───┼───┤
- graphics[10] = CHR(205) && │ ═ │ ║ │
- graphics[11] = CHR(186) && └───────┴───┘
-
- ELSEIF graph_set = 1
-
- graphics[1] = CHR(192) &&
- graphics[2] = CHR(193) && Single line
- graphics[3] = CHR(217) && ┌───┬───┬───┐
- graphics[4] = CHR(195) && │ ┌ │ ┬ │ ┐ │
- graphics[5] = CHR(197) && ├───┼───┼───┤
- graphics[6] = CHR(180) && │ ├ │ ┼ │ ┤ │
- graphics[7] = CHR(218) && ├───┼───┼───┤
- graphics[8] = CHR(194) && │ └ │ ┴ │ ┘ │
- graphics[9] = CHR(191) && ├───┴───┼───┤
- graphics[10] = CHR(196) && │ ─ │ │ │
- graphics[11] = CHR(179) && └───────┴───┘
-
-
- ELSEIF graph_set = 2
-
- graphics[1] = CHR(211) && Double
- graphics[2] = CHR(208) && vertical
- graphics[3] = CHR(189) && ┌───┬───┬───┐
- graphics[4] = CHR(199) && │ ╓ │ ╥ │ ╖ │
- graphics[5] = CHR(215) && ├───┼───┼───┤
- graphics[6] = CHR(182) && │ ╟ │ ╫ │ ╢ │
- graphics[7] = CHR(214) && ├───┼───┼───┤
- graphics[8] = CHR(210) && │ ╙ │ ╨ │ ╜ │
- graphics[9] = CHR(183) && ├───┴───┼───┤
- graphics[10] = CHR(196) && │ ─ │ ║ │
- graphics[11] = CHR(186) && └───────┴───┘
-
- ELSEIF graph_set = 3
-
- graphics[1] = CHR(212) && Single
- graphics[2] = CHR(207) && vertical
- graphics[3] = CHR(190) && ┌───┬───┬───┐
- graphics[4] = CHR(198) && │ ╒ │ ╤ │ ╕ │
- graphics[5] = CHR(216) && ├───┼───┼───┤
- graphics[6] = CHR(181) && │ ╞ │ ╪ │ ╡ │
- graphics[7] = CHR(213) && ├───┼───┼───┤
- graphics[8] = CHR(209) && │ ╘ │ ╧ │ ╛ │
- graphics[9] = CHR(184) && ├───┴───┼───┤
- graphics[10] = CHR(205) && │ ═ │ │ │
- graphics[11] = CHR(179) && └───────┴───┘
-
- ELSEIF graph_set = 4
-
- graphics[1] = CHR(221) && Miscellaneous
- graphics[2] = CHR(222) && Symbols
- graphics[3] = CHR(254) && ┌───┬───┬───┐
- graphics[4] = CHR(219) && │ ░ │ ▒ │ ▓ │
- graphics[5] = CHR(220) && ├───┼───┼───┤
- graphics[6] = CHR(223) && │ █ │ ▄ │ ▀ │
- graphics[7] = CHR(176) && ├───┼───┼───┤
- graphics[8] = CHR(177) && │ ▌ │ ▐ │ ■ │
- graphics[9] = CHR(178) && ├───┴───┼───┤
- graphics[10] = CHR(174) && │ » │ « │
- graphics[11] = CHR(175) && └───────┴───┘
-
- ELSEIF graph_set = 5
-
- graphics[1] = CHR(252) && Miscellaneous
- graphics[2] = CHR(253) && Symbols
- graphics[3] = CHR(172) && ┌───┬───┬───┐
- graphics[4] = CHR(246) && │ ± │ ≥ │ ≤ │
- graphics[5] = CHR(251) && ├───┼───┼───┤
- graphics[6] = CHR(171) && │ ÷ │ √ │ ½ │
- graphics[7] = CHR(241) && ├───┼───┼───┤
- graphics[8] = CHR(242) && │ ⁿ │ ² │ ¼ │
- graphics[9] = CHR(243) && ├───┴───┼───┤
- graphics[10] = CHR(155) && │ ¢ │ £ │
- graphics[11] = CHR(156) && └───────┴───┘
-
- ELSEIF graph_set = 6
-
- graphics[1] = CHR(224) && Miscellaneous
- graphics[2] = CHR(225) && Symbols
- graphics[3] = CHR(226) && ┌───┬───┬───┐
- graphics[4] = CHR(227) && │ α │ ß │ Γ │
- graphics[5] = CHR(228) && ├───┼───┼───┤
- graphics[6] = CHR(229) && │ π │ Σ │ σ │
- graphics[7] = CHR(230) && ├───┼───┼───┤
- graphics[8] = CHR(231) && │ µ │ τ │ Φ │
- graphics[9] = CHR(232) && ├───┴───┼───┤
- graphics[10] = CHR(233) && │ Θ │ Ω │
- graphics[11] = CHR(234) && └───────┴───┘
-
- ELSEIF graph_set = 7
-
- graphics[1] = CHR(235) && Miscellaneous
- graphics[2] = CHR(236) && Symbols
- graphics[3] = CHR(237) && ┌───┬───┬───┐
- graphics[4] = CHR(238) && │ δ │ ∞ │ φ │
- graphics[5] = CHR(239) && ├───┼───┼───┤
- graphics[6] = CHR(247) && │ ε │ ∩ │ ≈ │
- graphics[7] = CHR(244) && ├───┼───┼───┤
- graphics[8] = CHR(245) && │ ⌠ │ ⌡ │ ° │
- graphics[9] = CHR(248) && ├───┴───┼───┤
- graphics[10] = CHR(249) && │ ∙ │ │
- graphics[11] = CHR(127) && └───────┴───┘
-
- ENDIF
-
- RETURN NIL
-
-
- ****************************************************************
- STATIC FUNCTION SHOWBLOCK
- ****************************************************************
-
- * Display selected graphics set
-
- @ graph_row + 1, graph_col + 2 SAY graphics[7]
- @ graph_row + 1, graph_col + 6 SAY graphics[8]
- @ graph_row + 1, graph_col + 10 SAY graphics[9]
- @ graph_row + 3, graph_col + 2 SAY graphics[4]
- @ graph_row + 3, graph_col + 6 SAY graphics[5]
- @ graph_row + 3, graph_col + 10 SAY graphics[6]
- @ graph_row + 5, graph_col + 2 SAY graphics[1]
- @ graph_row + 5, graph_col + 6 SAY graphics[2]
- @ graph_row + 5, graph_col + 10 SAY graphics[3]
- @ graph_row + 7, graph_col + 4 SAY graphics[10]
- @ graph_row + 7, graph_col + 10 SAY graphics[11]
-
- RETURN NIL
-
-
- ****************************************************************
- STATIC FUNCTION MOVEBLOCK
- ****************************************************************
-
- * Let operator position the graph box on initial entry
-
- LOCAL init_scr, keypress
-
- * Display initial box at default area
-
- @ graph_row, graph_col SAY '┌───────────┐'
- @ graph_row + 1, graph_col SAY '│Cursor keys│'
- @ graph_row + 2, graph_col SAY '│move box. │'
- @ graph_row + 3, graph_col SAY '│Any key for│'
- @ graph_row + 4, graph_col SAY '│graphics. │'
- @ graph_row + 5, graph_col SAY '│Use +/- to │'
- @ graph_row + 6, graph_col SAY '│change key │'
- @ graph_row + 7, graph_col SAY '│set. │'
- @ graph_row + 8, graph_col SAY '└───────────┘'
-
- init_scr = SAVESCREEN(graph_row, graph_col, ;
- graph_row + 8, graph_col + 12)
-
- DO WHILE .T.
- * Wait for a key
- keypress = INKEY(0)
-
- * Restore entry screen before moving box
- SCRNREST(entry_scr)
-
- IF keypress = K_RIGHT
- graph_col = IF(graph_col < INT(MAXCOL()-12), graph_col + 1, INT(MAXCOL()-12))
- ELSEIF keypress = K_LEFT
- graph_col = IF(graph_col > 1, graph_col - 1, 0)
- ELSEIF keypress = K_UP
- graph_row = IF(graph_row > 0, graph_row - 1, 0)
- ELSEIF keypress = K_DOWN
- graph_row = IF(graph_row < INT(MAXROW()-8), graph_row + 1, INT(MAXROW()-8))
- ELSEIF keypress = K_CTRL_RIGHT
- graph_col = INT(MAXCOL()-12)
- ELSEIF keypress = K_CTRL_LEFT
- graph_col = 0
- ELSEIF keypress = K_CTRL_UP
- graph_row = 0
- ELSEIF keypress = K_CTRL_DOWN
- graph_row = INT(MAXROW()-8)
- ELSE
- * Any other key, exit and display graphics box.
- EXIT
- ENDIF
-
- * Save new entry screen area
- entry_scr = SCRNSAVE(graph_row, graph_col, ;
- graph_row + 8, graph_col + 12)
-
- * And redisplay initial box in new position
- RESTSCREEN(graph_row, graph_col, graph_row + 8,;
- graph_col + 12, init_scr)
- ENDDO
-
- * When box is positioned, display graphics outline
-
- @ graph_row, graph_col SAY '┌───┬───┬───┐'
- @ graph_row + 1, graph_col SAY '│ │ │ │'
- @ graph_row + 2, graph_col SAY '├───┼───┼───┤'
- @ graph_row + 3, graph_col SAY '│ │ │ │'
- @ graph_row + 4, graph_col SAY '├───┼───┼───┤'
- @ graph_row + 5, graph_col SAY '│ │ │ │'
- @ graph_row + 6, graph_col SAY '├───┴───┼───┤'
- @ graph_row + 7, graph_col SAY '│ │ │'
- @ graph_row + 8, graph_col SAY '└───────┴───┘'
-
- RETURN NIL
-
-
-