Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - fill() draw a box with optional fill and shadow http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fill()              Draw a box with optional fill and shadow
------------------------------------------------------------------------------
 Declaration
   screen.hdr

 Syntax
   proc fill extern
   param value int  iTop, ;
         value int  iLeft, ;
         value int  iBottom, ;
         value int  iRight, ;
         const char cBorder, ;
         const char cFillChars, ;
         value int  iBorderColor, ;
         value int  iFillColor, ;
         value int  iShadow

 Arguments
   iTop is the top row of the box.

   iLeft is the leftmost column of the box.

   iBottom is the bottom row of the box.

   iRight is the rightmost column of the box.

   cBorder is the border character string.

   cFillChars is a string to fill the box with.

   iBorderColor is the color of the box border.

   iFillColor is the color for the fill string.

   iShadow indicates the position of the shadow.

 Return
   None.

 Description
   This function draws a box on the screen using user-defined border
   characters. The box is optionally filled with a character string, and
   can have a shadow.

   The first four parameters define the screen coordinates for the box.

   The cBorder parameter is an 8-character string defining the border
   characters. fill() reads the string from left to right using each character
   to define a corner or side of the box. Character strings that create boxes
   using the double or single box characters are already defined in screen.hdr
   as BOX_SINGLE or BOX_DOUBLE.

   The cFillChars parameter specifies a character string to fill the inside
   of the box. If cFillChars is an empty string, the box is not filled. If
   cFillChars is a multi-character string, fill() starts at the first
   character of the string and rotates through the string as it fills
   the box. This enables programming of a screen that should be filled
   with a company name, for example.

   iBorderColor specifies the color attribute for the border of the box
   while iFillColor specifies the color attribute for the fill character
   string, cFillChars. See color.hdr for color defines.

   iShadow allows the box to be shadowed on any one or all sides. The
   shadowing effect is generated by either removing the highlight bit of the
   color attribute or making the color attribute black.

   Each side of a box is assigned a number, starting from the top side which
   is assigned number 1. The right side of the box is side 2, the bottom is
   side 3 and the left side is side 4. iShadow is interpreted by fill()
   as 4 binary bits, with each bit indicating whether a side is to be
   shadowed, or not. If the bit is set, the side is shadowed.

   For example, to shadow the top and the left side of a box, set
   iShadow to 4, which is binary 0011. See the Shadow table for
   binary and decimal values required to shadow a particular side.

 Example
   #define EXAMPLE_SCREEN
   #include example.hdr

   vardef static
      char( 25 ) cPress := "Press a key to exit."
   enddef
   
   proc Yell
   param const char cErrorMsg
   // An error procedure that prints a message in the middle of the screen.
   // The function figures out the size of the box required for the message.
   vardef
      int   nLeft
      int   iWidthFull
      int   iWidth
      byte  bColor
      _HSCR hScreen
   enddef
   iWidth := len( cErrorMsg )
   if iWidth < len( cPress )
      iWidth := len( cPress )
   endif
   iWidthFull := iWidth + 5
   nLeft := 40 - ( iWidth / 2 ) - 2
   hScreen := savescrn( 11, nLeft, 15, nLeft + iWidthFull )
   sound( 1500, 20 )
   fill( 11, nLeft, 15, nLeft + iWidthFull, BOX_SINGLE, " ", ;
      RED_WHITE, RED_WHITE, 6 )
   bColor := __syscolor[ CLR_STD ]
   __syscolor[ CLR_STD ] := RED_YELLOW
   @ 12, 40 - ( iWidth / 2 ) ?? cErrorMsg
   @ 13, 40 - ( len( cPress ) / 2 ) ?? cPress
   getkey()
   __syscolor[ CLR_STD ] := bColor
   restorescrn( hScreen )
   endproc
   
   proc Test_fill
   // Draw a box on screen using the "*" and "-" characters for the border.
   fill( 4, 4, 10, 40, "*-*-*-*-", " ", 7, 7, 0 )
   wait
   
   // Draw a box on screen using the double box and have the right and bottom
   // sides of the box be shadowed.
   fill( 10, 12, 20, 36, BOX_DOUBLE, "Ted's T.V.", ;
         &BLUE_GREEN, &BLUE_GREEN, 6 )
   wait
   
   // Drav a box without frame.
   fill( 20, 2, 23, 76, "        ", " ", CYAN_WHITE, CYAN_WHITE, 0 )
   wait
   
   Yell( "A fatal error occurred." )
   
   endproc

   proc main
   Test_fill()
   endproc

See Also: @ to Shadow table box() box3d() growbox() popbox() zoombox()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson