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

📄 mstatwnd.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
    return( rc );

} /* StatusWndInit */

/*
 * StatusWndStart - start a status window
 */
statwnd *StatusWndStart( void )
{
    statwnd *sw;

    sw = (statwnd *) MemAlloc( sizeof(statwnd) );
    if ( sw ) {
        memset ( sw, 0, sizeof(statwnd) );
    }
    return( sw );
} /* StatusWndStart */

/*
 * StatusWndCreate - create the status window
 */
int StatusWndCreate( statwnd *sw, HWND parent, RECT *size,
                     HINSTANCE hinstance, LPVOID lpvParam )
{
    if ( !sw ) {
        return ( FALSE );
    }

    cheesy_stat = sw;

#if defined (__NT__)
    if( LOBYTE(LOWORD(GetVersion())) >= 4 ) {
        sw->win = CreateWindow( className, NULL,
                             WS_CHILD | WS_CLIPSIBLINGS,
                             size->left, size->top,
                             size->right - size->left, size->bottom - size->top,
                             parent, (HMENU)NULL, hinstance, lpvParam );
    } else {
        sw->win= 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
    sw->win = 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( sw->win == (HWND)NULL ) {
        return ( FALSE );
    }

    ShowWindow( sw->win, SW_SHOWNORMAL );
    UpdateWindow( sw->win );

    return( TRUE );

} /* StatusWndCreate */

/*
 * StatusWndDraw3DBox - called by StatusWndDrawLine or externally
 *                      in StatusWndDrawLine is not used.
 */
void StatusWndDraw3DBox( statwnd *sw, HDC hdc )
{
    HPEN        old_pen;
    int         i;
    RECT        r;

    old_pen = SelectObject( hdc, penLight );
    for( i=0;i<=sw->numSections;i++ ) {
        getRect( sw, &r, i );
        outlineRect( hdc, &r );
        makeInsideRect( &r );
        FillRect( hdc, &r, brushButtonFace );
    }
    SelectObject( hdc, old_pen );

} /* StatusWndDraw3DBox */

/*
 * outputText - output a text string
 */
void outputText( statwnd *sw, HDC hdc, char *buff, RECT *r,
                 UINT flags, int curr_block )
{
    RECT        ir;
    int         len;
    int         ext;
    int         width;

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

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

#ifndef __NT__
    ext = LOWORD( GetTextExtent( hdc, buff, len ) );
#else
    {
        SIZE    sz;

        if( LOBYTE(LOWORD(GetVersion())) >= 4 ) {
            SelectObject( hdc, (HFONT)GetStockObject(DEFAULT_GUI_FONT) );
        } else {
            SelectObject( hdc, (HFONT)GetStockObject(SYSTEM_FONT) );
        }
        GetTextExtentPoint( hdc, buff, len, &sz );
        ext = sz.cx;
    }
#endif
    ir = *r;
    if( flags & DT_CENTER ) {
        width = (ir.right - ir.left - ext)/2;
        if( width > 0 ) {
            ir.right = ir.left+width;
            FillRect( hdc, &ir, brushButtonFace );
            ir.right = r->right;
            ir.left = r->right-width;
            FillRect( hdc, &ir, brushButtonFace );
        }
    } else if( flags & DT_RIGHT ) {
        ir.right -= ext;
        if( ir.right >= ir.left ) {
            FillRect( hdc, &ir, brushButtonFace );
        }
    } else {
        ir.left += ext;
        if( ir.left < ir.right ) {
            FillRect( hdc, &ir, brushButtonFace );
        }
    }
    DrawText( hdc, buff, -1, r, flags );

} /* outputText */

/*
 * StatusWndDrawLine - draws a line in the status bar
 */
void StatusWndDrawLine( statwnd *sw, HDC hdc, HFONT hfont,
                        char *str, UINT flags )
{
    RECT        rect;
    char        buff[256];
    char        *bptr;
    int         curr_block;

    curr_block = 0;
    sw->sectionDataFont = hfont;
    initHDC( sw, hdc );
    getRect( sw, &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( sw, hdc, buff, &rect, flags, curr_block );
                    curr_block++;
                    getRect( sw, &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( sw, hdc, bptr, &rect, flags, curr_block );
    finiHDC( hdc );

} /* StatusWndDrawLine */

/*
 * StatusWndSetSeparators - set the separator list
 */
void StatusWndSetSeparators( statwnd *sw, 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++ ) {
        sw->sectionDesc[i] = list[i];
    }
    sw->numSections = num_items;

} /* StatusWndSetSeparators */

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

    if( sw ) {
        if ( sw->win != (HWND)NULL ) {
            DestroyWindow ( sw->win );
        }
        for( i=0;i<=sw->numSections;i++ ) {
            MemFree( sw->sectionData[i] );
        }
        MemFree ( sw );
    }
} /* StatusWndDestroy */

/*
 * StatusWndFini - cleans up everything allocated for the status window
 */
void StatusWndFini( void )
{
    if( hasGDIObjects ) {
        DeleteObject( penLight );
        DeleteObject( penShade );
        DeleteObject( brushButtonFace );
        hasGDIObjects = FALSE;
    }

} /* StatusWndFini */

⌨️ 快捷键说明

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