home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / hl10osrc.lzh / Include / EditForm.h < prev    next >
Text File  |  1994-04-23  |  2KB  |  93 lines

  1. /* -*- Mode: C -*- */
  2. /* EditForm.h - EditForm class - a form for editing
  3.  * Created by Robert Heller on Thu Dec 12 19:11:03 1991
  4.  *
  5.  * ------------------------------------------------------------------
  6.  * Home Libarian by Deepwoods Software
  7.  * Common Header Files
  8.  * ------------------------------------------------------------------
  9.  * Modification History:
  10.  * ------------------------------------------------------------------
  11.  * Contents:
  12.  * ------------------------------------------------------------------
  13.  * 
  14.  * 
  15.  * Copyright (c) 1991,1992 by Robert heller (D/B/A Deepwoods Software)
  16.  *        All Rights Reserved
  17.  * 
  18.  */
  19.  
  20. #ifndef _EDITFORM_
  21. #define _EDITFORM_
  22. #include <stream.h>
  23. #include <common.h>
  24. #include <ctype.h>
  25. #include <Terminal.h>
  26.  
  27. #ifdef OSK
  28. #define DEFAULTEDITOR "umacs"
  29. #endif
  30. #ifdef MESSYDOS
  31. #define DEFAULTEDITOR "e"
  32. #endif
  33.  
  34. typedef char* (*FieldToString)(void*);
  35. typedef void  (*StringToField)(char*,void*);
  36.  
  37. enum FieldType {Literal, String, EditorString,
  38.         Int, Float, Special };
  39.  
  40. struct Field {
  41.     void *fieldp;
  42.     FieldType type;
  43.     FieldToString ftos;
  44.     StringToField stof;
  45.     int row;
  46.     int col;
  47.     int width;
  48.     int height;
  49.     int buffersize;
  50. };
  51.  
  52. typedef void (*KeyFun)(EditForm&);
  53.  
  54. struct KeyBinding {
  55.     KeyFun fun;
  56.     char *docstring;
  57.     short int keycode;    
  58. };
  59.  
  60. class EditForm {
  61.     static char EditorCommand[48];
  62.     static Boolean EditorCmdInit;
  63.     char  Title[80];
  64.     Field *fields;
  65.     int   nFields;
  66.     KeyBinding *bindings;
  67.     int   nBinds;
  68.     int   currentField;
  69.     void HiliteField(int fieldno,Boolean hilite);
  70. public:
  71.     Boolean IsModified;
  72.         EditForm(char* title,int fieldcount,Field *infields,
  73.              int bindcount,KeyBinding *inbinds);
  74.            ~EditForm();
  75.     Boolean RunForm();
  76.     void RePaint();
  77.     void ResetField() {
  78.         currentField = 0;
  79.         for (int i = 0;i < nFields;i++) {
  80.             if (fields[i].type != Literal) {
  81.                 currentField = i+1;
  82.                 break;
  83.             }
  84.         }
  85.     }
  86.     int CurField() { return(currentField); }
  87.     friend class Terminal;
  88. };
  89.  
  90. #endif
  91.  
  92.  
  93.