home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / CLIPPER / CHISEL / DOCHISEL.PRG
Text File  |  1993-12-30  |  4KB  |  145 lines

  1. /*****
  2.  *
  3.  *         Name: DoChisel    
  4.  *  Description: Demo of the "shadow" box with "chiseled" borders
  5.  *       Author: David L. Smith CIS 72351,225
  6.  * Date created: 12-30-93
  7.  *      Compile: Clipper DOCHISEL /n /m /w
  8.  */
  9. #include "box.ch"
  10. #define FUZZY_STUFF     CHR( 178 )
  11. #define RIGHT_CNR        CHR( 191 )
  12. #define LEFT_CNR        CHR( 218 )
  13. #define BOTTOM_CNR        CHR( 192 )
  14. #define SIDE_LINE        CHR( 179 )
  15. #define TOP_LINE        CHR( 196 )
  16.  
  17. FUNCTION Main()
  18. Setcolor("W/B")
  19. Setblink(.F.) 
  20. // Paint a backdrop for the shadow
  21. FuzzScreen(FUZZY_STUFF)
  22.  
  23. // Show the chisel box
  24. // Gray box looks best
  25. Chiselbox(8,20,16,60,"N/W")
  26.  
  27. // Add a title and exit instruction
  28. @ 12,24 SAY PADC("YOUR BOX TITLE HERE",32," ") COLOR "N/W"
  29. @ MAXROW(),0 SAY PADC("[ Press any key... ]",MAXCOL()+1,FUZZY_STUFF)
  30.  
  31. //Fini
  32. INKEY(0)
  33. RETURN NIL
  34.  
  35. /*****
  36.  *
  37.  *         Name: ChiselBox()    
  38.  *  Description: A "shadow" box with "chiseled" borders
  39.  *       Author: David L. Smith CIS 72351,225
  40.  * Date created: 12-30-93
  41.  *    Copyright: Free, gratis, Public Domain
  42.  *
  43.  *   Parameters: nTop 
  44.  *             : nLeft
  45.  *             : nBottom
  46.  *             : nRight  - Windows coordinates
  47.  *               : cColor  - Box Color  "N/W" looks best to me
  48.  *
  49.  *        Needs: Parameter checking for sloppy coders
  50.  */
  51.  
  52. FUNCTION ChiselBox(nTop,nLeft,nBottom,nRight,cColor)
  53. LOCAL i,cUpClr,cDnClr
  54.  
  55. // Calculate Chisel Up and Down Colors
  56. // You can also reverse the colors for a "sunken" border look
  57. // Use N+ for Up Color and W+ for Down Color
  58. cUpClr:="W+"+SUBSTR(cColor,AT("/",cColor))
  59. cDnClr:="N+"+SUBSTR(cColor,AT("/",cColor))
  60.  
  61. //Draw the shadow 
  62. Shadow(nTop+1,nLeft+2,nBottom+1,nRight+2)
  63.  
  64. //Draw the box
  65. FOR i = 1 TO nBottom-nTop
  66.     @ nTop+i, nLeft SAY REPLICATE(" ",nRight-nLeft+1) COLOR cColor
  67. NEXT
  68.  
  69. //Draw the outer and inner boxes with single lines
  70. @ nTop,nLeft,nBottom,nRight BOX B_SINGLE COLOR cDnClr
  71. @ nTop+1,nLeft+2,nBottom-1,nRight-2 BOX B_SINGLE COLOR cUpClr
  72.  
  73.  
  74. // Draw the outer box highlights
  75. @ nTop,nLeft SAY LEFT_CNR COLOR cUpClr
  76. @ nTop,nLeft+1 SAY REPLICATE(TOP_LINE,nRight-nLeft-1) COLOR cUpClr
  77. @ nTop,nRight SAY RIGHT_CNR COLOR cUpClr
  78. @ nBottom,nLeft SAY BOTTOM_CNR COLOR cUpClr
  79.  
  80. //Draw the inner box highlights
  81. @ nTop+1,nLeft+2 SAY LEFT_CNR COLOR cDnclr
  82. @ nTop+1,nLeft+3 SAY REPLICATE(TOP_LINE,nRight-nLeft-5) COLOR cDnclr
  83. @ nTop+1,nRight-2 SAY RIGHT_CNR COLOR cDnclr
  84. @ nBottom-1,nLeft+2 SAY BOTTOM_CNR COLOR cDnclr
  85.  
  86. //Finish the outer box vertical highlight
  87. FOR i = 1 TO nBottom-nTop-1
  88.     @ nTop+i, nLeft SAY SIDE_LINE COLOR cUpclr
  89. NEXT
  90.  
  91. //Finish the inner box vertical highlight
  92. FOR i = 1 TO nBottom-nTop-3
  93.     @ nTop+i+1, nLeft+2 SAY SIDE_LINE COLOR cDnclr
  94. NEXT
  95. RETURN NIL
  96.  
  97. /*****
  98.  *
  99.  *         Name: FuzzScreen()    
  100.  *  Description: A backdrop painter       
  101.  *       Author: David L. Smith, CIS 72351,225
  102.  *
  103.  *   Parameters: nTop 
  104.  *             : nLeft
  105.  *             : nBottom
  106.  *             : nRight  - Windows coordinates
  107.  *
  108.  */
  109. //Paint a Screen Background
  110. FUNCTION FuzzScreen(cFuzzChar)
  111.   LOCAL nRow := 0
  112.   DISPBEGIN()
  113.     FOR nRow := 0 TO MAXROW()
  114.       @ nRow, 00 SAY REPLICATE( cFuzzChar, MAXCOL()+1 )
  115.     NEXT
  116.   DISPEND()
  117. RETURN( NIL )
  118.  
  119. /*****
  120.  *
  121.  *         Name: Shadow()    
  122.  *  Description: A "shadow" with "see-thru"       
  123.  *       Author: Luiz Quintela
  124.  * Date created: 03-12-93
  125.  *    Copyright: Computer Associates International, Inc.
  126.  *
  127.  *   Parameters: nTop 
  128.  *             : nLeft
  129.  *             : nBottom
  130.  *             : nRight  - Windows coordinates
  131.  *
  132.  */
  133.  
  134. FUNCTION Shadow(nTop, nLeft, nBottom, nRight)
  135.    LOCAL nShadowLen, cShadow
  136.  
  137.    cShadow := SaveScreen( nTop, nLeft, nBottom, nRight )
  138.    nShadowLen := Len(cShadow)
  139.  
  140.    RestScreen( nTop, nLeft, nBottom, nRight,;
  141.                Transform(cShadow, Replicate("X" + Chr(8), nShadowLen)))
  142.    RETURN NIL
  143.  
  144.  
  145.