home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / ega / egapaint.arc / PHELP.C < prev    next >
Text File  |  1988-05-26  |  10KB  |  304 lines

  1. /**************************************************************************
  2.  *                                                                        *
  3.  *                      P A I N T ---- H E L P                            *
  4.  *                                                                        *
  5.  *    To keep the main file alittle smaller, and for a little practice    *
  6.  *     in external stuff, we'll keep this a separate file.  Someday I'll  *
  7.  *     have sub levels of help.                                           *
  8.  *                                                                        *
  9.  **************************************************************************/
  10.  
  11. #define FALSE 0
  12. #define TRUE  1
  13.  
  14. #include <dos.h>
  15. #include <bios.h>
  16. #include <conio.h>
  17. #include <graphics.h>
  18. #include <alloc.h>
  19. #include <stdlib.h>
  20.  
  21. extern int bkcolor, cc, maxx, maxy;
  22. extern int *first, *second;
  23. unsigned scr_size[2];
  24. void *scr_buffer[2];
  25.  
  26. int paint_help(void)
  27. {
  28.     union {
  29.         int i;
  30.         unsigned char c[2];
  31.     } key;
  32.  
  33.     struct textsettingstype oldtext;
  34.  
  35.     register int i = 10;
  36.     int title_x, title_y, title_color = YELLOW;
  37.     int hite, wide, max_i;
  38.     int ret_flag = 0;
  39.     int timer = 999;
  40.     void *text_buf;
  41.  
  42.     /* we are going to change the text style */
  43.  
  44.  
  45.     gettextsettings(&oldtext);
  46.     setusercharsize(1, 1, 7, 8);
  47.     settextstyle(SMALL_FONT, HORIZ_DIR, USER_CHAR_SIZE);
  48.     hite = textheight("H");
  49.     wide = textwidth("H");
  50.  
  51.     text_buf = malloc(640 * (unsigned)hite);
  52.  
  53.     /* save the image  */
  54.  
  55.     scr_size[0] = imagesize(0, 0, maxx, ((maxy+1)/2)-1);
  56.     scr_buffer[0] = malloc(scr_size[0]);
  57.     if(scr_buffer[0] == NULL) {
  58.         free(scr_buffer[0]);
  59.         return TRUE;
  60.     }
  61.     getimage(0, 0, maxx, ((maxy+1)/2)-1, scr_buffer[0]);
  62.  
  63.     scr_size[1] = imagesize(0, (maxy+1)/2, maxx, maxy);
  64.     scr_buffer[1] = malloc(scr_size[1]);
  65.     if(scr_buffer[1] == NULL) {
  66.         free(scr_buffer[0]);
  67.         free(scr_buffer[1]);
  68.         return TRUE;
  69.     }
  70.     getimage(0, (maxy+1)/2, maxx, maxy, scr_buffer[1]);
  71.  
  72.     setbkcolor(BLACK);
  73.     setcolor(YELLOW);
  74.     clearviewport();
  75.  
  76.     outtextxy((maxx/2)+30, 30+(1 *hite), "*******************************");
  77.     outtextxy((maxx/2)+30, 30+(2 *hite), "*                             *");
  78.     outtextxy((maxx/2)+30, 30+(3 *hite), "*                             *");
  79.     title_x = (maxx/2)+29+(7*wide);
  80.     title_y = 30+(3*hite);
  81.     outtextxy((maxx/2)+30, 30+(4 *hite), "*                             *");
  82.     outtextxy((maxx/2)+30, 30+(5 *hite), "*                             *");
  83.     outtextxy((maxx/2)+30, 30+(6 *hite), "*                             *");
  84.     outtextxy((maxx/2)+30, 30+(7 *hite), "*        by J. Hudson         *");
  85.     outtextxy((maxx/2)+30, 30+(8 *hite), "*                             *");
  86.     outtextxy((maxx/2)+30, 30+(9 *hite), "*            1988             *");
  87.     outtextxy((maxx/2)+30, 30+(10*hite), "*                             *");
  88.     outtextxy((maxx/2)+30, 30+(11*hite), "*******************************");
  89.  
  90.  
  91.     outtextxy(5, i, "F1, F2, F3, F4 - Set step increment to 1, 5, 10, 20");
  92.     i += hite;
  93.     outtextxy(5, i, "F5  - Change background color");
  94.     i += hite;
  95.     outtextxy(5, i, "F6  - Save the previously saved icon to a file");
  96.     i += hite;
  97.     outtextxy(5, i, "F7  - Read the icon file (use 'K' to display it)");
  98.     i += hite;
  99.     outtextxy(5, i, "F8  - Reset first and second markers");
  100.     i += hite;
  101.     outtextxy(5, i, "F9  - Turn header area on/off");
  102.     i += hite;
  103.     outtextxy(5, i, "F10 - Turn mouse ON/OFF");
  104.     i += hite;
  105.     outtextxy(5, i, "F11 - Change fill pattern");
  106.     i += hite;
  107.     outtextxy(5, i, "F12 - Change line width");
  108.     i += hite;
  109.     outtextxy(5, i, "1   - Set color number to 1  - ");
  110.     setcolor(1);
  111.     outtextxy((29 * wide) + 6, i, "BLUE");
  112.     setcolor(YELLOW);
  113.     i += hite;
  114.     outtextxy(5, i, "2   - Set color number to 2  - ");
  115.     setcolor(2);
  116.     outtextxy((29 * wide) + 6, i, "GREEN");
  117.     setcolor(YELLOW);
  118.     i += hite;
  119.     outtextxy(5, i, "3   - Set color number to 3  - ");
  120.     setcolor(3);
  121.     outtextxy((29 * wide) + 6, i, "CYAN");
  122.     setcolor(YELLOW);
  123.     i += hite;
  124.     outtextxy(5, i, "4   - Set color number to 4  - ");
  125.     setcolor(4);
  126.     outtextxy((29 * wide) + 6, i, "RED");
  127.     setcolor(YELLOW);
  128.     i += hite;
  129.     outtextxy(5, i, "5   - Set color number to 5  - ");
  130.     setcolor(5);
  131.     outtextxy((29 * wide) + 6, i, "MAGENTA");
  132.     setcolor(YELLOW);
  133.     i += hite;
  134.     outtextxy(5, i, "6   - Set color number to 6  - ");
  135.     setcolor(6);
  136.     outtextxy((29 * wide) + 6, i, "BROWN");
  137.     setcolor(YELLOW);
  138.     i += hite;
  139.     outtextxy(5, i, "7   - Set color number to 7  - ");
  140.     setcolor(7);
  141.     outtextxy((29 * wide) + 6, i, "LIGHT GRAY");
  142.     setcolor(YELLOW);
  143.     i += hite;
  144.     outtextxy(5, i, "8   - Set color number to 8  - ");
  145.     setcolor(8);
  146.     outtextxy((29 * wide) + 6, i, "DARK GRAY");
  147.     setcolor(YELLOW);
  148.     i += hite;
  149.     outtextxy(5, i, "9   - Set color number to 9  - ");
  150.     setcolor(9);
  151.     outtextxy((29 * wide) + 6, i, "LIGHT BLUE");
  152.     setcolor(YELLOW);
  153.     i += hite;
  154.     outtextxy(5, i, "0   - Set color number to 10 - ");
  155.     setcolor(10);
  156.     outtextxy((29 * wide) + 6, i, "LIGHT GREEN");
  157.     setcolor(YELLOW);
  158.     i += hite;
  159.     outtextxy(8, i, "!   - Set color number to 11 - ");
  160.     setcolor(11);
  161.     outtextxy((29 * wide) + 6, i, "LIGHT CYAN");
  162.     setcolor(YELLOW);
  163.     i += hite;
  164.     outtextxy(5, i, "@   - Set color number to 12 - ");
  165.     setcolor(12);
  166.     outtextxy((29 * wide) + 6, i, "LIGHT RED");
  167.     setcolor(YELLOW);
  168.     i += hite;
  169.     outtextxy(5, i, "#   - Set color number to 13 - ");
  170.     setcolor(13);
  171.     outtextxy((29 * wide) + 6, i, "LIGHT MAGENTA");
  172.     setcolor(YELLOW);
  173.     i += hite;
  174.     outtextxy(5, i, "$   - Set color number to 14 - ");
  175.     setcolor(14);
  176.     outtextxy((29 * wide) + 6, i, "YELLOW");
  177.     setcolor(YELLOW);
  178.     i += hite;
  179.     outtextxy(5, i, "%   - Set color number to 15 - ");
  180.     setcolor(15);
  181.     outtextxy((29 * wide) + 6, i, "WHITE");
  182.     setcolor(YELLOW);
  183.     i += hite;
  184.     outtextxy(5, i, "B   - Draw box around marked points");
  185.     i += hite;
  186.     outtextxy(5, i, "C   - Draw a circle, first point is the center, second point is the radius");
  187.     i += hite;
  188.     outtextxy(5, i, "D   - Delete a marked area");
  189.     i += hite;
  190.     outtextxy(5, i, "E   - Draw ellipse");
  191.     i += hite;
  192. /*    outtextxy(5, i, "F   - ");
  193.     i += hite;
  194. */    outtextxy(5, i, "G   - Turn grid ON/OFF");
  195.     i += hite;
  196. /*    outtextxy(5, i, "H   - ");
  197.     i += hite;
  198. */    outtextxy(5, i, "J   - Save an image to memory");
  199.     i += hite;
  200.     outtextxy(5, i, "K   - Restore the saved image from memory");
  201.     i += hite;
  202.     outtextxy(5, i, "L   - Draw a line between points");
  203.     i += hite;
  204.     outtextxy(5, i, "M   - Move an area");
  205.     i += hite;
  206.     outtextxy(5, i, "N   - New color for an area");
  207.     i += hite;
  208.     outtextxy(5, i, "O   - Turn DRAW on/off (Pen up - Pen down)");
  209.     i += hite;
  210.     outtextxy(5, i, "P   - Swap pages");
  211.     i += hite;
  212.     outtextxy(0, i, "^P  - Print Screen");
  213.     i += hite;
  214.     outtextxy(5, i, "Q   - Quit");
  215.     i += hite;
  216.     outtextxy(5, i, "R   - Restore image from a file ");
  217.     i += hite;
  218.     outtextxy(5, i, "S   - Save image to a file");
  219.     i += hite;
  220.     outtextxy(0, i, "^S   - Change the screen scale");
  221.     i += hite;
  222.     outtextxy(5, i, "T   - Enter text");
  223.     i += hite;
  224.     outtextxy(5, i, "V   - Jump to the nearest pixel that matches the drawing color");
  225.     i += hite;
  226.     outtextxy(5, i, "W   - Fill a bounded area (boundry must be same color)");
  227.     i += hite;
  228.     outtextxy(5, i, "X   - Copy an area");
  229.     i += hite;
  230.     outtextxy(5, i, "Z   - Clear the screen");
  231.     i += hite;
  232.     outtextxy(5, i, "?   - Print this help screen");
  233.     i += hite;
  234.     outtextxy(0, i, "<CR> - Mark first   ,then second   points");
  235.     putimage(5 + (17*wide), i-2, first, COPY_PUT);
  236.     putimage(5 + (32*wide), i+2, second, COPY_PUT);
  237.  
  238.     max_i = (i/hite) - 1;
  239.  
  240.     outtextxy(400, 349-hite, "Hit <ESC> to return");
  241.  
  242.     settextstyle(TRIPLEX_FONT, HORIZ_DIR, 2);
  243.  
  244.     i = 0;
  245.     getimage(0, (i*hite)+11, (wide*15)+7, ((i+1)*hite)+11, text_buf);
  246.     putimage(0, (i*hite)+11, text_buf, NOT_PUT);
  247.  
  248.     while(!ret_flag) {
  249.         if(bioskey(1)) {
  250.             key.i = bioskey(0);
  251.             if(key.c[0] == 0x1b) ret_flag = 1;
  252.             else {
  253.  
  254.                 /* only use the keypad --- alais not the mouse  */
  255.  
  256.  
  257.                 if(!key.c[0]) {
  258.                      if(key.c[1] == 72) {        /* up  */
  259.                         if(i == 0) getimage(0, (i*hite)+11, (wide*15)+7, ((i+1)*hite)+11, text_buf);
  260.                         else getimage(0, (i*hite)+11, (wide*3)+7, ((i+1)*hite)+11, text_buf);
  261.                         putimage(0, (i*hite)+11, text_buf, NOT_PUT); /* renew the old */
  262.                         i -= 1;
  263.                         if(i < 0) i = 0;
  264.                         if(i == 0) getimage(0, (i*hite)+11, (wide*15)+7, ((i+1)*hite)+11, text_buf);
  265.                         else getimage(0, (i*hite)+11, (wide*3)+7, ((i+1)*hite)+11, text_buf);
  266.                         putimage(0, (i*hite)+11, text_buf, NOT_PUT);
  267.                     }
  268.                      if(key.c[1] == 80) {        /* down  */
  269.                         if(i == 0) getimage(0, (i*hite)+11, (wide*15)+7, ((i+1)*hite)+11, text_buf);
  270.                         else getimage(0, (i*hite)+11, (wide*3)+7, ((i+1)*hite)+11, text_buf);
  271.                         putimage(0, (i*hite)+11, text_buf, NOT_PUT); /* renew th old */
  272.                         i += 1;
  273.                         if(i >= max_i) i = max_i;
  274.                         getimage(0, (i*hite)+11, (wide*3)+7, ((i+1)*hite)+11, text_buf);
  275.                         putimage(0, (i*hite)+11, text_buf, NOT_PUT);
  276.                     }
  277.  
  278.                 }
  279.             }
  280.         } else {
  281.             if(timer != 12000) timer++;
  282.             else {
  283.                 if(title_color++ >= MAXCOLORS) title_color = BLUE;
  284.                 setcolor(title_color);
  285.                 outtextxy(title_x, title_y, "P A I N T");
  286.                 timer = 0;
  287.             }
  288.         }
  289.     }
  290.     setbkcolor(bkcolor);
  291.     clearviewport();
  292.     setcolor(cc);
  293.     settextjustify(oldtext.horiz, oldtext.vert);
  294.     settextstyle(oldtext.font, oldtext.direction, oldtext.charsize);
  295.  
  296.     putimage(0, 0, scr_buffer[0], COPY_PUT);
  297.     putimage(0, (maxy+1)/2, scr_buffer[1], COPY_PUT);
  298.      free(scr_buffer[0]);
  299.     free(scr_buffer[1]);
  300.  
  301.     return FALSE;
  302. }
  303.  
  304.