home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 337_01 / mydef.h < prev    next >
C/C++ Source or Header  |  1991-01-14  |  11KB  |  382 lines

  1. /**********************   MYDEF.H   ***************************/
  2.  
  3. /*
  4. Set the following define statement to "#define TURBOC" if you are
  5. using Borland "Turbo C", set it to "#define QUICKC" if you are using
  6. Microsoft "QuickC".
  7. */
  8.  
  9. #define TURBOC
  10.  
  11. #define MAX_WINDOW 20
  12.  
  13. #define MAX_STRING 500   /* maximum length of strings.
  14.                             (includes '\0') */
  15.  
  16. #define MAKE_FP(seg,off) \
  17.        ((char far *) (((unsigned long)(seg) << 16)|(unsigned)(off)))
  18.  
  19. #define set_color(foreground,background)\
  20.                  (((background)<<4)|(foreground))
  21. #define set_intense(attribute)((attribute)|8)
  22.  
  23.  
  24. /* Screen mode definations (the most common)*/
  25.  
  26. #define BW_40      0  /* 40 column B&W */
  27. #define COLOR_40   1  /* 40 column color */
  28. #define BW_80      2  /* 80 column B&W */
  29. #define COLOR_80   3  /* 80 column color */
  30. #define MED_COLOR  4  /* 320x200 4 color graphics mode */
  31. #define MED_BW     5  /* 320x200 4 shade levels */
  32. #define HI_RES     6  /* 640x200 B&W */
  33. #define MONOCHROME 7  /* monochrome display */
  34.  
  35. #define FALSE 0          /* logic values */
  36. #define TRUE  1
  37.  
  38. #define ON 1
  39. #define OFF 0
  40.  
  41. #define BLACK   0         /* text attributes for color cards */
  42. #define BLUE    1
  43. #define GREEN   2
  44. #define CYAN    3
  45. #define RED     4
  46. #define MAGENTA 5
  47. #define BROWN   6
  48. #define WHITE   7
  49. #define YELLOW 14   /* intensity set on */
  50.  
  51. /* definitions of box types */
  52.  
  53. #define STD_FRAME    "\xda\xbf\xc0\xd9\xc4\xb3"  /* ┌ ┐ └ ┘ ─ │ */
  54. #define PD_FRAME     "\xc2\xc2\xc0\xd9\xc4\xb3"  /* ┬ ┬ └ ┘ ─ │ */
  55. #define TOP_FRAME    "\xda\xbf\xc3\xb4\xc4\xb3"  /* ┌ ┐ ├ ┤ ─ │ */
  56. #define MIDDLE_FRAME "\xc3\xb4\xc3\xb4\xc4\xb3"  /* ├ ┤ ├ ┤ ─ │ */
  57. #define BOTTOM_FRAME "\xc3\xb4\xc0\xd9\xc4\xb3"  /* ├ ┤ └ ┘ ─ │ */
  58. #define NO_FRAME  ""
  59.  
  60. #define UP        0x48
  61. #define DOWN      0x50
  62. #define LEFT      0x4b
  63. #define RIGHT     0x4d
  64. #define HOME      0x47
  65. #define END       0x4f
  66. #define INSERT    0x52
  67. #define DELETE    0x53
  68. #define PGDN      0x51
  69. #define PGUP      0x49
  70. #define ESCAPE    0x1b
  71. #define RETURN    0x0d
  72. #define BACKSPACE 0x08
  73. #define BELL      0x07
  74. #define F1        0x3b
  75.  
  76. #if defined QUICKC
  77.  #include <stddef.h>   /* for NULL definition */
  78. #endif
  79.  
  80. #define UNDERLINE 1     /* ATTRIBUTES FOR MONOCHROME CARDS */
  81. #define NORMAL    7
  82. #define BOLD      15
  83. #define INVERSE   112
  84.  
  85. /* cursor types */
  86. #define BIG_CURSOR    2
  87. #define NORMAL_CURSOR 1
  88. #define NO_CURSOR     0
  89.  
  90.  
  91. /* for input screens */
  92.  
  93. #define OK     0
  94. #define REDO   1
  95. #define REDRAW 2
  96.  
  97. /* window structure */
  98.  
  99. struct screen_structure{
  100.  /* Screen buffer related variables */
  101.  
  102.  char far *buffer;  /* pointer to screen buffer */
  103.  int rows;    /* number of rows the monitor can display */
  104.  int columns; /* number of columns the monitor can display */
  105.   int top;    /* the top margin of active screen area (row) */
  106.   int bottom; /* the bottom margin of active screen area(row) */
  107.   int left;   /* the left margin of active screen area(column) */
  108.   int right;  /* the right margin of active screen area(column)*/
  109.  int mode;    /* screen mode (as reported by BIOS) */
  110.  int page;    /* the text page in use (color cards only) */
  111.  int snow;    /* flag to indicate if snow avoidance ia used */
  112.  
  113.  /* Attribute related variables */
  114.  
  115.  char current; /* current text attribute used when printing text*/
  116.  char inverse; /* default inverse attribute (predefined for mode) */
  117.  char normal;  /* default normal attribute (predefined for mode */
  118.  int bold_caps; /* flag to indicate if upper case letters are
  119.                    printed with intensity set high */
  120.  
  121.  /* window related variables */
  122.  
  123.  int active;    /* the handle (number) of the active window */
  124.  int ptr;       /* pointer to the window list (how many windows) */
  125.  int list[MAX_WINDOW+1];  /* the list of windows (sequence)  */
  126.  int update;    /* flag to indicate if cursor should be updated */
  127. };
  128.  
  129. struct window_structure{
  130.  int frame; /* flag to indicate if window is framed or unframed */
  131.  int x,y;         /*cursor position (column,row) */
  132.  char attribute;  /* The attribute specified for the window */
  133.  int start, end;  /* cursor scan lines */
  134.  int top,bottom,left,right; /* window margins */
  135.  char  *buffer;             /* buffer to store image */
  136. };
  137.  
  138. /* information for menus */
  139.  
  140. #define MAX_BAR 10  /* The maximum number of options in the */
  141.                     /* moving light bar menu. */
  142.  
  143.  
  144. /* menu structure for the pop-up menu */
  145.  
  146. struct pop_struc{
  147.  char *name;       /* the menu option */
  148.  int (*fun)();     /* the pointer to function */
  149.  int select_id;    /* the list-select return code */
  150. };
  151.  
  152. /* menu structure for moving light bar menu */
  153.  
  154. struct bar_struc{
  155.  char *name;         /* the name of the function */
  156.  char *info;         /* the info line appearing under options */
  157.  int  (*fun)();      /* the pointer to function */
  158.  int select_id;      /* the list-select return code */
  159. };
  160.  
  161. /* menu structure for the pull-down menus */
  162.  
  163. #define MAIN_OPT   5  /* the actual number of options appearing
  164.                          in the main menu */
  165. #define PD_SUB     3  /* the maximum number of sub-options in the
  166.                          pull-down menus */
  167. #define PD_SUB_ROW 4  /* the row that the pull-down window appears */
  168.  
  169. #define PD_MAIN_FRAME STD_FRAME /* frame used for the main menu
  170.                                    window */
  171. #define PD_SUB_FRAME  PD_FRAME  /* frame used for the pull-down
  172.                                    menu window */
  173.  
  174. struct pd_str{
  175.  char *main;            /* option to appear in main menu */
  176.  char *sub[PD_SUB];     /* array of options to appear in Pull-down*/
  177.  int (*fun[PD_SUB])();  /* array of function pointers for pull-down*/
  178.  int select_id[PD_SUB]; /* array of list-select return code */
  179. };
  180.  
  181. struct window_colors{
  182.  char main_frame;       /* attribute used for main menu frame */
  183.  char main_interior;    /* " " " " menu interior */
  184.  char main_inverse;     /* " " " " menu highlighter */
  185.  
  186.  char pd_frame;         /* " " " pull-down frame */
  187.  char pd_interior;      /* " " " pull-down interior */
  188.  char pd_inverse;       /* " " " pull-down highlighter */
  189. };
  190.  
  191.  
  192. /* structure for help files */
  193.  
  194. struct help_structure{
  195.      char filename[80];  /* the current help file */
  196.      char message[80];   /* the window title */
  197.      int x;              /* the column for the upper left corner of
  198.                             the help window */
  199.      int y;              /* the row  for the upper left corner of
  200.                             the help window  */
  201.      int  page;          /* page within file to use */
  202.      char frame_attr;    /* character attribute for help interior */
  203.      char interior_attr; /* character attribute for help frame */
  204.      };
  205.  
  206.  
  207.  
  208. /* structure for input screens */
  209. struct in_struc {
  210.  int  x;      /* x position for data input field (start of label)*/
  211.  int  y;      /* y position for data input field (start of label)*/
  212.  
  213.  char *prompt;/* the prompt for the field */
  214.  char *ptr;   /* pointer to string to edit */
  215.  int  length; /* the maximum length of the field */
  216.  
  217.  unsigned int label_f,label_b;  /* label foreground,background color */
  218.  unsigned int input_f,input_b;  /* input field foreground,background
  219.                                    color */
  220.  };
  221.  
  222.  
  223.  
  224. /* function prototypes */
  225.  
  226. int start(void);   /* for start function */
  227.  
  228.  
  229. /***********     l_main.c     ***********/
  230.  
  231. int main(int argc,char *argv[]);
  232. static void init_window(void);
  233. static void set_screen_attr(void);
  234. static void test_dv(void);
  235. void update_margins(void);
  236.  
  237.  
  238. /***********     l_scrn1.c     ***********/
  239.  
  240. void ceol(int x, int y);
  241. void cls(void);
  242. void gotoxy(int x,int y);
  243. void scroll_up(int lines);
  244. void scroll_down(int lines);
  245. void set_mode(int mode);
  246. void what_mode(int *mode,int *page);
  247.  
  248.  
  249. /***********     l_scrn2.c     ***********/
  250.  
  251. void wherexy(int *x,int *y);
  252. void readxy(char *ch,char *attr);
  253. void what_cursor(int *start, int *end);
  254.  
  255.  
  256. /***********     l_scrn3.c     ***********/
  257.  
  258. void cursor(int size);
  259. void set_cursor(int start, int end);
  260.  
  261.  
  262. /***********     l_scrn4.c     ***********/
  263.  
  264. void alt_screen(int action);
  265.  
  266.  
  267. /***********     l_win1.c     ***********/
  268.  
  269. int win_make(int x,int y,int width,int height,char *array,\
  270.                char *title, char frame_attr, char win_attr);
  271. void win_save(void);
  272. void win_delete(int handle);
  273. int win_validate (int handle);
  274. void win_delete_top(void);
  275. void draw_frame (int x,int y,int width,int height,\
  276.                  char *array,char *title,char attribute);
  277. int win_center(int width,int height,char *array,char *title,\
  278.                char frame_attr, char win_attr);
  279.  
  280.  
  281. /***********     l_win2.c     ***********/
  282.  
  283. void win_pop_top(int handle);
  284. void display_cursor(void);
  285. static void win_redraw(int handle);
  286. void win_redraw_all(void);
  287.  
  288.  
  289. /***********     l_win3.c     ***********/
  290.  
  291. void win_ceol(int handle, int x, int y);
  292. void win_cls(int handle);
  293. void win_scroll_up(int handle,int lines);
  294. void win_scroll_down(int handle,int lines);
  295. void win_gotoxy(int handle,int x,int y);
  296. void win_print( int handle, int x,int y, char *string);
  297. static void win_point(int handle);
  298.  
  299.  
  300. /***********     l_win4.c     ***********/
  301.  
  302. void win_up(int handle, int amount);
  303. void win_right(int handle, int amount);
  304. void win_left(int handle, int amount);
  305. void win_down(int handle, int amount);
  306. void win_insert(int handle, int position);
  307.  
  308.  
  309. /***********     l_win5.c      ***********/
  310.  
  311. char win_what_attr(int handle);
  312. void win_set_attr(int handle, char attribute);
  313.  
  314.  
  315. /***********     l_print.c     ***********/
  316.  
  317. void print(int x,int y,char *string);
  318. void print_here(char *string);
  319. void dma_print(int *x, int *y,char *string);
  320. void move_scr_mem (char far *string,char far *video,int number);
  321.  
  322.  
  323. /***********     l_getkey.c      ***********/
  324. void get_key(char *ch, char *ext);
  325.  
  326.  
  327. /***********   l_popup.c    ***********/
  328.  
  329. int pop_up(struct pop_struc pop_menu[],int x,int y,\
  330.            char normal, char inverse);
  331.  
  332.  
  333. /***********     l_bar.c    ***********/
  334.  
  335. int bar_menu(struct bar_struc menu[], char normal, char inverse);
  336.  
  337.  
  338. /***********     l_chip.c    ***********/
  339.  
  340. void chip_left(char *chip,char *block,int number);
  341. void chip_right(char *chip,char *block, int number);
  342.  
  343.  
  344. /***********     l_copy.c    ***********/
  345.  
  346. void copy (char *from,char *to,int first,int length);
  347.  
  348.  
  349. /***********     l_getfld.c     ***********/
  350.  
  351. char getfield(char *string, int inlength, int start, char attribute);
  352. void hilight_field (int x, int y, int length, char attribute);
  353.  
  354.  
  355. /***********     l_input.c     ***********/
  356.  
  357. int  input(struct in_struc in_scrn[]);
  358.  
  359.  
  360. /***********     l_string.c    ***********/
  361.  
  362. int pos(char *string,char *pattern);
  363. void caps(char *string);
  364.  
  365.  
  366. /***********    l_list.c     ***********/
  367.  
  368. int list_select(char *ptr[]);
  369.  
  370.  
  371. /***********      l_dir.c     ***********/
  372.  
  373. int dir(char *filespec, char *selection);
  374. int file_count(char *filespec);
  375.  
  376.  
  377. /***********       pd.c    ***********/
  378.  
  379. int pull_down (struct pd_str m_menu[], struct window_colors color);
  380. static int pull_down_sub(struct pd_str m_menu[],struct window_colors\
  381.                           color,int option, char *ext, int *expert);
  382.