home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / POLYEDIT.LZH / MODEL / GRAPHPCO.C < prev    next >
C/C++ Source or Header  |  1995-05-31  |  2KB  |  117 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <dos.h>
  4. #include <graphics.h>
  5.  
  6. #include "graph.h"
  7.  
  8. #define        iskanji( c )    ( ( (c) & 0x80 ) != 0 )
  9.  
  10. int        Cols, Lines ;
  11.  
  12. void    graph_init()
  13. {
  14.     int        i ;
  15.     Cols = 80 ;
  16.     Lines = 25 ;
  17.  
  18.     GrSetMode( GR_default_graphics );
  19.  
  20.     Cols = GrSizeX() / 8 ;
  21.     Lines = GrSizeY() / 16 ;
  22.  
  23.     for (i = 0; i < 8; ++i) {
  24.         GrSetColor( i, (i&4) ? 255 : 0, (i&2) ? 255 : 0, (i&1) ? 255 : 0 );
  25.     }
  26. }
  27.  
  28. void    graph_exit()
  29. {
  30.     GrSetMode( GR_default_text );
  31. }
  32.  
  33. void    graph_line( x1, y1, x2, y2, color )
  34. int     x1 ;
  35. int     y1 ;
  36. int        x2 ;
  37. int        y2 ;
  38. int        color ;
  39. {
  40.     if ( color < 16 )
  41.         GrLine( x1, y1, x2, y2, color );
  42.     else
  43.         GrLine( x1, y1, x2, y2, 0x100 + 0x0f );
  44. }
  45.  
  46. void    graph_cls( color )
  47. int        color ;
  48. {
  49.     graph_fill( 0, 0, Cols*8, Lines*16, color );
  50. }
  51.  
  52. void    graph_fill( x1, y1, x2, y2, color )
  53. int        x1 ;
  54. int        y1 ;
  55. int        x2 ;
  56. int        y2 ;
  57. int        color ;
  58. {
  59.     int        y ;
  60.  
  61.     for( y = y1 ; y <= y2 ; y++ )
  62.     {
  63.         GrLine( x1, y, x2, y, color );
  64.     }
  65. }
  66.  
  67. void    graph_palet( paletmode, g, r, b )
  68. int        paletmode ;
  69. int        g, r, b ;
  70. {
  71.     GrSetColor( paletmode, r, g, b );
  72. }
  73.  
  74. void    graph_puts( str, x, y, atr )
  75. char    *str ;
  76. int        x, y ;
  77. int        atr ;
  78. {
  79.     int        i ;
  80.  
  81.     for( i = 0 ; str[i] != '\0' ; i++ )
  82.     {
  83.         if ( iskanji( str[i] ) )
  84.             return ;
  85.     }
  86.     GrTextXY( x, y, str, atr & 15, atr >> 4 );
  87. }
  88.  
  89. void    graph_pattern( x, y, color, pat, h, v )
  90. int        x, y ;
  91. int        color ;
  92. short    *pat ;
  93. int        h, v ;
  94. {
  95. }
  96.  
  97. /*    ボタン表示    */
  98. void    graph_box( x1, y1, x2, y2, sw )
  99. int        x1, y1, x2, y2 ;
  100. int        sw ;
  101. {
  102.     if ( sw )
  103.     {
  104.         graph_line( x1, y1, x2, y1, 7 );
  105.         graph_fill( x1, y1, x1+1, y2, 7 );
  106.         graph_line( x1, y2, x2, y2, 0 );
  107.         graph_line( x2, y1, x2, y2, 0 );
  108.     }
  109.     else
  110.     {
  111.         graph_line( x1, y1, x2, y1, 0 );
  112.         graph_line( x1, y1, x1, y2, 0 );
  113.         graph_line( x1, y2, x2, y2, 7 );
  114.         graph_fill( x2, y1, x2+1, y2, 7 );
  115.     }
  116. }
  117.