home *** CD-ROM | disk | FTP | other *** search
/ Dream 48 / Amiga_Dream_48.iso / Atari / c / libs / xaes_new.lzh / EXTENDED.C < prev    next >
C/C++ Source or Header  |  1994-12-25  |  27KB  |  886 lines

  1. /********************************************************************
  2.  *                                                                0.91*
  3.  *    XAES: Extended Object Types                                        *
  4.  *    Code by Ken Hollis                                                *
  5.  *                                                                    *
  6.  *    Copyright (C) 1994, Bitgate Software                            *
  7.  *                                                                    *
  8.  *    Enhanced object routines that supposedly couldn't be done        *
  9.  *    in an orderly fashion, or so GEM-List people said.  What do they*
  10.  *    know, anyway?  I created six 3D drawing types.  Isn't this        *
  11.  *    satisfactory?  I'm missing a few drawing bits, but no worries.. *
  12.  *                                                                    *
  13.  ********************************************************************/
  14.  
  15. #include <stdlib.h>
  16. #include <stddef.h>
  17. #include <string.h>
  18. #include <ctype.h>
  19.  
  20. #include "xaes.h"
  21.  
  22. #ifdef __TURBOC__
  23. #pragma warn -pia
  24. #endif
  25.  
  26. LOCAL void FixThick(int thickness, OBJECT *obj)
  27. {
  28.     if (thickness < 0) {
  29.         obj->ob_x -= (abs(thickness));
  30.         obj->ob_y -= (abs(thickness));
  31.         obj->ob_width += ((abs(thickness)) * 2);
  32.         obj->ob_height += ((abs(thickness)) * 2);
  33.     }
  34. }
  35.  
  36. LOCAL void FixShadow(int thickness, OBJECT *obj)
  37. {
  38.     if (obj->ob_state & SHADOWED) {
  39.         obj->ob_width += (abs(thickness)) * 2;
  40.         obj->ob_height += (abs(thickness)) * 2;
  41.     }
  42. }
  43.  
  44. LOCAL void FixPositioning(char *te_ptext, OBJECT *obj)
  45. {
  46.     if (strchr(te_ptext, '[')) {
  47.         obj->ob_y -= 2;
  48.         obj->ob_height += 4;
  49.     }
  50. }
  51.  
  52. LOCAL void FixMovement(OBJECT *obj)
  53. {
  54.     obj->ob_x++;
  55.     obj->ob_y++;
  56. }
  57.  
  58. LOCAL void FixSizing(char *te_ptext, OBJECT *obj)
  59. {
  60.     if (strchr(te_ptext, '['))
  61.         switch(obj->ob_type >> 8) {
  62.             case SLIDERLEFT:
  63.             case SLIDERRIGHT:
  64.             case SLIDERUP:
  65.             case SLIDERDOWN:
  66.             case SLIDERTRACK:
  67.             case SLIDERSLIDE:
  68.                 obj->ob_y += 2;
  69.                 obj->ob_height -= 4;
  70.                 break;
  71.         }
  72. }
  73.  
  74. LOCAL void pb_doobject(PARMBLK *pb, int xoff, int yoff)
  75. {
  76.     int dummy, attr[10], fillattr[5], lineattr[6], effects = 0;
  77.     int interiorpxy[4], shadowed[20];
  78.     int extent[8], x, y, gr_ch, gr_bw;
  79.     EXTINFO *ex = (EXTINFO *) pb->pb_parm;
  80.     char *string, *ptr, *unformatted = ex->te_ptext;
  81.     int hotkey = -1, i = 0;
  82.     int flags = pb->pb_tree[pb->pb_obj].ob_flags;
  83.     int tempcalc = (abs(ex->te_thickness)) * 2;
  84.  
  85.     pb->pb_x = pb->pb_x;
  86.     pb->pb_y = pb->pb_y;
  87.     pb->pb_w = pb->pb_tree[pb->pb_obj].ob_width - 1;
  88.     pb->pb_h = pb->pb_tree[pb->pb_obj].ob_height - 1;
  89.  
  90.     if (pb->pb_tree[pb->pb_obj].ob_state & SHADOWED) {
  91.         pb->pb_w -= tempcalc;
  92.         pb->pb_h -= tempcalc;
  93.     }
  94.  
  95.     if (ptr = string = strdup(unformatted)) {
  96.         while (*unformatted) {
  97.             if (*unformatted == '[')
  98.                 if (*(++unformatted))
  99.                     hotkey = i;
  100.                 else
  101.                     break;
  102.  
  103.             *(ptr++) = *(unformatted++);
  104.             i++;
  105.         }
  106.         *ptr = 0;
  107.  
  108.         pb->pb_x += xoff;
  109.         pb->pb_y += yoff;
  110.  
  111.         vqt_attributes(VDIhandle, attr);
  112.         vqf_attributes(VDIhandle, fillattr);
  113.         vql_attributes(VDIhandle, lineattr);
  114.  
  115.         vst_height(VDIhandle, ex->te_font == 3 ? large_font : small_font, &dummy, &gr_ch, &gr_bw, &dummy);
  116.         vst_color(VDIhandle, ex->te_color.text_color);
  117.         vswr_mode(VDIhandle, MD_TRANS);
  118.  
  119.         if (pb->pb_currstate & 0x100) effects |= 1;
  120.         if (pb->pb_currstate & 0x800) effects |= 2;
  121.         if (pb->pb_currstate & 0x400) effects |= 4;
  122.         if (pb->pb_currstate & 0x200) effects |= 8;
  123.         if (pb->pb_currstate & 0x1000) effects |= 16;
  124.  
  125.         vst_effects(VDIhandle, effects);
  126.         vqt_extent(VDIhandle, string, extent);
  127.  
  128.         y = pb->pb_y + ((pb->pb_h - (extent[7] - extent[1])) / 2) + ((((xaes.config1 & X_GENEVACOMPAT) && GenevaInstalled)) ? 1 : (gr_ch + 1));
  129.         x = pb->pb_x + 1;
  130.  
  131.         switch (ex->te_just) {
  132.             case 2:
  133.                 x += (pb->pb_w - (extent[2] - extent[0])) / 2;
  134.                 break;
  135.             case 1:
  136.                 x += pb->pb_w - (extent[2] - extent[0]);
  137.                 break;
  138.         }
  139.  
  140.         interiorpxy[2] = (interiorpxy[0] = pb->pb_x) + pb->pb_w;
  141.         interiorpxy[3] = (interiorpxy[1] = pb->pb_y) + pb->pb_h;
  142.  
  143.         interiorpxy[0] += (abs(ex->te_thickness));
  144.         interiorpxy[1] += (abs(ex->te_thickness));
  145.         interiorpxy[2] -= (abs(ex->te_thickness));
  146.         interiorpxy[3] -= (abs(ex->te_thickness));
  147.  
  148.         if (xaes.config2 & X_INTERFACE) {
  149.             interiorpxy[0]--;    interiorpxy[1]--;
  150.             interiorpxy[2]++;    interiorpxy[3]++;
  151.         }
  152.  
  153.         vsf_interior(VDIhandle, FIS_SOLID);
  154.         vsf_color(VDIhandle, WHITE);
  155.         vswr_mode(VDIhandle, MD_REPLACE);
  156.         vr_recfl(VDIhandle, interiorpxy);
  157.  
  158.         if ((num_colors > 4) ||
  159.             ((num_colors == 4) && (xaes.config1 & X_MEDEMUL))) {
  160.             vsf_style(VDIhandle, 8);
  161.             vsf_interior(VDIhandle, FIS_SOLID);
  162.             vsf_color(VDIhandle, ((num_colors == 4) && (xaes.config1 & X_MEDEMUL)) ? 2 : 8);
  163.             vr_recfl(VDIhandle, interiorpxy);
  164.         }
  165.  
  166.         if ((ex->te_color.fill_ptn) ||
  167.             (((xaes.config1 & X_DRAW3DCOMPAT) && (num_colors == 2)))) {
  168.             vsf_style(VDIhandle, ((xaes.config1 & X_DRAW3DCOMPAT) && (num_colors == 2)) ? ((pb->pb_currstate & DISABLED) ? 8 : 4) : (ex->te_color.fill_ptn == 7 ? 8 : ex->te_color.fill_ptn));
  169.             vsf_interior(VDIhandle, FIS_PATTERN);
  170.             vsf_color(VDIhandle, ((xaes.config1 * X_DRAW3DCOMPAT) && (num_colors == 2)) ? BLACK : ex->te_color.in_color);
  171.             vr_recfl(VDIhandle, interiorpxy);
  172.         }
  173.  
  174.         if (xaes.config2 & X_INTERFACE) {
  175.             interiorpxy[0]++;    interiorpxy[1]++;
  176.             interiorpxy[2]--;    interiorpxy[3]--;
  177.         }
  178.  
  179.         if ((ex->te_thickness) &&
  180.            ((pb->pb_tree[pb->pb_obj].ob_type >> 8) != UNDERLINE) &&
  181.            ((xaes.draw_3d == DRAW_STANDARD) || (xaes.draw_3d == DRAW_LTMF) ||
  182.             (xaes.draw_3d == DRAW_MULTITOS) || (xaes.draw_3d == DRAW_GENEVA)))
  183.             for (i = 0; i <= ((abs(ex->te_thickness)) - 1); i++)
  184.                 box(pb->pb_x + i, pb->pb_y + i, pb->pb_w - (2 * i), pb->pb_h - (2 * i), 1);
  185.  
  186.         if (flags & 0x200 && (xaes.draw_3d == DRAW_MULTITOS || xaes.draw_3d == DRAW_GENEVA)) {
  187.             int col1, col2, pxyarray[8];
  188.  
  189.             if (pb->pb_currstate & SELECTED && flags & 0x0400)
  190.                 col1 = 1, col2 = ((xaes.draw_3d == DRAW_GENEVA) && num_colors > 4) ? 8 : 0;
  191.             else
  192.                 col1 = 0, col2 = ((num_colors == 4) && (xaes.config1 & X_MEDEMUL)) ? 3 : 9;
  193.  
  194.             vsl_color(VDIhandle, col1);
  195.             pxyarray[0] = pxyarray[2] = interiorpxy[0];
  196.             pxyarray[1] = (xaes.draw_3d==DRAW_GENEVA) ? interiorpxy[3] : interiorpxy[3] - 1;
  197.             pxyarray[3] = pxyarray[5] = interiorpxy[1];
  198.             pxyarray[4] = (xaes.draw_3d==DRAW_GENEVA) ? interiorpxy[2] : interiorpxy[2] - 1;
  199.             v_pline(VDIhandle, 3, pxyarray);
  200.  
  201.             vsl_color(VDIhandle, col2);
  202.             pxyarray[0] = pxyarray[0] + 1;
  203.             pxyarray[1] = pxyarray[3] = interiorpxy[3];
  204.             pxyarray[2] = pxyarray[4] = interiorpxy[2];
  205.             pxyarray[5] = interiorpxy[1] + 1;
  206.             v_pline(VDIhandle, 3, pxyarray);
  207.  
  208.             if (xaes.draw_3d!=DRAW_GENEVA) {
  209.                 vsm_color(VDIhandle, (num_colors>4) ? 8 : 0);
  210.                 pxyarray[0] = interiorpxy[0];
  211.                 pxyarray[1] = interiorpxy[3];
  212.                 pxyarray[2] = interiorpxy[2];
  213.                 pxyarray[3] = interiorpxy[1];
  214.                 v_pmarker(VDIhandle, 2, pxyarray);
  215.             }
  216.         }
  217.  
  218.         if ((ex->te_thickness) && ((xaes.draw_3d == DRAW_ZOOM) || (xaes.draw_3d == DRAW_MOTIF))) {
  219.             int col1, col2;
  220.  
  221.             if (pb->pb_currstate & SELECTED && flags & 0x0400)
  222.                 col1 = 0, col2 = ((num_colors == 4) && (xaes.config1 & X_MEDEMUL)) ? 3 : 9;
  223.             else
  224.                 col1 = ((num_colors == 4) && (xaes.config1 & X_MEDEMUL)) ? 3 : 9, col2 = 0;
  225.  
  226.             for (i = 0; i <= (abs(ex->te_thickness)); i++) {
  227.                 int pxyarray[8];
  228.  
  229.                 vsl_color(VDIhandle, col1);
  230.  
  231.                 pxyarray[0] = pb->pb_x + i;
  232.                 pxyarray[1] = pxyarray[3] = pb->pb_y + pb->pb_h - i;
  233.                 pxyarray[2] = pxyarray[4] = pb->pb_x + pb->pb_w - i;
  234.                 pxyarray[5] = pb->pb_y + i;
  235.                 v_pline(VDIhandle, 3, pxyarray);
  236.  
  237.                 vsl_color(VDIhandle, col2);
  238.  
  239.                 pxyarray[0] = pb->pb_x + i;
  240.                 pxyarray[1] = pb->pb_y + pb->pb_h - i;
  241.                 pxyarray[2] = pb->pb_x + i;
  242.                 pxyarray[3] = pb->pb_y + i;
  243.                 pxyarray[4] = pb->pb_x + pb->pb_w - i;
  244.                 v_pline(VDIhandle, 3, pxyarray);
  245.  
  246.                 vsm_color(VDIhandle, (num_colors>4) ? 8 : 0);
  247.  
  248.                 pxyarray[0] = pb->pb_x + i;
  249.                 pxyarray[1] = pb->pb_y + pb->pb_h - i;
  250.                 pxyarray[2] = pb->pb_x + pb->pb_w - i;
  251.                 pxyarray[3] = pb->pb_y + i;
  252.                 v_pmarker(VDIhandle, 2, pxyarray);
  253.             }
  254.  
  255.             if (xaes.draw_3d != DRAW_MOTIF)
  256.                 box(pb->pb_x, pb->pb_y, pb->pb_w, pb->pb_h, 1);
  257.         }
  258.  
  259.         switch (xaes.draw_3d) {
  260.             case DRAW_STANDARD:
  261.             case DRAW_LTMF:
  262.             case DRAW_MULTITOS:
  263.             case DRAW_GENEVA:
  264.                 vswr_mode(VDIhandle, MD_TRANS);
  265.                 vst_color(VDIhandle, ((xaes.config1 & X_DRAW3DCOMPAT) && (num_colors == 2) && (pb->pb_currstate & DISABLED)) ? 0 : ex->te_color.text_color);
  266.  
  267.                 if (((xaes.draw_3d == DRAW_MULTITOS) || (xaes.draw_3d == DRAW_GENEVA)) &&
  268.                     (pb->pb_currstate & SELECTED) && (flags & 0x0400))
  269.                     v_gtext(VDIhandle, x + 1, y + 1, string);
  270.                 else
  271.                     v_gtext(VDIhandle, x, y, string);
  272.                 break;
  273.  
  274.             case DRAW_ZOOM:
  275.             case DRAW_MOTIF:
  276.                 vswr_mode(VDIhandle, MD_TRANS);
  277.                 vst_color(VDIhandle, ((xaes.config1 & X_DRAW3DCOMPAT) && (num_colors == 2) && (pb->pb_currstate & DISABLED)) ? 0 : ex->te_color.text_color);
  278.  
  279.                 if ((pb->pb_currstate & SELECTED) && (flags & 0x0400))
  280.                     v_gtext(VDIhandle, x + (abs(ex->te_thickness)), y + (abs(ex->te_thickness)), string);
  281.                 else
  282.                     v_gtext(VDIhandle, x, y, string);
  283.                 break;
  284.         }
  285.  
  286.         if (hotkey >= 0) {
  287.             int pxyarray[4];
  288.  
  289.             vsl_color(VDIhandle, xaes.hotkey_color);
  290.             vswr_mode(VDIhandle, MD_TRANS);
  291.  
  292.             if (((xaes.draw_3d == DRAW_MOTIF) ||
  293.                 (xaes.draw_3d == DRAW_ZOOM)) &&
  294.                 (pb->pb_currstate & SELECTED) &&
  295.                 (flags & 0x0400)) {
  296.                 pxyarray[2] = (pxyarray[0] = x + (abs(ex->te_thickness)) + gr_bw * hotkey) + gr_bw;
  297.                 pxyarray[1] = pxyarray[3] = y + (abs(ex->te_thickness)) + (gr_ch / 6);
  298.             } else if (((xaes.draw_3d == DRAW_MULTITOS) ||
  299.                         (xaes.draw_3d == DRAW_GENEVA)) &&
  300.                         (pb->pb_currstate & SELECTED) &&
  301.                         (flags & 0x0400)) {
  302.                 pxyarray[2] = (pxyarray[0] = x + gr_bw * hotkey) + gr_bw + 1;
  303.                 pxyarray[1] = pxyarray[3] = y + (gr_ch / 6) + 1;
  304.                 if ((xaes.config1 & X_GENEVACOMPAT) && GenevaInstalled) {
  305.                     pxyarray[1] += gr_ch;
  306.                     pxyarray[3] += gr_ch;
  307.                 }
  308.             } else {
  309.                 pxyarray[2] = (pxyarray[0] = x + gr_bw * hotkey) + gr_bw;
  310.                 pxyarray[1] = pxyarray[3] = y + (gr_ch / 6);
  311.                 if ((xaes.config1 & X_GENEVACOMPAT) && GenevaInstalled) {
  312.                     pxyarray[1] += gr_ch;
  313.                     pxyarray[3] += gr_ch;
  314.                 }
  315.             }
  316.  
  317.             v_pline(VDIhandle, 2, pxyarray);
  318.         }
  319.  
  320.         if ((pb->pb_currstate & SELECTED) &&
  321.             ((!(flags & 0x0400)) ||
  322.             (xaes.draw_3d == DRAW_STANDARD) ||
  323.             (xaes.draw_3d == DRAW_LTMF))) {
  324.             vsf_interior(VDIhandle, FIS_SOLID);
  325.             vsf_color(VDIhandle, BLACK);
  326.             vswr_mode(VDIhandle, MD_XOR);
  327.             vr_recfl(VDIhandle, interiorpxy);
  328.  
  329.             if (xaes.draw_3d == DRAW_LTMF) {
  330.                 vswr_mode(VDIhandle, MD_REPLACE);
  331.                 box(pb->pb_x + ((abs(ex->te_thickness)) - 1),
  332.                     pb->pb_y + ((abs(ex->te_thickness)) - 1),
  333.                     (pb->pb_w - (2 * (abs(ex->te_thickness)))) + 2,
  334.                     (pb->pb_h - (2 * (abs(ex->te_thickness)))) + 2, 0);
  335.                 vswr_mode(VDIhandle, MD_XOR);
  336.             }
  337.         }
  338.  
  339.         if (pb->pb_tree[pb->pb_obj].ob_state & SHADOWED) {
  340.             pb->pb_w += tempcalc;
  341.             pb->pb_h += tempcalc;
  342.  
  343.             vsf_interior(VDIhandle, FIS_SOLID);
  344.             vswr_mode(VDIhandle, MD_REPLACE);
  345.             vsf_color(VDIhandle, BLACK);
  346.             vsl_color(VDIhandle, BLACK);
  347.  
  348.             /* Wow, look, mommie!  I optimized it all by myself! */
  349.             shadowed[0] = shadowed[10] = shadowed[12] = pb->pb_x + pb->pb_w - tempcalc + 1;
  350.             shadowed[1] = shadowed[3] = shadowed[13] = pb->pb_y + tempcalc;
  351.             shadowed[2] = shadowed[4] = pb->pb_x + pb->pb_w;
  352.             shadowed[5] = shadowed[7] = pb->pb_y + pb->pb_h;
  353.             shadowed[6] = shadowed[8] = pb->pb_x + tempcalc;
  354.             shadowed[9] = shadowed[11] = pb->pb_y + pb->pb_h - tempcalc + 1;
  355.  
  356.             v_fillarea(VDIhandle, 7, shadowed);
  357.  
  358.             if (xaes.config1 & X_ROUNDSHADOW) {
  359.                 point(pb->pb_x + pb->pb_w, pb->pb_y + tempcalc, (num_colors > 4) ? 8 : 0);
  360.                 point(pb->pb_x + pb->pb_w, pb->pb_y + pb->pb_h, (num_colors > 4) ? 8 : 0);
  361.                 point(pb->pb_x + tempcalc, pb->pb_y + pb->pb_h, (num_colors > 4) ? 8 : 0);
  362.             }
  363.  
  364.             pb->pb_w -= tempcalc;
  365.             pb->pb_h -= tempcalc;
  366.         }
  367.  
  368.         if (effects)
  369.             vst_effects(VDIhandle, 0);
  370.  
  371.         if (xaes.config1 & X_ROUNDOBJECTS)
  372.             if (pb->pb_tree->ob_state & DRAW3D) {
  373.                 point(pb->pb_x, pb->pb_y, (num_colors > 4) ? 8 : 0);
  374.                 point(pb->pb_x + pb->pb_w, pb->pb_y, (num_colors > 4) ? 8 : 0);
  375.                 point(pb->pb_x, pb->pb_y + pb->pb_h, (num_colors > 4) ? 8 : 0);
  376.                 if (!(pb->pb_tree[pb->pb_obj].ob_state & SHADOWED))
  377.                     point(pb->pb_x + pb->pb_w, pb->pb_y + pb->pb_h, (num_colors > 4) ? 8 : 0);
  378.             } else {
  379.                 point(pb->pb_x, pb->pb_y, 0);
  380.                 point(pb->pb_x + pb->pb_w, pb->pb_y, 0);
  381.                 point(pb->pb_x, pb->pb_y + pb->pb_h, 0);
  382.                 if (!(pb->pb_tree[pb->pb_obj].ob_state & SHADOWED))
  383.                     point(pb->pb_x + pb->pb_w, pb->pb_y + pb->pb_h, 0);
  384.             }                
  385.  
  386.         if (pb->pb_currstate & DISABLED) {
  387.             vsf_interior(VDIhandle, FIS_PATTERN);
  388.  
  389.             interiorpxy[0] = pb->pb_x + (abs(ex->te_thickness));
  390.             interiorpxy[1] = pb->pb_y + (abs(ex->te_thickness));
  391.             interiorpxy[2] = pb->pb_x + pb->pb_w - (abs(ex->te_thickness)) - 1;
  392.             interiorpxy[3] = pb->pb_y + pb->pb_h - (abs(ex->te_thickness)) - 1;
  393.  
  394.             if (num_planes >= 4)
  395.                 vsf_color(VDIhandle, 8);
  396.             else
  397.                 vsf_color(VDIhandle, 0);
  398.  
  399.             vsf_style(VDIhandle, 4);
  400.             vswr_mode(VDIhandle, MD_TRANS);
  401.             vr_recfl(VDIhandle, interiorpxy);
  402.         }
  403.  
  404.         vst_height(VDIhandle, attr[7], &dummy, &dummy, &dummy, &dummy);
  405.         vst_color(VDIhandle, attr[1]);
  406.         vswr_mode(VDIhandle, attr[5]);
  407.  
  408.         vsf_color(VDIhandle, fillattr[1]);
  409.         vsf_interior(VDIhandle, fillattr[0]);
  410.         vsf_style(VDIhandle, fillattr[2]);
  411.  
  412.         vsl_color(VDIhandle, BLACK);
  413.  
  414.         pb->pb_x -= xoff;
  415.         pb->pb_y -= yoff;
  416.     }
  417.  
  418.     if (pb->pb_tree[pb->pb_obj].ob_state & SHADOWED) {
  419.         pb->pb_w += tempcalc;
  420.         pb->pb_h += tempcalc;
  421.     }
  422. }
  423.  
  424. LOCAL int cdecl    draw_specialtext(PARMBLK *pb)
  425. {
  426.     EXTINFO *ex = (EXTINFO *) pb->pb_parm;
  427.  
  428.     if (((ex->oldtype & 0xFF) != G_ICON) && ((ex->oldtype & 0xFF) != G_IMAGE))
  429.         pb_doobject(pb, 0, 0);
  430.  
  431.     return pb->pb_currstate & ~(SELECTED | OUTLINED | DISABLED);
  432. }
  433.  
  434. LOCAL int cdecl draw_menuline(PARMBLK *pb)
  435. {
  436.     int attr[10], fillattr[5], lineattr[6];
  437.     GRECT line1, line2;
  438.  
  439.     vqt_attributes(VDIhandle, attr);
  440.     vqf_attributes(VDIhandle, fillattr);
  441.     vql_attributes(VDIhandle, lineattr);
  442.  
  443.     line1.g_x = line2.g_x = pb->pb_x;
  444.     line1.g_y = line1.g_h = pb->pb_y + (pb->pb_h / 2) - 1;
  445.     line1.g_w = line2.g_w = pb->pb_x + pb->pb_w - 1;
  446.     line2.g_y = line2.g_h = pb->pb_y + (pb->pb_h / 2);
  447.  
  448.     vsl_color(VDIhandle, ((((EXTINFO *) pb->pb_parm)->te_color.bord_color == 0) ?
  449.                           1 : (((EXTINFO *) pb->pb_parm)->te_color.bord_color)));
  450.  
  451.     if (xaes.config1 & X_NICELINE) {
  452.         vsl_type(VDIhandle, 7);
  453.         vsl_udsty(VDIhandle, 0xAAAA);
  454.     }
  455.  
  456.     line(line1.g_x, line1.g_y, line1.g_w, line1.g_h);
  457.  
  458.     if (xaes.config1 & X_NICELINE)
  459.         vsl_udsty(VDIhandle, 0x5555);
  460.  
  461.     line(line2.g_x, line2.g_y, line2.g_w, line2.g_h);
  462.  
  463.     vst_color(VDIhandle, attr[1]);
  464.     vswr_mode(VDIhandle, attr[5]);
  465.  
  466.     vsf_color(VDIhandle, fillattr[1]);
  467.     vsf_interior(VDIhandle, fillattr[0]);
  468.     vsf_style(VDIhandle, fillattr[2]);
  469.  
  470.     vsl_color(VDIhandle, lineattr[1]);
  471.     vsl_type(VDIhandle, 7);
  472.     vsl_udsty(VDIhandle, 0xFFFF);
  473.  
  474.     return FALSE;
  475. }
  476.  
  477. LOCAL int cdecl    draw_underline(PARMBLK *pb)
  478. {
  479.     int pxyarray[4], dummy;
  480.     int attr[10], fillattr[5], lineattr[6];
  481.  
  482.     vqt_attributes(VDIhandle, attr);
  483.     vqf_attributes(VDIhandle, fillattr);
  484.     vql_attributes(VDIhandle, lineattr);
  485.  
  486.     pb_doobject(pb, 0, 0);
  487.  
  488.     pxyarray[0] = pb->pb_xc;
  489.     pxyarray[1] = pb->pb_yc;
  490.     pxyarray[2] = pb->pb_xc + pb->pb_wc - 1;
  491.     pxyarray[3] = pb->pb_yc + pb->pb_hc - 1;
  492.     vs_clip(VDIhandle, 1, pxyarray);
  493.  
  494.     if (pb->pb_tree[pb->pb_obj].ob_state & DISABLED) {
  495.         vsl_type(VDIhandle, 7);
  496.         vsl_udsty(VDIhandle, 0x5555);
  497.     }
  498.  
  499.     vswr_mode(VDIhandle, MD_REPLACE);
  500.     vsl_color(VDIhandle, ((EXTINFO *) pb->pb_parm)->te_color.bord_color);
  501.  
  502.     pxyarray[0] = pb->pb_x;
  503.     pxyarray[2] = pb->pb_x + pb->pb_w;
  504.     pxyarray[1] = pxyarray[3] = (pb->pb_y + pb->pb_h) + 1;
  505.     v_pline(VDIhandle, 2, pxyarray);
  506.  
  507.     vst_height(VDIhandle, attr[7], &dummy, &dummy, &dummy, &dummy);
  508.     vst_color(VDIhandle, attr[1]);
  509.     vswr_mode(VDIhandle, attr[5]);
  510.  
  511.     vsf_color(VDIhandle, fillattr[1]);
  512.     vsf_interior(VDIhandle, fillattr[0]);
  513.     vsf_style(VDIhandle, fillattr[2]);
  514.  
  515.     vsl_color(VDIhandle, BLACK);
  516.  
  517.     return FALSE;
  518. }
  519.  
  520. LOCAL int cdecl draw_boxframe(PARMBLK *pb)
  521. {
  522.     int pxyarray[10], dummy;
  523.     EXTINFO *ex = (EXTINFO *) pb->pb_parm;
  524.     char *unformatted = ex->te_ptext;
  525.     int state = pb->pb_tree[pb->pb_obj].ob_state;
  526.     int this_ch, this_bw;
  527.     int attr[10], fillattr[5], lineattr[6];
  528.  
  529.     vqt_attributes(VDIhandle, attr);
  530.     vqf_attributes(VDIhandle, fillattr);
  531.     vql_attributes(VDIhandle, lineattr);
  532.  
  533.     pxyarray[0] = pb->pb_xc;
  534.     pxyarray[1] = pb->pb_yc;
  535.     pxyarray[2] = pb->pb_xc + pb->pb_wc - 1;
  536.     pxyarray[3] = pb->pb_yc + pb->pb_hc - 1;
  537.     vs_clip(VDIhandle, 1, pxyarray);
  538.  
  539.     vswr_mode(VDIhandle, MD_REPLACE);
  540.     vsl_color(VDIhandle, ((EXTINFO *) pb->pb_parm)->te_color.bord_color);
  541.  
  542.     if ((num_colors<=4) || !(state & DRAW3D) || (xaes.draw_3d == DRAW_STANDARD))
  543.         box(pb->pb_x, pb->pb_y, pb->pb_w - 1, pb->pb_h - 1, ((EXTINFO *) pb->pb_parm)->te_color.bord_color);
  544.  
  545.     if ((state & DRAW3D) && (num_colors > 4) && (xaes.draw_3d != DRAW_STANDARD)) {
  546.         vsl_color(VDIhandle, 9);
  547.         pxyarray[0] = pb->pb_x + pb->pb_w - 1;
  548.         pxyarray[1] = pxyarray[3] = pb->pb_y;
  549.         pxyarray[2] = pxyarray[4] = pb->pb_x;
  550.         pxyarray[5] = pb->pb_y + pb->pb_h - 1;
  551.         v_pline(VDIhandle, 3, pxyarray);
  552.  
  553.         vsl_color(VDIhandle, 0);
  554.         pxyarray[0] = pxyarray[2] = pb->pb_x + pb->pb_w - 1;
  555.         pxyarray[1] = pb->pb_y + 1;
  556.         pxyarray[3] = pxyarray[5] = pb->pb_y + pb->pb_h - 1;
  557.         pxyarray[4] = pb->pb_x + 1;
  558.         v_pline(VDIhandle, 3, pxyarray);
  559.  
  560.         vsf_interior(VDIhandle, FIS_SOLID);
  561.  
  562.         if (state & 0x0040)
  563.             vsf_color(VDIhandle, WHITE);
  564.         else
  565.             vsf_color(VDIhandle, 8);
  566.  
  567.         pxyarray[0] = pb->pb_x + 1;
  568.         pxyarray[1] = pb->pb_y + 1;
  569.         pxyarray[2] = pb->pb_x + pb->pb_w - 3;
  570.         pxyarray[3] = pb->pb_y + pb->pb_h - 3;
  571.         vr_recfl(VDIhandle, pxyarray);
  572.  
  573.         box(pb->pb_x + 1, pb->pb_y + 1, pb->pb_w - 3, pb->pb_h - 3, (state & 0x0040) ? 8 : WHITE);
  574.  
  575.         if (!(state & 0x0040)) {
  576.             vsl_color(VDIhandle, 9);
  577.  
  578.             pxyarray[0] = pxyarray[2] = pb->pb_x + pb->pb_w - 2;
  579.             pxyarray[1] = pb->pb_y + 2;
  580.             pxyarray[3] = pxyarray[5] = pb->pb_y + pb->pb_h - 2;
  581.             pxyarray[4] = pb->pb_x + 2;
  582.  
  583.             v_pline(VDIhandle, 3, pxyarray);
  584.         }
  585.     }
  586.  
  587.     vst_height(VDIhandle, ex->te_font == 3 ? large_font : small_font, &dummy, &this_ch, &this_bw, &dummy);
  588.     v_gtext(VDIhandle, pb->pb_x + gr_cw, pb->pb_y + (this_ch / 2), unformatted);
  589.  
  590.     if (pb->pb_tree[pb->pb_obj].ob_flags & BOXFRAMETITLE) {
  591.         vsl_color(VDIhandle, 9);
  592.         pxyarray[0] = pxyarray[2] = pb->pb_x + gr_cw;
  593.         pxyarray[1] = pxyarray[7] = pb->pb_y;
  594.         pxyarray[3] = pxyarray[5] = pb->pb_y - (gr_ch / 2);
  595.         pxyarray[4] = pxyarray[6] = pb->pb_x + (int)((strlen(unformatted) + 1) * gr_cw);
  596.         v_pline(VDIhandle, 4, pxyarray);
  597.  
  598.         vsl_color(VDIhandle, 8);
  599.  
  600.         pxyarray[0] = pxyarray[2] = pb->pb_x + gr_cw;
  601.         pxyarray[1] = pxyarray[7] = pb->pb_y + 1;
  602.         pxyarray[3] = pxyarray[5] = pb->pb_y + (gr_ch / 2) + 1;
  603.         pxyarray[4] = pxyarray[6] = pb->pb_x + (int)((strlen(unformatted) + 1) * gr_cw);
  604.         v_pline(VDIhandle, 4, pxyarray);
  605.     }
  606.  
  607.     vst_height(VDIhandle, attr[7], &dummy, &dummy, &dummy, &dummy);
  608.     vst_color(VDIhandle, attr[1]);
  609.     vswr_mode(VDIhandle, attr[5]);
  610.  
  611.     vsf_color(VDIhandle, fillattr[1]);
  612.     vsf_interior(VDIhandle, fillattr[0]);
  613.     vsf_style(VDIhandle, fillattr[2]);
  614.  
  615.     vsl_color(VDIhandle, BLACK);
  616.  
  617.     return pb->pb_currstate & ~(SELECTED | OUTLINED | DISABLED);
  618. }
  619.  
  620. /*
  621.  *    Fix resource objects to include customised objects
  622.  *
  623.  *    *obj = pointer to object to fix
  624.  *
  625.  *    Returns: TRUE on success
  626.  */
  627. GLOBAL int fix_object(OBJECT *obj, BOOL pos, BOOL repos)
  628. {
  629.     int object = -1;
  630.     USERBLK *ub;
  631.  
  632.     do {
  633.         object++;
  634.  
  635. /* DJH - Couldn't you compress this into one big switch {} statement? */
  636.         if (((obj[object].ob_type >> 8) == FLYING) ||
  637.             ((obj[object].ob_type >> 8) == CUSTOM) ||
  638.             ((obj[object].ob_type >> 8) == UNDERLINE) ||
  639.             ((obj[object].ob_type >> 8) == BOXFRAME) ||
  640.             ((obj[object].ob_type >> 8) == HELPBTN) ||
  641.             ((obj[object].ob_type >> 8) == CYCLEBTN) ||
  642.             ((obj[object].ob_type >> 8) == TEXTEFFECTS) ||
  643.             ((obj[object].ob_type >> 8) == CUSTBTN) ||
  644.             ((obj[object].ob_type >> 8) == DROPDOWN) ||
  645.             ((obj[object].ob_type >> 8) == MENUTEAR) ||
  646.             ((obj[object].ob_type >> 8) == UNDOBTN) ||
  647.             ((obj[object].ob_type >> 8) == MENULINE) ||
  648.             ((obj[object].ob_type >> 8) == SLIDERLEFT) ||
  649.             ((obj[object].ob_type >> 8) == SLIDERRIGHT) ||
  650.             ((obj[object].ob_type >> 8) == SLIDERUP) ||
  651.             ((obj[object].ob_type >> 8) == SLIDERDOWN) ||
  652.             ((obj[object].ob_type >> 8) == SLIDERTRACK) ||
  653.             ((obj[object].ob_type >> 8) == SLIDERSLIDE)) {
  654.             if (ub = malloc(sizeof(USERBLK) + sizeof(EXTINFO))) {
  655.                 EXTINFO *ex = (EXTINFO *) (ub + 1);
  656.  
  657.                 switch(obj[object].ob_type & 0xff) {
  658.                     case G_TEXT:
  659.                         memset(ex, 0, sizeof(EXTINFO));
  660.                         memcpy(ex, obj[object].ob_spec.tedinfo, sizeof(TEDINFO));
  661.                         ex->te_thickness = 0;
  662.                         break;
  663.  
  664.                     case G_BOXTEXT:
  665.                         memset(ex, 0, sizeof(EXTINFO));
  666.                         memcpy(ex, obj[object].ob_spec.tedinfo, sizeof(TEDINFO));
  667.  
  668.                         FixThick(ex->te_thickness, &obj[object]);
  669.                         FixShadow(ex->te_thickness, &obj[object]);
  670.  
  671.                         if (pos) {
  672.                             FixPositioning(ex->te_ptext, &obj[object]);
  673.                             FixSizing(ex->te_ptext, &obj[object]);
  674.                         }
  675.  
  676.                         if (repos)
  677.                             FixMovement(&obj[object]);
  678.  
  679.                         break;
  680.  
  681.                     case G_STRING:
  682.                         memset(ex, 0, sizeof(EXTINFO));
  683.                         ex->te_ptext = obj[object].ob_spec.free_string;
  684.                         ex->te_font = 3;
  685.                         ex->te_color.bord_color = ex->te_color.text_color = 1;
  686.                         ex->te_thickness = 0;
  687.                         break;
  688.  
  689.                     case G_BUTTON:
  690.                         memset(ex, 0, sizeof(EXTINFO));
  691.                         ex->te_ptext = obj[object].ob_spec.free_string;
  692.                         ex->te_font = 3;
  693.                         ex->te_just = 2;
  694.                         ex->te_thickness = obj[object].ob_flags & EXIT ? (obj[object].ob_flags & DEFAULT ? -3 : -2) : -1;
  695.                         ex->te_color.bord_color = ex->te_color.text_color = 1;
  696.  
  697.                         FixThick(ex->te_thickness, &obj[object]);
  698.                         FixShadow(ex->te_thickness, &obj[object]);
  699.  
  700.                         if (pos) {
  701.                             FixPositioning(ex->te_ptext, &obj[object]);
  702.                             FixSizing(ex->te_ptext, &obj[object]);
  703.                         }
  704.  
  705.                         if (repos)
  706.                             FixMovement(&obj[object]);
  707.  
  708.                         break;
  709.  
  710.                     case G_BOX:
  711.                         memset(ex, 0, sizeof(EXTINFO));
  712.                         ex->te_ptext = "";
  713.                         ex->te_font = 3;
  714.                         ex->te_just = 2;
  715.                         ex->te_thickness = obj[object].ob_spec.obspec.framesize;
  716.                         ex->te_color.bord_color = obj[object].ob_spec.obspec.framecol;
  717.                         ex->te_color.text_color = obj[object].ob_spec.obspec.textcol;
  718.                         ex->te_color.in_color = obj[object].ob_spec.obspec.interiorcol;
  719.                         ex->te_color.fill_ptn = obj[object].ob_spec.obspec.fillpattern;
  720.                         if (ex->te_color.fill_ptn == 1)
  721.                             ex->te_color.fill_ptn = 0;
  722.  
  723.                         FixThick(ex->te_thickness, &obj[object]);
  724.                         FixShadow(ex->te_thickness, &obj[object]);
  725.                         break;
  726.  
  727.                     case G_IBOX:
  728.                         memset(ex, 0, sizeof(EXTINFO));
  729.                         ex->te_ptext = "";
  730.                         ex->te_font = 3;
  731.                         ex->te_just = 2;
  732.                         ex->te_thickness = obj[object].ob_spec.obspec.framesize;
  733.                         ex->te_color.bord_color = obj[object].ob_spec.obspec.framecol;
  734.                         ex->te_color.text_color = obj[object].ob_spec.obspec.textcol;
  735.                         ex->te_color.in_color = obj[object].ob_spec.obspec.interiorcol;
  736.                         ex->te_color.fill_ptn = 0;
  737.  
  738.                         FixThick(ex->te_thickness, &obj[object]);
  739.                         FixShadow(ex->te_thickness, &obj[object]);
  740.                         break;
  741.  
  742.                     case G_BOXCHAR:
  743.                         memset(ex, 0, sizeof(EXTINFO));
  744.                         ex->te_ptext = "X";
  745.                         *ex->te_ptext = (char) obj[object].ob_spec.obspec.character;
  746.                         ex->te_font = 3;
  747.                         ex->te_just = 2;
  748.                         ex->te_thickness = obj[object].ob_spec.obspec.framesize;
  749.                         ex->te_color.bord_color = obj[object].ob_spec.obspec.framecol;
  750.                         ex->te_color.text_color = obj[object].ob_spec.obspec.textcol;
  751.                         ex->te_color.in_color = obj[object].ob_spec.obspec.interiorcol;
  752.                         ex->te_color.fill_ptn = (obj[object].ob_spec.obspec.fillpattern == 1) ? 1 : obj[object].ob_spec.obspec.fillpattern;
  753.  
  754.                         FixThick(ex->te_thickness, &obj[object]);
  755.                         FixShadow(ex->te_thickness, &obj[object]);
  756.                         break;
  757.  
  758.                     default:
  759.                         break;
  760.                 }
  761.  
  762.                 ex->te_routines.mouse_down    = NULL;
  763.                 ex->te_routines.mouse_up    = NULL;
  764.                 ex->te_routines.mouse_move    = NULL;
  765.                 ex->te_routines.mouse_click    = NULL;
  766.  
  767.                 ex->oldparm = obj[object].ob_spec.userblk;
  768.                 ex->oldtype = obj[object].ob_type;
  769.  
  770.                 switch(obj[object].ob_type >> 8) {
  771.                     case SLIDERLEFT:
  772.                         ex->te_ptext = "\4";
  773.                         break;
  774.  
  775.                     case SLIDERRIGHT:
  776.                         ex->te_ptext = "\3";
  777.                         break;
  778.  
  779.                     case SLIDERUP:
  780.                         ex->te_ptext = "\1";
  781.                         break;
  782.  
  783.                     case SLIDERDOWN:
  784.                         ex->te_ptext = "\2";
  785.                         break;
  786.                 }
  787.  
  788.                 ub->ub_parm = (long) ex;
  789.  
  790.                 switch(obj[object].ob_type >> 8) {
  791.                     case MENULINE:
  792.                         ub->ub_code = (int cdecl (*)(PARMBLK *))draw_menuline;
  793.                         obj[object].ob_type = (MENULINE << 8) + G_USERDEF;
  794.                         break;
  795.  
  796.                     case UNDERLINE:
  797.                         ub->ub_code = (int cdecl (*)(PARMBLK *))draw_underline;
  798.                         obj[object].ob_type = (UNDERLINE << 8) + G_USERDEF;
  799.                         break;
  800.  
  801.                     case BOXFRAME:
  802.                         ub->ub_code = (int cdecl (*)(PARMBLK *))draw_boxframe;
  803.                         obj[object].ob_type = (BOXFRAME << 8) + G_USERDEF;
  804.                         break;
  805.  
  806.                     case SLIDERLEFT:
  807.                         ub->ub_code = (int cdecl (*)(PARMBLK *))draw_specialtext;
  808.                         obj[object].ob_type = (SLIDERLEFT << 8) + G_USERDEF;
  809.                         break;
  810.  
  811.                     case SLIDERRIGHT:
  812.                         ub->ub_code = (int cdecl (*)(PARMBLK *))draw_specialtext;
  813.                         obj[object].ob_type = (SLIDERRIGHT << 8) + G_USERDEF;
  814.                         break;
  815.  
  816.                     case SLIDERUP:
  817.                         ub->ub_code = (int cdecl (*)(PARMBLK *))draw_specialtext;
  818.                         obj[object].ob_type = (SLIDERUP << 8) + G_USERDEF;
  819.                         break;
  820.  
  821.                     case SLIDERDOWN:
  822.                         ub->ub_code = (int cdecl (*)(PARMBLK *))draw_specialtext;
  823.                         obj[object].ob_type = (SLIDERDOWN << 8) + G_USERDEF;
  824.                         break;
  825.  
  826.                     case SLIDERTRACK:
  827.                         ub->ub_code = (int cdecl (*)(PARMBLK *))draw_specialtext;
  828.                         obj[object].ob_type = (SLIDERTRACK << 8) + G_USERDEF;
  829.                         break;
  830.  
  831.                     case SLIDERSLIDE:
  832.                         ub->ub_code = (int cdecl (*)(PARMBLK *))draw_specialtext;
  833.                         obj[object].ob_type = (SLIDERSLIDE << 8) + G_USERDEF;
  834.                         break;
  835.  
  836.                     default:
  837.                         {
  838.                             char *ptr;
  839.  
  840.                             if (((obj[object].ob_type >> 8) != FLYING))
  841.                                 if ((ptr = strchr(ex->te_ptext, '[')) && *(++ptr))
  842.                                     ex->te_hotkey = ((toupper(*ptr)) & 0x7f);
  843.                                 else
  844.                                     ex->te_hotkey = 0;
  845.                             else
  846.                                 ex->te_hotkey = 0;
  847.                         }
  848.  
  849.                         ub->ub_code = (int cdecl (*)(PARMBLK *))draw_specialtext;
  850.                         obj[object].ob_type = G_USERDEF;
  851.                         break;
  852.                 }
  853.  
  854.                 obj[object].ob_spec.userblk = ub;
  855.             }
  856.         }
  857.     } while(!(obj[object].ob_flags & LASTOB));
  858.  
  859.     return TRUE;
  860. }
  861.  
  862. GLOBAL void unfix_object(OBJECT *obj)
  863. {
  864.     USERBLK *ub;
  865.     EXTINFO *ex;
  866.  
  867.     if (obj->ob_type != G_TITLE)
  868.         if ((obj->ob_type & 0xFF) == G_USERDEF) {
  869.             ub = obj->ob_spec.userblk;
  870.             ex = (EXTINFO *) ub->ub_parm;
  871.  
  872.             if (ex != NULL) {
  873.                 if (ex->te_thickness < 0) {
  874.                     obj->ob_width += ex->te_thickness * 2;
  875.                     obj->ob_height += ex->te_thickness * 2;
  876.                     obj->ob_x -= ex->te_thickness;
  877.                     obj->ob_y -= ex->te_thickness;
  878.                 }
  879.  
  880.                 obj->ob_spec.userblk = ex->oldparm;
  881.                 obj->ob_type = ex->oldtype;
  882.                 free(ub);
  883.             }
  884.         }
  885. }
  886.