guixdraw.c

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 490 行 · 第 1/2 页

C
490
字号
            area.height = 1;
            area.width = wnd->screen.area.width - 2;
            uivfill( &wnd->screen, area, attr, *(BOTTOM( inact )) );
        }
        /* right border */
        if( GUIUseGadget( wnd, wnd->vgadget ) ) {
            if( GUIDrawGadgetLine( wnd->vgadget ) ) {
                DrawText( wnd, wnd->screen.area.height-1-GUIGetScrollOffset(),
                          wnd->screen.area.width-1, attr, LRH_BAR( inact ), 1 );
            }
        } else {
            area.row = 1;
            area.height = wnd->screen.area.height- 2;
            area.col = wnd->screen.area.width - 1;
            area.width = 1;
            uivfill( &wnd->screen, area, attr, *(RIGHT( inact )) );
        }

        /* left border */
        area.row = 1;
        area.col = 0;
        area.height = wnd->screen.area.height-2;
        area.width = 1;
        uivfill( &wnd->screen, area, attr, *(LEFT( inact )) );

        wnd->flags &= ~FRAME_INVALID;
    }

    if( !( wnd->flags & TITLE_INVALID ) ) {
        return;
    }

    /* draw min and max gadgets or horizontal bar */
    width = wnd->use.width;
    closer_amount = 0;
    if( !inact || inact_gadgets ) {
        if( GUI_HAS_CLOSER( wnd ) ) {
            closer_amount = 3;
            width -= closer_amount;
            lgadget = LG_MARK( inact );
            if( wnd->flags & MAXIMIZED ) {
                mgadget = RESIZE_GAD( inact );
            } else {
                mgadget = MAX_GAD( inact );
            }
            rgadget = RG_MARK( inact );
            DrawText( wnd, 0, CLOSER_COL-1, attr, LG_MARK( inact ), 1 );
            DrawText( wnd, 0, CLOSER_COL,   attr, CLOSER( inact ), 1 );
            DrawText( wnd, 0, CLOSER_COL+1, attr, RG_MARK( inact ), 1 );
        }
        if( GUI_RESIZE_GADGETS_USEABLE( wnd ) ) {
            width -= 2 * GADGET_WIDTH;
            indent = wnd->screen.area.width - GADGET_WIDTH - 1;
            if( wnd->style & GUI_MAXIMIZE ) {
                lgadget = LG_MARK( inact );
                if( wnd->flags & MAXIMIZED ) {
                    mgadget = RESIZE_GAD( inact );
                } else {
                    mgadget = MAX_GAD( inact );
                }
                rgadget = RG_MARK( inact );
            } else {
                lgadget = mgadget = rgadget =  TOP( inact );
            }
            DrawText( wnd, 0, indent, attr, lgadget, 1 );
            DrawText( wnd, 0, indent + 1, attr, mgadget, 1 );
            DrawText( wnd, 0, indent + 2, attr, rgadget, 1 );

            indent = wnd->screen.area.width - 2 * GADGET_WIDTH - 1;
            if( wnd->style & GUI_MINIMIZE ) {
                lgadget = LG_MARK( inact );
                if( GUI_WND_MINIMIZED( wnd ) ) {
                    mgadget = RESIZE_GAD( inact );
                } else {
                    mgadget = MIN_GAD( inact );
                }
                rgadget = RG_MARK( inact );
            } else {
                lgadget = mgadget = rgadget =  TOP( inact );
            }
            DrawText( wnd, 0, indent, attr, lgadget, 1 );
            DrawText( wnd, 0, indent + 1, attr, mgadget, 1 );
            DrawText( wnd, 0, indent + 2, attr, rgadget, 1 );
        }
    }

    buffer = alloca( wnd->screen.area.width + 1 );
    buff = buffer;
    memset( buff, *(TOP( inact )), width ); /* width at least 1 */
    if( wnd->screen.name != NULL && *wnd->screen.name != NULLCHAR ) {
        str_length = strlen( wnd->screen.name );
        if( ( str_length + TITLE_EXTRA_AMOUNT ) > width ) {
            title_extra = 0;
            if( str_length > width ) {
                str_length = width;
            }
        } else {
            title_extra = TITLE_EXTRA_AMOUNT;
        }
        len = ( width - str_length - title_extra ) / 2;
        if( title_extra != 0 ) {
            memcpy( buff+len, LT_MARK( inact ), 1 );
            len++;
        }
        if( len > 0 ) {
            DrawText( wnd, 0, wnd->use.col + closer_amount, attr,
                      buffer, len );
        }
        indent = len;
        buff += len;
        len = 0;
        if( title_extra != 0 ) {
            memcpy( buff+len, TITLE_SP( inact ), 1 );
            len++;
        }
        memcpy( buff+len, wnd->screen.name, str_length );
        len += str_length;
        if( title_extra != 0 ) {
            memcpy( buff+len, TITLE_SP( inact ), 1 );
            len++;
        }
        if( len > 0 ) {
            DrawText( wnd, 0, wnd->use.col + closer_amount + indent,
                      title_attr, buff, len) ;
        }
        indent += len;
        buff += len;
        len = 0;
        if( title_extra != 0 ) {
            memcpy( buff+len, RT_MARK( inact ), 1 );
            len++;
        }
        if( width - indent > 0 ) {
            DrawText( wnd, 0, wnd->use.col + closer_amount + indent,
                      attr, buff, width - indent );
        }
    } else {
        DrawText( wnd, 0, wnd->use.col + closer_amount, attr,
                  buffer, width );
    }
    wnd->flags &= ~TITLE_INVALID;
}

static void WndClean( gui_window * wnd )
{
    wnd->dirty.row = 0;
    wnd->dirty.col = 0;
    wnd->dirty.width = 0;
    wnd->dirty.height = 0;
    wnd->flags &= ~CONTENTS_INVALID;
}

/*
 * GUIWndRfrshArea -- refresh a portion of the use are of the screen
 */

void GUIWndRfrshArea( gui_window *wnd, SAREA *area )
{
    gui_control *control;
    gui_row_num rownum;
    int         hscroll;
    int         vscroll;
    int         frame_adjust;

    /* if this window has a parent that is minimized or this window is
     * minimized, don't draw anything
     */
    if( GUI_WND_MINIMIZED( wnd ) ||
        ( ( wnd->parent != NULL ) && ( GUI_WND_MINIMIZED( wnd->parent ) ) ) ) {
        return;
    }

    if( wnd->style & GUI_NOFRAME ) {
        frame_adjust = 0;
    } else {
        frame_adjust = 1;
    }

    if( ( wnd->flags & CONTENTS_INVALID ) && !EMPTY_AREA( *area ) ) {
        hscroll = 0;
        vscroll = 0;
        if( GUI_WND_VISIBLE( wnd ) ) {
            if( ( wnd->hgadget != NULL ) && !GUI_HSCROLL_EVENTS_SET( wnd ) ) {
                hscroll += wnd->hgadget->pos;
            }
            if( ( wnd->vgadget != NULL ) && !GUI_VSCROLL_EVENTS_SET( wnd ) ) {
                vscroll += wnd->vgadget->pos;
            }
            COPYAREA( *area, wnd->dirty );
            if( ( wnd->dirty.col + wnd->dirty.width ) >
                ( wnd->screen.area.col + wnd->screen.area.width ) ) {
                wnd->dirty.width = wnd->screen.area.col + wnd->screen.area.width -
                                   wnd->dirty.col;
            }
            if( ( wnd->dirty.row + wnd->dirty.height ) >
                ( wnd->screen.area.row + wnd->screen.area.height ) ) {
                wnd->dirty.height = wnd->screen.area.row + wnd->screen.area.height -
                                    wnd->dirty.row;
            }
        }
        uivfill( &wnd->screen, wnd->dirty, wnd->colours[GUI_BACKGROUND],
                 wnd->background );

        if( GUI_WND_VISIBLE( wnd ) && !( wnd->flags & DONT_SEND_PAINT ) ) {
            rownum.start = vscroll + area->row - frame_adjust;
            rownum.num = area->height;
            GUIEVENTWND( wnd, GUI_PAINT, &rownum );
        }
        for( control = wnd->controls; control != NULL;
             control = control->sibling ) {
            GUIRefreshControl( control->parent, control->id );
        }
        GUIDrawStatus( wnd );
    }
    WndClean( wnd );
}

static void DrawGadget( gui_window * wnd, p_gadget gadget, gui_flags flag )
{
    if( ( wnd->flags & flag ) && ( gadget != NULL ) ) {
        GUISetShowGadget( gadget, TRUE, FALSE, 0 );
        wnd->flags &= ~flag;
    }
}
/*
 * GUIWndUpdate -- refresh the portions of the given window which require it
 */

void GUIWndUpdate( gui_window * wnd )
{
    if( !GUIIsOpen( wnd ) ) {
        return;
    }
    if( GUI_WND_VISIBLE( wnd ) && GUI_WND_MINIMIZED( wnd ) ) {
        GUIDrawIcon( wnd );
    } else {
        if( GUI_WND_VISIBLE( wnd ) ) {
            DrawFrame( wnd );
            DrawGadget( wnd, wnd->vgadget, VSCROLL_INVALID );
            DrawGadget( wnd, wnd->hgadget, HSCROLL_INVALID );
        }
        GUIWndRfrshArea( wnd, &wnd->dirty );
    }
}

⌨️ 快捷键说明

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