'왓콤C 함수'에 해당되는 글 29건

  1. 2021.10.26 Watcom C Library : _setcolor, setenv, _setfillmask, _setfont

 

 

Watcom C Library Reference : _setcolor, setenv, _setfillmask, _setfont

 

 

 

 

_setcolor

 

Synopsis : #include <graph.h> 

              short _FAR _setcolor( short pixval );

 


Description : The _setcolor function sets the pixel value for the current color to be that indicated by the pixval argument. The current color is only used by the functions that produce graphics output; text output with _outtext uses the current text color (see the _settextcolor function). The default color value is one less than the maximum number of colors in the current video mode.

 

 

Returns : The _setcolor function returns the previous value of the current color.

 

 

See Also : _getcolor, _settextcolor

 


Example :

#include <conio.h> 

#include <graph.h>


void main( )

{
    int     col, old_col;

 

    _setvideomode( _VRES16COLOR );

    old_col = _getcolor( );

    for( col = 0; col < 16; ++col ) {
        _setcolor( col );

        _rectangle( _GFILLINTERIOR, 100, 100, 540, 380 );

        getch( );

    }
    _setcolor( old_col );

    _setvideomode( _DEFAULTMODE );

}

 

Classification : PC Graphics
Systems : DOS, QNX

 

 

 

 

 

 

 

setenv

 

Synopsis : #include <env.h>

              int setenv( const char *name, const char *newvalue, int overwrite );

 


Description : The environment list consists of a number of environment names, each of which has a value
associated with it. Entries can be added to the environment list with the DOS set command or with the setenv function. All entries in the environment list can be displayed by using the DOS set command with no arguments. A program can obtain the value for an environment variable by using the getenv function.

 

The setenv function searches the environment list for an entry of the form name=value. If no such string is present, setenv adds an entry of the form name=newvalue to the environment list. Otherwise, if the overwrite argument is non-zero, setenv either will change the existing value to newvalue or will delete the string name=value and add the string name=newvalue.


If the newvalue pointer is NULL, all strings of the form name=value in the environment list will be deleted.


The value of the pointer environ may change across a call to the setenv function.


The setenv function will make copies of the strings associated with name and newvalue.


The matching is case-insensitive; all lowercase letters are treated as if they were in upper case.


Entries can also be added to the environment list with the DOS set command or with the putenv or setenv functions. All entries in the environment list can be obtained by using the getenv function.


To assign a string to a variable and place it in the environment list:
    C>SET INCLUDE=C:\WATCOM\H


To see what variables are in the environment list, and their current assignments:
    C>SET 

    COMSPEC=C:\COMMAND.COM 

    PATH=C:\;C:\WATCOM 

    INCLUDE=C:\WATCOM\H
    C>

 

 

Returns : The setenv function returns zero upon successful completion. Otherwise, it will return a non-zero value and set errno to indicate the error.

 

 

Errors : When an error has occurred errno contains a value indicating the type of error that has been detected.
    ENOMEM     Not enough memory to allocate a new environment string.

 

 

See Also : clearenv, exec Functions. getenv, putenv, _searchenv, spawn Functions, system

 


Example :

The following will change the string assigned to INCLUDE and then display the new string.


#include <stdio.h> 

#include <stdlib.h> 

#include <env.h>


void main( )

{
    char     *path;


    if( setenv( "INCLUDE", "D:\WATCOM\H", 1 ) == 0 )

        if( ( path = getenv( "INCLUDE" )) != NULL )
            printf( "INCLUDE=%s\n", path );

 

Classification : POSIX 1003.1
Systems : All

 

 

 

 

 

 

 

_setfillmask

 

Synopsis : #include <graph.h> 

              void _FAR _setfillmask( char _FAR *mask );

 


Description : The _setfillmask function sets the current fill mask to the value of the argument mask. When the value of the mask argument is NULL, there will be no fill mask set.


The fill mask is an eight-byte array which is interpreted as a square pattern (8 by 8) of 64 bits. Each bit in the mask corresponds to a pixel. When a region is filled, each point in the region is mapped onto the fill mask. When a bit from the mask is one, the pixel value of the corresponding point is set using the current plotting action with the current color; when the bit is zero, the pixel value of that point is not affected.


When the fill mask is not set, a fill operation will set all points in the fill region to have a pixel value of the current color. By default, no fill mask is set.

 

 

Returns : The _setfillmask function does not return a value.

 

 

See Also : _getfillmask, _ellipse, _floodfill, _rectangle, _polygon, _pie, _setcolor, _setplotaction

 


Example :

#include <conio.h> 

#include <graph.h>


char old_mask[8];

char new_mask[8] = { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 };


void main( )

{
    _setvideomode( _VRES16COLOR );

    _getfillmask( old_mask );

    _setfillmask( new_mask );

    _rectangle( _GFILLINTERIOR, 100, 100, 540, 380 );

    _setfillmask( old_mask );

   

    getch( );

    _setvideomode( _DEFAULTMODE );

}

 


produces the following :

 

Classification : PC Graphics
Systems : DOS, QNX

 

 

 

 

 

 

 

_setfont

 

Synopsis : #include <graph.h> 

              short _FAR _setfont( char _FAR *opt );

 


Description : The _setfont function selects a font from the list of registered fonts (see the _registerfonts function). The font selected becomes the current font and is used whenever text is displayed with the _outgtext function. The function will fail if no fonts have been registered, or if a font cannot be found that matches the given characteristics.


The argument opt is a string of characters specifying the characteristics of the desired font. These characteristics determine which font is selected. The options may be separated by blanks and are not case-sensitive. Any number of options may be specified and in any order. The available options are:

 Option  Meaning
 hX  character height X (in pixels)
 wX  character width X (in pixels)
 f  choose a fixed-width font
 p  choose a proportional-width font
 r  choose a raster (bit-mapped) font
 v  choose a vector font
 b  choose the font that best matches the options
 nX  choose font number X (the number of fonts is returned by the _registerfonts function)
 t'facename'  choose a font with specified facename

 

 

The facename option is specified as a "t" followed by a facename enclosed in single quotes. The available facenames are:

 facenames  Meaning
 Courier  fixed-width raster font with serifs
 Helv  proportional-width raster font without serifs
 Tms Rmn  proportional-width raster font with serifs
 Script  proportional-width vector font that appears similar to hand-writing
 Modern  proportional-width vector font without serifs
 Roman  proportional-width vector font with serifs

 

 

When "nX" is specified to select a particular font, the other options are ignored.


If the best fit option ("b") is specified, _setfont will always be able to select a font. The font chosen will be the one that best matches the options specified. The following precedence is given to the options when selecting a font:

 1. Pixel height (higher precedence is given to heights less than the specified height)
 2. Facename
 3. Pixel width
 4. Font type (fixed or proportional)


When a pixel height or width does not match exactly and a vector font has been selected, the font will be stretched appropriately to match the given size.

 

 

Returns : The _setfont function returns zero if successful; otherwise, (-1) is returned.

 

 

See Also : _registerfonts, _unregisterfonts, _getfontinfo, _outgtext, _getgtextextent, _setgtextvector, _getgtextvector

 


Example :

#include <conio.h> 

#include <stdio.h> 

#include <graph.h>


void main( )

{
    int     i, n;

    char   buf[10];


    _setvideomode( _VRES16COLOR );

    n = registerfonts ( "*.fon" );

    for( i = 0; i < n; ++i ) {
        sprintf( buf, "n%d", i );

        _setfont( buf );

        _moveto( 100, 100 );

        _outgtext( "WATCOM Graphics" );

        getch( );

        _clearscreen( _GCLEARSCREEN );

    }


    _unregisterfonts( );

    _setvideomode( _DEFAULTMODE );

}

 

Classification : PC Graphics
Systems : DOS, QNX

 

 

 

 

 

 

 

 

 

This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).

 

WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)

 

 

 

728x90
반응형
Posted by 전화카드
,