home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_srgp.lha / srgp / src / srgp_attrib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-09  |  16.4 KB  |  699 lines

  1. #include "HEADERS.h"
  2. #include "srgplocal.h"
  3.  
  4. #define __CURATT(xx)    srgp__curActiveCanvasSpec.attributes.xx
  5.  
  6.  
  7. #ifdef THINK_C
  8. #include "ChooseWhichQuickDraw.h"
  9. #endif
  10.  
  11. #ifdef X11
  12. static XGCValues gcvals;
  13.  
  14. static unsigned char writemode_table[4] = {
  15.    /*REPLACE*/    0x3, /* GXcopy from /usr/include/X11/X.h */
  16.    /*XOR*/     0x6, /* GXxor */
  17.    /*OR*/     0x7, /* GXor */
  18.    /*AND*/     0x1  /* GXand */
  19. };
  20.   
  21. static unsigned char inv_writemode_table[4] = {
  22.    /*REPLACE*/ 0x3, /* GXcopy */
  23.    /*XOR*/     0x9, /* GXequiv */
  24.    /*OR*/      0x1, /* GXand */
  25.    /*AND*/     0x7  /* GXor */
  26. };
  27.  
  28. #endif
  29.  
  30. #ifdef THINK_C
  31. #ifdef COLOR_QUICKDRAW
  32. static unsigned char transfermode_table[4][4] = {
  33.       /*REPLACE,SOLID*/ patCopy,
  34.       /* pixmap pattern entries in this table are unused */ 0,
  35.       /*REPLACE,BITMAP_PATTERN_TRANSPARENT*/ patOr,
  36.       /*REPLACE,BITMAP_PATTERN_OPAQUE*/ patCopy,
  37.       /*XOR,SOLID*/ patXor,
  38.       /* pixmap pattern entries in this table are unused */ 0,
  39.       /*XOR,BITMAP_PATTERN_TRANSPARENT*/ patXor,
  40.       /*XOR,BITMAP_PATTERN_OPAQUE*/ patXor,
  41.       /*OR,SOLID*/ patOr,
  42.       /* pixmap pattern entries in this table are unused */ 0,
  43.       /*OR,BITMAP_PATTERN_TRANSPARENT*/ patOr,
  44.       /*OR,BITMAP_PATTERN_OPAQUE*/ patOr,
  45.       /*AND,SOLID*/ notPatBic,
  46.       /* pixmap pattern entries in this table are unused */ 0,
  47.       /*AND,BITMAP_PATTERN_TRANSPARENT*/ notPatBic,
  48.       /*AND,BITMAP_PATTERN_OPAQUE*/ notPatBic
  49. };
  50.  
  51.  
  52. #define ComputeFrameTransfermode() \
  53.    srgp__curActiveCanvasSpec.transfermode_frame = \
  54.       transfermode_table \
  55.          [srgp__curActiveCanvasSpec.attributes.write_mode] \
  56.          [srgp__curActiveCanvasSpec.attributes.pen_style]
  57.  
  58. #define ComputeFillTransfermode() \
  59.    srgp__curActiveCanvasSpec.transfermode_fill = \
  60.       transfermode_table \
  61.          [srgp__curActiveCanvasSpec.attributes.write_mode] \
  62.          [srgp__curActiveCanvasSpec.attributes.fill_style]
  63.  
  64. #define SetTextTransfermode() \
  65.    TextMode (transfermode_table \
  66.            [srgp__curActiveCanvasSpec.attributes.write_mode] \
  67.            [BITMAP_PATTERN_TRANSPARENT] \
  68.             - 8)
  69.            
  70. #else
  71.  
  72. #define DONT_DRAW   -1
  73.  
  74. static unsigned char transfermode_table[4][2][4] = {
  75.   {
  76.     /*REPLACE,WHITE,...*/ {notPatCopy, 0, patBic, notPatCopy},
  77.     /*REPLACE,BLACK,...*/ {patCopy, 0, patOr, patCopy},
  78.   },
  79.   {
  80.     /*XOR,WHITE,...*/ {notPatXor, 0, DONT_DRAW, notPatXor},
  81.     /*XOR,BLACK,...*/ {patXor, 0, patXor, patXor} 
  82.   },
  83.   {
  84.     /*OR,WHITE,...*/ {notPatOr, 0, DONT_DRAW, notPatOr},
  85.     /*OR,BLACK,...*/ {patOr, 0, patOr, patOr} 
  86.   },
  87.   {
  88.     /*AND,WHITE,...*/ {patBic, 0, DONT_DRAW, patBic},
  89.     /*AND,BLACK,...*/ {notPatBic, 0, notPatBic, notPatBic} 
  90.   }
  91. };
  92.  
  93.  
  94. static void ComputeFrameTransfermode (void)
  95. {
  96.    srgp__curActiveCanvasSpec.transfermode_frame = 
  97.       transfermode_table[srgp__curActiveCanvasSpec.attributes.write_mode]
  98.            [srgp__curActiveCanvasSpec.attributes.color]
  99.            [srgp__curActiveCanvasSpec.attributes.pen_style];
  100. }
  101.  
  102. static void ComputeFillTransfermode (void)
  103. {
  104.    srgp__curActiveCanvasSpec.transfermode_fill = 
  105.       transfermode_table[srgp__curActiveCanvasSpec.attributes.write_mode]
  106.            [srgp__curActiveCanvasSpec.attributes.color]
  107.            [srgp__curActiveCanvasSpec.attributes.pen_style];
  108. }
  109.  
  110. static void SetTextTransfermode (void) {
  111.    TextMode (transfermode_table
  112.            [srgp__curActiveCanvasSpec.attributes.write_mode] 
  113.         [srgp__curActiveCanvasSpec.attributes.color]
  114.            [BITMAP_PATTERN_TRANSPARENT]
  115.             - 8);
  116. }
  117.  
  118. #endif
  119.  
  120. #endif
  121.  
  122.  
  123.  
  124.  
  125. /** WRITE_MODE
  126. X11 implementation:
  127.    Both GC's must be modified.
  128. **/
  129.  
  130. void
  131. SRGP_setWriteMode (writeMode value)
  132. {
  133.    if (value == __CURATT(write_mode)) return;
  134.  
  135.    DEBUG_AIDS{
  136.       SRGP_trace (SRGP_logStream, "SRGP_setWriteMode  %d\n", value);
  137.       srgp_check_system_state();
  138.       srgp_check_write_mode(value);
  139.       LeaveIfNonFatalErr();
  140.    }
  141.  
  142.    srgp__curActiveCanvasSpec.attributes.write_mode = value;
  143.  
  144. #ifdef X11
  145.    if (XWHITE == 0)
  146.        value = writemode_table[value];
  147.    else
  148.        value = inv_writemode_table[value];
  149.    XSetFunction
  150.       (srgpx__display,
  151.        srgp__curActiveCanvasSpec.gc_frame,
  152.        value);
  153.    XSetFunction
  154.       (srgpx__display,
  155.        srgp__curActiveCanvasSpec.gc_fill,
  156.        value);
  157. #endif
  158. #ifdef THINK_C
  159.    ComputeFrameTransfermode();
  160.    ComputeFillTransfermode();
  161.    SetTextTransfermode();
  162. #endif
  163. }
  164.  
  165.  
  166.  
  167. /** CLIP_RECTANGLE
  168. Both GC's must be modified.
  169. **/
  170. void
  171. SRGP_setClipRectangle (rectangle rect)
  172. {
  173. #ifdef X11
  174.    XRectangle xrect;
  175. #endif
  176. #ifdef THINK_C
  177.    Rect r;
  178. #endif
  179.  
  180.    DEBUG_AIDS{
  181.       SRGP_trace (SRGP_logStream, "SRGP_setClipRect  (%d,%d)->(%d,%d)\n", ExplodeRect(rect));
  182.       srgp_check_system_state();
  183.       srgp_check_rectangle
  184.      (rect.bottom_left.x, rect.bottom_left.y,
  185.       rect.top_right.x, rect.top_right.y);
  186.       LeaveIfNonFatalErr();
  187.    }
  188.  
  189.    srgp__curActiveCanvasSpec.attributes.clip_rectangle = rect;
  190.    
  191. #ifdef X11
  192.    xrect.x = rect.bottom_left.x;
  193.    xrect.y = FIXED(rect.top_right.y);
  194.    xrect.width = (rect.top_right.x - rect.bottom_left.x + 1);
  195.    xrect.height = (rect.top_right.y - rect.bottom_left.y + 1);
  196.    XSetClipRectangles
  197.       (srgpx__display,
  198.        srgp__curActiveCanvasSpec.gc_frame,
  199.        0, 0,
  200.        &xrect, 1, YXSorted);
  201.    XSetClipRectangles
  202.       (srgpx__display,
  203.        srgp__curActiveCanvasSpec.gc_fill,
  204.        0, 0,
  205.        &xrect, 1, YXSorted);
  206. #endif
  207.  
  208. #ifdef THINK_C
  209.    r = FIXED_RECT(ExplodeRect(rect));
  210.    ClipRect(&r);
  211. #endif
  212. }
  213.  
  214.  
  215.  
  216.  
  217. /** FILL STYLE
  218. Only the fill GC is to be modified.
  219. The SRGP fill-style maps directly to X's fill-style.
  220. **/
  221. void
  222. SRGP_setFillStyle (drawStyle value)
  223. {
  224.    if (value == __CURATT(fill_style)) return;
  225.  
  226.    DEBUG_AIDS{
  227.       SRGP_trace (SRGP_logStream, "SRGP_setFillStyle  %d\n", value);
  228.       srgp_check_system_state();
  229.       srgp_check_fill_style(value);
  230.       LeaveIfNonFatalErr();
  231.    }
  232.    
  233.    srgp__curActiveCanvasSpec.attributes.fill_style = value;
  234.    
  235. #ifdef X11
  236.    XSetFillStyle (srgpx__display, srgp__curActiveCanvasSpec.gc_fill, value);
  237. #endif
  238.  
  239. #ifdef THINK_C
  240.    ComputeFillTransfermode();
  241.    srgp__curActiveCanvasSpec.pat_fill = (Pattern*)
  242.       ((value == SOLID) ?
  243.           black :  /*Mac's "solid" pattern*/
  244.           srgp__bitmapPatternTable
  245.              [srgp__curActiveCanvasSpec.attributes.fill_bitmap_pattern_id]);
  246. #endif      
  247. }
  248.  
  249. /*!*/
  250. void
  251. SRGP_setFillBitmapPattern (int value)
  252. {
  253.    if (value == __CURATT(fill_bitmap_pattern_id)) return;
  254.  
  255.    DEBUG_AIDS{
  256.       SRGP_trace (SRGP_logStream, "SRGP_setFillBitmapPattern  %d\n", value);
  257.       srgp_check_system_state();
  258.       srgp_check_pattern_index(value);
  259.       srgp_check_pattern_table_entry(srgp__bitmapPatternTable[value]);
  260.       LeaveIfNonFatalErr();
  261.    }
  262.  
  263.    srgp__curActiveCanvasSpec.attributes.fill_bitmap_pattern_id = value;
  264.  
  265. #ifdef X11
  266.    XSetStipple
  267.       (srgpx__display,
  268.        srgp__curActiveCanvasSpec.gc_fill,
  269.        srgp__bitmapPatternTable[value]);
  270. #endif
  271.  
  272. #ifdef THINK_C
  273.    if (srgp__curActiveCanvasSpec.attributes.fill_style != SOLID)
  274.       srgp__curActiveCanvasSpec.pat_fill = (Pattern*)srgp__bitmapPatternTable[value];
  275. #endif
  276. }
  277.  
  278. /*!*/
  279. void
  280. SRGP_setFillPixmapPattern (int value)
  281. {
  282.    if (value == __CURATT(fill_pixmap_pattern_id)) return;
  283.       
  284.    DEBUG_AIDS{
  285.       SRGP_trace (SRGP_logStream, "SRGP_setFillPixmapPattern  %d\n", value);
  286.       srgp_check_system_state();
  287.       srgp_check_pattern_index(value);
  288.       srgp_check_pattern_table_entry(srgp__pixmapPatternTable[value]);
  289.       LeaveIfNonFatalErr();
  290.    }
  291.  
  292.    srgp__curActiveCanvasSpec.attributes.fill_pixmap_pattern_id = value;
  293.  
  294. #ifdef X11
  295.    gcvals.tile = srgp__pixmapPatternTable[value];
  296.    XChangeGC (srgpx__display, srgp__curActiveCanvasSpec.gc_fill,
  297.           GCTile, &gcvals);
  298. #endif
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307. /** PEN STYLE
  308. X11 implementation:
  309.    Only the frame GC is to be modified.
  310.    The SRGP pen-style maps directly to X's fill-style.
  311. **/
  312.  
  313. void
  314. SRGP_setPenStyle (drawStyle value)
  315. {
  316.    if (value == __CURATT(pen_style)) return;
  317.  
  318.    DEBUG_AIDS{
  319.       SRGP_trace (SRGP_logStream, "SRGP_setPenStyle  %d\n", value);
  320.       srgp_check_system_state();
  321.       srgp_check_fill_style(value);
  322.       LeaveIfNonFatalErr();
  323.    }
  324.  
  325.    srgp__curActiveCanvasSpec.attributes.pen_style = value;
  326.  
  327. #ifdef X11
  328.    XSetFillStyle (srgpx__display, srgp__curActiveCanvasSpec.gc_frame, value);
  329. #endif
  330. #ifdef THINK_C
  331.    ComputeFrameTransfermode();
  332.    srgp__curActiveCanvasSpec.pat_frame = (Pattern*)
  333.       ((value == SOLID) ?
  334.          black :  /*Mac's "solid" pattern*/
  335.          srgp__bitmapPatternTable
  336.             [srgp__curActiveCanvasSpec.attributes.pen_bitmap_pattern_id]);
  337. #endif      
  338. }
  339.  
  340. /*!*/
  341. void
  342. SRGP_setPenBitmapPattern (int value)
  343. {
  344.    if (value == __CURATT(pen_bitmap_pattern_id)) return;
  345.  
  346.    DEBUG_AIDS{
  347.       SRGP_trace (SRGP_logStream, "SRGP_setPenBitmapPattern  %d\n", value);
  348.       srgp_check_system_state();
  349.       srgp_check_pattern_index(value);
  350.       srgp_check_pattern_table_entry(srgp__bitmapPatternTable[value]);
  351.       LeaveIfNonFatalErr();
  352.    }
  353.  
  354.    srgp__curActiveCanvasSpec.attributes.pen_bitmap_pattern_id = value;
  355.  
  356. #ifdef X11
  357.    XSetStipple
  358.       (srgpx__display,
  359.        srgp__curActiveCanvasSpec.gc_frame,
  360.        srgp__bitmapPatternTable[value]);
  361. #endif
  362.  
  363. #ifdef THINK_C
  364.    if (srgp__curActiveCanvasSpec.attributes.pen_style != SOLID)
  365.       srgp__curActiveCanvasSpec.pat_frame = 
  366.          (Pattern*) srgp__bitmapPatternTable[value];
  367. #endif
  368. }
  369.  
  370.  
  371.  
  372. /*!*/
  373. void
  374. SRGP_setPenPixmapPattern (int value)
  375. {
  376.    if (value == __CURATT(pen_pixmap_pattern_id)) return;
  377.  
  378.    DEBUG_AIDS{
  379.       SRGP_trace (SRGP_logStream, "SRGP_setPenPixmapPattern  %d\n", value);
  380.       srgp_check_system_state();
  381.       srgp_check_pattern_index(value);
  382.       srgp_check_pattern_table_entry(srgp__pixmapPatternTable[value]);
  383.       LeaveIfNonFatalErr();
  384.    }
  385.  
  386.    srgp__curActiveCanvasSpec.attributes.pen_pixmap_pattern_id = value;
  387.  
  388. #ifdef X11
  389.    gcvals.tile = srgp__pixmapPatternTable[value];
  390.    XChangeGC (srgpx__display, srgp__curActiveCanvasSpec.gc_frame,
  391.           GCTile, &gcvals);
  392. #endif
  393. }
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. /** MARKER ATTRIBUTES
  401. **/
  402.  
  403. void 
  404. SRGP_setMarkerSize (int value)
  405. {
  406.    if (value == __CURATT(marker_size)) return;
  407.  
  408.    DEBUG_AIDS{
  409.       SRGP_trace (SRGP_logStream, "SRGP_setMarkerSize  %d\n", value);
  410.       srgp_check_system_state();
  411.       srgp_check_marker_size(value);
  412.       LeaveIfNonFatalErr();
  413.    }
  414.  
  415.    srgp__curActiveCanvasSpec.attributes.marker_size = value;
  416. }
  417.  
  418.  
  419. void 
  420. SRGP_setMarkerStyle (markerStyle value)
  421. {
  422.    if (value == __CURATT(marker_style)) return;
  423.  
  424.    DEBUG_AIDS{
  425.       SRGP_trace (SRGP_logStream, "SRGP_setMarkerStyle  %d\n", value);
  426.       srgp_check_system_state();
  427.       srgp_check_marker_style(value);
  428.       LeaveIfNonFatalErr();
  429.    }
  430.  
  431.    srgp__curActiveCanvasSpec.attributes.marker_style = value;
  432. }
  433.  
  434.  
  435.  
  436. #ifdef X11
  437. /** TRANSLATING SRGP DASHES TO X 
  438. **/
  439. #define LENGTH_OF_DASH_LIST   4
  440. static char dot[] = {4,4,4,4};
  441. static char dash[] = {10,5,10,5};
  442. static char dotdash[] = {12,4,4,4};
  443. static char *(dashmap[NUMBER_OF_LINE_STYLES]) =
  444.    { /*CONTINUOUS: unimportant*/ 0,
  445.      /*DASHED*/ dash,
  446.      /*DOTTED*/ dot,
  447.      /*DOT_DASHED*/ dotdash };
  448.  
  449.  
  450. /** STATIC INTERNAL: SetXLineAttributes()
  451. Notice that when the user desires a line-width of 1, we use 0.
  452. This uses the hardware's fastest line-drawer, according to X.
  453. **/
  454.  
  455. static void SetXLineAttributes()
  456. {
  457.    XSetLineAttributes
  458.       (
  459.        srgpx__display,
  460.        srgp__curActiveCanvasSpec.gc_frame,
  461.        ((srgp__curActiveCanvasSpec.attributes.line_width == 1) ?
  462.     0 : srgp__curActiveCanvasSpec.attributes.line_width),
  463.        ((srgp__curActiveCanvasSpec.attributes.line_style==CONTINUOUS) ?
  464.     LineSolid : LineOnOffDash),
  465.        CapButt,        /* CAPS and JOINS are no-ops when line width = 0 */
  466.        JoinBevel);
  467. }
  468. #endif
  469.  
  470.  
  471.  
  472. /*!*/
  473. void
  474. SRGP_setLineStyle (lineStyle value)
  475. {
  476.    if (value == __CURATT(line_style)) return;
  477.  
  478.    DEBUG_AIDS{
  479.       SRGP_trace (SRGP_logStream, "SRGP_setLineStyle  %d\n", value);
  480.       srgp_check_system_state();
  481.       srgp_check_line_style(value);
  482.       LeaveIfNonFatalErr();
  483.    }
  484.  
  485.    srgp__curActiveCanvasSpec.attributes.line_style = value;
  486.  
  487. #ifdef X11
  488.    if (value != CONTINUOUS)
  489.       XSetDashes (srgpx__display, srgp__curActiveCanvasSpec.gc_frame,
  490.           0, dashmap[value], LENGTH_OF_DASH_LIST);
  491.    SetXLineAttributes();
  492. #endif
  493. }
  494.  
  495.  
  496.  
  497. /*!*/
  498. void
  499. SRGP_setLineWidth (int value)
  500. {
  501.    if (value == __CURATT(line_width)) return;
  502.  
  503.    DEBUG_AIDS{
  504.       SRGP_trace (SRGP_logStream, "SRGP_setLineWidth  %d\n", value);
  505.       srgp_check_system_state();
  506.       srgp_check_line_width(value);
  507.       LeaveIfNonFatalErr();
  508.    }
  509.  
  510.    srgp__curActiveCanvasSpec.attributes.line_width = value;
  511.    
  512. #ifdef X11
  513.    SetXLineAttributes ();
  514. #endif
  515. #ifdef THINK_C
  516.    PenSize (value,value);
  517. #endif
  518.  
  519.  
  520.  
  521.  
  522.  
  523. /** ATTRIBUTES RELATED TO COLOR
  524. **/
  525.  
  526. void
  527. SRGP_setPlaneMask (int value)
  528. {
  529.    if (value == __CURATT(plane_mask)) return;
  530.  
  531.    DEBUG_AIDS{
  532.       SRGP_trace (SRGP_logStream, "SRGP_setPlaneMask  %x\n", value);
  533.       srgp_check_system_state();
  534.       LeaveIfNonFatalErr();
  535.    }
  536.  
  537.    srgp__curActiveCanvasSpec.attributes.plane_mask = value;
  538.  
  539. #ifdef X11
  540.    XSetPlaneMask
  541.       (srgpx__display, 
  542.        srgp__curActiveCanvasSpec.gc_fill, (unsigned long) value);
  543.    XSetPlaneMask
  544.       (srgpx__display, 
  545.        srgp__curActiveCanvasSpec.gc_frame, (unsigned long) value);
  546. #endif
  547. }
  548.  
  549.  
  550. void
  551. SRGP_setColor (int value)
  552. {
  553.    if (value == __CURATT(color)) return;
  554.  
  555.    DEBUG_AIDS{
  556.       SRGP_trace (SRGP_logStream, "SRGP_setColor  %x\n", value);
  557.       srgp_check_system_state();
  558.       SRGP_correct_color(value);
  559.       LeaveIfNonFatalErr();
  560.    }
  561.  
  562.    if (value > srgp__max_pixel_value)
  563.       value = srgp__max_pixel_value;
  564.    srgp__curActiveCanvasSpec.attributes.color = value;
  565.  
  566. #ifdef X11
  567.    XSetForeground(srgpx__display, srgp__curActiveCanvasSpec.gc_fill,
  568.           XCOLOR(COLORINDEX(value)));
  569.    XSetForeground(srgpx__display, srgp__curActiveCanvasSpec.gc_frame,
  570.           XCOLOR(COLORINDEX(value)));
  571. #endif
  572.  
  573. #ifdef THINK_C
  574. #ifdef COLOR_QUICKDRAW
  575.    srgp__curActiveCanvasSpec.drawable.win->fgColor = (COLORINDEX(value));
  576. #else
  577.    ComputeFrameTransfermode();
  578.    ComputeFillTransfermode();
  579.    SetTextTransfermode();
  580. #endif
  581. #endif
  582. }
  583.  
  584.  
  585.  
  586. void
  587. SRGP_setBackgroundColor (int value)
  588. {
  589.    if (value == __CURATT(background_color)) return;
  590.  
  591.    DEBUG_AIDS{
  592.       SRGP_trace (SRGP_logStream, "SRGP_setBackgroundColor  %x\n", value);
  593.       srgp_check_system_state();
  594.       SRGP_correct_color(value);
  595.       LeaveIfNonFatalErr();
  596.    }
  597.  
  598.    if (value > srgp__max_pixel_value)
  599.       value = srgp__max_pixel_value;
  600.    srgp__curActiveCanvasSpec.attributes.background_color = value;
  601.  
  602. #ifdef X11
  603.    XSetBackground(srgpx__display, srgp__curActiveCanvasSpec.gc_fill,
  604.           XCOLOR(COLORINDEX(value)));
  605.    XSetBackground(srgpx__display, srgp__curActiveCanvasSpec.gc_frame,
  606.           XCOLOR(COLORINDEX(value)));
  607. #endif
  608.  
  609. #ifdef THINK_C
  610. #ifdef COLOR_QUICKDRAW
  611.    srgp__curActiveCanvasSpec.drawable.win->bkColor = (COLORINDEX(value));
  612. #endif
  613. #endif
  614. }
  615.  
  616.  
  617.  
  618. /** Load Single Color
  619. A convenience subroutine for setting a single color table entry
  620. **/
  621. void SRGP_loadSingleColor
  622.    (int startentry,
  623.     unsigned short redi, 
  624.     unsigned short greeni,
  625.     unsigned short bluei)
  626. {
  627.    PUSH_TRACE;
  628.    SRGP_loadColorTable (startentry, 1, &redi, &greeni, &bluei);
  629.    POP_TRACE;
  630. }
  631.  
  632.  
  633.  
  634.  
  635. /** FONT
  636. The frame gc is used to draw text.  This is a cheat, and violates SRGP's
  637. spec.  This will be fixed someday.
  638. **/
  639. void
  640. SRGP_setFont (int value)
  641. {
  642.    if (value == __CURATT(font)) return;
  643.  
  644.    DEBUG_AIDS{
  645.       SRGP_trace (SRGP_logStream, "SRGP_setFont  %d\n", value);
  646.       srgp_check_system_state();
  647.       srgp_check_extant_font(value);
  648.       LeaveIfNonFatalErr();
  649.    }
  650.  
  651.    srgp__curActiveCanvasSpec.attributes.font = value;
  652.  
  653. #ifdef X11
  654.    XSetFont
  655.       (srgpx__display,
  656.        srgp__curActiveCanvasSpec.gc_frame,
  657.        srgp__fontTable[value]->fid);
  658. #endif
  659. #ifdef THINK_C
  660.       TextFont(srgp__fontTable[value].txFont);
  661.       TextSize(srgp__fontTable[value].txSize);
  662.       TextFace(srgp__fontTable[value].txFace);
  663. #endif
  664. }
  665.  
  666.    
  667.  
  668. /** BATCH SET ATTRIBUTES
  669. Woefully inefficient, but at least I don't reset attributes whose
  670. value has not changed.
  671. **/
  672.  
  673. void
  674. SRGP_setAttributes (attribute_group *att_group)
  675. {
  676.    SRGP_trace (SRGP_logStream, "SRGP_setAttributes 0x%x\n", att_group);
  677.    PUSH_TRACE;
  678.    SRGP_setWriteMode (att_group->write_mode);
  679.    SRGP_setClipRectangle (att_group->clip_rectangle);
  680.  
  681.    SRGP_setFont (att_group->font);
  682.    SRGP_setLineStyle (att_group->line_style);
  683.    SRGP_setLineWidth (att_group->line_width);
  684.    SRGP_setColor (att_group->color);
  685.    SRGP_setPlaneMask (att_group->plane_mask);
  686.    SRGP_setBackgroundColor (att_group->background_color);
  687.    SRGP_setFillStyle (att_group->fill_style);
  688.    SRGP_setFillPixmapPattern (att_group->fill_pixmap_pattern_id);
  689.    SRGP_setFillBitmapPattern (att_group->fill_bitmap_pattern_id);
  690.    SRGP_setPenStyle (att_group->pen_style);
  691.    SRGP_setPenPixmapPattern (att_group->pen_pixmap_pattern_id);
  692.    SRGP_setPenBitmapPattern (att_group->pen_bitmap_pattern_id);
  693.    SRGP_setMarkerSize (att_group->marker_size);
  694.    SRGP_setMarkerStyle (att_group->marker_style);
  695.    POP_TRACE;
  696. }
  697.