Creating Custom Shadows

When using sw_shad() to add shadows to a window, the offset, length, and width are set to defaults. The defaults used are:

Horizontal shadow
Offset = 2
Length = SHAD_WNSIZE
Width = 1

Vertical shadow
Offset = 1
Length = SHAD_WNSIZE
Width = 2


The Shadows:offset is the number of spaces that the shadow is offset from the origin. The origin (0,0) is the top left corner of the window. For horizontal shadows, shadows that begin in a column to the right of the origin have a positive offset. For vertical shadows, shadows that begin in a row below the origin have a positive offset.

The Shadows:length is expressed as the number of columns (horizontal shadows) or rows (vertical shadows) in the length of the shadow. The pre-defined length SHAD_WNSIZE uses the number of rows or columns of the window.

The Shadows:width is expressed as the number of characters in the width of the shadow. Since the shape of a character cell is rectangular, the default width of vertical shadows is set to two and the default width of horizontal shadows is set to one. These defaults are set to make it appear that both the horizontal and vertical shadows are the same width.

If you do not want to use these defaults, you can define your own shadows with the shadow define function, shad_def(). This function defines only one side of the shadow. If you want to have shadows on two sides of the window, you must call this function twice, once for the vertical shadow and once for the horizontal shadow.

The call for shad_def() is as follows:

int shad_def(fill_ch, att, location, offset, length, width, wnp)
 
UCHAR fill_ch;
/* Character to use to draw shadow
*/
UCHAR att;
/* Shadow color 
*/
UINT location;
/* Shadow location TOP, LEFT, RIGHT, BOTTOM 
*/
int offset;
/* Offset of shadow
*/
int length;
/* Length of shadow
*/
int width;
/* Width of shadow
*/
WINDOWPTR wnp;
/* Pointer to window to add shadows to
*/

Some examples of shadows drawn with this function are shown below. Each code fragment is followed by a figure that illustrates the defined shadow or shadows.

shad_def(CH_BLOCK, LREVERSE, TOP, -1, SHAD_WNSIZE, 1, wnp);

    ¦¦¦¦¦¦¦¦¦

     +-------+

     ¦       ¦

     ¦       ¦

     +-------+


shad_def(CH_BLOCK, LREVERSE, BOTTOM, 2, SHAD_WNSIZE, 1, wnp);

    +-------+

    ¦       ¦

    ¦       ¦

    +-------+

      ¦¦¦¦¦¦¦¦¦
shad_def(CH_BLOCK, LREVERSE, LEFT, 2, 3, 2, wnp);

shad_def(CH_MEDSHADE, LREVERSE, BOTTOM, 0, 7, 1, wnp);

      +-------+

      ¦       ¦

    ¦¦¦       ¦

    ¦¦+-------+

    ¦¦¦¦¦¦¦¦¦


Home Contents Previous Next