home *** CD-ROM | disk | FTP | other *** search
/ Dream 48 / Amiga_Dream_48.iso / Atari / c / libs / xaes_new.lzh / XAES.C < prev    next >
C/C++ Source or Header  |  1994-10-16  |  10KB  |  497 lines

  1. /********************************************************************
  2.  *                                                                1.00*
  3.  *    XAES: Extended AES Control Functions                            *
  4.  *    by Ken Hollis                                                    *
  5.  *                                                                    *
  6.  *    Copyright (c) 1994, Bitgate Software.  All Rights Reserved.        *
  7.  *                                                                    *
  8.  *    Extended AES routines.  Enough said.                            *
  9.  *                                                                    *
  10.  ********************************************************************/
  11.  
  12. #include "xaes.h"
  13.  
  14. LOCAL void draw_rubber(int *pxy)
  15. {
  16.     graf_mouse(M_OFF,0l);
  17.  
  18.     vsl_udsty(VDIhandle,(pxy[0] & 1) == (pxy[1] & 1) ? 21845 : (int) 43690L);
  19.     line(pxy[0],pxy[1],pxy[0],pxy[3]);
  20.     
  21.     vsl_udsty(VDIhandle,(pxy[2] & 1) == (pxy[1] & 1) ? 21845 : (int) 43690L);
  22.     line(pxy[2],pxy[1],pxy[2],pxy[3]);
  23.  
  24.     vsl_udsty(VDIhandle,(pxy[1] & 1) ? (int) 43690L : 21845);
  25.     line(pxy[0],pxy[1],pxy[2],pxy[1]);
  26.     
  27.     vsl_udsty(VDIhandle,(pxy[3] & 1) ? (int) 43690L : 21845);
  28.     line(pxy[0],pxy[3],pxy[2],pxy[3]);
  29.  
  30.     graf_mouse(M_ON,0l);
  31. }
  32.  
  33. GLOBAL void WGraf_Rubberbox(int bx, int by, int *endx, int *endy)
  34. {
  35.     int mx, my, button, dummy, origx, origy, cntr = 0, oldx, oldy,
  36.         boundx, boundy, boundw, boundh, moved = FALSE;
  37.     int pxy[8];
  38.     int attr[10], fillattr[5], lineattr[6];
  39.     GRECT pos;
  40.  
  41.     *endx = 0;
  42.     *endy = 0;
  43.  
  44.     vqt_attributes(VDIhandle, attr);
  45.     vqf_attributes(VDIhandle, fillattr);
  46.     vql_attributes(VDIhandle, lineattr);
  47.  
  48.     graf_mkstate(&origx, &origy, &dummy, &dummy);
  49.  
  50.     pxy[0] = desk.g_x;
  51.     pxy[1] = desk.g_y;
  52.     pxy[2] = desk.g_x + desk.g_w;
  53.     pxy[3] = desk.g_y + desk.g_h;
  54.  
  55.     vs_clip(VDIhandle, 1, pxy);
  56.  
  57.     vsl_color(VDIhandle, BLACK);
  58.     vsl_type(VDIhandle, 7);
  59.  
  60.     vswr_mode(VDIhandle, MD_XOR);
  61.  
  62.     pos.g_x = bx;
  63.     pos.g_y = by;
  64.     pos.g_w = 0;
  65.     pos.g_h = 0;
  66.  
  67.     pxy[0] = pos.g_x;
  68.     pxy[1] = pos.g_y;
  69.     pxy[2] = pos.g_x + pos.g_w;
  70.     pxy[3] = pos.g_y + pos.g_h;
  71.     draw_rubber(pxy);
  72.  
  73.     boundx = desk.g_x;
  74.     boundy = desk.g_y;
  75.     boundw = desk.g_x + desk.g_w;
  76.     boundh = desk.g_y + desk.g_h;
  77.  
  78.     do {
  79.         graf_mkstate(&mx, &my, &button, &dummy);
  80.  
  81.         cntr++;
  82.  
  83.         if ((mx != oldx) ||
  84.             (my != oldy)) {
  85.             moved = TRUE;
  86.             oldx = mx;
  87.             oldy = my;
  88.         }
  89.  
  90.         if (moved) {
  91.             pxy[0] = pos.g_x;
  92.             pxy[1] = pos.g_y;
  93.             pxy[2] = pos.g_x + pos.g_w;
  94.             pxy[3] = pos.g_y + pos.g_h;
  95.             draw_rubber(pxy);
  96.         }
  97.  
  98.         pos.g_w = mx - pos.g_x;
  99.         pos.g_h = my - pos.g_y;
  100.  
  101.         if (boundw!=-1) {
  102.             int tx;
  103.  
  104.             if ((tx = (pos.g_x + pos.g_w) - (boundw)) < 0)
  105.                 tx = 0;
  106.             else
  107.                 tx += 1;
  108.  
  109.             pos.g_x -= tx;
  110.         }
  111.  
  112.         if (boundh != -1 && boundy != -1) {
  113.             int ty;
  114.  
  115.             if ((ty = (pos.g_y + pos.g_h) - (boundy + boundh)) < 0)
  116.                 ty = 0;
  117.             else
  118.                 ty += 1;
  119.  
  120.             pos.g_y -= ty;
  121.         }
  122.  
  123.         if (boundx != -1)
  124.             if (pos.g_x < boundx)
  125.                 pos.g_x = boundx;
  126.  
  127.         if (boundy != -1)
  128.             if (pos.g_y < boundy)
  129.                 pos.g_y = boundy;
  130.  
  131.         if (moved) {
  132.             pxy[0] = pos.g_x;
  133.             pxy[1] = pos.g_y;
  134.             pxy[2] = pos.g_x + pos.g_w;
  135.             pxy[3] = pos.g_y + pos.g_h;
  136.             draw_rubber(pxy);
  137.             moved = FALSE;
  138.         }
  139.     } while (button);
  140.  
  141.     pxy[0] = pos.g_x;
  142.     pxy[1] = pos.g_y;
  143.     pxy[2] = pos.g_x + pos.g_w;
  144.     pxy[3] = pos.g_y + pos.g_h;
  145.     draw_rubber(pxy);
  146.  
  147.     vst_height(VDIhandle, attr[7], &dummy, &dummy, &dummy, &dummy);
  148.     vst_color(VDIhandle, attr[1]);
  149. /*    vswr_mode(VDIhandle, attr[5]); */
  150.     vswr_mode(VDIhandle, MD_XOR);
  151.  
  152.     vsf_color(VDIhandle, fillattr[1]);
  153.     vsf_interior(VDIhandle, fillattr[0]);
  154.     vsf_style(VDIhandle, fillattr[2]);
  155.  
  156.     vsl_type(VDIhandle, lineattr[0]);
  157.     vsl_color(VDIhandle, lineattr[1]);
  158.     vsl_udsty(VDIhandle, 0xFFFF);
  159.  
  160.     *endx = pos.g_x;
  161.     *endy = pos.g_y;
  162. }
  163.  
  164. GLOBAL void WDragBox(int width, int height, int beginx, int beginy,
  165.             int boundx, int boundy, int boundw, int boundh,
  166.             int *endx, int *endy)
  167. {
  168.     int mx = 0, my = 0, button, dummy, origx, origy, cntr = 0, xo,
  169.         yo, dx = 0, dy = 0, moved = FALSE;
  170.     int pxy[8];
  171.     int attr[10], fillattr[5], lineattr[6];
  172.     GRECT pos;
  173.  
  174.     *endx = 0;
  175.     *endy = 0;
  176.  
  177.     vqt_attributes(VDIhandle, attr);
  178.     vqf_attributes(VDIhandle, fillattr);
  179.     vql_attributes(VDIhandle, lineattr);
  180.  
  181.     graf_mkstate(&origx, &origy, &dummy, &dummy);
  182.  
  183.     pxy[0] = desk.g_x;
  184.     pxy[1] = desk.g_y;
  185.     pxy[2] = desk.g_x + desk.g_w;
  186.     pxy[3] = desk.g_y + desk.g_h;
  187.  
  188.     vs_clip(VDIhandle, 1, pxy);
  189.  
  190.     vsl_color(VDIhandle, BLACK);
  191.     vsl_type(VDIhandle, 7);
  192.  
  193.     vswr_mode(VDIhandle, MD_XOR);
  194.  
  195.     pos.g_x = beginx;
  196.     pos.g_y = beginy;
  197.     pos.g_w = width;
  198.     pos.g_h = height;
  199.  
  200.     pxy[0] = pos.g_x;
  201.     pxy[1] = pos.g_y;
  202.     pxy[2] = pos.g_x + pos.g_w;
  203.     pxy[3] = pos.g_y + pos.g_h;
  204.     draw_rubber(pxy);
  205.  
  206.     do {
  207.         xo = mx;
  208.         yo = my;
  209.  
  210.         graf_mkstate(&mx, &my, &button, &dummy);
  211.  
  212.         dx = mx - xo;
  213.         dy = my - yo;
  214.  
  215.         cntr++;
  216.  
  217.         if (dx || dy)
  218.             moved = TRUE;
  219.  
  220.         if (moved) {
  221.             pxy[0] = pos.g_x;
  222.             pxy[1] = pos.g_y;
  223.             pxy[2] = pos.g_x + pos.g_w;
  224.             pxy[3] = pos.g_y + pos.g_h;
  225.             draw_rubber(pxy);
  226.         }
  227.  
  228.         pos.g_x = beginx + (mx - origx);
  229.         pos.g_y = beginy + (my - origy);
  230.  
  231.         if (boundw != -1) {
  232.             int tx;
  233.  
  234.             if ((tx = (pos.g_x + pos.g_w) - (boundw)) < 0)
  235.                 tx = 0;
  236.             else
  237.                 tx += 1;
  238.  
  239.             pos.g_x -= tx;
  240.         }
  241.  
  242.         if (boundh != -1 && boundy != -1) {
  243.             int ty;
  244.  
  245.             if ((ty = (pos.g_y + pos.g_h) - (boundy + boundh)) < 0)
  246.                 ty = 0;
  247.             else
  248.                 ty += 1;
  249.  
  250.             pos.g_y -= ty;
  251.         }
  252.  
  253.         if (boundx != -1)
  254.             if (pos.g_x < boundx)
  255.                 pos.g_x = boundx;
  256.  
  257.         if (boundy != -1)
  258.             if (pos.g_y < boundy)
  259.                 pos.g_y = boundy;
  260.  
  261.         if (moved) {
  262.             pxy[0] = pos.g_x;
  263.             pxy[1] = pos.g_y;
  264.             pxy[2] = pos.g_x + pos.g_w;
  265.             pxy[3] = pos.g_y + pos.g_h;
  266.             draw_rubber(pxy);
  267.  
  268.             moved = FALSE;
  269.         }
  270.     } while (button);
  271.  
  272.     pxy[0] = pos.g_x;
  273.     pxy[1] = pos.g_y;
  274.     pxy[2] = pos.g_x + pos.g_w;
  275.     pxy[3] = pos.g_y + pos.g_h;
  276.     draw_rubber(pxy);
  277.  
  278.     pxy[0] = beginx;
  279.     pxy[1] = beginy;
  280.     pxy[2] = width;
  281.     pxy[3] = height;
  282.  
  283.     vs_clip(VDIhandle, 1, pxy);
  284.  
  285.     vst_height(VDIhandle, attr[7], &dummy, &dummy, &dummy, &dummy);
  286.     vst_color(VDIhandle, attr[1]);
  287.     vswr_mode(VDIhandle, attr[5]);
  288.  
  289.     vsf_color(VDIhandle, fillattr[1]);
  290.     vsf_interior(VDIhandle, fillattr[0]);
  291.     vsf_style(VDIhandle, fillattr[2]);
  292.  
  293.     vsl_type(VDIhandle, lineattr[0]);
  294.     vsl_color(VDIhandle, lineattr[1]);
  295.     vsl_udsty(VDIhandle, 0xFFFF);
  296.  
  297.     *endx = pos.g_x;
  298.     *endy = pos.g_y;
  299. }
  300.  
  301. GLOBAL void WSizeBox(WINDOW *win, int mode)
  302. {
  303.     int mx = 0, my = 0, button, dummy, origx, origy, xo, yo, dx = 0,
  304.         dy = 0, moved = FALSE;
  305.     int pxy[8];
  306.     int attr[10], fillattr[5], lineattr[6];
  307.     GRECT pos;
  308.  
  309.     if (win) {
  310.         vqt_attributes(VDIhandle, attr);
  311.         vqf_attributes(VDIhandle, fillattr);
  312.         vql_attributes(VDIhandle, lineattr);
  313.  
  314.         graf_mkstate(&origx, &origy, &dummy, &dummy);
  315.  
  316.         pxy[0] = desk.g_x;
  317.         pxy[1] = desk.g_y;
  318.         pxy[2] = desk.g_x + desk.g_w;
  319.         pxy[3] = desk.g_y + desk.g_h;
  320.  
  321.         vs_clip(VDIhandle, 1, pxy);
  322.  
  323.         vsl_color(VDIhandle, BLACK);
  324.         vsl_type(VDIhandle, 7);
  325.  
  326.         vswr_mode(VDIhandle, MD_XOR);
  327.  
  328.         pos.g_x = win->size.g_x;
  329.         pos.g_y = win->size.g_y;
  330.         pos.g_w = win->size.g_w;
  331.         pos.g_h = win->size.g_h;
  332.  
  333.         pxy[0] = pos.g_x;
  334.         pxy[1] = pos.g_y;
  335.         pxy[2] = pos.g_x + pos.g_w;
  336.         pxy[3] = pos.g_y + pos.g_h;
  337.         draw_rubber(pxy);
  338.  
  339.         if (xaes.config1 & X_MOUSEGADGETS)
  340.             switch(mode) {
  341.                 case S_BOTTOM:
  342.                     WGrafMouse(BSIZER_MOUSE);
  343.                     break;
  344.  
  345.                 case S_LOWERRIGHT:
  346.                     WGrafMouse(LRMOVE_MOUSE);
  347.                     break;
  348.  
  349.                 case S_RIGHT:
  350.                     WGrafMouse(RSIZER_MOUSE);
  351.                     break;
  352.  
  353.                 case S_UPPERRIGHT:
  354.                     WGrafMouse(URMOVE_MOUSE);
  355.                     break;
  356.  
  357.                 case S_TOP:
  358.                     WGrafMouse(TSIZER_MOUSE);
  359.                     break;
  360.  
  361.                 case S_UPPERLEFT:
  362.                     WGrafMouse(ULMOVE_MOUSE);
  363.                     break;
  364.  
  365.                 case S_LEFT:
  366.                     WGrafMouse(LSIZER_MOUSE);
  367.                     break;
  368.  
  369.                 case S_LOWERLEFT:
  370.                     WGrafMouse(LLMOVE_MOUSE);
  371.                     break;
  372.             }
  373.         else
  374.             WGrafMouse(ARROW);
  375.  
  376.         do {
  377.             xo = mx;
  378.             yo = my;
  379.  
  380.             graf_mkstate(&mx, &my, &button, &dummy);
  381.  
  382.             if (!(win->state & W_UNSIZABLE)) {
  383.                 dx = mx - xo;
  384.                 dy = my - yo;
  385.  
  386.                 if (dx || dy)
  387.                     moved = TRUE;
  388.  
  389.                 if (moved) {
  390.                     pxy[0] = pos.g_x;
  391.                     pxy[1] = pos.g_y;
  392.                     pxy[2] = pos.g_x + pos.g_w;
  393.                     pxy[3] = pos.g_y + pos.g_h;
  394.                     draw_rubber(pxy);
  395.                 }
  396.  
  397.                 switch(mode) {
  398.                     case S_BOTTOM:
  399.                         pos.g_h = my - win->size.g_y;
  400.                         break;
  401.  
  402.                     case S_LOWERRIGHT:
  403.                         pos.g_w = mx - win->size.g_x;
  404.                         pos.g_h = my - win->size.g_y;
  405.                         break;
  406.  
  407.                     case S_RIGHT:
  408.                         pos.g_w = mx - win->size.g_x;
  409.                         break;
  410.  
  411.                     case S_UPPERRIGHT:
  412.                         pos.g_y = my;
  413.                         pos.g_w = mx - win->size.g_x;
  414.                         pos.g_h = (win->size.g_y + win->size.g_h) - my;
  415.                         break;
  416.  
  417.                     case S_TOP:
  418.                         pos.g_y = my;
  419.                         pos.g_h = (win->size.g_y + win->size.g_h) - my;
  420.                         break;
  421.  
  422.                     case S_UPPERLEFT:
  423.                         pos.g_x = mx;
  424.                         pos.g_y = my;
  425.                         pos.g_w = (win->size.g_x + win->size.g_w) - mx;
  426.                         pos.g_h = (win->size.g_y + win->size.g_h) - my;
  427.                         break;
  428.  
  429.                     case S_LEFT:
  430.                         pos.g_x = mx;
  431.                         pos.g_w = (win->size.g_x + win->size.g_w) - mx;
  432.                         break;
  433.  
  434.                     case S_LOWERLEFT:
  435.                         pos.g_x = mx;
  436.                         pos.g_w = (win->size.g_x + win->size.g_w) - mx;
  437.                         pos.g_h = my - win->size.g_y;
  438.                         break;
  439.                 }
  440.  
  441.                 if (pos.g_x > win->minimum.g_x)
  442.                     pos.g_x = win->minimum.g_x;
  443.  
  444.                 if (pos.g_y > win->minimum.g_y)
  445.                     pos.g_y = win->minimum.g_y;
  446.  
  447.                 if (pos.g_w < win->minimum.g_w)
  448.                     pos.g_w = win->minimum.g_w;
  449.  
  450.                 if (pos.g_h < win->minimum.g_h)
  451.                     pos.g_h = win->minimum.g_h;
  452.  
  453.                 if (moved) {
  454.                     pxy[0] = pos.g_x;
  455.                     pxy[1] = pos.g_y;
  456.                     pxy[2] = pos.g_x + pos.g_w;
  457.                     pxy[3] = pos.g_y + pos.g_h;
  458.                     draw_rubber(pxy);
  459.  
  460.                     moved = FALSE;
  461.                 }
  462.             }
  463.         } while (button);
  464.  
  465.         pxy[0] = pos.g_x;
  466.         pxy[1] = pos.g_y;
  467.         pxy[2] = pos.g_x + pos.g_w;
  468.         pxy[3] = pos.g_y + pos.g_h;
  469.         draw_rubber(pxy);
  470.  
  471.         pxy[0] = win->size.g_x;
  472.         pxy[1] = win->size.g_y;
  473.         pxy[2] = win->size.g_w;
  474.         pxy[3] = win->size.g_h;
  475.  
  476.         vst_height(VDIhandle, attr[7], &dummy, &dummy, &dummy, &dummy);
  477.         vst_color(VDIhandle, attr[1]);
  478.         vswr_mode(VDIhandle, attr[5]);
  479.  
  480.         vsf_color(VDIhandle, fillattr[1]);
  481.         vsf_interior(VDIhandle, fillattr[0]);
  482.         vsf_style(VDIhandle, fillattr[2]);
  483.  
  484.         vsl_type(VDIhandle, lineattr[0]);
  485.         vsl_color(VDIhandle, lineattr[1]);
  486.         vsl_udsty(VDIhandle, 0xFFFF);
  487.  
  488.         vs_clip(VDIhandle, 1, pxy);
  489.  
  490.         win->size.g_x = pos.g_x;
  491.         win->size.g_y = pos.g_y;
  492.         win->size.g_w = pos.g_w;
  493.         win->size.g_h = pos.g_h;
  494.  
  495.         WGrafMouse(ARROW);
  496.     }
  497. }