⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wstatus.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
        brushButtonFace = CreateSolidBrush( colorButtonFace );
        penLight = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) );
        penShade = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) );
        hasGDIObjects = TRUE;
    }

    statusWndHookFunc = hook;

    rc = TRUE;
    if( !classRegistered ) {
        classHandle = hinstance;
        wc.style = CS_HREDRAW | CS_VREDRAW;
        wc.lpfnWndProc = (LPVOID) StatusWndCallback;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = extra;
        wc.hInstance = hinstance;
        wc.hIcon = LoadIcon( (HINSTANCE)NULL, IDI_APPLICATION );
        wc.hCursor = LoadCursor( (HINSTANCE)NULL, IDC_ARROW );
        wc.hbrBackground = (HBRUSH) 0;
        wc.lpszMenuName = NULL;
        wc.lpszClassName = className;
        rc = RegisterClass( &wc );
        classRegistered = TRUE;
    }
    return( rc );
#else
        /*
         ******************
         * PM Version of the initialization
         ******************
         */
    int         rc;

    colorButtonFace = CLR_PALEGRAY;

    if( !hasGDIObjects ) {
        brushButtonFace = _wpi_createsolidbrush( colorButtonFace );
        penLight = _wpi_createpen( PS_SOLID, 1, CLR_WHITE );
        penShade = _wpi_createpen( PS_SOLID, 1, CLR_DARKGRAY );
        hasGDIObjects = TRUE;
    }

    statusWndHookFunc = hook;

    rc = TRUE;
    if( !classRegistered ) {
        memcpy( &classHandle, &hinstance, sizeof(WPI_INST) );
        rc = WinRegisterClass( hinstance.hab, className,
                                (PFNWP)StatusWndCallback,
                                CS_SIZEREDRAW | CS_CLIPSIBLINGS, extra );
        classRegistered = TRUE;
    }
    return( rc );
#endif
} /* StatusWndInit */

/*
 * StatusWndCreate - create the status window
 */
HWND StatusWndCreate( HWND parent, WPI_RECT *size, WPI_INST hinstance,
                                                        LPVOID lpvParam )
{
    HWND        stat;

#ifndef __OS2_PM__
    /*
     ****************
     * Windows version of create
     ****************
     */
#if defined (__NT__)
    if( LOBYTE(LOWORD(GetVersion())) >= 4 ) {
        stat = CreateWindow( className, NULL,
                             WS_CHILD,
                             size->left, size->top,
                             size->right - size->left, size->bottom - size->top,
                             parent, (HMENU)NULL, hinstance, lpvParam );
    } else {
        stat = CreateWindow( className, NULL,
                             WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS,
                             size->left, size->top,
                             size->right - size->left, size->bottom - size->top,
                             parent, (HMENU)NULL, hinstance, lpvParam );
    }
#else  /* WIN16 */
    stat = CreateWindow( className, NULL,
                         WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS,
                         size->left, size->top,
                         size->right - size->left, size->bottom - size->top,
                         parent, (HMENU)NULL, hinstance, lpvParam );
#endif

    if( stat != NULL ) {
        ShowWindow( stat, SW_SHOWNORMAL );
        UpdateWindow( stat );
    }

#else
    /*
     ****************
     * PM version of create
     ****************
     */
    ULONG       flags;

    hinstance = hinstance;
    lpvParam = lpvParam;
    flags = FCF_BORDER;

    stat = WinCreateStdWindow( parent, WS_VISIBLE, &flags, className, "", 0L,
                                                    (HMODULE)0, 10, NULL);
    if(stat != NULLHANDLE) {
        WinSetWindowPos( stat, HWND_TOP, size->xLeft, size->yBottom,
                        size->xRight - size->xLeft, size->yTop - size->yBottom,
                        SWP_SIZE | SWP_MOVE | SWP_SHOW );
    }
#endif

    wndHeight = _wpi_getheightrect( *size );
    return( stat );
} /* StatusWndCreate */

/*
 * StatusWndDraw3DBox - called by StatusWndDrawLine or externally
 *                      in StatusWndDrawLine is not used.
 */
void StatusWndDraw3DBox( WPI_PRES pres )
{
    int         i;
    WPI_RECT    r;

    for( i = 0; i <= numSections; i++ ) {
        getRect( &r, i );
        outlineRect( pres, &r );
        makeInsideRect( &r );
        _wpi_fillrect( pres, &r, colorButtonFace, brushButtonFace );
    }

} /* StatusWndDraw3DBox */

/*
 * outputText - output a text string
 */
void outputText( WPI_PRES pres, char *buff, WPI_RECT *r, UINT flags, int curr_block )
{
    WPI_RECT    ir;
    WPI_RECT    draw_rect;
    int         len;
    int         ext;
    int         width;
    STATUS_DIM  ir_left;
    STATUS_DIM  ir_right;
    STATUS_DIM  ir_top;
    STATUS_DIM  ir_bottom;
    STATUS_DIM  r_left;
    STATUS_DIM  r_right;
    STATUS_DIM  r_top;
    STATUS_DIM  r_bottom;
    UINT        pmflags;

    if( sectionData[ curr_block ] != NULL ) {
        if( !strcmp( buff, sectionData[ curr_block ] ) ) {
            return;
        }
    }

    len = strlen( buff );
    if( len == 0 ) {
        return;
    }
    MemFree( sectionData[ curr_block ] );
    sectionData[ curr_block ] = MemAlloc( len+1 );
    memcpy( sectionData[ curr_block ], buff, len+1 );
    sectionDataFlags[ curr_block ] = flags | DT_TEXTATTRS;

#ifndef __NT__
    {
        int             height;

        _wpi_gettextextent( pres, buff, len, &ext, &height );
    }
#else
    {
        SIZE    sz;

        GetTextExtentPoint( pres, buff, len, &sz );
        ext = sz.cx;
    }
#endif
    ir = *r;
    _wpi_getrectvalues( ir, &ir_left, &ir_top, &ir_right, &ir_bottom );
#ifdef __OS2_PM__
    ir_left++;
    ir_top++;
    ir_bottom++;
    _wpi_setrectvalues( &draw_rect, ir_left, ir_top, ir_right, ir_bottom );
#else
    draw_rect = *r;
#endif
    if( flags & DT_CENTER ) {
        width = (ir_right - ir_left - ext)/2;
        if( width > 0 ) {
            ir_right = ir_left + width;
            _wpi_setrectvalues( &ir, ir_left, ir_top, ir_right, ir_bottom );
            _wpi_fillrect( pres, &ir, colorButtonFace, brushButtonFace );

            _wpi_getrectvalues( *r, &r_left, &r_top, &r_right, &r_bottom );
            ir_right = r_right;
            ir_left = r_right - width;
            _wpi_setrectvalues( &ir, ir_left, ir_top, ir_right, ir_bottom );
            _wpi_fillrect( pres, &ir, colorButtonFace, brushButtonFace );
        }
    } else if( flags & DT_RIGHT ) {
        ir_right -= ext;
        if( ir_right >= ir_left ) {
            _wpi_setrectvalues( &ir, ir_left, ir_top, ir_right, ir_bottom );
            _wpi_fillrect( pres, &ir, colorButtonFace, brushButtonFace );
        }
    } else {
        ir_left += ext;
        if( ir_left < ir_right ) {
            _wpi_setrectvalues( &ir, ir_left, ir_top, ir_right, ir_bottom );
            _wpi_fillrect( pres, &ir, colorButtonFace, brushButtonFace );
        }
    }
    pmflags = flags | DT_TEXTATTRS;
    _wpi_drawtext( pres, buff, -1, &draw_rect, pmflags );
} /* outputText */

/*
 * StatusWndDrawLine - draws a line in the status bar
 */
void StatusWndDrawLine( WPI_PRES pres, WPI_FONT hfont, char *str, UINT flags )
{
    WPI_RECT    rect;
    char        buff[256];
    char        *bptr;
    int         curr_block;

    curr_block = 0;
    sectionDataFont = hfont;
    if( !initPRES( pres ) ) {
        return;
    }
    getRect( &rect, curr_block );
    makeInsideRect( &rect );
    bptr = str;
    if( flags == (UINT) -1  ) {
        flags = DT_VCENTER | DT_LEFT;
        bptr = buff;
        while( *str ) {
            if( *str == STATUS_ESC_CHAR ) {
                str++;
                switch( *str ) {
                case STATUS_NEXT_BLOCK:
                    *bptr = 0;
                    outputText( pres, buff, &rect, flags, curr_block );
                    curr_block++;
                    getRect( &rect, curr_block );
                    makeInsideRect( &rect );
                    flags = DT_VCENTER | DT_LEFT;
                    bptr = buff;
                    break;
                case STATUS_FORMAT_CENTER:
                    flags &= ~(DT_RIGHT|DT_LEFT);
                    flags |= DT_CENTER;
                    break;
                case STATUS_FORMAT_RIGHT:
                    flags &= ~(DT_CENTER|DT_LEFT);
                    flags |= DT_RIGHT;
                    break;
                case STATUS_FORMAT_LEFT:
                    flags &= ~(DT_CENTER|DT_RIGHT);
                    flags |= DT_LEFT;
                    break;
                }
            } else {
                *bptr++ = *str;
            }
            str++;
        }
        *bptr = 0;
        bptr = buff;
    }
    outputText( pres, bptr, &rect, flags, curr_block );
    finiPRES( pres );
} /* StatusWndDrawLine */

/*
 * StatusWndSetSeparators - set the separator list
 */
void StatusWndSetSeparators( int num_items, status_block_desc *list )
{
    int i;

    if( num_items > MAX_SECTIONS ) {
        num_items = MAX_SECTIONS;
    }
    for( i = 0; i < num_items; i++ ) {
        sectionDesc[i] = list[i];
    }
    numSections = num_items;

} /* StatusWndSetSeparators */

/*
 * StatusWndFini - cleans up everything allocated for the status window
 */
void StatusWndFini( void )
{
    int i;

    if( hasGDIObjects ) {
        _wpi_deleteobject( penLight );
        _wpi_deleteobject( penShade );
        _wpi_deleteobject( brushButtonFace );
        hasGDIObjects = FALSE;
    }
    for( i = 0; i <= numSections; i++ ) {
        MemFree( sectionData[i] );
        sectionData[i] = NULL;
    }
    numSections = 0;
    if( classRegistered ) {
        _wpi_unregisterclass( className, classHandle );
        classRegistered = FALSE;
    }
} /* StatusWndFini */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -