home *** CD-ROM | disk | FTP | other *** search
- /***
- * Gets13.prg
- *
- * Reader for memo get
- */
-
- #include "Getexit.ch"
- #include "InKey.ch"
-
- // Note - cannot use _GET as it uses oGet:display() before
- // we can change var to "memo"
- #command @ <row>, <col> GET <var> ;
- MEMO AT <t>, <l>, <b>, <r> ;
- [VALID <valid>] ;
- [WHEN <when> ] ;
- ;
- => ;
- SetPos( <row>, <col> ) ;
- ; Aadd(GetList, ;
- MemoGetNew( <var>, ;
- {|x| iif( x == NIL, "Memo", <var> := x ) }, ;
- <(var)>, <{valid}>, <{when}>, ;
- {<t>, <l>, <b>, <r>} )) ;
- ; Atail(GetList):reader := {|oGet| MemoReader(oGet) } ;
- ; Atail(GetList):display()
-
- MEMVAR GetList
-
- FUNCTION Gets13
-
- LOCAL cVar1 := Space(10), ;
- cVar2 := "This is the memo var", ;
- cVar3 := Space(12)
-
- CLEAR SCREEN
- @ 10, 10 SAY "Enter cVar" GET cVar1
- @ 11, 10 SAY "Enter cVar" GET cVar2 MEMO AT 10, 10, 20, 20
- @ 12, 10 SAY "Enter cVar" GET cVar3
-
- READ
-
- RETURN NIL
-
- #define VAR_ELEM 1
- #define COORDS_ELEM 2
-
- proc MemoReader( oGet )
-
- // read the GET if the WHEN condition is satisfied
- IF ( GetPreValidate(oGet) )
- // activate the GET for reading
- oGet:SetFocus()
-
- DO WHILE ( oGet:exitState == GE_NOEXIT )
- // apply keystrokes until exit
- DO WHILE ( oGet:exitState == GE_NOEXIT )
- GetMemoApplyKey(oGet, InKey(0))
- ENDDO
-
- // disallow exit if the VALID condition is not satisfied
- IF ( !GetPostValidate(oGet) )
- oGet:exitState := GE_NOEXIT
- ENDIF
- ENDDO
-
- // de-activate the GET
- oGet:KillFocus()
- ENDIF
-
- RETURN
-
-
- FUNCTION EditMemo(oGet)
-
- LOCAL t, l, b, r, aCoords, cSaveScreen, nRow, nCol
-
- aCoords := oGet:cargo[COORDS_ELEM]
- t := aCoords[1]
- l := aCoords[2]
- b := aCoords[3]
- r := aCoords[4]
-
- cSaveScreen := SaveScreen(t, l, b, r)
- nRow := Row()
- nCol := Col()
-
- @ t, l CLEAR TO b, r
- @ t, l TO b, r
- oGet:cargo[VAR_ELEM] := MemoEdit(oGet:cargo[VAR_ELEM], ;
- t + 1, l + 1, b - 1, r - 1)
- oGet:VarPut(oGet:cargo[VAR_ELEM])
- oGet:updateBuffer()
- DevPos(nRow, nCol)
- RestScreen(t, l, b, r, cSaveScreen)
-
- RETURN NIL
-
-
- FUNCTION MemoGetNew(cVar, bBlock, cName, bvalid, bWhen, aMemoCoords)
-
- LOCAL oGet := GetNew(Row(), Col(), bBlock, cname)
-
- oGet:postBlock := bValid
- oGet:preBlock := bWhen
- oGet:cargo := {cVar, aMemoCoords}
-
- RETURN oGet
-
-
- FUNCTION GetMemoApplyKey(oGet, nKey)
-
- LOCAL bKeyBlock
-
- // check for SET KEY first
- IF ( (bKeyBlock := SetKey(nKey)) <> NIL )
- GetDoSetKey(bKeyBlock, oGet)
- RETURN NIL // NOTE
- ENDIF
-
- DO CASE
- CASE nKey == K_UP
- oGet:exitState := GE_UP
-
- CASE nKey == K_SH_TAB
- oGet:exitState := GE_UP
-
- CASE nKey == K_DOWN
- oGet:exitState := GE_DOWN
-
- CASE nKey == K_TAB
- oGet:exitState := GE_DOWN
-
- CASE nKey == K_ENTER
- oGet:exitState := GE_ENTER
-
- CASE nKey == K_ESC
- IF Set(_SET_ESCAPE)
- oGet:exitState := GE_ESCAPE
- ENDIF
-
- CASE nKey == K_PGUP
- oGet:exitState := GE_WRITE
-
- CASE nKey == K_PGDN
- oGet:exitState := GE_WRITE
-
- CASE nKey == K_CTRL_HOME
- oGet:exitState := GE_TOP
-
- CASE nKey == K_CTRL_PGDN
- EditMemo(oGet)
- oGet:exitState := GE_ENTER
-
- ENDCASE
-
- RETURN NIL