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